babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Engines/constants" {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending is DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending is SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending is SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending is SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending is SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. * Alpha will be set to DST ALPHA
  643. */
  644. static readonly ALPHA_EXCLUSION: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and no mip */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** mag = nearest and min = nearest and mip = none */
  767. static readonly TEXTURE_NEAREST_NEAREST: number;
  768. /** Bilinear is mag = linear and min = linear and no mip */
  769. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  770. /** mag = linear and min = linear and mip = none */
  771. static readonly TEXTURE_LINEAR_LINEAR: number;
  772. /** Trilinear is mag = linear and min = linear and mip = linear */
  773. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** nearest is mag = nearest and min = nearest and mip = linear */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1039. import { Nullable } from "babylonjs/types";
  1040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1041. /**
  1042. * This represents the required contract to create a new type of texture loader.
  1043. */
  1044. export interface IInternalTextureLoader {
  1045. /**
  1046. * Defines wether the loader supports cascade loading the different faces.
  1047. */
  1048. supportCascades: boolean;
  1049. /**
  1050. * This returns if the loader support the current file information.
  1051. * @param extension defines the file extension of the file being loaded
  1052. * @returns true if the loader can load the specified file
  1053. */
  1054. canLoad(extension: string): boolean;
  1055. /**
  1056. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1057. * @param data contains the texture data
  1058. * @param texture defines the BabylonJS internal texture
  1059. * @param createPolynomials will be true if polynomials have been requested
  1060. * @param onLoad defines the callback to trigger once the texture is ready
  1061. * @param onError defines the callback to trigger in case of error
  1062. */
  1063. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1064. /**
  1065. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1066. * @param data contains the texture data
  1067. * @param texture defines the BabylonJS internal texture
  1068. * @param callback defines the method to call once ready to upload
  1069. */
  1070. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1071. }
  1072. }
  1073. declare module "babylonjs/Engines/IPipelineContext" {
  1074. /**
  1075. * Class used to store and describe the pipeline context associated with an effect
  1076. */
  1077. export interface IPipelineContext {
  1078. /**
  1079. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1080. */
  1081. isAsync: boolean;
  1082. /**
  1083. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1084. */
  1085. isReady: boolean;
  1086. /** @hidden */
  1087. _getVertexShaderCode(): string | null;
  1088. /** @hidden */
  1089. _getFragmentShaderCode(): string | null;
  1090. /** @hidden */
  1091. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1092. }
  1093. }
  1094. declare module "babylonjs/Meshes/dataBuffer" {
  1095. /**
  1096. * Class used to store gfx data (like WebGLBuffer)
  1097. */
  1098. export class DataBuffer {
  1099. /**
  1100. * Gets or sets the number of objects referencing this buffer
  1101. */
  1102. references: number;
  1103. /** Gets or sets the size of the underlying buffer */
  1104. capacity: number;
  1105. /**
  1106. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1107. */
  1108. is32Bits: boolean;
  1109. /**
  1110. * Gets the underlying buffer
  1111. */
  1112. get underlyingResource(): any;
  1113. }
  1114. }
  1115. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1116. /** @hidden */
  1117. export interface IShaderProcessor {
  1118. attributeProcessor?: (attribute: string) => string;
  1119. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1120. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1121. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1122. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1123. lineProcessor?: (line: string, isFragment: boolean) => string;
  1124. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1125. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. }
  1127. }
  1128. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1129. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1148. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1149. /** @hidden */
  1150. export class ShaderCodeNode {
  1151. line: string;
  1152. children: ShaderCodeNode[];
  1153. additionalDefineKey?: string;
  1154. additionalDefineValue?: string;
  1155. isValid(preprocessors: {
  1156. [key: string]: string;
  1157. }): boolean;
  1158. process(preprocessors: {
  1159. [key: string]: string;
  1160. }, options: ProcessingOptions): string;
  1161. }
  1162. }
  1163. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1164. /** @hidden */
  1165. export class ShaderCodeCursor {
  1166. private _lines;
  1167. lineIndex: number;
  1168. get currentLine(): string;
  1169. get canRead(): boolean;
  1170. set lines(value: string[]);
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1174. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1175. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1176. /** @hidden */
  1177. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1178. process(preprocessors: {
  1179. [key: string]: string;
  1180. }, options: ProcessingOptions): string;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1184. /** @hidden */
  1185. export class ShaderDefineExpression {
  1186. isTrue(preprocessors: {
  1187. [key: string]: string;
  1188. }): boolean;
  1189. }
  1190. }
  1191. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1192. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1193. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1194. /** @hidden */
  1195. export class ShaderCodeTestNode extends ShaderCodeNode {
  1196. testExpression: ShaderDefineExpression;
  1197. isValid(preprocessors: {
  1198. [key: string]: string;
  1199. }): boolean;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1203. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1204. /** @hidden */
  1205. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1206. define: string;
  1207. not: boolean;
  1208. constructor(define: string, not?: boolean);
  1209. isTrue(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1215. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1216. /** @hidden */
  1217. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1218. leftOperand: ShaderDefineExpression;
  1219. rightOperand: ShaderDefineExpression;
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1226. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1227. /** @hidden */
  1228. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1237. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Offline/IOfflineProvider" {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module "babylonjs/Misc/filesInputStore" {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/retryStrategy" {
  1301. import { WebRequest } from "babylonjs/Misc/webRequest";
  1302. /**
  1303. * Class used to define a retry strategy when error happens while loading assets
  1304. */
  1305. export class RetryStrategy {
  1306. /**
  1307. * Function used to defines an exponential back off strategy
  1308. * @param maxRetries defines the maximum number of retries (3 by default)
  1309. * @param baseInterval defines the interval between retries
  1310. * @returns the strategy function to use
  1311. */
  1312. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1313. }
  1314. }
  1315. declare module "babylonjs/Misc/baseError" {
  1316. /**
  1317. * @ignore
  1318. * Application error to support additional information when loading a file
  1319. */
  1320. export abstract class BaseError extends Error {
  1321. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/fileTools" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. import { Nullable } from "babylonjs/types";
  1327. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1328. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1329. import { BaseError } from "babylonjs/Misc/baseError";
  1330. /** @ignore */
  1331. export class LoadFileError extends BaseError {
  1332. request?: WebRequest;
  1333. file?: File;
  1334. /**
  1335. * Creates a new LoadFileError
  1336. * @param message defines the message of the error
  1337. * @param request defines the optional web request
  1338. * @param file defines the optional file
  1339. */
  1340. constructor(message: string, object?: WebRequest | File);
  1341. }
  1342. /** @ignore */
  1343. export class RequestFileError extends BaseError {
  1344. request: WebRequest;
  1345. /**
  1346. * Creates a new LoadFileError
  1347. * @param message defines the message of the error
  1348. * @param request defines the optional web request
  1349. */
  1350. constructor(message: string, request: WebRequest);
  1351. }
  1352. /** @ignore */
  1353. export class ReadFileError extends BaseError {
  1354. file: File;
  1355. /**
  1356. * Creates a new ReadFileError
  1357. * @param message defines the message of the error
  1358. * @param file defines the optional file
  1359. */
  1360. constructor(message: string, file: File);
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export class FileTools {
  1366. /**
  1367. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1368. */
  1369. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1370. /**
  1371. * Gets or sets the base URL to use to load assets
  1372. */
  1373. static BaseUrl: string;
  1374. /**
  1375. * Default behaviour for cors in the application.
  1376. * It can be a string if the expected behavior is identical in the entire app.
  1377. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1378. */
  1379. static CorsBehavior: string | ((url: string | string[]) => string);
  1380. /**
  1381. * Gets or sets a function used to pre-process url before using them to load assets
  1382. */
  1383. static PreprocessUrl: (url: string) => string;
  1384. /**
  1385. * Removes unwanted characters from an url
  1386. * @param url defines the url to clean
  1387. * @returns the cleaned url
  1388. */
  1389. private static _CleanUrl;
  1390. /**
  1391. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1392. * @param url define the url we are trying
  1393. * @param element define the dom element where to configure the cors policy
  1394. */
  1395. static SetCorsBehavior(url: string | string[], element: {
  1396. crossOrigin: string | null;
  1397. }): void;
  1398. /**
  1399. * Loads an image as an HTMLImageElement.
  1400. * @param input url string, ArrayBuffer, or Blob to load
  1401. * @param onLoad callback called when the image successfully loads
  1402. * @param onError callback called when the image fails to load
  1403. * @param offlineProvider offline provider for caching
  1404. * @param mimeType optional mime type
  1405. * @returns the HTMLImageElement of the loaded image
  1406. */
  1407. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1408. /**
  1409. * Reads a file from a File object
  1410. * @param file defines the file to load
  1411. * @param onSuccess defines the callback to call when data is loaded
  1412. * @param onProgress defines the callback to call during loading process
  1413. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1414. * @param onError defines the callback to call when an error occurs
  1415. * @returns a file request object
  1416. */
  1417. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1418. /**
  1419. * Loads a file from a url
  1420. * @param url url to load
  1421. * @param onSuccess callback called when the file successfully loads
  1422. * @param onProgress callback called while file is loading (if the server supports this mode)
  1423. * @param offlineProvider defines the offline provider for caching
  1424. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1425. * @param onError callback called when the file fails to load
  1426. * @returns a file request object
  1427. */
  1428. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1429. /**
  1430. * Loads a file
  1431. * @param url url to load
  1432. * @param onSuccess callback called when the file successfully loads
  1433. * @param onProgress callback called while file is loading (if the server supports this mode)
  1434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1435. * @param onError callback called when the file fails to load
  1436. * @param onOpened callback called when the web request is opened
  1437. * @returns a file request object
  1438. */
  1439. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1440. /**
  1441. * Checks if the loaded document was accessed via `file:`-Protocol.
  1442. * @returns boolean
  1443. */
  1444. static IsFileURL(): boolean;
  1445. }
  1446. }
  1447. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1448. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1449. import { WebRequest } from "babylonjs/Misc/webRequest";
  1450. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1451. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1452. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1453. /** @hidden */
  1454. export class ShaderProcessor {
  1455. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1456. private static _ProcessPrecision;
  1457. private static _ExtractOperation;
  1458. private static _BuildSubExpression;
  1459. private static _BuildExpression;
  1460. private static _MoveCursorWithinIf;
  1461. private static _MoveCursor;
  1462. private static _EvaluatePreProcessors;
  1463. private static _PreparePreProcessors;
  1464. private static _ProcessShaderConversion;
  1465. private static _ProcessIncludes;
  1466. /**
  1467. * Loads a file from a url
  1468. * @param url url to load
  1469. * @param onSuccess callback called when the file successfully loads
  1470. * @param onProgress callback called while file is loading (if the server supports this mode)
  1471. * @param offlineProvider defines the offline provider for caching
  1472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1473. * @param onError callback called when the file fails to load
  1474. * @returns a file request object
  1475. * @hidden
  1476. */
  1477. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1478. }
  1479. }
  1480. declare module "babylonjs/Maths/math.like" {
  1481. import { float, int, DeepImmutable } from "babylonjs/types";
  1482. /**
  1483. * @hidden
  1484. */
  1485. export interface IColor4Like {
  1486. r: float;
  1487. g: float;
  1488. b: float;
  1489. a: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IColor3Like {
  1495. r: float;
  1496. g: float;
  1497. b: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IVector4Like {
  1503. x: float;
  1504. y: float;
  1505. z: float;
  1506. w: float;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IVector3Like {
  1512. x: float;
  1513. y: float;
  1514. z: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IVector2Like {
  1520. x: float;
  1521. y: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IMatrixLike {
  1527. toArray(): DeepImmutable<Float32Array>;
  1528. updateFlag: int;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IViewportLike {
  1534. x: float;
  1535. y: float;
  1536. width: float;
  1537. height: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IPlaneLike {
  1543. normal: IVector3Like;
  1544. d: float;
  1545. normalize(): void;
  1546. }
  1547. }
  1548. declare module "babylonjs/Materials/iEffectFallbacks" {
  1549. import { Effect } from "babylonjs/Materials/effect";
  1550. /**
  1551. * Interface used to define common properties for effect fallbacks
  1552. */
  1553. export interface IEffectFallbacks {
  1554. /**
  1555. * Removes the defines that should be removed when falling back.
  1556. * @param currentDefines defines the current define statements for the shader.
  1557. * @param effect defines the current effect we try to compile
  1558. * @returns The resulting defines with defines of the current rank removed.
  1559. */
  1560. reduce(currentDefines: string, effect: Effect): string;
  1561. /**
  1562. * Removes the fallback from the bound mesh.
  1563. */
  1564. unBindMesh(): void;
  1565. /**
  1566. * Checks to see if more fallbacks are still availible.
  1567. */
  1568. hasMoreFallbacks: boolean;
  1569. }
  1570. }
  1571. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1572. /**
  1573. * Class used to evalaute queries containing `and` and `or` operators
  1574. */
  1575. export class AndOrNotEvaluator {
  1576. /**
  1577. * Evaluate a query
  1578. * @param query defines the query to evaluate
  1579. * @param evaluateCallback defines the callback used to filter result
  1580. * @returns true if the query matches
  1581. */
  1582. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1583. private static _HandleParenthesisContent;
  1584. private static _SimplifyNegation;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/tags" {
  1588. /**
  1589. * Class used to store custom tags
  1590. */
  1591. export class Tags {
  1592. /**
  1593. * Adds support for tags on the given object
  1594. * @param obj defines the object to use
  1595. */
  1596. static EnableFor(obj: any): void;
  1597. /**
  1598. * Removes tags support
  1599. * @param obj defines the object to use
  1600. */
  1601. static DisableFor(obj: any): void;
  1602. /**
  1603. * Gets a boolean indicating if the given object has tags
  1604. * @param obj defines the object to use
  1605. * @returns a boolean
  1606. */
  1607. static HasTags(obj: any): boolean;
  1608. /**
  1609. * Gets the tags available on a given object
  1610. * @param obj defines the object to use
  1611. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1612. * @returns the tags
  1613. */
  1614. static GetTags(obj: any, asString?: boolean): any;
  1615. /**
  1616. * Adds tags to an object
  1617. * @param obj defines the object to use
  1618. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1619. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1620. */
  1621. static AddTagsTo(obj: any, tagsString: string): void;
  1622. /**
  1623. * @hidden
  1624. */
  1625. static _AddTagTo(obj: any, tag: string): void;
  1626. /**
  1627. * Removes specific tags from a specific object
  1628. * @param obj defines the object to use
  1629. * @param tagsString defines the tags to remove
  1630. */
  1631. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1632. /**
  1633. * @hidden
  1634. */
  1635. static _RemoveTagFrom(obj: any, tag: string): void;
  1636. /**
  1637. * Defines if tags hosted on an object match a given query
  1638. * @param obj defines the object to use
  1639. * @param tagsQuery defines the tag query
  1640. * @returns a boolean
  1641. */
  1642. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1643. }
  1644. }
  1645. declare module "babylonjs/Maths/math.scalar" {
  1646. /**
  1647. * Scalar computation library
  1648. */
  1649. export class Scalar {
  1650. /**
  1651. * Two pi constants convenient for computation.
  1652. */
  1653. static TwoPi: number;
  1654. /**
  1655. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. * @param a number
  1657. * @param b number
  1658. * @param epsilon (default = 1.401298E-45)
  1659. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1660. */
  1661. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1662. /**
  1663. * Returns a string : the upper case translation of the number i to hexadecimal.
  1664. * @param i number
  1665. * @returns the upper case translation of the number i to hexadecimal.
  1666. */
  1667. static ToHex(i: number): string;
  1668. /**
  1669. * Returns -1 if value is negative and +1 is value is positive.
  1670. * @param value the value
  1671. * @returns the value itself if it's equal to zero.
  1672. */
  1673. static Sign(value: number): number;
  1674. /**
  1675. * Returns the value itself if it's between min and max.
  1676. * Returns min if the value is lower than min.
  1677. * Returns max if the value is greater than max.
  1678. * @param value the value to clmap
  1679. * @param min the min value to clamp to (default: 0)
  1680. * @param max the max value to clamp to (default: 1)
  1681. * @returns the clamped value
  1682. */
  1683. static Clamp(value: number, min?: number, max?: number): number;
  1684. /**
  1685. * the log2 of value.
  1686. * @param value the value to compute log2 of
  1687. * @returns the log2 of value.
  1688. */
  1689. static Log2(value: number): number;
  1690. /**
  1691. * Loops the value, so that it is never larger than length and never smaller than 0.
  1692. *
  1693. * This is similar to the modulo operator but it works with floating point numbers.
  1694. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1695. * With t = 5 and length = 2.5, the result would be 0.0.
  1696. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1697. * @param value the value
  1698. * @param length the length
  1699. * @returns the looped value
  1700. */
  1701. static Repeat(value: number, length: number): number;
  1702. /**
  1703. * Normalize the value between 0.0 and 1.0 using min and max values
  1704. * @param value value to normalize
  1705. * @param min max to normalize between
  1706. * @param max min to normalize between
  1707. * @returns the normalized value
  1708. */
  1709. static Normalize(value: number, min: number, max: number): number;
  1710. /**
  1711. * Denormalize the value from 0.0 and 1.0 using min and max values
  1712. * @param normalized value to denormalize
  1713. * @param min max to denormalize between
  1714. * @param max min to denormalize between
  1715. * @returns the denormalized value
  1716. */
  1717. static Denormalize(normalized: number, min: number, max: number): number;
  1718. /**
  1719. * Calculates the shortest difference between two given angles given in degrees.
  1720. * @param current current angle in degrees
  1721. * @param target target angle in degrees
  1722. * @returns the delta
  1723. */
  1724. static DeltaAngle(current: number, target: number): number;
  1725. /**
  1726. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1727. * @param tx value
  1728. * @param length length
  1729. * @returns The returned value will move back and forth between 0 and length
  1730. */
  1731. static PingPong(tx: number, length: number): number;
  1732. /**
  1733. * Interpolates between min and max with smoothing at the limits.
  1734. *
  1735. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1736. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1737. * @param from from
  1738. * @param to to
  1739. * @param tx value
  1740. * @returns the smooth stepped value
  1741. */
  1742. static SmoothStep(from: number, to: number, tx: number): number;
  1743. /**
  1744. * Moves a value current towards target.
  1745. *
  1746. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1747. * Negative values of maxDelta pushes the value away from target.
  1748. * @param current current value
  1749. * @param target target value
  1750. * @param maxDelta max distance to move
  1751. * @returns resulting value
  1752. */
  1753. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1754. /**
  1755. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1756. *
  1757. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1758. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1759. * @param current current value
  1760. * @param target target value
  1761. * @param maxDelta max distance to move
  1762. * @returns resulting angle
  1763. */
  1764. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1765. /**
  1766. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1767. * @param start start value
  1768. * @param end target value
  1769. * @param amount amount to lerp between
  1770. * @returns the lerped value
  1771. */
  1772. static Lerp(start: number, end: number, amount: number): number;
  1773. /**
  1774. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1775. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1776. * @param start start value
  1777. * @param end target value
  1778. * @param amount amount to lerp between
  1779. * @returns the lerped value
  1780. */
  1781. static LerpAngle(start: number, end: number, amount: number): number;
  1782. /**
  1783. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1784. * @param a start value
  1785. * @param b target value
  1786. * @param value value between a and b
  1787. * @returns the inverseLerp value
  1788. */
  1789. static InverseLerp(a: number, b: number, value: number): number;
  1790. /**
  1791. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1792. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1793. * @param value1 spline value
  1794. * @param tangent1 spline value
  1795. * @param value2 spline value
  1796. * @param tangent2 spline value
  1797. * @param amount input value
  1798. * @returns hermite result
  1799. */
  1800. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1801. /**
  1802. * Returns a random float number between and min and max values
  1803. * @param min min value of random
  1804. * @param max max value of random
  1805. * @returns random value
  1806. */
  1807. static RandomRange(min: number, max: number): number;
  1808. /**
  1809. * This function returns percentage of a number in a given range.
  1810. *
  1811. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1812. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1813. * @param number to convert to percentage
  1814. * @param min min range
  1815. * @param max max range
  1816. * @returns the percentage
  1817. */
  1818. static RangeToPercent(number: number, min: number, max: number): number;
  1819. /**
  1820. * This function returns number that corresponds to the percentage in a given range.
  1821. *
  1822. * PercentToRange(0.34,0,100) will return 34.
  1823. * @param percent to convert to number
  1824. * @param min min range
  1825. * @param max max range
  1826. * @returns the number
  1827. */
  1828. static PercentToRange(percent: number, min: number, max: number): number;
  1829. /**
  1830. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1831. * @param angle The angle to normalize in radian.
  1832. * @return The converted angle.
  1833. */
  1834. static NormalizeRadians(angle: number): number;
  1835. }
  1836. }
  1837. declare module "babylonjs/Maths/math.constants" {
  1838. /**
  1839. * Constant used to convert a value to gamma space
  1840. * @ignorenaming
  1841. */
  1842. export const ToGammaSpace: number;
  1843. /**
  1844. * Constant used to convert a value to linear space
  1845. * @ignorenaming
  1846. */
  1847. export const ToLinearSpace = 2.2;
  1848. /**
  1849. * Constant used to define the minimal number value in Babylon.js
  1850. * @ignorenaming
  1851. */
  1852. let Epsilon: number;
  1853. export { Epsilon };
  1854. }
  1855. declare module "babylonjs/Maths/math.viewport" {
  1856. /**
  1857. * Class used to represent a viewport on screen
  1858. */
  1859. export class Viewport {
  1860. /** viewport left coordinate */
  1861. x: number;
  1862. /** viewport top coordinate */
  1863. y: number;
  1864. /**viewport width */
  1865. width: number;
  1866. /** viewport height */
  1867. height: number;
  1868. /**
  1869. * Creates a Viewport object located at (x, y) and sized (width, height)
  1870. * @param x defines viewport left coordinate
  1871. * @param y defines viewport top coordinate
  1872. * @param width defines the viewport width
  1873. * @param height defines the viewport height
  1874. */
  1875. constructor(
  1876. /** viewport left coordinate */
  1877. x: number,
  1878. /** viewport top coordinate */
  1879. y: number,
  1880. /**viewport width */
  1881. width: number,
  1882. /** viewport height */
  1883. height: number);
  1884. /**
  1885. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1886. * @param renderWidth defines the rendering width
  1887. * @param renderHeight defines the rendering height
  1888. * @returns a new Viewport
  1889. */
  1890. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1891. /**
  1892. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1893. * @param renderWidth defines the rendering width
  1894. * @param renderHeight defines the rendering height
  1895. * @param ref defines the target viewport
  1896. * @returns the current viewport
  1897. */
  1898. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1899. /**
  1900. * Returns a new Viewport copied from the current one
  1901. * @returns a new Viewport
  1902. */
  1903. clone(): Viewport;
  1904. }
  1905. }
  1906. declare module "babylonjs/Misc/arrayTools" {
  1907. /**
  1908. * Class containing a set of static utilities functions for arrays.
  1909. */
  1910. export class ArrayTools {
  1911. /**
  1912. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1913. * @param size the number of element to construct and put in the array
  1914. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1915. * @returns a new array filled with new objects
  1916. */
  1917. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1918. }
  1919. }
  1920. declare module "babylonjs/Maths/math.vector" {
  1921. import { Viewport } from "babylonjs/Maths/math.viewport";
  1922. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1923. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1924. /**
  1925. * Class representing a vector containing 2 coordinates
  1926. */
  1927. export class Vector2 {
  1928. /** defines the first coordinate */
  1929. x: number;
  1930. /** defines the second coordinate */
  1931. y: number;
  1932. /**
  1933. * Creates a new Vector2 from the given x and y coordinates
  1934. * @param x defines the first coordinate
  1935. * @param y defines the second coordinate
  1936. */
  1937. constructor(
  1938. /** defines the first coordinate */
  1939. x?: number,
  1940. /** defines the second coordinate */
  1941. y?: number);
  1942. /**
  1943. * Gets a string with the Vector2 coordinates
  1944. * @returns a string with the Vector2 coordinates
  1945. */
  1946. toString(): string;
  1947. /**
  1948. * Gets class name
  1949. * @returns the string "Vector2"
  1950. */
  1951. getClassName(): string;
  1952. /**
  1953. * Gets current vector hash code
  1954. * @returns the Vector2 hash code as a number
  1955. */
  1956. getHashCode(): number;
  1957. /**
  1958. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1959. * @param array defines the source array
  1960. * @param index defines the offset in source array
  1961. * @returns the current Vector2
  1962. */
  1963. toArray(array: FloatArray, index?: number): Vector2;
  1964. /**
  1965. * Copy the current vector to an array
  1966. * @returns a new array with 2 elements: the Vector2 coordinates.
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1971. * @param source defines the source Vector2
  1972. * @returns the current updated Vector2
  1973. */
  1974. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1975. /**
  1976. * Sets the Vector2 coordinates with the given floats
  1977. * @param x defines the first coordinate
  1978. * @param y defines the second coordinate
  1979. * @returns the current updated Vector2
  1980. */
  1981. copyFromFloats(x: number, y: number): Vector2;
  1982. /**
  1983. * Sets the Vector2 coordinates with the given floats
  1984. * @param x defines the first coordinate
  1985. * @param y defines the second coordinate
  1986. * @returns the current updated Vector2
  1987. */
  1988. set(x: number, y: number): Vector2;
  1989. /**
  1990. * Add another vector with the current one
  1991. * @param otherVector defines the other vector
  1992. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1993. */
  1994. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1995. /**
  1996. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1997. * @param otherVector defines the other vector
  1998. * @param result defines the target vector
  1999. * @returns the unmodified current Vector2
  2000. */
  2001. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2002. /**
  2003. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2004. * @param otherVector defines the other vector
  2005. * @returns the current updated Vector2
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2008. /**
  2009. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns a new Vector2
  2012. */
  2013. addVector3(otherVector: Vector3): Vector2;
  2014. /**
  2015. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2016. * @param otherVector defines the other vector
  2017. * @returns a new Vector2
  2018. */
  2019. subtract(otherVector: Vector2): Vector2;
  2020. /**
  2021. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2022. * @param otherVector defines the other vector
  2023. * @param result defines the target vector
  2024. * @returns the unmodified current Vector2
  2025. */
  2026. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2027. /**
  2028. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2029. * @param otherVector defines the other vector
  2030. * @returns the current updated Vector2
  2031. */
  2032. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2033. /**
  2034. * Multiplies in place the current Vector2 coordinates by the given ones
  2035. * @param otherVector defines the other vector
  2036. * @returns the current updated Vector2
  2037. */
  2038. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2039. /**
  2040. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @returns a new Vector2
  2043. */
  2044. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2045. /**
  2046. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2047. * @param otherVector defines the other vector
  2048. * @param result defines the target vector
  2049. * @returns the unmodified current Vector2
  2050. */
  2051. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2052. /**
  2053. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2054. * @param x defines the first coordinate
  2055. * @param y defines the second coordinate
  2056. * @returns a new Vector2
  2057. */
  2058. multiplyByFloats(x: number, y: number): Vector2;
  2059. /**
  2060. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2061. * @param otherVector defines the other vector
  2062. * @returns a new Vector2
  2063. */
  2064. divide(otherVector: Vector2): Vector2;
  2065. /**
  2066. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @param result defines the target vector
  2069. * @returns the unmodified current Vector2
  2070. */
  2071. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2072. /**
  2073. * Divides the current Vector2 coordinates by the given ones
  2074. * @param otherVector defines the other vector
  2075. * @returns the current updated Vector2
  2076. */
  2077. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2078. /**
  2079. * Gets a new Vector2 with current Vector2 negated coordinates
  2080. * @returns a new Vector2
  2081. */
  2082. negate(): Vector2;
  2083. /**
  2084. * Negate this vector in place
  2085. * @returns this
  2086. */
  2087. negateInPlace(): Vector2;
  2088. /**
  2089. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2090. * @param result defines the Vector3 object where to store the result
  2091. * @returns the current Vector2
  2092. */
  2093. negateToRef(result: Vector2): Vector2;
  2094. /**
  2095. * Multiply the Vector2 coordinates by scale
  2096. * @param scale defines the scaling factor
  2097. * @returns the current updated Vector2
  2098. */
  2099. scaleInPlace(scale: number): Vector2;
  2100. /**
  2101. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2102. * @param scale defines the scaling factor
  2103. * @returns a new Vector2
  2104. */
  2105. scale(scale: number): Vector2;
  2106. /**
  2107. * Scale the current Vector2 values by a factor to a given Vector2
  2108. * @param scale defines the scale factor
  2109. * @param result defines the Vector2 object where to store the result
  2110. * @returns the unmodified current Vector2
  2111. */
  2112. scaleToRef(scale: number, result: Vector2): Vector2;
  2113. /**
  2114. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector2 object where to store the result
  2117. * @returns the unmodified current Vector2
  2118. */
  2119. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2120. /**
  2121. * Gets a boolean if two vectors are equals
  2122. * @param otherVector defines the other vector
  2123. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2124. */
  2125. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2126. /**
  2127. * Gets a boolean if two vectors are equals (using an epsilon value)
  2128. * @param otherVector defines the other vector
  2129. * @param epsilon defines the minimal distance to consider equality
  2130. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2131. */
  2132. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2133. /**
  2134. * Gets a new Vector2 from current Vector2 floored values
  2135. * @returns a new Vector2
  2136. */
  2137. floor(): Vector2;
  2138. /**
  2139. * Gets a new Vector2 from current Vector2 floored values
  2140. * @returns a new Vector2
  2141. */
  2142. fract(): Vector2;
  2143. /**
  2144. * Gets the length of the vector
  2145. * @returns the vector length (float)
  2146. */
  2147. length(): number;
  2148. /**
  2149. * Gets the vector squared length
  2150. * @returns the vector squared length (float)
  2151. */
  2152. lengthSquared(): number;
  2153. /**
  2154. * Normalize the vector
  2155. * @returns the current updated Vector2
  2156. */
  2157. normalize(): Vector2;
  2158. /**
  2159. * Gets a new Vector2 copied from the Vector2
  2160. * @returns a new Vector2
  2161. */
  2162. clone(): Vector2;
  2163. /**
  2164. * Gets a new Vector2(0, 0)
  2165. * @returns a new Vector2
  2166. */
  2167. static Zero(): Vector2;
  2168. /**
  2169. * Gets a new Vector2(1, 1)
  2170. * @returns a new Vector2
  2171. */
  2172. static One(): Vector2;
  2173. /**
  2174. * Gets a new Vector2 set from the given index element of the given array
  2175. * @param array defines the data source
  2176. * @param offset defines the offset in the data source
  2177. * @returns a new Vector2
  2178. */
  2179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2180. /**
  2181. * Sets "result" from the given index element of the given array
  2182. * @param array defines the data source
  2183. * @param offset defines the offset in the data source
  2184. * @param result defines the target vector
  2185. */
  2186. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2187. /**
  2188. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2189. * @param value1 defines 1st point of control
  2190. * @param value2 defines 2nd point of control
  2191. * @param value3 defines 3rd point of control
  2192. * @param value4 defines 4th point of control
  2193. * @param amount defines the interpolation factor
  2194. * @returns a new Vector2
  2195. */
  2196. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2197. /**
  2198. * 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".
  2199. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2200. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2201. * @param value defines the value to clamp
  2202. * @param min defines the lower limit
  2203. * @param max defines the upper limit
  2204. * @returns a new Vector2
  2205. */
  2206. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2209. * @param value1 defines the 1st control point
  2210. * @param tangent1 defines the outgoing tangent
  2211. * @param value2 defines the 2nd control point
  2212. * @param tangent2 defines the incoming tangent
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2219. * @param start defines the start vector
  2220. * @param end defines the end vector
  2221. * @param amount defines the interpolation factor
  2222. * @returns a new Vector2
  2223. */
  2224. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2225. /**
  2226. * Gets the dot product of the vector "left" and the vector "right"
  2227. * @param left defines first vector
  2228. * @param right defines second vector
  2229. * @returns the dot product (float)
  2230. */
  2231. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2232. /**
  2233. * Returns a new Vector2 equal to the normalized given vector
  2234. * @param vector defines the vector to normalize
  2235. * @returns a new Vector2
  2236. */
  2237. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2240. * @param left defines 1st vector
  2241. * @param right defines 2nd vector
  2242. * @returns a new Vector2
  2243. */
  2244. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2247. * @param left defines 1st vector
  2248. * @param right defines 2nd vector
  2249. * @returns a new Vector2
  2250. */
  2251. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2254. * @param vector defines the vector to transform
  2255. * @param transformation defines the matrix to apply
  2256. * @returns a new Vector2
  2257. */
  2258. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2259. /**
  2260. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2261. * @param vector defines the vector to transform
  2262. * @param transformation defines the matrix to apply
  2263. * @param result defines the target vector
  2264. */
  2265. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2266. /**
  2267. * Determines if a given vector is included in a triangle
  2268. * @param p defines the vector to test
  2269. * @param p0 defines 1st triangle point
  2270. * @param p1 defines 2nd triangle point
  2271. * @param p2 defines 3rd triangle point
  2272. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2273. */
  2274. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2275. /**
  2276. * Gets the distance between the vectors "value1" and "value2"
  2277. * @param value1 defines first vector
  2278. * @param value2 defines second vector
  2279. * @returns the distance between vectors
  2280. */
  2281. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2282. /**
  2283. * Returns the squared distance between the vectors "value1" and "value2"
  2284. * @param value1 defines first vector
  2285. * @param value2 defines second vector
  2286. * @returns the squared distance between vectors
  2287. */
  2288. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2289. /**
  2290. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns a new Vector2
  2294. */
  2295. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2296. /**
  2297. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2298. * @param p defines the middle point
  2299. * @param segA defines one point of the segment
  2300. * @param segB defines the other point of the segment
  2301. * @returns the shortest distance
  2302. */
  2303. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2304. }
  2305. /**
  2306. * Class used to store (x,y,z) vector representation
  2307. * A Vector3 is the main object used in 3D geometry
  2308. * It can represent etiher the coordinates of a point the space, either a direction
  2309. * Reminder: js uses a left handed forward facing system
  2310. */
  2311. export class Vector3 {
  2312. /**
  2313. * Defines the first coordinates (on X axis)
  2314. */
  2315. x: number;
  2316. /**
  2317. * Defines the second coordinates (on Y axis)
  2318. */
  2319. y: number;
  2320. /**
  2321. * Defines the third coordinates (on Z axis)
  2322. */
  2323. z: number;
  2324. private static _UpReadOnly;
  2325. private static _ZeroReadOnly;
  2326. /**
  2327. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2328. * @param x defines the first coordinates (on X axis)
  2329. * @param y defines the second coordinates (on Y axis)
  2330. * @param z defines the third coordinates (on Z axis)
  2331. */
  2332. constructor(
  2333. /**
  2334. * Defines the first coordinates (on X axis)
  2335. */
  2336. x?: number,
  2337. /**
  2338. * Defines the second coordinates (on Y axis)
  2339. */
  2340. y?: number,
  2341. /**
  2342. * Defines the third coordinates (on Z axis)
  2343. */
  2344. z?: number);
  2345. /**
  2346. * Creates a string representation of the Vector3
  2347. * @returns a string with the Vector3 coordinates.
  2348. */
  2349. toString(): string;
  2350. /**
  2351. * Gets the class name
  2352. * @returns the string "Vector3"
  2353. */
  2354. getClassName(): string;
  2355. /**
  2356. * Creates the Vector3 hash code
  2357. * @returns a number which tends to be unique between Vector3 instances
  2358. */
  2359. getHashCode(): number;
  2360. /**
  2361. * Creates an array containing three elements : the coordinates of the Vector3
  2362. * @returns a new array of numbers
  2363. */
  2364. asArray(): number[];
  2365. /**
  2366. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2367. * @param array defines the destination array
  2368. * @param index defines the offset in the destination array
  2369. * @returns the current Vector3
  2370. */
  2371. toArray(array: FloatArray, index?: number): Vector3;
  2372. /**
  2373. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2374. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2375. */
  2376. toQuaternion(): Quaternion;
  2377. /**
  2378. * Adds the given vector to the current Vector3
  2379. * @param otherVector defines the second operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2383. /**
  2384. * Adds the given coordinates to the current Vector3
  2385. * @param x defines the x coordinate of the operand
  2386. * @param y defines the y coordinate of the operand
  2387. * @param z defines the z coordinate of the operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2391. /**
  2392. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Subtract the given vector from the current Vector3
  2406. * @param otherVector defines the second operand
  2407. * @returns the current updated Vector3
  2408. */
  2409. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2410. /**
  2411. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2412. * @param otherVector defines the second operand
  2413. * @returns the resulting Vector3
  2414. */
  2415. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2416. /**
  2417. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2418. * @param otherVector defines the second operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2423. /**
  2424. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @returns the resulting Vector3
  2429. */
  2430. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2431. /**
  2432. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2433. * @param x defines the x coordinate of the operand
  2434. * @param y defines the y coordinate of the operand
  2435. * @param z defines the z coordinate of the operand
  2436. * @param result defines the Vector3 object where to store the result
  2437. * @returns the current Vector3
  2438. */
  2439. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2440. /**
  2441. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2442. * @returns a new Vector3
  2443. */
  2444. negate(): Vector3;
  2445. /**
  2446. * Negate this vector in place
  2447. * @returns this
  2448. */
  2449. negateInPlace(): Vector3;
  2450. /**
  2451. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. negateToRef(result: Vector3): Vector3;
  2456. /**
  2457. * Multiplies the Vector3 coordinates by the float "scale"
  2458. * @param scale defines the multiplier factor
  2459. * @returns the current updated Vector3
  2460. */
  2461. scaleInPlace(scale: number): Vector3;
  2462. /**
  2463. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2464. * @param scale defines the multiplier factor
  2465. * @returns a new Vector3
  2466. */
  2467. scale(scale: number): Vector3;
  2468. /**
  2469. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2470. * @param scale defines the multiplier factor
  2471. * @param result defines the Vector3 object where to store the result
  2472. * @returns the current Vector3
  2473. */
  2474. scaleToRef(scale: number, result: Vector3): Vector3;
  2475. /**
  2476. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2477. * @param scale defines the scale factor
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the unmodified current Vector3
  2480. */
  2481. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2482. /**
  2483. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2484. * @param otherVector defines the second operand
  2485. * @returns true if both vectors are equals
  2486. */
  2487. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2488. /**
  2489. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2490. * @param otherVector defines the second operand
  2491. * @param epsilon defines the minimal distance to define values as equals
  2492. * @returns true if both vectors are distant less than epsilon
  2493. */
  2494. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2495. /**
  2496. * Returns true if the current Vector3 coordinates equals the given floats
  2497. * @param x defines the x coordinate of the operand
  2498. * @param y defines the y coordinate of the operand
  2499. * @param z defines the z coordinate of the operand
  2500. * @returns true if both vectors are equals
  2501. */
  2502. equalsToFloats(x: number, y: number, z: number): boolean;
  2503. /**
  2504. * Multiplies the current Vector3 coordinates by the given ones
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2511. * @param otherVector defines the second operand
  2512. * @returns the new Vector3
  2513. */
  2514. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the new Vector3
  2528. */
  2529. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2532. * @param otherVector defines the second operand
  2533. * @returns the new Vector3
  2534. */
  2535. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2538. * @param otherVector defines the second operand
  2539. * @param result defines the Vector3 object where to store the result
  2540. * @returns the current Vector3
  2541. */
  2542. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2543. /**
  2544. * Divides the current Vector3 coordinates by the given ones.
  2545. * @param otherVector defines the second operand
  2546. * @returns the current updated Vector3
  2547. */
  2548. divideInPlace(otherVector: Vector3): Vector3;
  2549. /**
  2550. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2551. * @param other defines the second operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2555. /**
  2556. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2557. * @param other defines the second operand
  2558. * @returns the current updated Vector3
  2559. */
  2560. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2561. /**
  2562. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the current updated Vector3
  2567. */
  2568. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2577. /**
  2578. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2579. * Check if is non uniform within a certain amount of decimal places to account for this
  2580. * @param epsilon the amount the values can differ
  2581. * @returns if the the vector is non uniform to a certain number of decimal places
  2582. */
  2583. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2584. /**
  2585. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2586. */
  2587. get isNonUniform(): boolean;
  2588. /**
  2589. * Gets a new Vector3 from current Vector3 floored values
  2590. * @returns a new Vector3
  2591. */
  2592. floor(): Vector3;
  2593. /**
  2594. * Gets a new Vector3 from current Vector3 floored values
  2595. * @returns a new Vector3
  2596. */
  2597. fract(): Vector3;
  2598. /**
  2599. * Gets the length of the Vector3
  2600. * @returns the length of the Vector3
  2601. */
  2602. length(): number;
  2603. /**
  2604. * Gets the squared length of the Vector3
  2605. * @returns squared length of the Vector3
  2606. */
  2607. lengthSquared(): number;
  2608. /**
  2609. * Normalize the current Vector3.
  2610. * Please note that this is an in place operation.
  2611. * @returns the current updated Vector3
  2612. */
  2613. normalize(): Vector3;
  2614. /**
  2615. * Reorders the x y z properties of the vector in place
  2616. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2617. * @returns the current updated vector
  2618. */
  2619. reorderInPlace(order: string): this;
  2620. /**
  2621. * Rotates the vector around 0,0,0 by a quaternion
  2622. * @param quaternion the rotation quaternion
  2623. * @param result vector to store the result
  2624. * @returns the resulting vector
  2625. */
  2626. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2627. /**
  2628. * Rotates a vector around a given point
  2629. * @param quaternion the rotation quaternion
  2630. * @param point the point to rotate around
  2631. * @param result vector to store the result
  2632. * @returns the resulting vector
  2633. */
  2634. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2637. * The cross product is then orthogonal to both current and "other"
  2638. * @param other defines the right operand
  2639. * @returns the cross product
  2640. */
  2641. cross(other: Vector3): Vector3;
  2642. /**
  2643. * Normalize the current Vector3 with the given input length.
  2644. * Please note that this is an in place operation.
  2645. * @param len the length of the vector
  2646. * @returns the current updated Vector3
  2647. */
  2648. normalizeFromLength(len: number): Vector3;
  2649. /**
  2650. * Normalize the current Vector3 to a new vector
  2651. * @returns the new Vector3
  2652. */
  2653. normalizeToNew(): Vector3;
  2654. /**
  2655. * Normalize the current Vector3 to the reference
  2656. * @param reference define the Vector3 to update
  2657. * @returns the updated Vector3
  2658. */
  2659. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2660. /**
  2661. * Creates a new Vector3 copied from the current Vector3
  2662. * @returns the new Vector3
  2663. */
  2664. clone(): Vector3;
  2665. /**
  2666. * Copies the given vector coordinates to the current Vector3 ones
  2667. * @param source defines the source Vector3
  2668. * @returns the current updated Vector3
  2669. */
  2670. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2671. /**
  2672. * Copies the given floats to the current Vector3 coordinates
  2673. * @param x defines the x coordinate of the operand
  2674. * @param y defines the y coordinate of the operand
  2675. * @param z defines the z coordinate of the operand
  2676. * @returns the current updated Vector3
  2677. */
  2678. copyFromFloats(x: number, y: number, z: number): Vector3;
  2679. /**
  2680. * Copies the given floats to the current Vector3 coordinates
  2681. * @param x defines the x coordinate of the operand
  2682. * @param y defines the y coordinate of the operand
  2683. * @param z defines the z coordinate of the operand
  2684. * @returns the current updated Vector3
  2685. */
  2686. set(x: number, y: number, z: number): Vector3;
  2687. /**
  2688. * Copies the given float to the current Vector3 coordinates
  2689. * @param v defines the x, y and z coordinates of the operand
  2690. * @returns the current updated Vector3
  2691. */
  2692. setAll(v: number): Vector3;
  2693. /**
  2694. * Get the clip factor between two vectors
  2695. * @param vector0 defines the first operand
  2696. * @param vector1 defines the second operand
  2697. * @param axis defines the axis to use
  2698. * @param size defines the size along the axis
  2699. * @returns the clip factor
  2700. */
  2701. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2702. /**
  2703. * Get angle between two vectors
  2704. * @param vector0 angle between vector0 and vector1
  2705. * @param vector1 angle between vector0 and vector1
  2706. * @param normal direction of the normal
  2707. * @return the angle between vector0 and vector1
  2708. */
  2709. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2710. /**
  2711. * Returns a new Vector3 set from the index "offset" of the given array
  2712. * @param array defines the source array
  2713. * @param offset defines the offset in the source array
  2714. * @returns the new Vector3
  2715. */
  2716. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2717. /**
  2718. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @returns the new Vector3
  2722. * @deprecated Please use FromArray instead.
  2723. */
  2724. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2725. /**
  2726. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2727. * @param array defines the source array
  2728. * @param offset defines the offset in the source array
  2729. * @param result defines the Vector3 where to store the result
  2730. */
  2731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2732. /**
  2733. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2734. * @param array defines the source array
  2735. * @param offset defines the offset in the source array
  2736. * @param result defines the Vector3 where to store the result
  2737. * @deprecated Please use FromArrayToRef instead.
  2738. */
  2739. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2740. /**
  2741. * Sets the given vector "result" with the given floats.
  2742. * @param x defines the x coordinate of the source
  2743. * @param y defines the y coordinate of the source
  2744. * @param z defines the z coordinate of the source
  2745. * @param result defines the Vector3 where to store the result
  2746. */
  2747. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2748. /**
  2749. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2750. * @returns a new empty Vector3
  2751. */
  2752. static Zero(): Vector3;
  2753. /**
  2754. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2755. * @returns a new unit Vector3
  2756. */
  2757. static One(): Vector3;
  2758. /**
  2759. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2760. * @returns a new up Vector3
  2761. */
  2762. static Up(): Vector3;
  2763. /**
  2764. * Gets a up Vector3 that must not be updated
  2765. */
  2766. static get UpReadOnly(): DeepImmutable<Vector3>;
  2767. /**
  2768. * Gets a zero Vector3 that must not be updated
  2769. */
  2770. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2771. /**
  2772. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2773. * @returns a new down Vector3
  2774. */
  2775. static Down(): Vector3;
  2776. /**
  2777. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2778. * @returns a new forward Vector3
  2779. */
  2780. static Forward(): Vector3;
  2781. /**
  2782. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2783. * @returns a new forward Vector3
  2784. */
  2785. static Backward(): Vector3;
  2786. /**
  2787. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2788. * @returns a new right Vector3
  2789. */
  2790. static Right(): Vector3;
  2791. /**
  2792. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2793. * @returns a new left Vector3
  2794. */
  2795. static Left(): Vector3;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2798. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the transformed Vector3
  2802. */
  2803. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2806. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2814. * This method computes tranformed coordinates only, not transformed direction vectors
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2824. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2825. * @param vector defines the Vector3 to transform
  2826. * @param transformation defines the transformation matrix
  2827. * @returns the new Vector3
  2828. */
  2829. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2832. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2833. * @param vector defines the Vector3 to transform
  2834. * @param transformation defines the transformation matrix
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2838. /**
  2839. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2840. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2841. * @param x define the x coordinate of the source vector
  2842. * @param y define the y coordinate of the source vector
  2843. * @param z define the z coordinate of the source vector
  2844. * @param transformation defines the transformation matrix
  2845. * @param result defines the Vector3 where to store the result
  2846. */
  2847. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2848. /**
  2849. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2850. * @param value1 defines the first control point
  2851. * @param value2 defines the second control point
  2852. * @param value3 defines the third control point
  2853. * @param value4 defines the fourth control point
  2854. * @param amount defines the amount on the spline to use
  2855. * @returns the new Vector3
  2856. */
  2857. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2858. /**
  2859. * 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"
  2860. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2861. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2862. * @param value defines the current value
  2863. * @param min defines the lower range value
  2864. * @param max defines the upper range value
  2865. * @returns the new Vector3
  2866. */
  2867. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2868. /**
  2869. * 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"
  2870. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2871. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2872. * @param value defines the current value
  2873. * @param min defines the lower range value
  2874. * @param max defines the upper range value
  2875. * @param result defines the Vector3 where to store the result
  2876. */
  2877. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2878. /**
  2879. * Checks if a given vector is inside a specific range
  2880. * @param v defines the vector to test
  2881. * @param min defines the minimum range
  2882. * @param max defines the maximum range
  2883. */
  2884. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2885. /**
  2886. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2887. * @param value1 defines the first control point
  2888. * @param tangent1 defines the first tangent vector
  2889. * @param value2 defines the second control point
  2890. * @param tangent2 defines the second tangent vector
  2891. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2892. * @returns the new Vector3
  2893. */
  2894. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2895. /**
  2896. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2897. * @param start defines the start value
  2898. * @param end defines the end value
  2899. * @param amount max defines amount between both (between 0 and 1)
  2900. * @returns the new Vector3
  2901. */
  2902. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2903. /**
  2904. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2905. * @param start defines the start value
  2906. * @param end defines the end value
  2907. * @param amount max defines amount between both (between 0 and 1)
  2908. * @param result defines the Vector3 where to store the result
  2909. */
  2910. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2911. /**
  2912. * Returns the dot product (float) between the vectors "left" and "right"
  2913. * @param left defines the left operand
  2914. * @param right defines the right operand
  2915. * @returns the dot product
  2916. */
  2917. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2918. /**
  2919. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2920. * The cross product is then orthogonal to both "left" and "right"
  2921. * @param left defines the left operand
  2922. * @param right defines the right operand
  2923. * @returns the cross product
  2924. */
  2925. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2926. /**
  2927. * Sets the given vector "result" with the cross product of "left" and "right"
  2928. * The cross product is then orthogonal to both "left" and "right"
  2929. * @param left defines the left operand
  2930. * @param right defines the right operand
  2931. * @param result defines the Vector3 where to store the result
  2932. */
  2933. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2934. /**
  2935. * Returns a new Vector3 as the normalization of the given vector
  2936. * @param vector defines the Vector3 to normalize
  2937. * @returns the new Vector3
  2938. */
  2939. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2940. /**
  2941. * Sets the given vector "result" with the normalization of the given first vector
  2942. * @param vector defines the Vector3 to normalize
  2943. * @param result defines the Vector3 where to store the result
  2944. */
  2945. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2946. /**
  2947. * Project a Vector3 onto screen space
  2948. * @param vector defines the Vector3 to project
  2949. * @param world defines the world matrix to use
  2950. * @param transform defines the transform (view x projection) matrix to use
  2951. * @param viewport defines the screen viewport to use
  2952. * @returns the new Vector3
  2953. */
  2954. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2955. /** @hidden */
  2956. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2957. /**
  2958. * Unproject from screen space to object space
  2959. * @param source defines the screen space Vector3 to use
  2960. * @param viewportWidth defines the current width of the viewport
  2961. * @param viewportHeight defines the current height of the viewport
  2962. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2963. * @param transform defines the transform (view x projection) matrix to use
  2964. * @returns the new Vector3
  2965. */
  2966. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2967. /**
  2968. * Unproject from screen space to object space
  2969. * @param source defines the screen space Vector3 to use
  2970. * @param viewportWidth defines the current width of the viewport
  2971. * @param viewportHeight defines the current height of the viewport
  2972. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2973. * @param view defines the view matrix to use
  2974. * @param projection defines the projection matrix to use
  2975. * @returns the new Vector3
  2976. */
  2977. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2978. /**
  2979. * Unproject from screen space to object space
  2980. * @param source defines the screen space Vector3 to use
  2981. * @param viewportWidth defines the current width of the viewport
  2982. * @param viewportHeight defines the current height of the viewport
  2983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2984. * @param view defines the view matrix to use
  2985. * @param projection defines the projection matrix to use
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Unproject from screen space to object space
  2991. * @param sourceX defines the screen space x coordinate to use
  2992. * @param sourceY defines the screen space y coordinate to use
  2993. * @param sourceZ defines the screen space z coordinate to use
  2994. * @param viewportWidth defines the current width of the viewport
  2995. * @param viewportHeight defines the current height of the viewport
  2996. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2997. * @param view defines the view matrix to use
  2998. * @param projection defines the projection matrix to use
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Gets the minimal coordinate values between two Vector3
  3004. * @param left defines the first operand
  3005. * @param right defines the second operand
  3006. * @returns the new Vector3
  3007. */
  3008. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3009. /**
  3010. * Gets the maximal coordinate values between two Vector3
  3011. * @param left defines the first operand
  3012. * @param right defines the second operand
  3013. * @returns the new Vector3
  3014. */
  3015. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3016. /**
  3017. * Returns the distance between the vectors "value1" and "value2"
  3018. * @param value1 defines the first operand
  3019. * @param value2 defines the second operand
  3020. * @returns the distance
  3021. */
  3022. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3023. /**
  3024. * Returns the squared distance between the vectors "value1" and "value2"
  3025. * @param value1 defines the first operand
  3026. * @param value2 defines the second operand
  3027. * @returns the squared distance
  3028. */
  3029. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3030. /**
  3031. * Returns a new Vector3 located at the center between "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the new Vector3
  3035. */
  3036. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3037. /**
  3038. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3039. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3040. * to something in order to rotate it from its local system to the given target system
  3041. * Note: axis1, axis2 and axis3 are normalized during this operation
  3042. * @param axis1 defines the first axis
  3043. * @param axis2 defines the second axis
  3044. * @param axis3 defines the third axis
  3045. * @returns a new Vector3
  3046. */
  3047. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3048. /**
  3049. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3050. * @param axis1 defines the first axis
  3051. * @param axis2 defines the second axis
  3052. * @param axis3 defines the third axis
  3053. * @param ref defines the Vector3 where to store the result
  3054. */
  3055. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3056. }
  3057. /**
  3058. * Vector4 class created for EulerAngle class conversion to Quaternion
  3059. */
  3060. export class Vector4 {
  3061. /** x value of the vector */
  3062. x: number;
  3063. /** y value of the vector */
  3064. y: number;
  3065. /** z value of the vector */
  3066. z: number;
  3067. /** w value of the vector */
  3068. w: number;
  3069. /**
  3070. * Creates a Vector4 object from the given floats.
  3071. * @param x x value of the vector
  3072. * @param y y value of the vector
  3073. * @param z z value of the vector
  3074. * @param w w value of the vector
  3075. */
  3076. constructor(
  3077. /** x value of the vector */
  3078. x: number,
  3079. /** y value of the vector */
  3080. y: number,
  3081. /** z value of the vector */
  3082. z: number,
  3083. /** w value of the vector */
  3084. w: number);
  3085. /**
  3086. * Returns the string with the Vector4 coordinates.
  3087. * @returns a string containing all the vector values
  3088. */
  3089. toString(): string;
  3090. /**
  3091. * Returns the string "Vector4".
  3092. * @returns "Vector4"
  3093. */
  3094. getClassName(): string;
  3095. /**
  3096. * Returns the Vector4 hash code.
  3097. * @returns a unique hash code
  3098. */
  3099. getHashCode(): number;
  3100. /**
  3101. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3102. * @returns the resulting array
  3103. */
  3104. asArray(): number[];
  3105. /**
  3106. * Populates the given array from the given index with the Vector4 coordinates.
  3107. * @param array array to populate
  3108. * @param index index of the array to start at (default: 0)
  3109. * @returns the Vector4.
  3110. */
  3111. toArray(array: FloatArray, index?: number): Vector4;
  3112. /**
  3113. * Adds the given vector to the current Vector4.
  3114. * @param otherVector the vector to add
  3115. * @returns the updated Vector4.
  3116. */
  3117. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3120. * @param otherVector the vector to add
  3121. * @returns the resulting vector
  3122. */
  3123. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3126. * @param otherVector the vector to add
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Subtract in place the given vector from the current Vector4.
  3133. * @param otherVector the vector to subtract
  3134. * @returns the updated Vector4.
  3135. */
  3136. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3137. /**
  3138. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3139. * @param otherVector the vector to add
  3140. * @returns the new vector with the result
  3141. */
  3142. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3143. /**
  3144. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3145. * @param otherVector the vector to subtract
  3146. * @param result the vector to store the result
  3147. * @returns the current Vector4.
  3148. */
  3149. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3150. /**
  3151. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3152. */
  3153. /**
  3154. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3155. * @param x value to subtract
  3156. * @param y value to subtract
  3157. * @param z value to subtract
  3158. * @param w value to subtract
  3159. * @returns new vector containing the result
  3160. */
  3161. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3162. /**
  3163. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3164. * @param x value to subtract
  3165. * @param y value to subtract
  3166. * @param z value to subtract
  3167. * @param w value to subtract
  3168. * @param result the vector to store the result in
  3169. * @returns the current Vector4.
  3170. */
  3171. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3172. /**
  3173. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3174. * @returns a new vector with the negated values
  3175. */
  3176. negate(): Vector4;
  3177. /**
  3178. * Negate this vector in place
  3179. * @returns this
  3180. */
  3181. negateInPlace(): Vector4;
  3182. /**
  3183. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3184. * @param result defines the Vector3 object where to store the result
  3185. * @returns the current Vector4
  3186. */
  3187. negateToRef(result: Vector4): Vector4;
  3188. /**
  3189. * Multiplies the current Vector4 coordinates by scale (float).
  3190. * @param scale the number to scale with
  3191. * @returns the updated Vector4.
  3192. */
  3193. scaleInPlace(scale: number): Vector4;
  3194. /**
  3195. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3196. * @param scale the number to scale with
  3197. * @returns a new vector with the result
  3198. */
  3199. scale(scale: number): Vector4;
  3200. /**
  3201. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3202. * @param scale the number to scale with
  3203. * @param result a vector to store the result in
  3204. * @returns the current Vector4.
  3205. */
  3206. scaleToRef(scale: number, result: Vector4): Vector4;
  3207. /**
  3208. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3209. * @param scale defines the scale factor
  3210. * @param result defines the Vector4 object where to store the result
  3211. * @returns the unmodified current Vector4
  3212. */
  3213. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3214. /**
  3215. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3216. * @param otherVector the vector to compare against
  3217. * @returns true if they are equal
  3218. */
  3219. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3220. /**
  3221. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3222. * @param otherVector vector to compare against
  3223. * @param epsilon (Default: very small number)
  3224. * @returns true if they are equal
  3225. */
  3226. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3227. /**
  3228. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3229. * @param x x value to compare against
  3230. * @param y y value to compare against
  3231. * @param z z value to compare against
  3232. * @param w w value to compare against
  3233. * @returns true if equal
  3234. */
  3235. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3236. /**
  3237. * Multiplies in place the current Vector4 by the given one.
  3238. * @param otherVector vector to multiple with
  3239. * @returns the updated Vector4.
  3240. */
  3241. multiplyInPlace(otherVector: Vector4): Vector4;
  3242. /**
  3243. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3244. * @param otherVector vector to multiple with
  3245. * @returns resulting new vector
  3246. */
  3247. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3248. /**
  3249. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3250. * @param otherVector vector to multiple with
  3251. * @param result vector to store the result
  3252. * @returns the current Vector4.
  3253. */
  3254. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3255. /**
  3256. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3257. * @param x x value multiply with
  3258. * @param y y value multiply with
  3259. * @param z z value multiply with
  3260. * @param w w value multiply with
  3261. * @returns resulting new vector
  3262. */
  3263. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3264. /**
  3265. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3266. * @param otherVector vector to devide with
  3267. * @returns resulting new vector
  3268. */
  3269. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3272. * @param otherVector vector to devide with
  3273. * @param result vector to store the result
  3274. * @returns the current Vector4.
  3275. */
  3276. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3277. /**
  3278. * Divides the current Vector3 coordinates by the given ones.
  3279. * @param otherVector vector to devide with
  3280. * @returns the updated Vector3.
  3281. */
  3282. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3283. /**
  3284. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3285. * @param other defines the second operand
  3286. * @returns the current updated Vector4
  3287. */
  3288. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3289. /**
  3290. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3291. * @param other defines the second operand
  3292. * @returns the current updated Vector4
  3293. */
  3294. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3295. /**
  3296. * Gets a new Vector4 from current Vector4 floored values
  3297. * @returns a new Vector4
  3298. */
  3299. floor(): Vector4;
  3300. /**
  3301. * Gets a new Vector4 from current Vector3 floored values
  3302. * @returns a new Vector4
  3303. */
  3304. fract(): Vector4;
  3305. /**
  3306. * Returns the Vector4 length (float).
  3307. * @returns the length
  3308. */
  3309. length(): number;
  3310. /**
  3311. * Returns the Vector4 squared length (float).
  3312. * @returns the length squared
  3313. */
  3314. lengthSquared(): number;
  3315. /**
  3316. * Normalizes in place the Vector4.
  3317. * @returns the updated Vector4.
  3318. */
  3319. normalize(): Vector4;
  3320. /**
  3321. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3322. * @returns this converted to a new vector3
  3323. */
  3324. toVector3(): Vector3;
  3325. /**
  3326. * Returns a new Vector4 copied from the current one.
  3327. * @returns the new cloned vector
  3328. */
  3329. clone(): Vector4;
  3330. /**
  3331. * Updates the current Vector4 with the given one coordinates.
  3332. * @param source the source vector to copy from
  3333. * @returns the updated Vector4.
  3334. */
  3335. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3336. /**
  3337. * Updates the current Vector4 coordinates with the given floats.
  3338. * @param x float to copy from
  3339. * @param y float to copy from
  3340. * @param z float to copy from
  3341. * @param w float to copy from
  3342. * @returns the updated Vector4.
  3343. */
  3344. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3345. /**
  3346. * Updates the current Vector4 coordinates with the given floats.
  3347. * @param x float to set from
  3348. * @param y float to set from
  3349. * @param z float to set from
  3350. * @param w float to set from
  3351. * @returns the updated Vector4.
  3352. */
  3353. set(x: number, y: number, z: number, w: number): Vector4;
  3354. /**
  3355. * Copies the given float to the current Vector3 coordinates
  3356. * @param v defines the x, y, z and w coordinates of the operand
  3357. * @returns the current updated Vector3
  3358. */
  3359. setAll(v: number): Vector4;
  3360. /**
  3361. * Returns a new Vector4 set from the starting index of the given array.
  3362. * @param array the array to pull values from
  3363. * @param offset the offset into the array to start at
  3364. * @returns the new vector
  3365. */
  3366. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3367. /**
  3368. * Updates the given vector "result" from the starting index of the given array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @param result the vector to store the result in
  3372. */
  3373. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3374. /**
  3375. * Updates the given vector "result" from the starting index of the given Float32Array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @param result the vector to store the result in
  3379. */
  3380. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3381. /**
  3382. * Updates the given vector "result" coordinates from the given floats.
  3383. * @param x float to set from
  3384. * @param y float to set from
  3385. * @param z float to set from
  3386. * @param w float to set from
  3387. * @param result the vector to the floats in
  3388. */
  3389. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3390. /**
  3391. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3392. * @returns the new vector
  3393. */
  3394. static Zero(): Vector4;
  3395. /**
  3396. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3397. * @returns the new vector
  3398. */
  3399. static One(): Vector4;
  3400. /**
  3401. * Returns a new normalized Vector4 from the given one.
  3402. * @param vector the vector to normalize
  3403. * @returns the vector
  3404. */
  3405. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3406. /**
  3407. * Updates the given vector "result" from the normalization of the given one.
  3408. * @param vector the vector to normalize
  3409. * @param result the vector to store the result in
  3410. */
  3411. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3412. /**
  3413. * Returns a vector with the minimum values from the left and right vectors
  3414. * @param left left vector to minimize
  3415. * @param right right vector to minimize
  3416. * @returns a new vector with the minimum of the left and right vector values
  3417. */
  3418. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3419. /**
  3420. * Returns a vector with the maximum values from the left and right vectors
  3421. * @param left left vector to maximize
  3422. * @param right right vector to maximize
  3423. * @returns a new vector with the maximum of the left and right vector values
  3424. */
  3425. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Returns the distance (float) between the vectors "value1" and "value2".
  3428. * @param value1 value to calulate the distance between
  3429. * @param value2 value to calulate the distance between
  3430. * @return the distance between the two vectors
  3431. */
  3432. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3433. /**
  3434. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the distance between
  3436. * @param value2 value to calulate the distance between
  3437. * @return the distance between the two vectors squared
  3438. */
  3439. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3440. /**
  3441. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the center between
  3443. * @param value2 value to calulate the center between
  3444. * @return the center between the two vectors
  3445. */
  3446. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3447. /**
  3448. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3449. * This methods computes transformed normalized direction vectors only.
  3450. * @param vector the vector to transform
  3451. * @param transformation the transformation matrix to apply
  3452. * @returns the new vector
  3453. */
  3454. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3455. /**
  3456. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3457. * This methods computes transformed normalized direction vectors only.
  3458. * @param vector the vector to transform
  3459. * @param transformation the transformation matrix to apply
  3460. * @param result the vector to store the result in
  3461. */
  3462. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3463. /**
  3464. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3465. * This methods computes transformed normalized direction vectors only.
  3466. * @param x value to transform
  3467. * @param y value to transform
  3468. * @param z value to transform
  3469. * @param w value to transform
  3470. * @param transformation the transformation matrix to apply
  3471. * @param result the vector to store the results in
  3472. */
  3473. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3474. /**
  3475. * Creates a new Vector4 from a Vector3
  3476. * @param source defines the source data
  3477. * @param w defines the 4th component (default is 0)
  3478. * @returns a new Vector4
  3479. */
  3480. static FromVector3(source: Vector3, w?: number): Vector4;
  3481. }
  3482. /**
  3483. * Class used to store quaternion data
  3484. * @see https://en.wikipedia.org/wiki/Quaternion
  3485. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3486. */
  3487. export class Quaternion {
  3488. /** defines the first component (0 by default) */
  3489. x: number;
  3490. /** defines the second component (0 by default) */
  3491. y: number;
  3492. /** defines the third component (0 by default) */
  3493. z: number;
  3494. /** defines the fourth component (1.0 by default) */
  3495. w: number;
  3496. /**
  3497. * Creates a new Quaternion from the given floats
  3498. * @param x defines the first component (0 by default)
  3499. * @param y defines the second component (0 by default)
  3500. * @param z defines the third component (0 by default)
  3501. * @param w defines the fourth component (1.0 by default)
  3502. */
  3503. constructor(
  3504. /** defines the first component (0 by default) */
  3505. x?: number,
  3506. /** defines the second component (0 by default) */
  3507. y?: number,
  3508. /** defines the third component (0 by default) */
  3509. z?: number,
  3510. /** defines the fourth component (1.0 by default) */
  3511. w?: number);
  3512. /**
  3513. * Gets a string representation for the current quaternion
  3514. * @returns a string with the Quaternion coordinates
  3515. */
  3516. toString(): string;
  3517. /**
  3518. * Gets the class name of the quaternion
  3519. * @returns the string "Quaternion"
  3520. */
  3521. getClassName(): string;
  3522. /**
  3523. * Gets a hash code for this quaternion
  3524. * @returns the quaternion hash code
  3525. */
  3526. getHashCode(): number;
  3527. /**
  3528. * Copy the quaternion to an array
  3529. * @returns a new array populated with 4 elements from the quaternion coordinates
  3530. */
  3531. asArray(): number[];
  3532. /**
  3533. * Check if two quaternions are equals
  3534. * @param otherQuaternion defines the second operand
  3535. * @return true if the current quaternion and the given one coordinates are strictly equals
  3536. */
  3537. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3538. /**
  3539. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3540. * @param otherQuaternion defines the other quaternion
  3541. * @param epsilon defines the minimal distance to consider equality
  3542. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3543. */
  3544. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3545. /**
  3546. * Clone the current quaternion
  3547. * @returns a new quaternion copied from the current one
  3548. */
  3549. clone(): Quaternion;
  3550. /**
  3551. * Copy a quaternion to the current one
  3552. * @param other defines the other quaternion
  3553. * @returns the updated current quaternion
  3554. */
  3555. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3556. /**
  3557. * Updates the current quaternion with the given float coordinates
  3558. * @param x defines the x coordinate
  3559. * @param y defines the y coordinate
  3560. * @param z defines the z coordinate
  3561. * @param w defines the w coordinate
  3562. * @returns the updated current quaternion
  3563. */
  3564. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3565. /**
  3566. * Updates the current quaternion from the given float coordinates
  3567. * @param x defines the x coordinate
  3568. * @param y defines the y coordinate
  3569. * @param z defines the z coordinate
  3570. * @param w defines the w coordinate
  3571. * @returns the updated current quaternion
  3572. */
  3573. set(x: number, y: number, z: number, w: number): Quaternion;
  3574. /**
  3575. * Adds two quaternions
  3576. * @param other defines the second operand
  3577. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3578. */
  3579. add(other: DeepImmutable<Quaternion>): Quaternion;
  3580. /**
  3581. * Add a quaternion to the current one
  3582. * @param other defines the quaternion to add
  3583. * @returns the current quaternion
  3584. */
  3585. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3586. /**
  3587. * Subtract two quaternions
  3588. * @param other defines the second operand
  3589. * @returns a new quaternion as the subtraction result of the given one from the current one
  3590. */
  3591. subtract(other: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies the current quaternion by a scale factor
  3594. * @param value defines the scale factor
  3595. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3596. */
  3597. scale(value: number): Quaternion;
  3598. /**
  3599. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3600. * @param scale defines the scale factor
  3601. * @param result defines the Quaternion object where to store the result
  3602. * @returns the unmodified current quaternion
  3603. */
  3604. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3605. /**
  3606. * Multiplies in place the current quaternion by a scale factor
  3607. * @param value defines the scale factor
  3608. * @returns the current modified quaternion
  3609. */
  3610. scaleInPlace(value: number): Quaternion;
  3611. /**
  3612. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3613. * @param scale defines the scale factor
  3614. * @param result defines the Quaternion object where to store the result
  3615. * @returns the unmodified current quaternion
  3616. */
  3617. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3618. /**
  3619. * Multiplies two quaternions
  3620. * @param q1 defines the second operand
  3621. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3622. */
  3623. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3624. /**
  3625. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3626. * @param q1 defines the second operand
  3627. * @param result defines the target quaternion
  3628. * @returns the current quaternion
  3629. */
  3630. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3631. /**
  3632. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3633. * @param q1 defines the second operand
  3634. * @returns the currentupdated quaternion
  3635. */
  3636. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3637. /**
  3638. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3639. * @param ref defines the target quaternion
  3640. * @returns the current quaternion
  3641. */
  3642. conjugateToRef(ref: Quaternion): Quaternion;
  3643. /**
  3644. * Conjugates in place (1-q) the current quaternion
  3645. * @returns the current updated quaternion
  3646. */
  3647. conjugateInPlace(): Quaternion;
  3648. /**
  3649. * Conjugates in place (1-q) the current quaternion
  3650. * @returns a new quaternion
  3651. */
  3652. conjugate(): Quaternion;
  3653. /**
  3654. * Gets length of current quaternion
  3655. * @returns the quaternion length (float)
  3656. */
  3657. length(): number;
  3658. /**
  3659. * Normalize in place the current quaternion
  3660. * @returns the current updated quaternion
  3661. */
  3662. normalize(): Quaternion;
  3663. /**
  3664. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3665. * @param order is a reserved parameter and is ignore for now
  3666. * @returns a new Vector3 containing the Euler angles
  3667. */
  3668. toEulerAngles(order?: string): Vector3;
  3669. /**
  3670. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3671. * @param result defines the vector which will be filled with the Euler angles
  3672. * @param order is a reserved parameter and is ignore for now
  3673. * @returns the current unchanged quaternion
  3674. */
  3675. toEulerAnglesToRef(result: Vector3): Quaternion;
  3676. /**
  3677. * Updates the given rotation matrix with the current quaternion values
  3678. * @param result defines the target matrix
  3679. * @returns the current unchanged quaternion
  3680. */
  3681. toRotationMatrix(result: Matrix): Quaternion;
  3682. /**
  3683. * Updates the current quaternion from the given rotation matrix values
  3684. * @param matrix defines the source matrix
  3685. * @returns the current updated quaternion
  3686. */
  3687. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3688. /**
  3689. * Creates a new quaternion from a rotation matrix
  3690. * @param matrix defines the source matrix
  3691. * @returns a new quaternion created from the given rotation matrix values
  3692. */
  3693. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3694. /**
  3695. * Updates the given quaternion with the given rotation matrix values
  3696. * @param matrix defines the source matrix
  3697. * @param result defines the target quaternion
  3698. */
  3699. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3700. /**
  3701. * Returns the dot product (float) between the quaternions "left" and "right"
  3702. * @param left defines the left operand
  3703. * @param right defines the right operand
  3704. * @returns the dot product
  3705. */
  3706. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3707. /**
  3708. * Checks if the two quaternions are close to each other
  3709. * @param quat0 defines the first quaternion to check
  3710. * @param quat1 defines the second quaternion to check
  3711. * @returns true if the two quaternions are close to each other
  3712. */
  3713. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3714. /**
  3715. * Creates an empty quaternion
  3716. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3717. */
  3718. static Zero(): Quaternion;
  3719. /**
  3720. * Inverse a given quaternion
  3721. * @param q defines the source quaternion
  3722. * @returns a new quaternion as the inverted current quaternion
  3723. */
  3724. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3725. /**
  3726. * Inverse a given quaternion
  3727. * @param q defines the source quaternion
  3728. * @param result the quaternion the result will be stored in
  3729. * @returns the result quaternion
  3730. */
  3731. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates an identity quaternion
  3734. * @returns the identity quaternion
  3735. */
  3736. static Identity(): Quaternion;
  3737. /**
  3738. * Gets a boolean indicating if the given quaternion is identity
  3739. * @param quaternion defines the quaternion to check
  3740. * @returns true if the quaternion is identity
  3741. */
  3742. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3743. /**
  3744. * Creates a quaternion from a rotation around an axis
  3745. * @param axis defines the axis to use
  3746. * @param angle defines the angle to use
  3747. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3748. */
  3749. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3750. /**
  3751. * Creates a rotation around an axis and stores it into the given quaternion
  3752. * @param axis defines the axis to use
  3753. * @param angle defines the angle to use
  3754. * @param result defines the target quaternion
  3755. * @returns the target quaternion
  3756. */
  3757. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from data stored into an array
  3760. * @param array defines the data source
  3761. * @param offset defines the offset in the source array where the data starts
  3762. * @returns a new quaternion
  3763. */
  3764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3765. /**
  3766. * Create a quaternion from Euler rotation angles
  3767. * @param x Pitch
  3768. * @param y Yaw
  3769. * @param z Roll
  3770. * @returns the new Quaternion
  3771. */
  3772. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3773. /**
  3774. * Updates a quaternion from Euler rotation angles
  3775. * @param x Pitch
  3776. * @param y Yaw
  3777. * @param z Roll
  3778. * @param result the quaternion to store the result
  3779. * @returns the updated quaternion
  3780. */
  3781. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3782. /**
  3783. * Create a quaternion from Euler rotation vector
  3784. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3785. * @returns the new Quaternion
  3786. */
  3787. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3788. /**
  3789. * Updates a quaternion from Euler rotation vector
  3790. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3791. * @param result the quaternion to store the result
  3792. * @returns the updated quaternion
  3793. */
  3794. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3795. /**
  3796. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3797. * @param yaw defines the rotation around Y axis
  3798. * @param pitch defines the rotation around X axis
  3799. * @param roll defines the rotation around Z axis
  3800. * @returns the new quaternion
  3801. */
  3802. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3803. /**
  3804. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3805. * @param yaw defines the rotation around Y axis
  3806. * @param pitch defines the rotation around X axis
  3807. * @param roll defines the rotation around Z axis
  3808. * @param result defines the target quaternion
  3809. */
  3810. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3811. /**
  3812. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3813. * @param alpha defines the rotation around first axis
  3814. * @param beta defines the rotation around second axis
  3815. * @param gamma defines the rotation around third axis
  3816. * @returns the new quaternion
  3817. */
  3818. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3819. /**
  3820. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3821. * @param alpha defines the rotation around first axis
  3822. * @param beta defines the rotation around second axis
  3823. * @param gamma defines the rotation around third axis
  3824. * @param result defines the target quaternion
  3825. */
  3826. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3827. /**
  3828. * 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)
  3829. * @param axis1 defines the first axis
  3830. * @param axis2 defines the second axis
  3831. * @param axis3 defines the third axis
  3832. * @returns the new quaternion
  3833. */
  3834. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3835. /**
  3836. * 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
  3837. * @param axis1 defines the first axis
  3838. * @param axis2 defines the second axis
  3839. * @param axis3 defines the third axis
  3840. * @param ref defines the target quaternion
  3841. */
  3842. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3843. /**
  3844. * Interpolates between two quaternions
  3845. * @param left defines first quaternion
  3846. * @param right defines second quaternion
  3847. * @param amount defines the gradient to use
  3848. * @returns the new interpolated quaternion
  3849. */
  3850. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3851. /**
  3852. * Interpolates between two quaternions and stores it into a target quaternion
  3853. * @param left defines first quaternion
  3854. * @param right defines second quaternion
  3855. * @param amount defines the gradient to use
  3856. * @param result defines the target quaternion
  3857. */
  3858. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3859. /**
  3860. * Interpolate between two quaternions using Hermite interpolation
  3861. * @param value1 defines first quaternion
  3862. * @param tangent1 defines the incoming tangent
  3863. * @param value2 defines second quaternion
  3864. * @param tangent2 defines the outgoing tangent
  3865. * @param amount defines the target quaternion
  3866. * @returns the new interpolated quaternion
  3867. */
  3868. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3869. }
  3870. /**
  3871. * Class used to store matrix data (4x4)
  3872. */
  3873. export class Matrix {
  3874. private static _updateFlagSeed;
  3875. private static _identityReadOnly;
  3876. private _isIdentity;
  3877. private _isIdentityDirty;
  3878. private _isIdentity3x2;
  3879. private _isIdentity3x2Dirty;
  3880. /**
  3881. * Gets the update flag of the matrix which is an unique number for the matrix.
  3882. * It will be incremented every time the matrix data change.
  3883. * You can use it to speed the comparison between two versions of the same matrix.
  3884. */
  3885. updateFlag: number;
  3886. private readonly _m;
  3887. /**
  3888. * Gets the internal data of the matrix
  3889. */
  3890. get m(): DeepImmutable<Float32Array>;
  3891. /** @hidden */
  3892. _markAsUpdated(): void;
  3893. /** @hidden */
  3894. private _updateIdentityStatus;
  3895. /**
  3896. * Creates an empty matrix (filled with zeros)
  3897. */
  3898. constructor();
  3899. /**
  3900. * Check if the current matrix is identity
  3901. * @returns true is the matrix is the identity matrix
  3902. */
  3903. isIdentity(): boolean;
  3904. /**
  3905. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3906. * @returns true is the matrix is the identity matrix
  3907. */
  3908. isIdentityAs3x2(): boolean;
  3909. /**
  3910. * Gets the determinant of the matrix
  3911. * @returns the matrix determinant
  3912. */
  3913. determinant(): number;
  3914. /**
  3915. * Returns the matrix as a Float32Array
  3916. * @returns the matrix underlying array
  3917. */
  3918. toArray(): DeepImmutable<Float32Array>;
  3919. /**
  3920. * Returns the matrix as a Float32Array
  3921. * @returns the matrix underlying array.
  3922. */
  3923. asArray(): DeepImmutable<Float32Array>;
  3924. /**
  3925. * Inverts the current matrix in place
  3926. * @returns the current inverted matrix
  3927. */
  3928. invert(): Matrix;
  3929. /**
  3930. * Sets all the matrix elements to zero
  3931. * @returns the current matrix
  3932. */
  3933. reset(): Matrix;
  3934. /**
  3935. * Adds the current matrix with a second one
  3936. * @param other defines the matrix to add
  3937. * @returns a new matrix as the addition of the current matrix and the given one
  3938. */
  3939. add(other: DeepImmutable<Matrix>): Matrix;
  3940. /**
  3941. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3942. * @param other defines the matrix to add
  3943. * @param result defines the target matrix
  3944. * @returns the current matrix
  3945. */
  3946. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3947. /**
  3948. * Adds in place the given matrix to the current matrix
  3949. * @param other defines the second operand
  3950. * @returns the current updated matrix
  3951. */
  3952. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3953. /**
  3954. * Sets the given matrix to the current inverted Matrix
  3955. * @param other defines the target matrix
  3956. * @returns the unmodified current matrix
  3957. */
  3958. invertToRef(other: Matrix): Matrix;
  3959. /**
  3960. * add a value at the specified position in the current Matrix
  3961. * @param index the index of the value within the matrix. between 0 and 15.
  3962. * @param value the value to be added
  3963. * @returns the current updated matrix
  3964. */
  3965. addAtIndex(index: number, value: number): Matrix;
  3966. /**
  3967. * mutiply the specified position in the current Matrix by a value
  3968. * @param index the index of the value within the matrix. between 0 and 15.
  3969. * @param value the value to be added
  3970. * @returns the current updated matrix
  3971. */
  3972. multiplyAtIndex(index: number, value: number): Matrix;
  3973. /**
  3974. * Inserts the translation vector (using 3 floats) in the current matrix
  3975. * @param x defines the 1st component of the translation
  3976. * @param y defines the 2nd component of the translation
  3977. * @param z defines the 3rd component of the translation
  3978. * @returns the current updated matrix
  3979. */
  3980. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3981. /**
  3982. * Adds the translation vector (using 3 floats) in the current matrix
  3983. * @param x defines the 1st component of the translation
  3984. * @param y defines the 2nd component of the translation
  3985. * @param z defines the 3rd component of the translation
  3986. * @returns the current updated matrix
  3987. */
  3988. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3989. /**
  3990. * Inserts the translation vector in the current matrix
  3991. * @param vector3 defines the translation to insert
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3995. /**
  3996. * Gets the translation value of the current matrix
  3997. * @returns a new Vector3 as the extracted translation from the matrix
  3998. */
  3999. getTranslation(): Vector3;
  4000. /**
  4001. * Fill a Vector3 with the extracted translation from the matrix
  4002. * @param result defines the Vector3 where to store the translation
  4003. * @returns the current matrix
  4004. */
  4005. getTranslationToRef(result: Vector3): Matrix;
  4006. /**
  4007. * Remove rotation and scaling part from the matrix
  4008. * @returns the updated matrix
  4009. */
  4010. removeRotationAndScaling(): Matrix;
  4011. /**
  4012. * Multiply two matrices
  4013. * @param other defines the second operand
  4014. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4015. */
  4016. multiply(other: DeepImmutable<Matrix>): Matrix;
  4017. /**
  4018. * Copy the current matrix from the given one
  4019. * @param other defines the source matrix
  4020. * @returns the current updated matrix
  4021. */
  4022. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4023. /**
  4024. * Populates the given array from the starting index with the current matrix values
  4025. * @param array defines the target array
  4026. * @param offset defines the offset in the target array where to start storing values
  4027. * @returns the current matrix
  4028. */
  4029. copyToArray(array: Float32Array, offset?: number): Matrix;
  4030. /**
  4031. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4032. * @param other defines the second operand
  4033. * @param result defines the matrix where to store the multiplication
  4034. * @returns the current matrix
  4035. */
  4036. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4037. /**
  4038. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4039. * @param other defines the second operand
  4040. * @param result defines the array where to store the multiplication
  4041. * @param offset defines the offset in the target array where to start storing values
  4042. * @returns the current matrix
  4043. */
  4044. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4045. /**
  4046. * Check equality between this matrix and a second one
  4047. * @param value defines the second matrix to compare
  4048. * @returns true is the current matrix and the given one values are strictly equal
  4049. */
  4050. equals(value: DeepImmutable<Matrix>): boolean;
  4051. /**
  4052. * Clone the current matrix
  4053. * @returns a new matrix from the current matrix
  4054. */
  4055. clone(): Matrix;
  4056. /**
  4057. * Returns the name of the current matrix class
  4058. * @returns the string "Matrix"
  4059. */
  4060. getClassName(): string;
  4061. /**
  4062. * Gets the hash code of the current matrix
  4063. * @returns the hash code
  4064. */
  4065. getHashCode(): number;
  4066. /**
  4067. * Decomposes the current Matrix into a translation, rotation and scaling components
  4068. * @param scale defines the scale vector3 given as a reference to update
  4069. * @param rotation defines the rotation quaternion given as a reference to update
  4070. * @param translation defines the translation vector3 given as a reference to update
  4071. * @returns true if operation was successful
  4072. */
  4073. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4074. /**
  4075. * Gets specific row of the matrix
  4076. * @param index defines the number of the row to get
  4077. * @returns the index-th row of the current matrix as a new Vector4
  4078. */
  4079. getRow(index: number): Nullable<Vector4>;
  4080. /**
  4081. * Sets the index-th row of the current matrix to the vector4 values
  4082. * @param index defines the number of the row to set
  4083. * @param row defines the target vector4
  4084. * @returns the updated current matrix
  4085. */
  4086. setRow(index: number, row: Vector4): Matrix;
  4087. /**
  4088. * Compute the transpose of the matrix
  4089. * @returns the new transposed matrix
  4090. */
  4091. transpose(): Matrix;
  4092. /**
  4093. * Compute the transpose of the matrix and store it in a given matrix
  4094. * @param result defines the target matrix
  4095. * @returns the current matrix
  4096. */
  4097. transposeToRef(result: Matrix): Matrix;
  4098. /**
  4099. * Sets the index-th row of the current matrix with the given 4 x float values
  4100. * @param index defines the row index
  4101. * @param x defines the x component to set
  4102. * @param y defines the y component to set
  4103. * @param z defines the z component to set
  4104. * @param w defines the w component to set
  4105. * @returns the updated current matrix
  4106. */
  4107. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4108. /**
  4109. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4110. * @param scale defines the scale factor
  4111. * @returns a new matrix
  4112. */
  4113. scale(scale: number): Matrix;
  4114. /**
  4115. * Scale the current matrix values by a factor to a given result matrix
  4116. * @param scale defines the scale factor
  4117. * @param result defines the matrix to store the result
  4118. * @returns the current matrix
  4119. */
  4120. scaleToRef(scale: number, result: Matrix): Matrix;
  4121. /**
  4122. * Scale the current matrix values by a factor and add the result to a given matrix
  4123. * @param scale defines the scale factor
  4124. * @param result defines the Matrix to store the result
  4125. * @returns the current matrix
  4126. */
  4127. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4128. /**
  4129. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4130. * @param ref matrix to store the result
  4131. */
  4132. toNormalMatrix(ref: Matrix): void;
  4133. /**
  4134. * Gets only rotation part of the current matrix
  4135. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4136. */
  4137. getRotationMatrix(): Matrix;
  4138. /**
  4139. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4140. * @param result defines the target matrix to store data to
  4141. * @returns the current matrix
  4142. */
  4143. getRotationMatrixToRef(result: Matrix): Matrix;
  4144. /**
  4145. * Toggles model matrix from being right handed to left handed in place and vice versa
  4146. */
  4147. toggleModelMatrixHandInPlace(): void;
  4148. /**
  4149. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4150. */
  4151. toggleProjectionMatrixHandInPlace(): void;
  4152. /**
  4153. * Creates a matrix from an array
  4154. * @param array defines the source array
  4155. * @param offset defines an offset in the source array
  4156. * @returns a new Matrix set from the starting index of the given array
  4157. */
  4158. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4159. /**
  4160. * Copy the content of an array into a given matrix
  4161. * @param array defines the source array
  4162. * @param offset defines an offset in the source array
  4163. * @param result defines the target matrix
  4164. */
  4165. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4166. /**
  4167. * Stores an array into a matrix after having multiplied each component by a given factor
  4168. * @param array defines the source array
  4169. * @param offset defines the offset in the source array
  4170. * @param scale defines the scaling factor
  4171. * @param result defines the target matrix
  4172. */
  4173. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4174. /**
  4175. * Gets an identity matrix that must not be updated
  4176. */
  4177. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4178. /**
  4179. * Stores a list of values (16) inside a given matrix
  4180. * @param initialM11 defines 1st value of 1st row
  4181. * @param initialM12 defines 2nd value of 1st row
  4182. * @param initialM13 defines 3rd value of 1st row
  4183. * @param initialM14 defines 4th value of 1st row
  4184. * @param initialM21 defines 1st value of 2nd row
  4185. * @param initialM22 defines 2nd value of 2nd row
  4186. * @param initialM23 defines 3rd value of 2nd row
  4187. * @param initialM24 defines 4th value of 2nd row
  4188. * @param initialM31 defines 1st value of 3rd row
  4189. * @param initialM32 defines 2nd value of 3rd row
  4190. * @param initialM33 defines 3rd value of 3rd row
  4191. * @param initialM34 defines 4th value of 3rd row
  4192. * @param initialM41 defines 1st value of 4th row
  4193. * @param initialM42 defines 2nd value of 4th row
  4194. * @param initialM43 defines 3rd value of 4th row
  4195. * @param initialM44 defines 4th value of 4th row
  4196. * @param result defines the target matrix
  4197. */
  4198. 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;
  4199. /**
  4200. * Creates new matrix from a list of values (16)
  4201. * @param initialM11 defines 1st value of 1st row
  4202. * @param initialM12 defines 2nd value of 1st row
  4203. * @param initialM13 defines 3rd value of 1st row
  4204. * @param initialM14 defines 4th value of 1st row
  4205. * @param initialM21 defines 1st value of 2nd row
  4206. * @param initialM22 defines 2nd value of 2nd row
  4207. * @param initialM23 defines 3rd value of 2nd row
  4208. * @param initialM24 defines 4th value of 2nd row
  4209. * @param initialM31 defines 1st value of 3rd row
  4210. * @param initialM32 defines 2nd value of 3rd row
  4211. * @param initialM33 defines 3rd value of 3rd row
  4212. * @param initialM34 defines 4th value of 3rd row
  4213. * @param initialM41 defines 1st value of 4th row
  4214. * @param initialM42 defines 2nd value of 4th row
  4215. * @param initialM43 defines 3rd value of 4th row
  4216. * @param initialM44 defines 4th value of 4th row
  4217. * @returns the new matrix
  4218. */
  4219. 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;
  4220. /**
  4221. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4222. * @param scale defines the scale vector3
  4223. * @param rotation defines the rotation quaternion
  4224. * @param translation defines the translation vector3
  4225. * @returns a new matrix
  4226. */
  4227. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4228. /**
  4229. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4230. * @param scale defines the scale vector3
  4231. * @param rotation defines the rotation quaternion
  4232. * @param translation defines the translation vector3
  4233. * @param result defines the target matrix
  4234. */
  4235. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4236. /**
  4237. * Creates a new identity matrix
  4238. * @returns a new identity matrix
  4239. */
  4240. static Identity(): Matrix;
  4241. /**
  4242. * Creates a new identity matrix and stores the result in a given matrix
  4243. * @param result defines the target matrix
  4244. */
  4245. static IdentityToRef(result: Matrix): void;
  4246. /**
  4247. * Creates a new zero matrix
  4248. * @returns a new zero matrix
  4249. */
  4250. static Zero(): Matrix;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the X axis
  4253. * @param angle defines the angle (in radians) to use
  4254. * @return the new matrix
  4255. */
  4256. static RotationX(angle: number): Matrix;
  4257. /**
  4258. * Creates a new matrix as the invert of a given matrix
  4259. * @param source defines the source matrix
  4260. * @returns the new matrix
  4261. */
  4262. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4265. * @param angle defines the angle (in radians) to use
  4266. * @param result defines the target matrix
  4267. */
  4268. static RotationXToRef(angle: number, result: Matrix): void;
  4269. /**
  4270. * Creates a new rotation matrix for "angle" radians around the Y axis
  4271. * @param angle defines the angle (in radians) to use
  4272. * @return the new matrix
  4273. */
  4274. static RotationY(angle: number): Matrix;
  4275. /**
  4276. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4277. * @param angle defines the angle (in radians) to use
  4278. * @param result defines the target matrix
  4279. */
  4280. static RotationYToRef(angle: number, result: Matrix): void;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the Z axis
  4283. * @param angle defines the angle (in radians) to use
  4284. * @return the new matrix
  4285. */
  4286. static RotationZ(angle: number): Matrix;
  4287. /**
  4288. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4289. * @param angle defines the angle (in radians) to use
  4290. * @param result defines the target matrix
  4291. */
  4292. static RotationZToRef(angle: number, result: Matrix): void;
  4293. /**
  4294. * Creates a new rotation matrix for "angle" radians around the given axis
  4295. * @param axis defines the axis to use
  4296. * @param angle defines the angle (in radians) to use
  4297. * @return the new matrix
  4298. */
  4299. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4300. /**
  4301. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4302. * @param axis defines the axis to use
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4307. /**
  4308. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4309. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4310. * @param from defines the vector to align
  4311. * @param to defines the vector to align to
  4312. * @param result defines the target matrix
  4313. */
  4314. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4315. /**
  4316. * Creates a rotation matrix
  4317. * @param yaw defines the yaw angle in radians (Y axis)
  4318. * @param pitch defines the pitch angle in radians (X axis)
  4319. * @param roll defines the roll angle in radians (X axis)
  4320. * @returns the new rotation matrix
  4321. */
  4322. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4323. /**
  4324. * Creates a rotation matrix and stores it in a given matrix
  4325. * @param yaw defines the yaw angle in radians (Y axis)
  4326. * @param pitch defines the pitch angle in radians (X axis)
  4327. * @param roll defines the roll angle in radians (X axis)
  4328. * @param result defines the target matrix
  4329. */
  4330. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4331. /**
  4332. * Creates a scaling matrix
  4333. * @param x defines the scale factor on X axis
  4334. * @param y defines the scale factor on Y axis
  4335. * @param z defines the scale factor on Z axis
  4336. * @returns the new matrix
  4337. */
  4338. static Scaling(x: number, y: number, z: number): Matrix;
  4339. /**
  4340. * Creates a scaling matrix and stores it in a given matrix
  4341. * @param x defines the scale factor on X axis
  4342. * @param y defines the scale factor on Y axis
  4343. * @param z defines the scale factor on Z axis
  4344. * @param result defines the target matrix
  4345. */
  4346. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4347. /**
  4348. * Creates a translation matrix
  4349. * @param x defines the translation on X axis
  4350. * @param y defines the translation on Y axis
  4351. * @param z defines the translationon Z axis
  4352. * @returns the new matrix
  4353. */
  4354. static Translation(x: number, y: number, z: number): Matrix;
  4355. /**
  4356. * Creates a translation matrix and stores it in a given matrix
  4357. * @param x defines the translation on X axis
  4358. * @param y defines the translation on Y axis
  4359. * @param z defines the translationon Z axis
  4360. * @param result defines the target matrix
  4361. */
  4362. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4363. /**
  4364. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4365. * @param startValue defines the start value
  4366. * @param endValue defines the end value
  4367. * @param gradient defines the gradient factor
  4368. * @returns the new matrix
  4369. */
  4370. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4373. * @param startValue defines the start value
  4374. * @param endValue defines the end value
  4375. * @param gradient defines the gradient factor
  4376. * @param result defines the Matrix object where to store data
  4377. */
  4378. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4379. /**
  4380. * Builds a new matrix whose values are computed by:
  4381. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4382. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4383. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4384. * @param startValue defines the first matrix
  4385. * @param endValue defines the second matrix
  4386. * @param gradient defines the gradient between the two matrices
  4387. * @returns the new matrix
  4388. */
  4389. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4390. /**
  4391. * Update a matrix to values which are computed by:
  4392. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4393. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4394. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4395. * @param startValue defines the first matrix
  4396. * @param endValue defines the second matrix
  4397. * @param gradient defines the gradient between the two matrices
  4398. * @param result defines the target matrix
  4399. */
  4400. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4401. /**
  4402. * 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"
  4403. * This function works in left handed mode
  4404. * @param eye defines the final position of the entity
  4405. * @param target defines where the entity should look at
  4406. * @param up defines the up vector for the entity
  4407. * @returns the new matrix
  4408. */
  4409. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4410. /**
  4411. * 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".
  4412. * This function works in left handed mode
  4413. * @param eye defines the final position of the entity
  4414. * @param target defines where the entity should look at
  4415. * @param up defines the up vector for the entity
  4416. * @param result defines the target matrix
  4417. */
  4418. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4419. /**
  4420. * 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"
  4421. * This function works in right handed mode
  4422. * @param eye defines the final position of the entity
  4423. * @param target defines where the entity should look at
  4424. * @param up defines the up vector for the entity
  4425. * @returns the new matrix
  4426. */
  4427. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4428. /**
  4429. * 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".
  4430. * This function works in right handed mode
  4431. * @param eye defines the final position of the entity
  4432. * @param target defines where the entity should look at
  4433. * @param up defines the up vector for the entity
  4434. * @param result defines the target matrix
  4435. */
  4436. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Create a left-handed orthographic projection matrix
  4439. * @param width defines the viewport width
  4440. * @param height defines the viewport height
  4441. * @param znear defines the near clip plane
  4442. * @param zfar defines the far clip plane
  4443. * @returns a new matrix as a left-handed orthographic projection matrix
  4444. */
  4445. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4446. /**
  4447. * Store a left-handed orthographic projection to a given matrix
  4448. * @param width defines the viewport width
  4449. * @param height defines the viewport height
  4450. * @param znear defines the near clip plane
  4451. * @param zfar defines the far clip plane
  4452. * @param result defines the target matrix
  4453. */
  4454. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4455. /**
  4456. * Create a left-handed orthographic projection matrix
  4457. * @param left defines the viewport left coordinate
  4458. * @param right defines the viewport right coordinate
  4459. * @param bottom defines the viewport bottom coordinate
  4460. * @param top defines the viewport top coordinate
  4461. * @param znear defines the near clip plane
  4462. * @param zfar defines the far clip plane
  4463. * @returns a new matrix as a left-handed orthographic projection matrix
  4464. */
  4465. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4466. /**
  4467. * Stores a left-handed orthographic projection into a given matrix
  4468. * @param left defines the viewport left coordinate
  4469. * @param right defines the viewport right coordinate
  4470. * @param bottom defines the viewport bottom coordinate
  4471. * @param top defines the viewport top coordinate
  4472. * @param znear defines the near clip plane
  4473. * @param zfar defines the far clip plane
  4474. * @param result defines the target matrix
  4475. */
  4476. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4477. /**
  4478. * Creates a right-handed orthographic projection matrix
  4479. * @param left defines the viewport left coordinate
  4480. * @param right defines the viewport right coordinate
  4481. * @param bottom defines the viewport bottom coordinate
  4482. * @param top defines the viewport top coordinate
  4483. * @param znear defines the near clip plane
  4484. * @param zfar defines the far clip plane
  4485. * @returns a new matrix as a right-handed orthographic projection matrix
  4486. */
  4487. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4488. /**
  4489. * Stores a right-handed orthographic projection into a given matrix
  4490. * @param left defines the viewport left coordinate
  4491. * @param right defines the viewport right coordinate
  4492. * @param bottom defines the viewport bottom coordinate
  4493. * @param top defines the viewport top coordinate
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @param result defines the target matrix
  4497. */
  4498. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4499. /**
  4500. * Creates a left-handed perspective projection matrix
  4501. * @param width defines the viewport width
  4502. * @param height defines the viewport height
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @returns a new matrix as a left-handed perspective projection matrix
  4506. */
  4507. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4508. /**
  4509. * Creates a left-handed perspective projection matrix
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @returns a new matrix as a left-handed perspective projection matrix
  4515. */
  4516. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4517. /**
  4518. * Stores a left-handed perspective projection into a given matrix
  4519. * @param fov defines the horizontal field of view
  4520. * @param aspect defines the aspect ratio
  4521. * @param znear defines the near clip plane
  4522. * @param zfar defines the far clip plane
  4523. * @param result defines the target matrix
  4524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4525. */
  4526. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4527. /**
  4528. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar not used as infinity is used as far clip
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Creates a right-handed perspective projection matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar defines the far clip plane
  4543. * @returns a new matrix as a right-handed perspective projection matrix
  4544. */
  4545. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4546. /**
  4547. * Stores a right-handed perspective projection into a given matrix
  4548. * @param fov defines the horizontal field of view
  4549. * @param aspect defines the aspect ratio
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4554. */
  4555. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4556. /**
  4557. * Stores a right-handed perspective projection into a given matrix
  4558. * @param fov defines the horizontal field of view
  4559. * @param aspect defines the aspect ratio
  4560. * @param znear defines the near clip plane
  4561. * @param zfar not used as infinity is used as far clip
  4562. * @param result defines the target matrix
  4563. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4564. */
  4565. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4566. /**
  4567. * Stores a perspective projection for WebVR info a given matrix
  4568. * @param fov defines the field of view
  4569. * @param znear defines the near clip plane
  4570. * @param zfar defines the far clip plane
  4571. * @param result defines the target matrix
  4572. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4573. */
  4574. static PerspectiveFovWebVRToRef(fov: {
  4575. upDegrees: number;
  4576. downDegrees: number;
  4577. leftDegrees: number;
  4578. rightDegrees: number;
  4579. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4580. /**
  4581. * Computes a complete transformation matrix
  4582. * @param viewport defines the viewport to use
  4583. * @param world defines the world matrix
  4584. * @param view defines the view matrix
  4585. * @param projection defines the projection matrix
  4586. * @param zmin defines the near clip plane
  4587. * @param zmax defines the far clip plane
  4588. * @returns the transformation matrix
  4589. */
  4590. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4591. /**
  4592. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4593. * @param matrix defines the matrix to use
  4594. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4595. */
  4596. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4597. /**
  4598. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4599. * @param matrix defines the matrix to use
  4600. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4601. */
  4602. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4603. /**
  4604. * Compute the transpose of a given matrix
  4605. * @param matrix defines the matrix to transpose
  4606. * @returns the new matrix
  4607. */
  4608. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4609. /**
  4610. * Compute the transpose of a matrix and store it in a target matrix
  4611. * @param matrix defines the matrix to transpose
  4612. * @param result defines the target matrix
  4613. */
  4614. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4615. /**
  4616. * Computes a reflection matrix from a plane
  4617. * @param plane defines the reflection plane
  4618. * @returns a new matrix
  4619. */
  4620. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4621. /**
  4622. * Computes a reflection matrix from a plane
  4623. * @param plane defines the reflection plane
  4624. * @param result defines the target matrix
  4625. */
  4626. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4627. /**
  4628. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4629. * @param xaxis defines the value of the 1st axis
  4630. * @param yaxis defines the value of the 2nd axis
  4631. * @param zaxis defines the value of the 3rd axis
  4632. * @param result defines the target matrix
  4633. */
  4634. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4635. /**
  4636. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4637. * @param quat defines the quaternion to use
  4638. * @param result defines the target matrix
  4639. */
  4640. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4641. }
  4642. /**
  4643. * @hidden
  4644. */
  4645. export class TmpVectors {
  4646. static Vector2: Vector2[];
  4647. static Vector3: Vector3[];
  4648. static Vector4: Vector4[];
  4649. static Quaternion: Quaternion[];
  4650. static Matrix: Matrix[];
  4651. }
  4652. }
  4653. declare module "babylonjs/Maths/math.path" {
  4654. import { DeepImmutable, Nullable } from "babylonjs/types";
  4655. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4656. /**
  4657. * Defines potential orientation for back face culling
  4658. */
  4659. export enum Orientation {
  4660. /**
  4661. * Clockwise
  4662. */
  4663. CW = 0,
  4664. /** Counter clockwise */
  4665. CCW = 1
  4666. }
  4667. /** Class used to represent a Bezier curve */
  4668. export class BezierCurve {
  4669. /**
  4670. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4671. * @param t defines the time
  4672. * @param x1 defines the left coordinate on X axis
  4673. * @param y1 defines the left coordinate on Y axis
  4674. * @param x2 defines the right coordinate on X axis
  4675. * @param y2 defines the right coordinate on Y axis
  4676. * @returns the interpolated value
  4677. */
  4678. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4679. }
  4680. /**
  4681. * Defines angle representation
  4682. */
  4683. export class Angle {
  4684. private _radians;
  4685. /**
  4686. * Creates an Angle object of "radians" radians (float).
  4687. * @param radians the angle in radians
  4688. */
  4689. constructor(radians: number);
  4690. /**
  4691. * Get value in degrees
  4692. * @returns the Angle value in degrees (float)
  4693. */
  4694. degrees(): number;
  4695. /**
  4696. * Get value in radians
  4697. * @returns the Angle value in radians (float)
  4698. */
  4699. radians(): number;
  4700. /**
  4701. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4702. * @param a defines first vector
  4703. * @param b defines second vector
  4704. * @returns a new Angle
  4705. */
  4706. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4707. /**
  4708. * Gets a new Angle object from the given float in radians
  4709. * @param radians defines the angle value in radians
  4710. * @returns a new Angle
  4711. */
  4712. static FromRadians(radians: number): Angle;
  4713. /**
  4714. * Gets a new Angle object from the given float in degrees
  4715. * @param degrees defines the angle value in degrees
  4716. * @returns a new Angle
  4717. */
  4718. static FromDegrees(degrees: number): Angle;
  4719. }
  4720. /**
  4721. * This represents an arc in a 2d space.
  4722. */
  4723. export class Arc2 {
  4724. /** Defines the start point of the arc */
  4725. startPoint: Vector2;
  4726. /** Defines the mid point of the arc */
  4727. midPoint: Vector2;
  4728. /** Defines the end point of the arc */
  4729. endPoint: Vector2;
  4730. /**
  4731. * Defines the center point of the arc.
  4732. */
  4733. centerPoint: Vector2;
  4734. /**
  4735. * Defines the radius of the arc.
  4736. */
  4737. radius: number;
  4738. /**
  4739. * Defines the angle of the arc (from mid point to end point).
  4740. */
  4741. angle: Angle;
  4742. /**
  4743. * Defines the start angle of the arc (from start point to middle point).
  4744. */
  4745. startAngle: Angle;
  4746. /**
  4747. * Defines the orientation of the arc (clock wise/counter clock wise).
  4748. */
  4749. orientation: Orientation;
  4750. /**
  4751. * Creates an Arc object from the three given points : start, middle and end.
  4752. * @param startPoint Defines the start point of the arc
  4753. * @param midPoint Defines the midlle point of the arc
  4754. * @param endPoint Defines the end point of the arc
  4755. */
  4756. constructor(
  4757. /** Defines the start point of the arc */
  4758. startPoint: Vector2,
  4759. /** Defines the mid point of the arc */
  4760. midPoint: Vector2,
  4761. /** Defines the end point of the arc */
  4762. endPoint: Vector2);
  4763. }
  4764. /**
  4765. * Represents a 2D path made up of multiple 2D points
  4766. */
  4767. export class Path2 {
  4768. private _points;
  4769. private _length;
  4770. /**
  4771. * If the path start and end point are the same
  4772. */
  4773. closed: boolean;
  4774. /**
  4775. * Creates a Path2 object from the starting 2D coordinates x and y.
  4776. * @param x the starting points x value
  4777. * @param y the starting points y value
  4778. */
  4779. constructor(x: number, y: number);
  4780. /**
  4781. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4782. * @param x the added points x value
  4783. * @param y the added points y value
  4784. * @returns the updated Path2.
  4785. */
  4786. addLineTo(x: number, y: number): Path2;
  4787. /**
  4788. * 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.
  4789. * @param midX middle point x value
  4790. * @param midY middle point y value
  4791. * @param endX end point x value
  4792. * @param endY end point y value
  4793. * @param numberOfSegments (default: 36)
  4794. * @returns the updated Path2.
  4795. */
  4796. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4797. /**
  4798. * Closes the Path2.
  4799. * @returns the Path2.
  4800. */
  4801. close(): Path2;
  4802. /**
  4803. * Gets the sum of the distance between each sequential point in the path
  4804. * @returns the Path2 total length (float).
  4805. */
  4806. length(): number;
  4807. /**
  4808. * Gets the points which construct the path
  4809. * @returns the Path2 internal array of points.
  4810. */
  4811. getPoints(): Vector2[];
  4812. /**
  4813. * Retreives the point at the distance aways from the starting point
  4814. * @param normalizedLengthPosition the length along the path to retreive the point from
  4815. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4816. */
  4817. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4818. /**
  4819. * Creates a new path starting from an x and y position
  4820. * @param x starting x value
  4821. * @param y starting y value
  4822. * @returns a new Path2 starting at the coordinates (x, y).
  4823. */
  4824. static StartingAt(x: number, y: number): Path2;
  4825. }
  4826. /**
  4827. * Represents a 3D path made up of multiple 3D points
  4828. */
  4829. export class Path3D {
  4830. /**
  4831. * an array of Vector3, the curve axis of the Path3D
  4832. */
  4833. path: Vector3[];
  4834. private _curve;
  4835. private _distances;
  4836. private _tangents;
  4837. private _normals;
  4838. private _binormals;
  4839. private _raw;
  4840. private _alignTangentsWithPath;
  4841. private readonly _pointAtData;
  4842. /**
  4843. * new Path3D(path, normal, raw)
  4844. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4845. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4846. * @param path an array of Vector3, the curve axis of the Path3D
  4847. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4848. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4849. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4850. */
  4851. constructor(
  4852. /**
  4853. * an array of Vector3, the curve axis of the Path3D
  4854. */
  4855. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4856. /**
  4857. * Returns the Path3D array of successive Vector3 designing its curve.
  4858. * @returns the Path3D array of successive Vector3 designing its curve.
  4859. */
  4860. getCurve(): Vector3[];
  4861. /**
  4862. * Returns the Path3D array of successive Vector3 designing its curve.
  4863. * @returns the Path3D array of successive Vector3 designing its curve.
  4864. */
  4865. getPoints(): Vector3[];
  4866. /**
  4867. * @returns the computed length (float) of the path.
  4868. */
  4869. length(): number;
  4870. /**
  4871. * Returns an array populated with tangent vectors on each Path3D curve point.
  4872. * @returns an array populated with tangent vectors on each Path3D curve point.
  4873. */
  4874. getTangents(): Vector3[];
  4875. /**
  4876. * Returns an array populated with normal vectors on each Path3D curve point.
  4877. * @returns an array populated with normal vectors on each Path3D curve point.
  4878. */
  4879. getNormals(): Vector3[];
  4880. /**
  4881. * Returns an array populated with binormal vectors on each Path3D curve point.
  4882. * @returns an array populated with binormal vectors on each Path3D curve point.
  4883. */
  4884. getBinormals(): Vector3[];
  4885. /**
  4886. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4887. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4888. */
  4889. getDistances(): number[];
  4890. /**
  4891. * Returns an interpolated point along this path
  4892. * @param position the position of the point along this path, from 0.0 to 1.0
  4893. * @returns a new Vector3 as the point
  4894. */
  4895. getPointAt(position: number): Vector3;
  4896. /**
  4897. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4900. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4901. */
  4902. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4903. /**
  4904. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4905. * @param position the position of the point along this path, from 0.0 to 1.0
  4906. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4907. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4908. */
  4909. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4910. /**
  4911. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4914. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4915. */
  4916. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4921. */
  4922. getDistanceAt(position: number): number;
  4923. /**
  4924. * Returns the array index of the previous point of an interpolated point along this path
  4925. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4926. * @returns the array index
  4927. */
  4928. getPreviousPointIndexAt(position: number): number;
  4929. /**
  4930. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4931. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4932. * @returns the sub position
  4933. */
  4934. getSubPositionAt(position: number): number;
  4935. /**
  4936. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4937. * @param target the vector of which to get the closest position to
  4938. * @returns the position of the closest virtual point on this path to the target vector
  4939. */
  4940. getClosestPositionTo(target: Vector3): number;
  4941. /**
  4942. * Returns a sub path (slice) of this path
  4943. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4944. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4945. * @returns a sub path (slice) of this path
  4946. */
  4947. slice(start?: number, end?: number): Path3D;
  4948. /**
  4949. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4950. * @param path path which all values are copied into the curves points
  4951. * @param firstNormal which should be projected onto the curve
  4952. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4953. * @returns the same object updated.
  4954. */
  4955. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4956. private _compute;
  4957. private _getFirstNonNullVector;
  4958. private _getLastNonNullVector;
  4959. private _normalVector;
  4960. /**
  4961. * Updates the point at data for an interpolated point along this curve
  4962. * @param position the position of the point along this curve, from 0.0 to 1.0
  4963. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4964. * @returns the (updated) point at data
  4965. */
  4966. private _updatePointAtData;
  4967. /**
  4968. * Updates the point at data from the specified parameters
  4969. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4970. * @param point the interpolated point
  4971. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4972. */
  4973. private _setPointAtData;
  4974. /**
  4975. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4976. */
  4977. private _updateInterpolationMatrix;
  4978. }
  4979. /**
  4980. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4981. * A Curve3 is designed from a series of successive Vector3.
  4982. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4983. */
  4984. export class Curve3 {
  4985. private _points;
  4986. private _length;
  4987. /**
  4988. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4989. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4990. * @param v1 (Vector3) the control point
  4991. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4992. * @param nbPoints (integer) the wanted number of points in the curve
  4993. * @returns the created Curve3
  4994. */
  4995. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4996. /**
  4997. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4998. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4999. * @param v1 (Vector3) the first control point
  5000. * @param v2 (Vector3) the second control point
  5001. * @param v3 (Vector3) the end point of the Cubic Bezier
  5002. * @param nbPoints (integer) the wanted number of points in the curve
  5003. * @returns the created Curve3
  5004. */
  5005. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5006. /**
  5007. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5008. * @param p1 (Vector3) the origin point of the Hermite Spline
  5009. * @param t1 (Vector3) the tangent vector at the origin point
  5010. * @param p2 (Vector3) the end point of the Hermite Spline
  5011. * @param t2 (Vector3) the tangent vector at the end point
  5012. * @param nbPoints (integer) the wanted number of points in the curve
  5013. * @returns the created Curve3
  5014. */
  5015. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5016. /**
  5017. * Returns a Curve3 object along a CatmullRom Spline curve :
  5018. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5019. * @param nbPoints (integer) the wanted number of points between each curve control points
  5020. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5021. * @returns the created Curve3
  5022. */
  5023. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5024. /**
  5025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5026. * A Curve3 is designed from a series of successive Vector3.
  5027. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5028. * @param points points which make up the curve
  5029. */
  5030. constructor(points: Vector3[]);
  5031. /**
  5032. * @returns the Curve3 stored array of successive Vector3
  5033. */
  5034. getPoints(): Vector3[];
  5035. /**
  5036. * @returns the computed length (float) of the curve.
  5037. */
  5038. length(): number;
  5039. /**
  5040. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5041. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5042. * curveA and curveB keep unchanged.
  5043. * @param curve the curve to continue from this curve
  5044. * @returns the newly constructed curve
  5045. */
  5046. continue(curve: DeepImmutable<Curve3>): Curve3;
  5047. private _computeLength;
  5048. }
  5049. }
  5050. declare module "babylonjs/Animations/easing" {
  5051. /**
  5052. * This represents the main contract an easing function should follow.
  5053. * Easing functions are used throughout the animation system.
  5054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5055. */
  5056. export interface IEasingFunction {
  5057. /**
  5058. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5059. * of the easing function.
  5060. * The link below provides some of the most common examples of easing functions.
  5061. * @see https://easings.net/
  5062. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5063. * @returns the corresponding value on the curve defined by the easing function
  5064. */
  5065. ease(gradient: number): number;
  5066. }
  5067. /**
  5068. * Base class used for every default easing function.
  5069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5070. */
  5071. export class EasingFunction implements IEasingFunction {
  5072. /**
  5073. * Interpolation follows the mathematical formula associated with the easing function.
  5074. */
  5075. static readonly EASINGMODE_EASEIN: number;
  5076. /**
  5077. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5078. */
  5079. static readonly EASINGMODE_EASEOUT: number;
  5080. /**
  5081. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5082. */
  5083. static readonly EASINGMODE_EASEINOUT: number;
  5084. private _easingMode;
  5085. /**
  5086. * Sets the easing mode of the current function.
  5087. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5088. */
  5089. setEasingMode(easingMode: number): void;
  5090. /**
  5091. * Gets the current easing mode.
  5092. * @returns the easing mode
  5093. */
  5094. getEasingMode(): number;
  5095. /**
  5096. * @hidden
  5097. */
  5098. easeInCore(gradient: number): number;
  5099. /**
  5100. * Given an input gradient between 0 and 1, this returns the corresponding value
  5101. * of the easing function.
  5102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5103. * @returns the corresponding value on the curve defined by the easing function
  5104. */
  5105. ease(gradient: number): number;
  5106. }
  5107. /**
  5108. * Easing function with a circle shape (see link below).
  5109. * @see https://easings.net/#easeInCirc
  5110. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5111. */
  5112. export class CircleEase extends EasingFunction implements IEasingFunction {
  5113. /** @hidden */
  5114. easeInCore(gradient: number): number;
  5115. }
  5116. /**
  5117. * Easing function with a ease back shape (see link below).
  5118. * @see https://easings.net/#easeInBack
  5119. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5120. */
  5121. export class BackEase extends EasingFunction implements IEasingFunction {
  5122. /** Defines the amplitude of the function */
  5123. amplitude: number;
  5124. /**
  5125. * Instantiates a back ease easing
  5126. * @see https://easings.net/#easeInBack
  5127. * @param amplitude Defines the amplitude of the function
  5128. */
  5129. constructor(
  5130. /** Defines the amplitude of the function */
  5131. amplitude?: number);
  5132. /** @hidden */
  5133. easeInCore(gradient: number): number;
  5134. }
  5135. /**
  5136. * Easing function with a bouncing shape (see link below).
  5137. * @see https://easings.net/#easeInBounce
  5138. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5139. */
  5140. export class BounceEase extends EasingFunction implements IEasingFunction {
  5141. /** Defines the number of bounces */
  5142. bounces: number;
  5143. /** Defines the amplitude of the bounce */
  5144. bounciness: number;
  5145. /**
  5146. * Instantiates a bounce easing
  5147. * @see https://easings.net/#easeInBounce
  5148. * @param bounces Defines the number of bounces
  5149. * @param bounciness Defines the amplitude of the bounce
  5150. */
  5151. constructor(
  5152. /** Defines the number of bounces */
  5153. bounces?: number,
  5154. /** Defines the amplitude of the bounce */
  5155. bounciness?: number);
  5156. /** @hidden */
  5157. easeInCore(gradient: number): number;
  5158. }
  5159. /**
  5160. * Easing function with a power of 3 shape (see link below).
  5161. * @see https://easings.net/#easeInCubic
  5162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5163. */
  5164. export class CubicEase extends EasingFunction implements IEasingFunction {
  5165. /** @hidden */
  5166. easeInCore(gradient: number): number;
  5167. }
  5168. /**
  5169. * Easing function with an elastic shape (see link below).
  5170. * @see https://easings.net/#easeInElastic
  5171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5172. */
  5173. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5174. /** Defines the number of oscillations*/
  5175. oscillations: number;
  5176. /** Defines the amplitude of the oscillations*/
  5177. springiness: number;
  5178. /**
  5179. * Instantiates an elastic easing function
  5180. * @see https://easings.net/#easeInElastic
  5181. * @param oscillations Defines the number of oscillations
  5182. * @param springiness Defines the amplitude of the oscillations
  5183. */
  5184. constructor(
  5185. /** Defines the number of oscillations*/
  5186. oscillations?: number,
  5187. /** Defines the amplitude of the oscillations*/
  5188. springiness?: number);
  5189. /** @hidden */
  5190. easeInCore(gradient: number): number;
  5191. }
  5192. /**
  5193. * Easing function with an exponential shape (see link below).
  5194. * @see https://easings.net/#easeInExpo
  5195. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5196. */
  5197. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5198. /** Defines the exponent of the function */
  5199. exponent: number;
  5200. /**
  5201. * Instantiates an exponential easing function
  5202. * @see https://easings.net/#easeInExpo
  5203. * @param exponent Defines the exponent of the function
  5204. */
  5205. constructor(
  5206. /** Defines the exponent of the function */
  5207. exponent?: number);
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power shape (see link below).
  5213. * @see https://easings.net/#easeInQuad
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class PowerEase extends EasingFunction implements IEasingFunction {
  5217. /** Defines the power of the function */
  5218. power: number;
  5219. /**
  5220. * Instantiates an power base easing function
  5221. * @see https://easings.net/#easeInQuad
  5222. * @param power Defines the power of the function
  5223. */
  5224. constructor(
  5225. /** Defines the power of the function */
  5226. power?: number);
  5227. /** @hidden */
  5228. easeInCore(gradient: number): number;
  5229. }
  5230. /**
  5231. * Easing function with a power of 2 shape (see link below).
  5232. * @see https://easings.net/#easeInQuad
  5233. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5234. */
  5235. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5236. /** @hidden */
  5237. easeInCore(gradient: number): number;
  5238. }
  5239. /**
  5240. * Easing function with a power of 4 shape (see link below).
  5241. * @see https://easings.net/#easeInQuart
  5242. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5243. */
  5244. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5245. /** @hidden */
  5246. easeInCore(gradient: number): number;
  5247. }
  5248. /**
  5249. * Easing function with a power of 5 shape (see link below).
  5250. * @see https://easings.net/#easeInQuint
  5251. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5252. */
  5253. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5254. /** @hidden */
  5255. easeInCore(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a sin shape (see link below).
  5259. * @see https://easings.net/#easeInSine
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class SineEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a bezier shape (see link below).
  5268. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5272. /** Defines the x component of the start tangent in the bezier curve */
  5273. x1: number;
  5274. /** Defines the y component of the start tangent in the bezier curve */
  5275. y1: number;
  5276. /** Defines the x component of the end tangent in the bezier curve */
  5277. x2: number;
  5278. /** Defines the y component of the end tangent in the bezier curve */
  5279. y2: number;
  5280. /**
  5281. * Instantiates a bezier function
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @param x1 Defines the x component of the start tangent in the bezier curve
  5284. * @param y1 Defines the y component of the start tangent in the bezier curve
  5285. * @param x2 Defines the x component of the end tangent in the bezier curve
  5286. * @param y2 Defines the y component of the end tangent in the bezier curve
  5287. */
  5288. constructor(
  5289. /** Defines the x component of the start tangent in the bezier curve */
  5290. x1?: number,
  5291. /** Defines the y component of the start tangent in the bezier curve */
  5292. y1?: number,
  5293. /** Defines the x component of the end tangent in the bezier curve */
  5294. x2?: number,
  5295. /** Defines the y component of the end tangent in the bezier curve */
  5296. y2?: number);
  5297. /** @hidden */
  5298. easeInCore(gradient: number): number;
  5299. }
  5300. }
  5301. declare module "babylonjs/Maths/math.color" {
  5302. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5303. /**
  5304. * Class used to hold a RBG color
  5305. */
  5306. export class Color3 {
  5307. /**
  5308. * Defines the red component (between 0 and 1, default is 0)
  5309. */
  5310. r: number;
  5311. /**
  5312. * Defines the green component (between 0 and 1, default is 0)
  5313. */
  5314. g: number;
  5315. /**
  5316. * Defines the blue component (between 0 and 1, default is 0)
  5317. */
  5318. b: number;
  5319. /**
  5320. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5321. * @param r defines the red component (between 0 and 1, default is 0)
  5322. * @param g defines the green component (between 0 and 1, default is 0)
  5323. * @param b defines the blue component (between 0 and 1, default is 0)
  5324. */
  5325. constructor(
  5326. /**
  5327. * Defines the red component (between 0 and 1, default is 0)
  5328. */
  5329. r?: number,
  5330. /**
  5331. * Defines the green component (between 0 and 1, default is 0)
  5332. */
  5333. g?: number,
  5334. /**
  5335. * Defines the blue component (between 0 and 1, default is 0)
  5336. */
  5337. b?: number);
  5338. /**
  5339. * Creates a string with the Color3 current values
  5340. * @returns the string representation of the Color3 object
  5341. */
  5342. toString(): string;
  5343. /**
  5344. * Returns the string "Color3"
  5345. * @returns "Color3"
  5346. */
  5347. getClassName(): string;
  5348. /**
  5349. * Compute the Color3 hash code
  5350. * @returns an unique number that can be used to hash Color3 objects
  5351. */
  5352. getHashCode(): number;
  5353. /**
  5354. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5355. * @param array defines the array where to store the r,g,b components
  5356. * @param index defines an optional index in the target array to define where to start storing values
  5357. * @returns the current Color3 object
  5358. */
  5359. toArray(array: FloatArray, index?: number): Color3;
  5360. /**
  5361. * Returns a new Color4 object from the current Color3 and the given alpha
  5362. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5363. * @returns a new Color4 object
  5364. */
  5365. toColor4(alpha?: number): Color4;
  5366. /**
  5367. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5368. * @returns the new array
  5369. */
  5370. asArray(): number[];
  5371. /**
  5372. * Returns the luminance value
  5373. * @returns a float value
  5374. */
  5375. toLuminance(): number;
  5376. /**
  5377. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5378. * @param otherColor defines the second operand
  5379. * @returns the new Color3 object
  5380. */
  5381. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5382. /**
  5383. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5384. * @param otherColor defines the second operand
  5385. * @param result defines the Color3 object where to store the result
  5386. * @returns the current Color3
  5387. */
  5388. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5389. /**
  5390. * Determines equality between Color3 objects
  5391. * @param otherColor defines the second operand
  5392. * @returns true if the rgb values are equal to the given ones
  5393. */
  5394. equals(otherColor: DeepImmutable<Color3>): boolean;
  5395. /**
  5396. * Determines equality between the current Color3 object and a set of r,b,g values
  5397. * @param r defines the red component to check
  5398. * @param g defines the green component to check
  5399. * @param b defines the blue component to check
  5400. * @returns true if the rgb values are equal to the given ones
  5401. */
  5402. equalsFloats(r: number, g: number, b: number): boolean;
  5403. /**
  5404. * Multiplies in place each rgb value by scale
  5405. * @param scale defines the scaling factor
  5406. * @returns the updated Color3
  5407. */
  5408. scale(scale: number): Color3;
  5409. /**
  5410. * Multiplies the rgb values by scale and stores the result into "result"
  5411. * @param scale defines the scaling factor
  5412. * @param result defines the Color3 object where to store the result
  5413. * @returns the unmodified current Color3
  5414. */
  5415. scaleToRef(scale: number, result: Color3): Color3;
  5416. /**
  5417. * Scale the current Color3 values by a factor and add the result to a given Color3
  5418. * @param scale defines the scale factor
  5419. * @param result defines color to store the result into
  5420. * @returns the unmodified current Color3
  5421. */
  5422. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5423. /**
  5424. * Clamps the rgb values by the min and max values and stores the result into "result"
  5425. * @param min defines minimum clamping value (default is 0)
  5426. * @param max defines maximum clamping value (default is 1)
  5427. * @param result defines color to store the result into
  5428. * @returns the original Color3
  5429. */
  5430. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5431. /**
  5432. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5433. * @param otherColor defines the second operand
  5434. * @returns the new Color3
  5435. */
  5436. add(otherColor: DeepImmutable<Color3>): Color3;
  5437. /**
  5438. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5439. * @param otherColor defines the second operand
  5440. * @param result defines Color3 object to store the result into
  5441. * @returns the unmodified current Color3
  5442. */
  5443. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5444. /**
  5445. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5446. * @param otherColor defines the second operand
  5447. * @returns the new Color3
  5448. */
  5449. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5450. /**
  5451. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5452. * @param otherColor defines the second operand
  5453. * @param result defines Color3 object to store the result into
  5454. * @returns the unmodified current Color3
  5455. */
  5456. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5457. /**
  5458. * Copy the current object
  5459. * @returns a new Color3 copied the current one
  5460. */
  5461. clone(): Color3;
  5462. /**
  5463. * Copies the rgb values from the source in the current Color3
  5464. * @param source defines the source Color3 object
  5465. * @returns the updated Color3 object
  5466. */
  5467. copyFrom(source: DeepImmutable<Color3>): Color3;
  5468. /**
  5469. * Updates the Color3 rgb values from the given floats
  5470. * @param r defines the red component to read from
  5471. * @param g defines the green component to read from
  5472. * @param b defines the blue component to read from
  5473. * @returns the current Color3 object
  5474. */
  5475. copyFromFloats(r: number, g: number, b: number): Color3;
  5476. /**
  5477. * Updates the Color3 rgb values from the given floats
  5478. * @param r defines the red component to read from
  5479. * @param g defines the green component to read from
  5480. * @param b defines the blue component to read from
  5481. * @returns the current Color3 object
  5482. */
  5483. set(r: number, g: number, b: number): Color3;
  5484. /**
  5485. * Compute the Color3 hexadecimal code as a string
  5486. * @returns a string containing the hexadecimal representation of the Color3 object
  5487. */
  5488. toHexString(): string;
  5489. /**
  5490. * Computes a new Color3 converted from the current one to linear space
  5491. * @returns a new Color3 object
  5492. */
  5493. toLinearSpace(): Color3;
  5494. /**
  5495. * Converts current color in rgb space to HSV values
  5496. * @returns a new color3 representing the HSV values
  5497. */
  5498. toHSV(): Color3;
  5499. /**
  5500. * Converts current color in rgb space to HSV values
  5501. * @param result defines the Color3 where to store the HSV values
  5502. */
  5503. toHSVToRef(result: Color3): void;
  5504. /**
  5505. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5506. * @param convertedColor defines the Color3 object where to store the linear space version
  5507. * @returns the unmodified Color3
  5508. */
  5509. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5510. /**
  5511. * Computes a new Color3 converted from the current one to gamma space
  5512. * @returns a new Color3 object
  5513. */
  5514. toGammaSpace(): Color3;
  5515. /**
  5516. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5517. * @param convertedColor defines the Color3 object where to store the gamma space version
  5518. * @returns the unmodified Color3
  5519. */
  5520. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5521. private static _BlackReadOnly;
  5522. /**
  5523. * Convert Hue, saturation and value to a Color3 (RGB)
  5524. * @param hue defines the hue
  5525. * @param saturation defines the saturation
  5526. * @param value defines the value
  5527. * @param result defines the Color3 where to store the RGB values
  5528. */
  5529. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5530. /**
  5531. * Creates a new Color3 from the string containing valid hexadecimal values
  5532. * @param hex defines a string containing valid hexadecimal values
  5533. * @returns a new Color3 object
  5534. */
  5535. static FromHexString(hex: string): Color3;
  5536. /**
  5537. * Creates a new Color3 from the starting index of the given array
  5538. * @param array defines the source array
  5539. * @param offset defines an offset in the source array
  5540. * @returns a new Color3 object
  5541. */
  5542. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5543. /**
  5544. * Creates a new Color3 from integer values (< 256)
  5545. * @param r defines the red component to read from (value between 0 and 255)
  5546. * @param g defines the green component to read from (value between 0 and 255)
  5547. * @param b defines the blue component to read from (value between 0 and 255)
  5548. * @returns a new Color3 object
  5549. */
  5550. static FromInts(r: number, g: number, b: number): Color3;
  5551. /**
  5552. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5553. * @param start defines the start Color3 value
  5554. * @param end defines the end Color3 value
  5555. * @param amount defines the gradient value between start and end
  5556. * @returns a new Color3 object
  5557. */
  5558. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5559. /**
  5560. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5561. * @param left defines the start value
  5562. * @param right defines the end value
  5563. * @param amount defines the gradient factor
  5564. * @param result defines the Color3 object where to store the result
  5565. */
  5566. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5567. /**
  5568. * Returns a Color3 value containing a red color
  5569. * @returns a new Color3 object
  5570. */
  5571. static Red(): Color3;
  5572. /**
  5573. * Returns a Color3 value containing a green color
  5574. * @returns a new Color3 object
  5575. */
  5576. static Green(): Color3;
  5577. /**
  5578. * Returns a Color3 value containing a blue color
  5579. * @returns a new Color3 object
  5580. */
  5581. static Blue(): Color3;
  5582. /**
  5583. * Returns a Color3 value containing a black color
  5584. * @returns a new Color3 object
  5585. */
  5586. static Black(): Color3;
  5587. /**
  5588. * Gets a Color3 value containing a black color that must not be updated
  5589. */
  5590. static get BlackReadOnly(): DeepImmutable<Color3>;
  5591. /**
  5592. * Returns a Color3 value containing a white color
  5593. * @returns a new Color3 object
  5594. */
  5595. static White(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a purple color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Purple(): Color3;
  5601. /**
  5602. * Returns a Color3 value containing a magenta color
  5603. * @returns a new Color3 object
  5604. */
  5605. static Magenta(): Color3;
  5606. /**
  5607. * Returns a Color3 value containing a yellow color
  5608. * @returns a new Color3 object
  5609. */
  5610. static Yellow(): Color3;
  5611. /**
  5612. * Returns a Color3 value containing a gray color
  5613. * @returns a new Color3 object
  5614. */
  5615. static Gray(): Color3;
  5616. /**
  5617. * Returns a Color3 value containing a teal color
  5618. * @returns a new Color3 object
  5619. */
  5620. static Teal(): Color3;
  5621. /**
  5622. * Returns a Color3 value containing a random color
  5623. * @returns a new Color3 object
  5624. */
  5625. static Random(): Color3;
  5626. }
  5627. /**
  5628. * Class used to hold a RBGA color
  5629. */
  5630. export class Color4 {
  5631. /**
  5632. * Defines the red component (between 0 and 1, default is 0)
  5633. */
  5634. r: number;
  5635. /**
  5636. * Defines the green component (between 0 and 1, default is 0)
  5637. */
  5638. g: number;
  5639. /**
  5640. * Defines the blue component (between 0 and 1, default is 0)
  5641. */
  5642. b: number;
  5643. /**
  5644. * Defines the alpha component (between 0 and 1, default is 1)
  5645. */
  5646. a: number;
  5647. /**
  5648. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5649. * @param r defines the red component (between 0 and 1, default is 0)
  5650. * @param g defines the green component (between 0 and 1, default is 0)
  5651. * @param b defines the blue component (between 0 and 1, default is 0)
  5652. * @param a defines the alpha component (between 0 and 1, default is 1)
  5653. */
  5654. constructor(
  5655. /**
  5656. * Defines the red component (between 0 and 1, default is 0)
  5657. */
  5658. r?: number,
  5659. /**
  5660. * Defines the green component (between 0 and 1, default is 0)
  5661. */
  5662. g?: number,
  5663. /**
  5664. * Defines the blue component (between 0 and 1, default is 0)
  5665. */
  5666. b?: number,
  5667. /**
  5668. * Defines the alpha component (between 0 and 1, default is 1)
  5669. */
  5670. a?: number);
  5671. /**
  5672. * Adds in place the given Color4 values to the current Color4 object
  5673. * @param right defines the second operand
  5674. * @returns the current updated Color4 object
  5675. */
  5676. addInPlace(right: DeepImmutable<Color4>): Color4;
  5677. /**
  5678. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5679. * @returns the new array
  5680. */
  5681. asArray(): number[];
  5682. /**
  5683. * Stores from the starting index in the given array the Color4 successive values
  5684. * @param array defines the array where to store the r,g,b components
  5685. * @param index defines an optional index in the target array to define where to start storing values
  5686. * @returns the current Color4 object
  5687. */
  5688. toArray(array: number[], index?: number): Color4;
  5689. /**
  5690. * Determines equality between Color4 objects
  5691. * @param otherColor defines the second operand
  5692. * @returns true if the rgba values are equal to the given ones
  5693. */
  5694. equals(otherColor: DeepImmutable<Color4>): boolean;
  5695. /**
  5696. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5697. * @param right defines the second operand
  5698. * @returns a new Color4 object
  5699. */
  5700. add(right: DeepImmutable<Color4>): Color4;
  5701. /**
  5702. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5703. * @param right defines the second operand
  5704. * @returns a new Color4 object
  5705. */
  5706. subtract(right: DeepImmutable<Color4>): Color4;
  5707. /**
  5708. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5709. * @param right defines the second operand
  5710. * @param result defines the Color4 object where to store the result
  5711. * @returns the current Color4 object
  5712. */
  5713. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5714. /**
  5715. * Creates a new Color4 with the current Color4 values multiplied by scale
  5716. * @param scale defines the scaling factor to apply
  5717. * @returns a new Color4 object
  5718. */
  5719. scale(scale: number): Color4;
  5720. /**
  5721. * Multiplies the current Color4 values by scale and stores the result in "result"
  5722. * @param scale defines the scaling factor to apply
  5723. * @param result defines the Color4 object where to store the result
  5724. * @returns the current unmodified Color4
  5725. */
  5726. scaleToRef(scale: number, result: Color4): Color4;
  5727. /**
  5728. * Scale the current Color4 values by a factor and add the result to a given Color4
  5729. * @param scale defines the scale factor
  5730. * @param result defines the Color4 object where to store the result
  5731. * @returns the unmodified current Color4
  5732. */
  5733. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5734. /**
  5735. * Clamps the rgb values by the min and max values and stores the result into "result"
  5736. * @param min defines minimum clamping value (default is 0)
  5737. * @param max defines maximum clamping value (default is 1)
  5738. * @param result defines color to store the result into.
  5739. * @returns the cuurent Color4
  5740. */
  5741. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5742. /**
  5743. * Multipy an Color4 value by another and return a new Color4 object
  5744. * @param color defines the Color4 value to multiply by
  5745. * @returns a new Color4 object
  5746. */
  5747. multiply(color: Color4): Color4;
  5748. /**
  5749. * Multipy a Color4 value by another and push the result in a reference value
  5750. * @param color defines the Color4 value to multiply by
  5751. * @param result defines the Color4 to fill the result in
  5752. * @returns the result Color4
  5753. */
  5754. multiplyToRef(color: Color4, result: Color4): Color4;
  5755. /**
  5756. * Creates a string with the Color4 current values
  5757. * @returns the string representation of the Color4 object
  5758. */
  5759. toString(): string;
  5760. /**
  5761. * Returns the string "Color4"
  5762. * @returns "Color4"
  5763. */
  5764. getClassName(): string;
  5765. /**
  5766. * Compute the Color4 hash code
  5767. * @returns an unique number that can be used to hash Color4 objects
  5768. */
  5769. getHashCode(): number;
  5770. /**
  5771. * Creates a new Color4 copied from the current one
  5772. * @returns a new Color4 object
  5773. */
  5774. clone(): Color4;
  5775. /**
  5776. * Copies the given Color4 values into the current one
  5777. * @param source defines the source Color4 object
  5778. * @returns the current updated Color4 object
  5779. */
  5780. copyFrom(source: Color4): Color4;
  5781. /**
  5782. * Copies the given float values into the current one
  5783. * @param r defines the red component to read from
  5784. * @param g defines the green component to read from
  5785. * @param b defines the blue component to read from
  5786. * @param a defines the alpha component to read from
  5787. * @returns the current updated Color4 object
  5788. */
  5789. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5790. /**
  5791. * Copies the given float values into the current one
  5792. * @param r defines the red component to read from
  5793. * @param g defines the green component to read from
  5794. * @param b defines the blue component to read from
  5795. * @param a defines the alpha component to read from
  5796. * @returns the current updated Color4 object
  5797. */
  5798. set(r: number, g: number, b: number, a: number): Color4;
  5799. /**
  5800. * Compute the Color4 hexadecimal code as a string
  5801. * @returns a string containing the hexadecimal representation of the Color4 object
  5802. */
  5803. toHexString(): string;
  5804. /**
  5805. * Computes a new Color4 converted from the current one to linear space
  5806. * @returns a new Color4 object
  5807. */
  5808. toLinearSpace(): Color4;
  5809. /**
  5810. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5811. * @param convertedColor defines the Color4 object where to store the linear space version
  5812. * @returns the unmodified Color4
  5813. */
  5814. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5815. /**
  5816. * Computes a new Color4 converted from the current one to gamma space
  5817. * @returns a new Color4 object
  5818. */
  5819. toGammaSpace(): Color4;
  5820. /**
  5821. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5822. * @param convertedColor defines the Color4 object where to store the gamma space version
  5823. * @returns the unmodified Color4
  5824. */
  5825. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5826. /**
  5827. * Creates a new Color4 from the string containing valid hexadecimal values
  5828. * @param hex defines a string containing valid hexadecimal values
  5829. * @returns a new Color4 object
  5830. */
  5831. static FromHexString(hex: string): Color4;
  5832. /**
  5833. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5834. * @param left defines the start value
  5835. * @param right defines the end value
  5836. * @param amount defines the gradient factor
  5837. * @returns a new Color4 object
  5838. */
  5839. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5840. /**
  5841. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5842. * @param left defines the start value
  5843. * @param right defines the end value
  5844. * @param amount defines the gradient factor
  5845. * @param result defines the Color4 object where to store data
  5846. */
  5847. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5848. /**
  5849. * Creates a new Color4 from a Color3 and an alpha value
  5850. * @param color3 defines the source Color3 to read from
  5851. * @param alpha defines the alpha component (1.0 by default)
  5852. * @returns a new Color4 object
  5853. */
  5854. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5855. /**
  5856. * Creates a new Color4 from the starting index element of the given array
  5857. * @param array defines the source array to read from
  5858. * @param offset defines the offset in the source array
  5859. * @returns a new Color4 object
  5860. */
  5861. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5862. /**
  5863. * Creates a new Color3 from integer values (< 256)
  5864. * @param r defines the red component to read from (value between 0 and 255)
  5865. * @param g defines the green component to read from (value between 0 and 255)
  5866. * @param b defines the blue component to read from (value between 0 and 255)
  5867. * @param a defines the alpha component to read from (value between 0 and 255)
  5868. * @returns a new Color3 object
  5869. */
  5870. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5871. /**
  5872. * Check the content of a given array and convert it to an array containing RGBA data
  5873. * If the original array was already containing count * 4 values then it is returned directly
  5874. * @param colors defines the array to check
  5875. * @param count defines the number of RGBA data to expect
  5876. * @returns an array containing count * 4 values (RGBA)
  5877. */
  5878. static CheckColors4(colors: number[], count: number): number[];
  5879. }
  5880. /**
  5881. * @hidden
  5882. */
  5883. export class TmpColors {
  5884. static Color3: Color3[];
  5885. static Color4: Color4[];
  5886. }
  5887. }
  5888. declare module "babylonjs/Animations/animationKey" {
  5889. /**
  5890. * Defines an interface which represents an animation key frame
  5891. */
  5892. export interface IAnimationKey {
  5893. /**
  5894. * Frame of the key frame
  5895. */
  5896. frame: number;
  5897. /**
  5898. * Value at the specifies key frame
  5899. */
  5900. value: any;
  5901. /**
  5902. * The input tangent for the cubic hermite spline
  5903. */
  5904. inTangent?: any;
  5905. /**
  5906. * The output tangent for the cubic hermite spline
  5907. */
  5908. outTangent?: any;
  5909. /**
  5910. * The animation interpolation type
  5911. */
  5912. interpolation?: AnimationKeyInterpolation;
  5913. }
  5914. /**
  5915. * Enum for the animation key frame interpolation type
  5916. */
  5917. export enum AnimationKeyInterpolation {
  5918. /**
  5919. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5920. */
  5921. STEP = 1
  5922. }
  5923. }
  5924. declare module "babylonjs/Animations/animationRange" {
  5925. /**
  5926. * Represents the range of an animation
  5927. */
  5928. export class AnimationRange {
  5929. /**The name of the animation range**/
  5930. name: string;
  5931. /**The starting frame of the animation */
  5932. from: number;
  5933. /**The ending frame of the animation*/
  5934. to: number;
  5935. /**
  5936. * Initializes the range of an animation
  5937. * @param name The name of the animation range
  5938. * @param from The starting frame of the animation
  5939. * @param to The ending frame of the animation
  5940. */
  5941. constructor(
  5942. /**The name of the animation range**/
  5943. name: string,
  5944. /**The starting frame of the animation */
  5945. from: number,
  5946. /**The ending frame of the animation*/
  5947. to: number);
  5948. /**
  5949. * Makes a copy of the animation range
  5950. * @returns A copy of the animation range
  5951. */
  5952. clone(): AnimationRange;
  5953. }
  5954. }
  5955. declare module "babylonjs/Animations/animationEvent" {
  5956. /**
  5957. * Composed of a frame, and an action function
  5958. */
  5959. export class AnimationEvent {
  5960. /** The frame for which the event is triggered **/
  5961. frame: number;
  5962. /** The event to perform when triggered **/
  5963. action: (currentFrame: number) => void;
  5964. /** Specifies if the event should be triggered only once**/
  5965. onlyOnce?: boolean | undefined;
  5966. /**
  5967. * Specifies if the animation event is done
  5968. */
  5969. isDone: boolean;
  5970. /**
  5971. * Initializes the animation event
  5972. * @param frame The frame for which the event is triggered
  5973. * @param action The event to perform when triggered
  5974. * @param onlyOnce Specifies if the event should be triggered only once
  5975. */
  5976. constructor(
  5977. /** The frame for which the event is triggered **/
  5978. frame: number,
  5979. /** The event to perform when triggered **/
  5980. action: (currentFrame: number) => void,
  5981. /** Specifies if the event should be triggered only once**/
  5982. onlyOnce?: boolean | undefined);
  5983. /** @hidden */
  5984. _clone(): AnimationEvent;
  5985. }
  5986. }
  5987. declare module "babylonjs/Behaviors/behavior" {
  5988. import { Nullable } from "babylonjs/types";
  5989. /**
  5990. * Interface used to define a behavior
  5991. */
  5992. export interface Behavior<T> {
  5993. /** gets or sets behavior's name */
  5994. name: string;
  5995. /**
  5996. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5997. */
  5998. init(): void;
  5999. /**
  6000. * Called when the behavior is attached to a target
  6001. * @param target defines the target where the behavior is attached to
  6002. */
  6003. attach(target: T): void;
  6004. /**
  6005. * Called when the behavior is detached from its target
  6006. */
  6007. detach(): void;
  6008. }
  6009. /**
  6010. * Interface implemented by classes supporting behaviors
  6011. */
  6012. export interface IBehaviorAware<T> {
  6013. /**
  6014. * Attach a behavior
  6015. * @param behavior defines the behavior to attach
  6016. * @returns the current host
  6017. */
  6018. addBehavior(behavior: Behavior<T>): T;
  6019. /**
  6020. * Remove a behavior from the current object
  6021. * @param behavior defines the behavior to detach
  6022. * @returns the current host
  6023. */
  6024. removeBehavior(behavior: Behavior<T>): T;
  6025. /**
  6026. * Gets a behavior using its name to search
  6027. * @param name defines the name to search
  6028. * @returns the behavior or null if not found
  6029. */
  6030. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6031. }
  6032. }
  6033. declare module "babylonjs/Misc/smartArray" {
  6034. /**
  6035. * Defines an array and its length.
  6036. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6037. */
  6038. export interface ISmartArrayLike<T> {
  6039. /**
  6040. * The data of the array.
  6041. */
  6042. data: Array<T>;
  6043. /**
  6044. * The active length of the array.
  6045. */
  6046. length: number;
  6047. }
  6048. /**
  6049. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6050. */
  6051. export class SmartArray<T> implements ISmartArrayLike<T> {
  6052. /**
  6053. * The full set of data from the array.
  6054. */
  6055. data: Array<T>;
  6056. /**
  6057. * The active length of the array.
  6058. */
  6059. length: number;
  6060. protected _id: number;
  6061. /**
  6062. * Instantiates a Smart Array.
  6063. * @param capacity defines the default capacity of the array.
  6064. */
  6065. constructor(capacity: number);
  6066. /**
  6067. * Pushes a value at the end of the active data.
  6068. * @param value defines the object to push in the array.
  6069. */
  6070. push(value: T): void;
  6071. /**
  6072. * Iterates over the active data and apply the lambda to them.
  6073. * @param func defines the action to apply on each value.
  6074. */
  6075. forEach(func: (content: T) => void): void;
  6076. /**
  6077. * Sorts the full sets of data.
  6078. * @param compareFn defines the comparison function to apply.
  6079. */
  6080. sort(compareFn: (a: T, b: T) => number): void;
  6081. /**
  6082. * Resets the active data to an empty array.
  6083. */
  6084. reset(): void;
  6085. /**
  6086. * Releases all the data from the array as well as the array.
  6087. */
  6088. dispose(): void;
  6089. /**
  6090. * Concats the active data with a given array.
  6091. * @param array defines the data to concatenate with.
  6092. */
  6093. concat(array: any): void;
  6094. /**
  6095. * Returns the position of a value in the active data.
  6096. * @param value defines the value to find the index for
  6097. * @returns the index if found in the active data otherwise -1
  6098. */
  6099. indexOf(value: T): number;
  6100. /**
  6101. * Returns whether an element is part of the active data.
  6102. * @param value defines the value to look for
  6103. * @returns true if found in the active data otherwise false
  6104. */
  6105. contains(value: T): boolean;
  6106. private static _GlobalId;
  6107. }
  6108. /**
  6109. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6110. * The data in this array can only be present once
  6111. */
  6112. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6113. private _duplicateId;
  6114. /**
  6115. * Pushes a value at the end of the active data.
  6116. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6117. * @param value defines the object to push in the array.
  6118. */
  6119. push(value: T): void;
  6120. /**
  6121. * Pushes a value at the end of the active data.
  6122. * If the data is already present, it won t be added again
  6123. * @param value defines the object to push in the array.
  6124. * @returns true if added false if it was already present
  6125. */
  6126. pushNoDuplicate(value: T): boolean;
  6127. /**
  6128. * Resets the active data to an empty array.
  6129. */
  6130. reset(): void;
  6131. /**
  6132. * Concats the active data with a given array.
  6133. * This ensures no dupplicate will be present in the result.
  6134. * @param array defines the data to concatenate with.
  6135. */
  6136. concatWithNoDuplicate(array: any): void;
  6137. }
  6138. }
  6139. declare module "babylonjs/Cameras/cameraInputsManager" {
  6140. import { Nullable } from "babylonjs/types";
  6141. import { Camera } from "babylonjs/Cameras/camera";
  6142. /**
  6143. * @ignore
  6144. * This is a list of all the different input types that are available in the application.
  6145. * Fo instance: ArcRotateCameraGamepadInput...
  6146. */
  6147. export var CameraInputTypes: {};
  6148. /**
  6149. * This is the contract to implement in order to create a new input class.
  6150. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6151. */
  6152. export interface ICameraInput<TCamera extends Camera> {
  6153. /**
  6154. * Defines the camera the input is attached to.
  6155. */
  6156. camera: Nullable<TCamera>;
  6157. /**
  6158. * Gets the class name of the current intput.
  6159. * @returns the class name
  6160. */
  6161. getClassName(): string;
  6162. /**
  6163. * Get the friendly name associated with the input class.
  6164. * @returns the input friendly name
  6165. */
  6166. getSimpleName(): string;
  6167. /**
  6168. * Attach the input controls to a specific dom element to get the input from.
  6169. * @param element Defines the element the controls should be listened from
  6170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6171. */
  6172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6173. /**
  6174. * Detach the current controls from the specified dom element.
  6175. * @param element Defines the element to stop listening the inputs from
  6176. */
  6177. detachControl(element: Nullable<HTMLElement>): void;
  6178. /**
  6179. * Update the current camera state depending on the inputs that have been used this frame.
  6180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6181. */
  6182. checkInputs?: () => void;
  6183. }
  6184. /**
  6185. * Represents a map of input types to input instance or input index to input instance.
  6186. */
  6187. export interface CameraInputsMap<TCamera extends Camera> {
  6188. /**
  6189. * Accessor to the input by input type.
  6190. */
  6191. [name: string]: ICameraInput<TCamera>;
  6192. /**
  6193. * Accessor to the input by input index.
  6194. */
  6195. [idx: number]: ICameraInput<TCamera>;
  6196. }
  6197. /**
  6198. * This represents the input manager used within a camera.
  6199. * It helps dealing with all the different kind of input attached to a camera.
  6200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6201. */
  6202. export class CameraInputsManager<TCamera extends Camera> {
  6203. /**
  6204. * Defines the list of inputs attahed to the camera.
  6205. */
  6206. attached: CameraInputsMap<TCamera>;
  6207. /**
  6208. * Defines the dom element the camera is collecting inputs from.
  6209. * This is null if the controls have not been attached.
  6210. */
  6211. attachedElement: Nullable<HTMLElement>;
  6212. /**
  6213. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6214. */
  6215. noPreventDefault: boolean;
  6216. /**
  6217. * Defined the camera the input manager belongs to.
  6218. */
  6219. camera: TCamera;
  6220. /**
  6221. * Update the current camera state depending on the inputs that have been used this frame.
  6222. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6223. */
  6224. checkInputs: () => void;
  6225. /**
  6226. * Instantiate a new Camera Input Manager.
  6227. * @param camera Defines the camera the input manager blongs to
  6228. */
  6229. constructor(camera: TCamera);
  6230. /**
  6231. * Add an input method to a camera
  6232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6233. * @param input camera input method
  6234. */
  6235. add(input: ICameraInput<TCamera>): void;
  6236. /**
  6237. * Remove a specific input method from a camera
  6238. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6239. * @param inputToRemove camera input method
  6240. */
  6241. remove(inputToRemove: ICameraInput<TCamera>): void;
  6242. /**
  6243. * Remove a specific input type from a camera
  6244. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6245. * @param inputType the type of the input to remove
  6246. */
  6247. removeByType(inputType: string): void;
  6248. private _addCheckInputs;
  6249. /**
  6250. * Attach the input controls to the currently attached dom element to listen the events from.
  6251. * @param input Defines the input to attach
  6252. */
  6253. attachInput(input: ICameraInput<TCamera>): void;
  6254. /**
  6255. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6256. * @param element Defines the dom element to collect the events from
  6257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6258. */
  6259. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6260. /**
  6261. * Detach the current manager inputs controls from a specific dom element.
  6262. * @param element Defines the dom element to collect the events from
  6263. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6264. */
  6265. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6266. /**
  6267. * Rebuild the dynamic inputCheck function from the current list of
  6268. * defined inputs in the manager.
  6269. */
  6270. rebuildInputCheck(): void;
  6271. /**
  6272. * Remove all attached input methods from a camera
  6273. */
  6274. clear(): void;
  6275. /**
  6276. * Serialize the current input manager attached to a camera.
  6277. * This ensures than once parsed,
  6278. * the input associated to the camera will be identical to the current ones
  6279. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6280. */
  6281. serialize(serializedCamera: any): void;
  6282. /**
  6283. * Parses an input manager serialized JSON to restore the previous list of inputs
  6284. * and states associated to a camera.
  6285. * @param parsedCamera Defines the JSON to parse
  6286. */
  6287. parse(parsedCamera: any): void;
  6288. }
  6289. }
  6290. declare module "babylonjs/Meshes/buffer" {
  6291. import { Nullable, DataArray } from "babylonjs/types";
  6292. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6293. /**
  6294. * Class used to store data that will be store in GPU memory
  6295. */
  6296. export class Buffer {
  6297. private _engine;
  6298. private _buffer;
  6299. /** @hidden */
  6300. _data: Nullable<DataArray>;
  6301. private _updatable;
  6302. private _instanced;
  6303. private _divisor;
  6304. /**
  6305. * Gets the byte stride.
  6306. */
  6307. readonly byteStride: number;
  6308. /**
  6309. * Constructor
  6310. * @param engine the engine
  6311. * @param data the data to use for this buffer
  6312. * @param updatable whether the data is updatable
  6313. * @param stride the stride (optional)
  6314. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6315. * @param instanced whether the buffer is instanced (optional)
  6316. * @param useBytes set to true if the stride in in bytes (optional)
  6317. * @param divisor sets an optional divisor for instances (1 by default)
  6318. */
  6319. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6320. /**
  6321. * Create a new VertexBuffer based on the current buffer
  6322. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6323. * @param offset defines offset in the buffer (0 by default)
  6324. * @param size defines the size in floats of attributes (position is 3 for instance)
  6325. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6326. * @param instanced defines if the vertex buffer contains indexed data
  6327. * @param useBytes defines if the offset and stride are in bytes *
  6328. * @param divisor sets an optional divisor for instances (1 by default)
  6329. * @returns the new vertex buffer
  6330. */
  6331. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6332. /**
  6333. * Gets a boolean indicating if the Buffer is updatable?
  6334. * @returns true if the buffer is updatable
  6335. */
  6336. isUpdatable(): boolean;
  6337. /**
  6338. * Gets current buffer's data
  6339. * @returns a DataArray or null
  6340. */
  6341. getData(): Nullable<DataArray>;
  6342. /**
  6343. * Gets underlying native buffer
  6344. * @returns underlying native buffer
  6345. */
  6346. getBuffer(): Nullable<DataBuffer>;
  6347. /**
  6348. * Gets the stride in float32 units (i.e. byte stride / 4).
  6349. * May not be an integer if the byte stride is not divisible by 4.
  6350. * @returns the stride in float32 units
  6351. * @deprecated Please use byteStride instead.
  6352. */
  6353. getStrideSize(): number;
  6354. /**
  6355. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6356. * @param data defines the data to store
  6357. */
  6358. create(data?: Nullable<DataArray>): void;
  6359. /** @hidden */
  6360. _rebuild(): void;
  6361. /**
  6362. * Update current buffer data
  6363. * @param data defines the data to store
  6364. */
  6365. update(data: DataArray): void;
  6366. /**
  6367. * Updates the data directly.
  6368. * @param data the new data
  6369. * @param offset the new offset
  6370. * @param vertexCount the vertex count (optional)
  6371. * @param useBytes set to true if the offset is in bytes
  6372. */
  6373. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6374. /**
  6375. * Release all resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. /**
  6380. * Specialized buffer used to store vertex data
  6381. */
  6382. export class VertexBuffer {
  6383. /** @hidden */
  6384. _buffer: Buffer;
  6385. private _kind;
  6386. private _size;
  6387. private _ownsBuffer;
  6388. private _instanced;
  6389. private _instanceDivisor;
  6390. /**
  6391. * The byte type.
  6392. */
  6393. static readonly BYTE: number;
  6394. /**
  6395. * The unsigned byte type.
  6396. */
  6397. static readonly UNSIGNED_BYTE: number;
  6398. /**
  6399. * The short type.
  6400. */
  6401. static readonly SHORT: number;
  6402. /**
  6403. * The unsigned short type.
  6404. */
  6405. static readonly UNSIGNED_SHORT: number;
  6406. /**
  6407. * The integer type.
  6408. */
  6409. static readonly INT: number;
  6410. /**
  6411. * The unsigned integer type.
  6412. */
  6413. static readonly UNSIGNED_INT: number;
  6414. /**
  6415. * The float type.
  6416. */
  6417. static readonly FLOAT: number;
  6418. /**
  6419. * Gets or sets the instance divisor when in instanced mode
  6420. */
  6421. get instanceDivisor(): number;
  6422. set instanceDivisor(value: number);
  6423. /**
  6424. * Gets the byte stride.
  6425. */
  6426. readonly byteStride: number;
  6427. /**
  6428. * Gets the byte offset.
  6429. */
  6430. readonly byteOffset: number;
  6431. /**
  6432. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6433. */
  6434. readonly normalized: boolean;
  6435. /**
  6436. * Gets the data type of each component in the array.
  6437. */
  6438. readonly type: number;
  6439. /**
  6440. * Constructor
  6441. * @param engine the engine
  6442. * @param data the data to use for this vertex buffer
  6443. * @param kind the vertex buffer kind
  6444. * @param updatable whether the data is updatable
  6445. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6446. * @param stride the stride (optional)
  6447. * @param instanced whether the buffer is instanced (optional)
  6448. * @param offset the offset of the data (optional)
  6449. * @param size the number of components (optional)
  6450. * @param type the type of the component (optional)
  6451. * @param normalized whether the data contains normalized data (optional)
  6452. * @param useBytes set to true if stride and offset are in bytes (optional)
  6453. * @param divisor defines the instance divisor to use (1 by default)
  6454. */
  6455. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6456. /** @hidden */
  6457. _rebuild(): void;
  6458. /**
  6459. * Returns the kind of the VertexBuffer (string)
  6460. * @returns a string
  6461. */
  6462. getKind(): string;
  6463. /**
  6464. * Gets a boolean indicating if the VertexBuffer is updatable?
  6465. * @returns true if the buffer is updatable
  6466. */
  6467. isUpdatable(): boolean;
  6468. /**
  6469. * Gets current buffer's data
  6470. * @returns a DataArray or null
  6471. */
  6472. getData(): Nullable<DataArray>;
  6473. /**
  6474. * Gets underlying native buffer
  6475. * @returns underlying native buffer
  6476. */
  6477. getBuffer(): Nullable<DataBuffer>;
  6478. /**
  6479. * Gets the stride in float32 units (i.e. byte stride / 4).
  6480. * May not be an integer if the byte stride is not divisible by 4.
  6481. * @returns the stride in float32 units
  6482. * @deprecated Please use byteStride instead.
  6483. */
  6484. getStrideSize(): number;
  6485. /**
  6486. * Returns the offset as a multiple of the type byte length.
  6487. * @returns the offset in bytes
  6488. * @deprecated Please use byteOffset instead.
  6489. */
  6490. getOffset(): number;
  6491. /**
  6492. * Returns the number of components per vertex attribute (integer)
  6493. * @returns the size in float
  6494. */
  6495. getSize(): number;
  6496. /**
  6497. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6498. * @returns true if this buffer is instanced
  6499. */
  6500. getIsInstanced(): boolean;
  6501. /**
  6502. * Returns the instancing divisor, zero for non-instanced (integer).
  6503. * @returns a number
  6504. */
  6505. getInstanceDivisor(): number;
  6506. /**
  6507. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6508. * @param data defines the data to store
  6509. */
  6510. create(data?: DataArray): void;
  6511. /**
  6512. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6513. * This function will create a new buffer if the current one is not updatable
  6514. * @param data defines the data to store
  6515. */
  6516. update(data: DataArray): void;
  6517. /**
  6518. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6519. * Returns the directly updated WebGLBuffer.
  6520. * @param data the new data
  6521. * @param offset the new offset
  6522. * @param useBytes set to true if the offset is in bytes
  6523. */
  6524. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6525. /**
  6526. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6527. */
  6528. dispose(): void;
  6529. /**
  6530. * Enumerates each value of this vertex buffer as numbers.
  6531. * @param count the number of values to enumerate
  6532. * @param callback the callback function called for each value
  6533. */
  6534. forEach(count: number, callback: (value: number, index: number) => void): void;
  6535. /**
  6536. * Positions
  6537. */
  6538. static readonly PositionKind: string;
  6539. /**
  6540. * Normals
  6541. */
  6542. static readonly NormalKind: string;
  6543. /**
  6544. * Tangents
  6545. */
  6546. static readonly TangentKind: string;
  6547. /**
  6548. * Texture coordinates
  6549. */
  6550. static readonly UVKind: string;
  6551. /**
  6552. * Texture coordinates 2
  6553. */
  6554. static readonly UV2Kind: string;
  6555. /**
  6556. * Texture coordinates 3
  6557. */
  6558. static readonly UV3Kind: string;
  6559. /**
  6560. * Texture coordinates 4
  6561. */
  6562. static readonly UV4Kind: string;
  6563. /**
  6564. * Texture coordinates 5
  6565. */
  6566. static readonly UV5Kind: string;
  6567. /**
  6568. * Texture coordinates 6
  6569. */
  6570. static readonly UV6Kind: string;
  6571. /**
  6572. * Colors
  6573. */
  6574. static readonly ColorKind: string;
  6575. /**
  6576. * Matrix indices (for bones)
  6577. */
  6578. static readonly MatricesIndicesKind: string;
  6579. /**
  6580. * Matrix weights (for bones)
  6581. */
  6582. static readonly MatricesWeightsKind: string;
  6583. /**
  6584. * Additional matrix indices (for bones)
  6585. */
  6586. static readonly MatricesIndicesExtraKind: string;
  6587. /**
  6588. * Additional matrix weights (for bones)
  6589. */
  6590. static readonly MatricesWeightsExtraKind: string;
  6591. /**
  6592. * Deduces the stride given a kind.
  6593. * @param kind The kind string to deduce
  6594. * @returns The deduced stride
  6595. */
  6596. static DeduceStride(kind: string): number;
  6597. /**
  6598. * Gets the byte length of the given type.
  6599. * @param type the type
  6600. * @returns the number of bytes
  6601. */
  6602. static GetTypeByteLength(type: number): number;
  6603. /**
  6604. * Enumerates each value of the given parameters as numbers.
  6605. * @param data the data to enumerate
  6606. * @param byteOffset the byte offset of the data
  6607. * @param byteStride the byte stride of the data
  6608. * @param componentCount the number of components per element
  6609. * @param componentType the type of the component
  6610. * @param count the number of values to enumerate
  6611. * @param normalized whether the data is normalized
  6612. * @param callback the callback function called for each value
  6613. */
  6614. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6615. private static _GetFloatValue;
  6616. }
  6617. }
  6618. declare module "babylonjs/Collisions/intersectionInfo" {
  6619. import { Nullable } from "babylonjs/types";
  6620. /**
  6621. * @hidden
  6622. */
  6623. export class IntersectionInfo {
  6624. bu: Nullable<number>;
  6625. bv: Nullable<number>;
  6626. distance: number;
  6627. faceId: number;
  6628. subMeshId: number;
  6629. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6630. }
  6631. }
  6632. declare module "babylonjs/Maths/math.plane" {
  6633. import { DeepImmutable } from "babylonjs/types";
  6634. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6635. /**
  6636. * Represens a plane by the equation ax + by + cz + d = 0
  6637. */
  6638. export class Plane {
  6639. private static _TmpMatrix;
  6640. /**
  6641. * Normal of the plane (a,b,c)
  6642. */
  6643. normal: Vector3;
  6644. /**
  6645. * d component of the plane
  6646. */
  6647. d: number;
  6648. /**
  6649. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6650. * @param a a component of the plane
  6651. * @param b b component of the plane
  6652. * @param c c component of the plane
  6653. * @param d d component of the plane
  6654. */
  6655. constructor(a: number, b: number, c: number, d: number);
  6656. /**
  6657. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6658. */
  6659. asArray(): number[];
  6660. /**
  6661. * @returns a new plane copied from the current Plane.
  6662. */
  6663. clone(): Plane;
  6664. /**
  6665. * @returns the string "Plane".
  6666. */
  6667. getClassName(): string;
  6668. /**
  6669. * @returns the Plane hash code.
  6670. */
  6671. getHashCode(): number;
  6672. /**
  6673. * Normalize the current Plane in place.
  6674. * @returns the updated Plane.
  6675. */
  6676. normalize(): Plane;
  6677. /**
  6678. * Applies a transformation the plane and returns the result
  6679. * @param transformation the transformation matrix to be applied to the plane
  6680. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6681. */
  6682. transform(transformation: DeepImmutable<Matrix>): Plane;
  6683. /**
  6684. * Calcualtte the dot product between the point and the plane normal
  6685. * @param point point to calculate the dot product with
  6686. * @returns the dot product (float) of the point coordinates and the plane normal.
  6687. */
  6688. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6689. /**
  6690. * Updates the current Plane from the plane defined by the three given points.
  6691. * @param point1 one of the points used to contruct the plane
  6692. * @param point2 one of the points used to contruct the plane
  6693. * @param point3 one of the points used to contruct the plane
  6694. * @returns the updated Plane.
  6695. */
  6696. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6697. /**
  6698. * Checks if the plane is facing a given direction
  6699. * @param direction the direction to check if the plane is facing
  6700. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6701. * @returns True is the vector "direction" is the same side than the plane normal.
  6702. */
  6703. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6704. /**
  6705. * Calculates the distance to a point
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance (float) from the given point to the Plane.
  6708. */
  6709. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6710. /**
  6711. * Creates a plane from an array
  6712. * @param array the array to create a plane from
  6713. * @returns a new Plane from the given array.
  6714. */
  6715. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6716. /**
  6717. * Creates a plane from three points
  6718. * @param point1 point used to create the plane
  6719. * @param point2 point used to create the plane
  6720. * @param point3 point used to create the plane
  6721. * @returns a new Plane defined by the three given points.
  6722. */
  6723. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6724. /**
  6725. * Creates a plane from an origin point and a normal
  6726. * @param origin origin of the plane to be constructed
  6727. * @param normal normal of the plane to be constructed
  6728. * @returns a new Plane the normal vector to this plane at the given origin point.
  6729. * Note : the vector "normal" is updated because normalized.
  6730. */
  6731. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6732. /**
  6733. * Calculates the distance from a plane and a point
  6734. * @param origin origin of the plane to be constructed
  6735. * @param normal normal of the plane to be constructed
  6736. * @param point point to calculate distance to
  6737. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6738. */
  6739. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6740. }
  6741. }
  6742. declare module "babylonjs/Culling/boundingSphere" {
  6743. import { DeepImmutable } from "babylonjs/types";
  6744. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6745. import { Plane } from "babylonjs/Maths/math.plane";
  6746. /**
  6747. * Class used to store bounding sphere information
  6748. */
  6749. export class BoundingSphere {
  6750. /**
  6751. * Gets the center of the bounding sphere in local space
  6752. */
  6753. readonly center: Vector3;
  6754. /**
  6755. * Radius of the bounding sphere in local space
  6756. */
  6757. radius: number;
  6758. /**
  6759. * Gets the center of the bounding sphere in world space
  6760. */
  6761. readonly centerWorld: Vector3;
  6762. /**
  6763. * Radius of the bounding sphere in world space
  6764. */
  6765. radiusWorld: number;
  6766. /**
  6767. * Gets the minimum vector in local space
  6768. */
  6769. readonly minimum: Vector3;
  6770. /**
  6771. * Gets the maximum vector in local space
  6772. */
  6773. readonly maximum: Vector3;
  6774. private _worldMatrix;
  6775. private static readonly TmpVector3;
  6776. /**
  6777. * Creates a new bounding sphere
  6778. * @param min defines the minimum vector (in local space)
  6779. * @param max defines the maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6783. /**
  6784. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6785. * @param min defines the new minimum vector (in local space)
  6786. * @param max defines the new maximum vector (in local space)
  6787. * @param worldMatrix defines the new world matrix
  6788. */
  6789. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6790. /**
  6791. * Scale the current bounding sphere by applying a scale factor
  6792. * @param factor defines the scale factor to apply
  6793. * @returns the current bounding box
  6794. */
  6795. scale(factor: number): BoundingSphere;
  6796. /**
  6797. * Gets the world matrix of the bounding box
  6798. * @returns a matrix
  6799. */
  6800. getWorldMatrix(): DeepImmutable<Matrix>;
  6801. /** @hidden */
  6802. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6803. /**
  6804. * Tests if the bounding sphere is intersecting the frustum planes
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if the bounding sphere center is in between the frustum planes.
  6811. * Used for optimistic fast inclusion.
  6812. * @param frustumPlanes defines the frustum planes to test
  6813. * @returns true if the sphere center is in between the frustum planes
  6814. */
  6815. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6816. /**
  6817. * Tests if a point is inside the bounding sphere
  6818. * @param point defines the point to test
  6819. * @returns true if the point is inside the bounding sphere
  6820. */
  6821. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6822. /**
  6823. * Checks if two sphere intersct
  6824. * @param sphere0 sphere 0
  6825. * @param sphere1 sphere 1
  6826. * @returns true if the speres intersect
  6827. */
  6828. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6829. }
  6830. }
  6831. declare module "babylonjs/Culling/boundingBox" {
  6832. import { DeepImmutable } from "babylonjs/types";
  6833. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6834. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6835. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6836. import { Plane } from "babylonjs/Maths/math.plane";
  6837. /**
  6838. * Class used to store bounding box information
  6839. */
  6840. export class BoundingBox implements ICullable {
  6841. /**
  6842. * Gets the 8 vectors representing the bounding box in local space
  6843. */
  6844. readonly vectors: Vector3[];
  6845. /**
  6846. * Gets the center of the bounding box in local space
  6847. */
  6848. readonly center: Vector3;
  6849. /**
  6850. * Gets the center of the bounding box in world space
  6851. */
  6852. readonly centerWorld: Vector3;
  6853. /**
  6854. * Gets the extend size in local space
  6855. */
  6856. readonly extendSize: Vector3;
  6857. /**
  6858. * Gets the extend size in world space
  6859. */
  6860. readonly extendSizeWorld: Vector3;
  6861. /**
  6862. * Gets the OBB (object bounding box) directions
  6863. */
  6864. readonly directions: Vector3[];
  6865. /**
  6866. * Gets the 8 vectors representing the bounding box in world space
  6867. */
  6868. readonly vectorsWorld: Vector3[];
  6869. /**
  6870. * Gets the minimum vector in world space
  6871. */
  6872. readonly minimumWorld: Vector3;
  6873. /**
  6874. * Gets the maximum vector in world space
  6875. */
  6876. readonly maximumWorld: Vector3;
  6877. /**
  6878. * Gets the minimum vector in local space
  6879. */
  6880. readonly minimum: Vector3;
  6881. /**
  6882. * Gets the maximum vector in local space
  6883. */
  6884. readonly maximum: Vector3;
  6885. private _worldMatrix;
  6886. private static readonly TmpVector3;
  6887. /**
  6888. * @hidden
  6889. */
  6890. _tag: number;
  6891. /**
  6892. * Creates a new bounding box
  6893. * @param min defines the minimum vector (in local space)
  6894. * @param max defines the maximum vector (in local space)
  6895. * @param worldMatrix defines the new world matrix
  6896. */
  6897. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6898. /**
  6899. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6900. * @param min defines the new minimum vector (in local space)
  6901. * @param max defines the new maximum vector (in local space)
  6902. * @param worldMatrix defines the new world matrix
  6903. */
  6904. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6905. /**
  6906. * Scale the current bounding box by applying a scale factor
  6907. * @param factor defines the scale factor to apply
  6908. * @returns the current bounding box
  6909. */
  6910. scale(factor: number): BoundingBox;
  6911. /**
  6912. * Gets the world matrix of the bounding box
  6913. * @returns a matrix
  6914. */
  6915. getWorldMatrix(): DeepImmutable<Matrix>;
  6916. /** @hidden */
  6917. _update(world: DeepImmutable<Matrix>): void;
  6918. /**
  6919. * Tests if the bounding box is intersecting the frustum planes
  6920. * @param frustumPlanes defines the frustum planes to test
  6921. * @returns true if there is an intersection
  6922. */
  6923. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6924. /**
  6925. * Tests if the bounding box is entirely inside the frustum planes
  6926. * @param frustumPlanes defines the frustum planes to test
  6927. * @returns true if there is an inclusion
  6928. */
  6929. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6930. /**
  6931. * Tests if a point is inside the bounding box
  6932. * @param point defines the point to test
  6933. * @returns true if the point is inside the bounding box
  6934. */
  6935. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6936. /**
  6937. * Tests if the bounding box intersects with a bounding sphere
  6938. * @param sphere defines the sphere to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6942. /**
  6943. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6944. * @param min defines the min vector to use
  6945. * @param max defines the max vector to use
  6946. * @returns true if there is an intersection
  6947. */
  6948. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6949. /**
  6950. * Tests if two bounding boxes are intersections
  6951. * @param box0 defines the first box to test
  6952. * @param box1 defines the second box to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6956. /**
  6957. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6958. * @param minPoint defines the minimum vector of the bounding box
  6959. * @param maxPoint defines the maximum vector of the bounding box
  6960. * @param sphereCenter defines the sphere center
  6961. * @param sphereRadius defines the sphere radius
  6962. * @returns true if there is an intersection
  6963. */
  6964. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6965. /**
  6966. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6967. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @return true if there is an inclusion
  6970. */
  6971. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6974. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @return true if there is an intersection
  6977. */
  6978. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. }
  6980. }
  6981. declare module "babylonjs/Collisions/collider" {
  6982. import { Nullable, IndicesArray } from "babylonjs/types";
  6983. import { Vector3 } from "babylonjs/Maths/math.vector";
  6984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6985. import { Plane } from "babylonjs/Maths/math.plane";
  6986. /** @hidden */
  6987. export class Collider {
  6988. /** Define if a collision was found */
  6989. collisionFound: boolean;
  6990. /**
  6991. * Define last intersection point in local space
  6992. */
  6993. intersectionPoint: Vector3;
  6994. /**
  6995. * Define last collided mesh
  6996. */
  6997. collidedMesh: Nullable<AbstractMesh>;
  6998. private _collisionPoint;
  6999. private _planeIntersectionPoint;
  7000. private _tempVector;
  7001. private _tempVector2;
  7002. private _tempVector3;
  7003. private _tempVector4;
  7004. private _edge;
  7005. private _baseToVertex;
  7006. private _destinationPoint;
  7007. private _slidePlaneNormal;
  7008. private _displacementVector;
  7009. /** @hidden */
  7010. _radius: Vector3;
  7011. /** @hidden */
  7012. _retry: number;
  7013. private _velocity;
  7014. private _basePoint;
  7015. private _epsilon;
  7016. /** @hidden */
  7017. _velocityWorldLength: number;
  7018. /** @hidden */
  7019. _basePointWorld: Vector3;
  7020. private _velocityWorld;
  7021. private _normalizedVelocity;
  7022. /** @hidden */
  7023. _initialVelocity: Vector3;
  7024. /** @hidden */
  7025. _initialPosition: Vector3;
  7026. private _nearestDistance;
  7027. private _collisionMask;
  7028. get collisionMask(): number;
  7029. set collisionMask(mask: number);
  7030. /**
  7031. * Gets the plane normal used to compute the sliding response (in local space)
  7032. */
  7033. get slidePlaneNormal(): Vector3;
  7034. /** @hidden */
  7035. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7036. /** @hidden */
  7037. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7038. /** @hidden */
  7039. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7040. /** @hidden */
  7041. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7042. /** @hidden */
  7043. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7044. /** @hidden */
  7045. _getResponse(pos: Vector3, vel: Vector3): void;
  7046. }
  7047. }
  7048. declare module "babylonjs/Culling/boundingInfo" {
  7049. import { DeepImmutable } from "babylonjs/types";
  7050. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7051. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7052. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7053. import { Plane } from "babylonjs/Maths/math.plane";
  7054. import { Collider } from "babylonjs/Collisions/collider";
  7055. /**
  7056. * Interface for cullable objects
  7057. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7058. */
  7059. export interface ICullable {
  7060. /**
  7061. * Checks if the object or part of the object is in the frustum
  7062. * @param frustumPlanes Camera near/planes
  7063. * @returns true if the object is in frustum otherwise false
  7064. */
  7065. isInFrustum(frustumPlanes: Plane[]): boolean;
  7066. /**
  7067. * Checks if a cullable object (mesh...) is in the camera frustum
  7068. * Unlike isInFrustum this cheks the full bounding box
  7069. * @param frustumPlanes Camera near/planes
  7070. * @returns true if the object is in frustum otherwise false
  7071. */
  7072. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7073. }
  7074. /**
  7075. * Info for a bounding data of a mesh
  7076. */
  7077. export class BoundingInfo implements ICullable {
  7078. /**
  7079. * Bounding box for the mesh
  7080. */
  7081. readonly boundingBox: BoundingBox;
  7082. /**
  7083. * Bounding sphere for the mesh
  7084. */
  7085. readonly boundingSphere: BoundingSphere;
  7086. private _isLocked;
  7087. private static readonly TmpVector3;
  7088. /**
  7089. * Constructs bounding info
  7090. * @param minimum min vector of the bounding box/sphere
  7091. * @param maximum max vector of the bounding box/sphere
  7092. * @param worldMatrix defines the new world matrix
  7093. */
  7094. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7095. /**
  7096. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7097. * @param min defines the new minimum vector (in local space)
  7098. * @param max defines the new maximum vector (in local space)
  7099. * @param worldMatrix defines the new world matrix
  7100. */
  7101. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7102. /**
  7103. * min vector of the bounding box/sphere
  7104. */
  7105. get minimum(): Vector3;
  7106. /**
  7107. * max vector of the bounding box/sphere
  7108. */
  7109. get maximum(): Vector3;
  7110. /**
  7111. * If the info is locked and won't be updated to avoid perf overhead
  7112. */
  7113. get isLocked(): boolean;
  7114. set isLocked(value: boolean);
  7115. /**
  7116. * Updates the bounding sphere and box
  7117. * @param world world matrix to be used to update
  7118. */
  7119. update(world: DeepImmutable<Matrix>): void;
  7120. /**
  7121. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7122. * @param center New center of the bounding info
  7123. * @param extend New extend of the bounding info
  7124. * @returns the current bounding info
  7125. */
  7126. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7127. /**
  7128. * Scale the current bounding info by applying a scale factor
  7129. * @param factor defines the scale factor to apply
  7130. * @returns the current bounding info
  7131. */
  7132. scale(factor: number): BoundingInfo;
  7133. /**
  7134. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7135. * @param frustumPlanes defines the frustum to test
  7136. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7137. * @returns true if the bounding info is in the frustum planes
  7138. */
  7139. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7140. /**
  7141. * Gets the world distance between the min and max points of the bounding box
  7142. */
  7143. get diagonalLength(): number;
  7144. /**
  7145. * Checks if a cullable object (mesh...) is in the camera frustum
  7146. * Unlike isInFrustum this cheks the full bounding box
  7147. * @param frustumPlanes Camera near/planes
  7148. * @returns true if the object is in frustum otherwise false
  7149. */
  7150. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7151. /** @hidden */
  7152. _checkCollision(collider: Collider): boolean;
  7153. /**
  7154. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7155. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7156. * @param point the point to check intersection with
  7157. * @returns if the point intersects
  7158. */
  7159. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7160. /**
  7161. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7162. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7163. * @param boundingInfo the bounding info to check intersection with
  7164. * @param precise if the intersection should be done using OBB
  7165. * @returns if the bounding info intersects
  7166. */
  7167. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7168. }
  7169. }
  7170. declare module "babylonjs/Maths/math.functions" {
  7171. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7172. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7173. /**
  7174. * Extracts minimum and maximum values from a list of indexed positions
  7175. * @param positions defines the positions to use
  7176. * @param indices defines the indices to the positions
  7177. * @param indexStart defines the start index
  7178. * @param indexCount defines the end index
  7179. * @param bias defines bias value to add to the result
  7180. * @return minimum and maximum values
  7181. */
  7182. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7183. minimum: Vector3;
  7184. maximum: Vector3;
  7185. };
  7186. /**
  7187. * Extracts minimum and maximum values from a list of positions
  7188. * @param positions defines the positions to use
  7189. * @param start defines the start index in the positions array
  7190. * @param count defines the number of positions to handle
  7191. * @param bias defines bias value to add to the result
  7192. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7193. * @return minimum and maximum values
  7194. */
  7195. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7196. minimum: Vector3;
  7197. maximum: Vector3;
  7198. };
  7199. }
  7200. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7201. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7202. /** @hidden */
  7203. export class WebGLDataBuffer extends DataBuffer {
  7204. private _buffer;
  7205. constructor(resource: WebGLBuffer);
  7206. get underlyingResource(): any;
  7207. }
  7208. }
  7209. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7210. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7211. import { Nullable } from "babylonjs/types";
  7212. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7213. /** @hidden */
  7214. export class WebGLPipelineContext implements IPipelineContext {
  7215. engine: ThinEngine;
  7216. program: Nullable<WebGLProgram>;
  7217. context?: WebGLRenderingContext;
  7218. vertexShader?: WebGLShader;
  7219. fragmentShader?: WebGLShader;
  7220. isParallelCompiled: boolean;
  7221. onCompiled?: () => void;
  7222. transformFeedback?: WebGLTransformFeedback | null;
  7223. vertexCompilationError: Nullable<string>;
  7224. fragmentCompilationError: Nullable<string>;
  7225. programLinkError: Nullable<string>;
  7226. programValidationError: Nullable<string>;
  7227. get isAsync(): boolean;
  7228. get isReady(): boolean;
  7229. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7230. _getVertexShaderCode(): string | null;
  7231. _getFragmentShaderCode(): string | null;
  7232. }
  7233. }
  7234. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7235. import { FloatArray, Nullable } from "babylonjs/types";
  7236. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7237. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7238. module "babylonjs/Engines/thinEngine" {
  7239. interface ThinEngine {
  7240. /**
  7241. * Create an uniform buffer
  7242. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7243. * @param elements defines the content of the uniform buffer
  7244. * @returns the webGL uniform buffer
  7245. */
  7246. createUniformBuffer(elements: FloatArray): DataBuffer;
  7247. /**
  7248. * Create a dynamic uniform buffer
  7249. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7250. * @param elements defines the content of the uniform buffer
  7251. * @returns the webGL uniform buffer
  7252. */
  7253. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7254. /**
  7255. * Update an existing uniform buffer
  7256. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7257. * @param uniformBuffer defines the target uniform buffer
  7258. * @param elements defines the content to update
  7259. * @param offset defines the offset in the uniform buffer where update should start
  7260. * @param count defines the size of the data to update
  7261. */
  7262. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7263. /**
  7264. * Bind an uniform buffer to the current webGL context
  7265. * @param buffer defines the buffer to bind
  7266. */
  7267. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7268. /**
  7269. * Bind a buffer to the current webGL context at a given location
  7270. * @param buffer defines the buffer to bind
  7271. * @param location defines the index where to bind the buffer
  7272. */
  7273. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7274. /**
  7275. * Bind a specific block at a given index in a specific shader program
  7276. * @param pipelineContext defines the pipeline context to use
  7277. * @param blockName defines the block name
  7278. * @param index defines the index where to bind the block
  7279. */
  7280. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7281. }
  7282. }
  7283. }
  7284. declare module "babylonjs/Materials/uniformBuffer" {
  7285. import { Nullable, FloatArray } from "babylonjs/types";
  7286. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7287. import { Engine } from "babylonjs/Engines/engine";
  7288. import { Effect } from "babylonjs/Materials/effect";
  7289. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7291. import { Color3 } from "babylonjs/Maths/math.color";
  7292. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7293. /**
  7294. * Uniform buffer objects.
  7295. *
  7296. * Handles blocks of uniform on the GPU.
  7297. *
  7298. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7299. *
  7300. * For more information, please refer to :
  7301. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7302. */
  7303. export class UniformBuffer {
  7304. private _engine;
  7305. private _buffer;
  7306. private _data;
  7307. private _bufferData;
  7308. private _dynamic?;
  7309. private _uniformLocations;
  7310. private _uniformSizes;
  7311. private _uniformLocationPointer;
  7312. private _needSync;
  7313. private _noUBO;
  7314. private _currentEffect;
  7315. /** @hidden */
  7316. _alreadyBound: boolean;
  7317. private static _MAX_UNIFORM_SIZE;
  7318. private static _tempBuffer;
  7319. /**
  7320. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7321. * This is dynamic to allow compat with webgl 1 and 2.
  7322. * You will need to pass the name of the uniform as well as the value.
  7323. */
  7324. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7325. /**
  7326. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7327. * This is dynamic to allow compat with webgl 1 and 2.
  7328. * You will need to pass the name of the uniform as well as the value.
  7329. */
  7330. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7331. /**
  7332. * Lambda to Update a single float in a uniform buffer.
  7333. * This is dynamic to allow compat with webgl 1 and 2.
  7334. * You will need to pass the name of the uniform as well as the value.
  7335. */
  7336. updateFloat: (name: string, x: number) => void;
  7337. /**
  7338. * Lambda to Update a vec2 of float in a uniform buffer.
  7339. * This is dynamic to allow compat with webgl 1 and 2.
  7340. * You will need to pass the name of the uniform as well as the value.
  7341. */
  7342. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7343. /**
  7344. * Lambda to Update a vec3 of float in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7349. /**
  7350. * Lambda to Update a vec4 of float in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7355. /**
  7356. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateMatrix: (name: string, mat: Matrix) => void;
  7361. /**
  7362. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateVector3: (name: string, vector: Vector3) => void;
  7367. /**
  7368. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateVector4: (name: string, vector: Vector4) => void;
  7373. /**
  7374. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7379. /**
  7380. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7385. /**
  7386. * Instantiates a new Uniform buffer objects.
  7387. *
  7388. * Handles blocks of uniform on the GPU.
  7389. *
  7390. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7391. *
  7392. * For more information, please refer to :
  7393. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7394. * @param engine Define the engine the buffer is associated with
  7395. * @param data Define the data contained in the buffer
  7396. * @param dynamic Define if the buffer is updatable
  7397. */
  7398. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7399. /**
  7400. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7401. * or just falling back on setUniformXXX calls.
  7402. */
  7403. get useUbo(): boolean;
  7404. /**
  7405. * Indicates if the WebGL underlying uniform buffer is in sync
  7406. * with the javascript cache data.
  7407. */
  7408. get isSync(): boolean;
  7409. /**
  7410. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7411. * Also, a dynamic UniformBuffer will disable cache verification and always
  7412. * update the underlying WebGL uniform buffer to the GPU.
  7413. * @returns if Dynamic, otherwise false
  7414. */
  7415. isDynamic(): boolean;
  7416. /**
  7417. * The data cache on JS side.
  7418. * @returns the underlying data as a float array
  7419. */
  7420. getData(): Float32Array;
  7421. /**
  7422. * The underlying WebGL Uniform buffer.
  7423. * @returns the webgl buffer
  7424. */
  7425. getBuffer(): Nullable<DataBuffer>;
  7426. /**
  7427. * std140 layout specifies how to align data within an UBO structure.
  7428. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7429. * for specs.
  7430. */
  7431. private _fillAlignment;
  7432. /**
  7433. * Adds an uniform in the buffer.
  7434. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7435. * for the layout to be correct !
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param size Data size, or data directly.
  7438. */
  7439. addUniform(name: string, size: number | number[]): void;
  7440. /**
  7441. * Adds a Matrix 4x4 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param mat A 4x4 matrix.
  7444. */
  7445. addMatrix(name: string, mat: Matrix): void;
  7446. /**
  7447. * Adds a vec2 to the uniform buffer.
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. * @param x Define the x component value of the vec2
  7450. * @param y Define the y component value of the vec2
  7451. */
  7452. addFloat2(name: string, x: number, y: number): void;
  7453. /**
  7454. * Adds a vec3 to the uniform buffer.
  7455. * @param name Name of the uniform, as used in the uniform block in the shader.
  7456. * @param x Define the x component value of the vec3
  7457. * @param y Define the y component value of the vec3
  7458. * @param z Define the z component value of the vec3
  7459. */
  7460. addFloat3(name: string, x: number, y: number, z: number): void;
  7461. /**
  7462. * Adds a vec3 to the uniform buffer.
  7463. * @param name Name of the uniform, as used in the uniform block in the shader.
  7464. * @param color Define the vec3 from a Color
  7465. */
  7466. addColor3(name: string, color: Color3): void;
  7467. /**
  7468. * Adds a vec4 to the uniform buffer.
  7469. * @param name Name of the uniform, as used in the uniform block in the shader.
  7470. * @param color Define the rgb components from a Color
  7471. * @param alpha Define the a component of the vec4
  7472. */
  7473. addColor4(name: string, color: Color3, alpha: number): void;
  7474. /**
  7475. * Adds a vec3 to the uniform buffer.
  7476. * @param name Name of the uniform, as used in the uniform block in the shader.
  7477. * @param vector Define the vec3 components from a Vector
  7478. */
  7479. addVector3(name: string, vector: Vector3): void;
  7480. /**
  7481. * Adds a Matrix 3x3 to the uniform buffer.
  7482. * @param name Name of the uniform, as used in the uniform block in the shader.
  7483. */
  7484. addMatrix3x3(name: string): void;
  7485. /**
  7486. * Adds a Matrix 2x2 to the uniform buffer.
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. */
  7489. addMatrix2x2(name: string): void;
  7490. /**
  7491. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7492. */
  7493. create(): void;
  7494. /** @hidden */
  7495. _rebuild(): void;
  7496. /**
  7497. * Updates the WebGL Uniform Buffer on the GPU.
  7498. * If the `dynamic` flag is set to true, no cache comparison is done.
  7499. * Otherwise, the buffer will be updated only if the cache differs.
  7500. */
  7501. update(): void;
  7502. /**
  7503. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7504. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7505. * @param data Define the flattened data
  7506. * @param size Define the size of the data.
  7507. */
  7508. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7509. private _valueCache;
  7510. private _cacheMatrix;
  7511. private _updateMatrix3x3ForUniform;
  7512. private _updateMatrix3x3ForEffect;
  7513. private _updateMatrix2x2ForEffect;
  7514. private _updateMatrix2x2ForUniform;
  7515. private _updateFloatForEffect;
  7516. private _updateFloatForUniform;
  7517. private _updateFloat2ForEffect;
  7518. private _updateFloat2ForUniform;
  7519. private _updateFloat3ForEffect;
  7520. private _updateFloat3ForUniform;
  7521. private _updateFloat4ForEffect;
  7522. private _updateFloat4ForUniform;
  7523. private _updateMatrixForEffect;
  7524. private _updateMatrixForUniform;
  7525. private _updateVector3ForEffect;
  7526. private _updateVector3ForUniform;
  7527. private _updateVector4ForEffect;
  7528. private _updateVector4ForUniform;
  7529. private _updateColor3ForEffect;
  7530. private _updateColor3ForUniform;
  7531. private _updateColor4ForEffect;
  7532. private _updateColor4ForUniform;
  7533. /**
  7534. * Sets a sampler uniform on the effect.
  7535. * @param name Define the name of the sampler.
  7536. * @param texture Define the texture to set in the sampler
  7537. */
  7538. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7539. /**
  7540. * Directly updates the value of the uniform in the cache AND on the GPU.
  7541. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7542. * @param data Define the flattened data
  7543. */
  7544. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7545. /**
  7546. * Binds this uniform buffer to an effect.
  7547. * @param effect Define the effect to bind the buffer to
  7548. * @param name Name of the uniform block in the shader.
  7549. */
  7550. bindToEffect(effect: Effect, name: string): void;
  7551. /**
  7552. * Disposes the uniform buffer.
  7553. */
  7554. dispose(): void;
  7555. }
  7556. }
  7557. declare module "babylonjs/Misc/iInspectable" {
  7558. /**
  7559. * Enum that determines the text-wrapping mode to use.
  7560. */
  7561. export enum InspectableType {
  7562. /**
  7563. * Checkbox for booleans
  7564. */
  7565. Checkbox = 0,
  7566. /**
  7567. * Sliders for numbers
  7568. */
  7569. Slider = 1,
  7570. /**
  7571. * Vector3
  7572. */
  7573. Vector3 = 2,
  7574. /**
  7575. * Quaternions
  7576. */
  7577. Quaternion = 3,
  7578. /**
  7579. * Color3
  7580. */
  7581. Color3 = 4,
  7582. /**
  7583. * String
  7584. */
  7585. String = 5
  7586. }
  7587. /**
  7588. * Interface used to define custom inspectable properties.
  7589. * This interface is used by the inspector to display custom property grids
  7590. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7591. */
  7592. export interface IInspectable {
  7593. /**
  7594. * Gets the label to display
  7595. */
  7596. label: string;
  7597. /**
  7598. * Gets the name of the property to edit
  7599. */
  7600. propertyName: string;
  7601. /**
  7602. * Gets the type of the editor to use
  7603. */
  7604. type: InspectableType;
  7605. /**
  7606. * Gets the minimum value of the property when using in "slider" mode
  7607. */
  7608. min?: number;
  7609. /**
  7610. * Gets the maximum value of the property when using in "slider" mode
  7611. */
  7612. max?: number;
  7613. /**
  7614. * Gets the setp to use when using in "slider" mode
  7615. */
  7616. step?: number;
  7617. }
  7618. }
  7619. declare module "babylonjs/Misc/timingTools" {
  7620. /**
  7621. * Class used to provide helper for timing
  7622. */
  7623. export class TimingTools {
  7624. /**
  7625. * Polyfill for setImmediate
  7626. * @param action defines the action to execute after the current execution block
  7627. */
  7628. static SetImmediate(action: () => void): void;
  7629. }
  7630. }
  7631. declare module "babylonjs/Misc/instantiationTools" {
  7632. /**
  7633. * Class used to enable instatition of objects by class name
  7634. */
  7635. export class InstantiationTools {
  7636. /**
  7637. * Use this object to register external classes like custom textures or material
  7638. * to allow the laoders to instantiate them
  7639. */
  7640. static RegisteredExternalClasses: {
  7641. [key: string]: Object;
  7642. };
  7643. /**
  7644. * Tries to instantiate a new object from a given class name
  7645. * @param className defines the class name to instantiate
  7646. * @returns the new object or null if the system was not able to do the instantiation
  7647. */
  7648. static Instantiate(className: string): any;
  7649. }
  7650. }
  7651. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7652. /**
  7653. * Define options used to create a depth texture
  7654. */
  7655. export class DepthTextureCreationOptions {
  7656. /** Specifies whether or not a stencil should be allocated in the texture */
  7657. generateStencil?: boolean;
  7658. /** Specifies whether or not bilinear filtering is enable on the texture */
  7659. bilinearFiltering?: boolean;
  7660. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7661. comparisonFunction?: number;
  7662. /** Specifies if the created texture is a cube texture */
  7663. isCube?: boolean;
  7664. }
  7665. }
  7666. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7667. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7668. import { Nullable } from "babylonjs/types";
  7669. import { Scene } from "babylonjs/scene";
  7670. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7671. module "babylonjs/Engines/thinEngine" {
  7672. interface ThinEngine {
  7673. /**
  7674. * Creates a depth stencil cube texture.
  7675. * This is only available in WebGL 2.
  7676. * @param size The size of face edge in the cube texture.
  7677. * @param options The options defining the cube texture.
  7678. * @returns The cube texture
  7679. */
  7680. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7681. /**
  7682. * Creates a cube texture
  7683. * @param rootUrl defines the url where the files to load is located
  7684. * @param scene defines the current scene
  7685. * @param files defines the list of files to load (1 per face)
  7686. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7687. * @param onLoad defines an optional callback raised when the texture is loaded
  7688. * @param onError defines an optional callback raised if there is an issue to load the texture
  7689. * @param format defines the format of the data
  7690. * @param forcedExtension defines the extension to use to pick the right loader
  7691. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7692. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7693. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7694. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7695. * @returns the cube texture as an InternalTexture
  7696. */
  7697. 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>): InternalTexture;
  7698. /**
  7699. * Creates a cube texture
  7700. * @param rootUrl defines the url where the files to load is located
  7701. * @param scene defines the current scene
  7702. * @param files defines the list of files to load (1 per face)
  7703. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7704. * @param onLoad defines an optional callback raised when the texture is loaded
  7705. * @param onError defines an optional callback raised if there is an issue to load the texture
  7706. * @param format defines the format of the data
  7707. * @param forcedExtension defines the extension to use to pick the right loader
  7708. * @returns the cube texture as an InternalTexture
  7709. */
  7710. 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;
  7711. /**
  7712. * Creates a cube texture
  7713. * @param rootUrl defines the url where the files to load is located
  7714. * @param scene defines the current scene
  7715. * @param files defines the list of files to load (1 per face)
  7716. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7717. * @param onLoad defines an optional callback raised when the texture is loaded
  7718. * @param onError defines an optional callback raised if there is an issue to load the texture
  7719. * @param format defines the format of the data
  7720. * @param forcedExtension defines the extension to use to pick the right loader
  7721. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7722. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7723. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7724. * @returns the cube texture as an InternalTexture
  7725. */
  7726. 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;
  7727. /** @hidden */
  7728. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7729. /** @hidden */
  7730. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7731. /** @hidden */
  7732. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7733. /** @hidden */
  7734. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7735. /**
  7736. * @hidden
  7737. */
  7738. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7739. }
  7740. }
  7741. }
  7742. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7743. import { Nullable } from "babylonjs/types";
  7744. import { Scene } from "babylonjs/scene";
  7745. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7747. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7748. import { Observable } from "babylonjs/Misc/observable";
  7749. /**
  7750. * Class for creating a cube texture
  7751. */
  7752. export class CubeTexture extends BaseTexture {
  7753. private _delayedOnLoad;
  7754. /**
  7755. * Observable triggered once the texture has been loaded.
  7756. */
  7757. onLoadObservable: Observable<CubeTexture>;
  7758. /**
  7759. * The url of the texture
  7760. */
  7761. url: string;
  7762. /**
  7763. * Gets or sets the center of the bounding box associated with the cube texture.
  7764. * It must define where the camera used to render the texture was set
  7765. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7766. */
  7767. boundingBoxPosition: Vector3;
  7768. private _boundingBoxSize;
  7769. /**
  7770. * Gets or sets the size of the bounding box associated with the cube texture
  7771. * When defined, the cubemap will switch to local mode
  7772. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7773. * @example https://www.babylonjs-playground.com/#RNASML
  7774. */
  7775. set boundingBoxSize(value: Vector3);
  7776. /**
  7777. * Returns the bounding box size
  7778. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7779. */
  7780. get boundingBoxSize(): Vector3;
  7781. protected _rotationY: number;
  7782. /**
  7783. * Sets texture matrix rotation angle around Y axis in radians.
  7784. */
  7785. set rotationY(value: number);
  7786. /**
  7787. * Gets texture matrix rotation angle around Y axis radians.
  7788. */
  7789. get rotationY(): number;
  7790. /**
  7791. * Are mip maps generated for this texture or not.
  7792. */
  7793. get noMipmap(): boolean;
  7794. private _noMipmap;
  7795. private _files;
  7796. protected _forcedExtension: Nullable<string>;
  7797. private _extensions;
  7798. private _textureMatrix;
  7799. private _format;
  7800. private _createPolynomials;
  7801. /** @hidden */
  7802. _prefiltered: boolean;
  7803. /**
  7804. * Creates a cube texture from an array of image urls
  7805. * @param files defines an array of image urls
  7806. * @param scene defines the hosting scene
  7807. * @param noMipmap specifies if mip maps are not used
  7808. * @returns a cube texture
  7809. */
  7810. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7811. /**
  7812. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7813. * @param url defines the url of the prefiltered texture
  7814. * @param scene defines the scene the texture is attached to
  7815. * @param forcedExtension defines the extension of the file if different from the url
  7816. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7817. * @return the prefiltered texture
  7818. */
  7819. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7820. /**
  7821. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7822. * as prefiltered data.
  7823. * @param rootUrl defines the url of the texture or the root name of the six images
  7824. * @param scene defines the scene the texture is attached to
  7825. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7826. * @param noMipmap defines if mipmaps should be created or not
  7827. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7828. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7829. * @param onError defines a callback triggered in case of error during load
  7830. * @param format defines the internal format to use for the texture once loaded
  7831. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7832. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7833. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7834. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7835. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7836. * @return the cube texture
  7837. */
  7838. 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);
  7839. /**
  7840. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7841. */
  7842. get isPrefiltered(): boolean;
  7843. /**
  7844. * Get the current class name of the texture useful for serialization or dynamic coding.
  7845. * @returns "CubeTexture"
  7846. */
  7847. getClassName(): string;
  7848. /**
  7849. * Update the url (and optional buffer) of this texture if url was null during construction.
  7850. * @param url the url of the texture
  7851. * @param forcedExtension defines the extension to use
  7852. * @param onLoad callback called when the texture is loaded (defaults to null)
  7853. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7854. */
  7855. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7856. /**
  7857. * Delays loading of the cube texture
  7858. * @param forcedExtension defines the extension to use
  7859. */
  7860. delayLoad(forcedExtension?: string): void;
  7861. /**
  7862. * Returns the reflection texture matrix
  7863. * @returns the reflection texture matrix
  7864. */
  7865. getReflectionTextureMatrix(): Matrix;
  7866. /**
  7867. * Sets the reflection texture matrix
  7868. * @param value Reflection texture matrix
  7869. */
  7870. setReflectionTextureMatrix(value: Matrix): void;
  7871. /**
  7872. * Parses text to create a cube texture
  7873. * @param parsedTexture define the serialized text to read from
  7874. * @param scene defines the hosting scene
  7875. * @param rootUrl defines the root url of the cube texture
  7876. * @returns a cube texture
  7877. */
  7878. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7879. /**
  7880. * Makes a clone, or deep copy, of the cube texture
  7881. * @returns a new cube texture
  7882. */
  7883. clone(): CubeTexture;
  7884. }
  7885. }
  7886. declare module "babylonjs/Materials/materialDefines" {
  7887. /**
  7888. * Manages the defines for the Material
  7889. */
  7890. export class MaterialDefines {
  7891. /** @hidden */
  7892. protected _keys: string[];
  7893. private _isDirty;
  7894. /** @hidden */
  7895. _renderId: number;
  7896. /** @hidden */
  7897. _areLightsDirty: boolean;
  7898. /** @hidden */
  7899. _areLightsDisposed: boolean;
  7900. /** @hidden */
  7901. _areAttributesDirty: boolean;
  7902. /** @hidden */
  7903. _areTexturesDirty: boolean;
  7904. /** @hidden */
  7905. _areFresnelDirty: boolean;
  7906. /** @hidden */
  7907. _areMiscDirty: boolean;
  7908. /** @hidden */
  7909. _areImageProcessingDirty: boolean;
  7910. /** @hidden */
  7911. _normals: boolean;
  7912. /** @hidden */
  7913. _uvs: boolean;
  7914. /** @hidden */
  7915. _needNormals: boolean;
  7916. /** @hidden */
  7917. _needUVs: boolean;
  7918. [id: string]: any;
  7919. /**
  7920. * Specifies if the material needs to be re-calculated
  7921. */
  7922. get isDirty(): boolean;
  7923. /**
  7924. * Marks the material to indicate that it has been re-calculated
  7925. */
  7926. markAsProcessed(): void;
  7927. /**
  7928. * Marks the material to indicate that it needs to be re-calculated
  7929. */
  7930. markAsUnprocessed(): void;
  7931. /**
  7932. * Marks the material to indicate all of its defines need to be re-calculated
  7933. */
  7934. markAllAsDirty(): void;
  7935. /**
  7936. * Marks the material to indicate that image processing needs to be re-calculated
  7937. */
  7938. markAsImageProcessingDirty(): void;
  7939. /**
  7940. * Marks the material to indicate the lights need to be re-calculated
  7941. * @param disposed Defines whether the light is dirty due to dispose or not
  7942. */
  7943. markAsLightDirty(disposed?: boolean): void;
  7944. /**
  7945. * Marks the attribute state as changed
  7946. */
  7947. markAsAttributesDirty(): void;
  7948. /**
  7949. * Marks the texture state as changed
  7950. */
  7951. markAsTexturesDirty(): void;
  7952. /**
  7953. * Marks the fresnel state as changed
  7954. */
  7955. markAsFresnelDirty(): void;
  7956. /**
  7957. * Marks the misc state as changed
  7958. */
  7959. markAsMiscDirty(): void;
  7960. /**
  7961. * Rebuilds the material defines
  7962. */
  7963. rebuild(): void;
  7964. /**
  7965. * Specifies if two material defines are equal
  7966. * @param other - A material define instance to compare to
  7967. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7968. */
  7969. isEqual(other: MaterialDefines): boolean;
  7970. /**
  7971. * Clones this instance's defines to another instance
  7972. * @param other - material defines to clone values to
  7973. */
  7974. cloneTo(other: MaterialDefines): void;
  7975. /**
  7976. * Resets the material define values
  7977. */
  7978. reset(): void;
  7979. /**
  7980. * Converts the material define values to a string
  7981. * @returns - String of material define information
  7982. */
  7983. toString(): string;
  7984. }
  7985. }
  7986. declare module "babylonjs/Materials/colorCurves" {
  7987. import { Effect } from "babylonjs/Materials/effect";
  7988. /**
  7989. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7990. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7991. * 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;
  7992. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7993. */
  7994. export class ColorCurves {
  7995. private _dirty;
  7996. private _tempColor;
  7997. private _globalCurve;
  7998. private _highlightsCurve;
  7999. private _midtonesCurve;
  8000. private _shadowsCurve;
  8001. private _positiveCurve;
  8002. private _negativeCurve;
  8003. private _globalHue;
  8004. private _globalDensity;
  8005. private _globalSaturation;
  8006. private _globalExposure;
  8007. /**
  8008. * Gets the global Hue value.
  8009. * 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).
  8010. */
  8011. get globalHue(): number;
  8012. /**
  8013. * Sets the global Hue value.
  8014. * 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).
  8015. */
  8016. set globalHue(value: number);
  8017. /**
  8018. * Gets the global Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. get globalDensity(): number;
  8023. /**
  8024. * Sets the global Density value.
  8025. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. set globalDensity(value: number);
  8029. /**
  8030. * Gets the global Saturation value.
  8031. * 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.
  8032. */
  8033. get globalSaturation(): number;
  8034. /**
  8035. * Sets the global Saturation value.
  8036. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8037. */
  8038. set globalSaturation(value: number);
  8039. /**
  8040. * Gets the global Exposure value.
  8041. * 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.
  8042. */
  8043. get globalExposure(): number;
  8044. /**
  8045. * Sets the global Exposure value.
  8046. * 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.
  8047. */
  8048. set globalExposure(value: number);
  8049. private _highlightsHue;
  8050. private _highlightsDensity;
  8051. private _highlightsSaturation;
  8052. private _highlightsExposure;
  8053. /**
  8054. * Gets the highlights Hue value.
  8055. * 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).
  8056. */
  8057. get highlightsHue(): number;
  8058. /**
  8059. * Sets the highlights Hue value.
  8060. * 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).
  8061. */
  8062. set highlightsHue(value: number);
  8063. /**
  8064. * Gets the highlights Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. get highlightsDensity(): number;
  8069. /**
  8070. * Sets the highlights Density value.
  8071. * 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.
  8072. * Values less than zero provide a filter of opposite hue.
  8073. */
  8074. set highlightsDensity(value: number);
  8075. /**
  8076. * Gets the highlights Saturation value.
  8077. * 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.
  8078. */
  8079. get highlightsSaturation(): number;
  8080. /**
  8081. * Sets the highlights Saturation value.
  8082. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8083. */
  8084. set highlightsSaturation(value: number);
  8085. /**
  8086. * Gets the highlights Exposure value.
  8087. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8088. */
  8089. get highlightsExposure(): number;
  8090. /**
  8091. * Sets the highlights Exposure value.
  8092. * 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.
  8093. */
  8094. set highlightsExposure(value: number);
  8095. private _midtonesHue;
  8096. private _midtonesDensity;
  8097. private _midtonesSaturation;
  8098. private _midtonesExposure;
  8099. /**
  8100. * Gets the midtones Hue value.
  8101. * 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).
  8102. */
  8103. get midtonesHue(): number;
  8104. /**
  8105. * Sets the midtones Hue value.
  8106. * 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).
  8107. */
  8108. set midtonesHue(value: number);
  8109. /**
  8110. * Gets the midtones Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. get midtonesDensity(): number;
  8115. /**
  8116. * Sets the midtones Density value.
  8117. * 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.
  8118. * Values less than zero provide a filter of opposite hue.
  8119. */
  8120. set midtonesDensity(value: number);
  8121. /**
  8122. * Gets the midtones Saturation value.
  8123. * 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.
  8124. */
  8125. get midtonesSaturation(): number;
  8126. /**
  8127. * Sets the midtones Saturation value.
  8128. * 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.
  8129. */
  8130. set midtonesSaturation(value: number);
  8131. /**
  8132. * Gets the midtones Exposure value.
  8133. * 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.
  8134. */
  8135. get midtonesExposure(): number;
  8136. /**
  8137. * Sets the midtones Exposure value.
  8138. * 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.
  8139. */
  8140. set midtonesExposure(value: number);
  8141. private _shadowsHue;
  8142. private _shadowsDensity;
  8143. private _shadowsSaturation;
  8144. private _shadowsExposure;
  8145. /**
  8146. * Gets the shadows Hue value.
  8147. * 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).
  8148. */
  8149. get shadowsHue(): number;
  8150. /**
  8151. * Sets the shadows Hue value.
  8152. * 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).
  8153. */
  8154. set shadowsHue(value: number);
  8155. /**
  8156. * Gets the shadows Density value.
  8157. * 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.
  8158. * Values less than zero provide a filter of opposite hue.
  8159. */
  8160. get shadowsDensity(): number;
  8161. /**
  8162. * Sets the shadows Density value.
  8163. * 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.
  8164. * Values less than zero provide a filter of opposite hue.
  8165. */
  8166. set shadowsDensity(value: number);
  8167. /**
  8168. * Gets the shadows Saturation value.
  8169. * 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.
  8170. */
  8171. get shadowsSaturation(): number;
  8172. /**
  8173. * Sets the shadows Saturation value.
  8174. * 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.
  8175. */
  8176. set shadowsSaturation(value: number);
  8177. /**
  8178. * Gets the shadows Exposure value.
  8179. * 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.
  8180. */
  8181. get shadowsExposure(): number;
  8182. /**
  8183. * Sets the shadows Exposure value.
  8184. * 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.
  8185. */
  8186. set shadowsExposure(value: number);
  8187. /**
  8188. * Returns the class name
  8189. * @returns The class name
  8190. */
  8191. getClassName(): string;
  8192. /**
  8193. * Binds the color curves to the shader.
  8194. * @param colorCurves The color curve to bind
  8195. * @param effect The effect to bind to
  8196. * @param positiveUniform The positive uniform shader parameter
  8197. * @param neutralUniform The neutral uniform shader parameter
  8198. * @param negativeUniform The negative uniform shader parameter
  8199. */
  8200. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8201. /**
  8202. * Prepare the list of uniforms associated with the ColorCurves effects.
  8203. * @param uniformsList The list of uniforms used in the effect
  8204. */
  8205. static PrepareUniforms(uniformsList: string[]): void;
  8206. /**
  8207. * Returns color grading data based on a hue, density, saturation and exposure value.
  8208. * @param filterHue The hue of the color filter.
  8209. * @param filterDensity The density of the color filter.
  8210. * @param saturation The saturation.
  8211. * @param exposure The exposure.
  8212. * @param result The result data container.
  8213. */
  8214. private getColorGradingDataToRef;
  8215. /**
  8216. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8217. * @param value The input slider value in range [-100,100].
  8218. * @returns Adjusted value.
  8219. */
  8220. private static applyColorGradingSliderNonlinear;
  8221. /**
  8222. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8223. * @param hue The hue (H) input.
  8224. * @param saturation The saturation (S) input.
  8225. * @param brightness The brightness (B) input.
  8226. * @result An RGBA color represented as Vector4.
  8227. */
  8228. private static fromHSBToRef;
  8229. /**
  8230. * Returns a value clamped between min and max
  8231. * @param value The value to clamp
  8232. * @param min The minimum of value
  8233. * @param max The maximum of value
  8234. * @returns The clamped value.
  8235. */
  8236. private static clamp;
  8237. /**
  8238. * Clones the current color curve instance.
  8239. * @return The cloned curves
  8240. */
  8241. clone(): ColorCurves;
  8242. /**
  8243. * Serializes the current color curve instance to a json representation.
  8244. * @return a JSON representation
  8245. */
  8246. serialize(): any;
  8247. /**
  8248. * Parses the color curve from a json representation.
  8249. * @param source the JSON source to parse
  8250. * @return The parsed curves
  8251. */
  8252. static Parse(source: any): ColorCurves;
  8253. }
  8254. }
  8255. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8256. import { Observable } from "babylonjs/Misc/observable";
  8257. import { Nullable } from "babylonjs/types";
  8258. import { Color4 } from "babylonjs/Maths/math.color";
  8259. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8260. import { Effect } from "babylonjs/Materials/effect";
  8261. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8262. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8263. /**
  8264. * Interface to follow in your material defines to integrate easily the
  8265. * Image proccessing functions.
  8266. * @hidden
  8267. */
  8268. export interface IImageProcessingConfigurationDefines {
  8269. IMAGEPROCESSING: boolean;
  8270. VIGNETTE: boolean;
  8271. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8272. VIGNETTEBLENDMODEOPAQUE: boolean;
  8273. TONEMAPPING: boolean;
  8274. TONEMAPPING_ACES: boolean;
  8275. CONTRAST: boolean;
  8276. EXPOSURE: boolean;
  8277. COLORCURVES: boolean;
  8278. COLORGRADING: boolean;
  8279. COLORGRADING3D: boolean;
  8280. SAMPLER3DGREENDEPTH: boolean;
  8281. SAMPLER3DBGRMAP: boolean;
  8282. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8283. }
  8284. /**
  8285. * @hidden
  8286. */
  8287. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8288. IMAGEPROCESSING: boolean;
  8289. VIGNETTE: boolean;
  8290. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8291. VIGNETTEBLENDMODEOPAQUE: boolean;
  8292. TONEMAPPING: boolean;
  8293. TONEMAPPING_ACES: boolean;
  8294. CONTRAST: boolean;
  8295. COLORCURVES: boolean;
  8296. COLORGRADING: boolean;
  8297. COLORGRADING3D: boolean;
  8298. SAMPLER3DGREENDEPTH: boolean;
  8299. SAMPLER3DBGRMAP: boolean;
  8300. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8301. EXPOSURE: boolean;
  8302. constructor();
  8303. }
  8304. /**
  8305. * This groups together the common properties used for image processing either in direct forward pass
  8306. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8307. * or not.
  8308. */
  8309. export class ImageProcessingConfiguration {
  8310. /**
  8311. * Default tone mapping applied in BabylonJS.
  8312. */
  8313. static readonly TONEMAPPING_STANDARD: number;
  8314. /**
  8315. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8316. * to other engines rendering to increase portability.
  8317. */
  8318. static readonly TONEMAPPING_ACES: number;
  8319. /**
  8320. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8321. */
  8322. colorCurves: Nullable<ColorCurves>;
  8323. private _colorCurvesEnabled;
  8324. /**
  8325. * Gets wether the color curves effect is enabled.
  8326. */
  8327. get colorCurvesEnabled(): boolean;
  8328. /**
  8329. * Sets wether the color curves effect is enabled.
  8330. */
  8331. set colorCurvesEnabled(value: boolean);
  8332. private _colorGradingTexture;
  8333. /**
  8334. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8335. */
  8336. get colorGradingTexture(): Nullable<BaseTexture>;
  8337. /**
  8338. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8339. */
  8340. set colorGradingTexture(value: Nullable<BaseTexture>);
  8341. private _colorGradingEnabled;
  8342. /**
  8343. * Gets wether the color grading effect is enabled.
  8344. */
  8345. get colorGradingEnabled(): boolean;
  8346. /**
  8347. * Sets wether the color grading effect is enabled.
  8348. */
  8349. set colorGradingEnabled(value: boolean);
  8350. private _colorGradingWithGreenDepth;
  8351. /**
  8352. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8353. */
  8354. get colorGradingWithGreenDepth(): boolean;
  8355. /**
  8356. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8357. */
  8358. set colorGradingWithGreenDepth(value: boolean);
  8359. private _colorGradingBGR;
  8360. /**
  8361. * Gets wether the color grading texture contains BGR values.
  8362. */
  8363. get colorGradingBGR(): boolean;
  8364. /**
  8365. * Sets wether the color grading texture contains BGR values.
  8366. */
  8367. set colorGradingBGR(value: boolean);
  8368. /** @hidden */
  8369. _exposure: number;
  8370. /**
  8371. * Gets the Exposure used in the effect.
  8372. */
  8373. get exposure(): number;
  8374. /**
  8375. * Sets the Exposure used in the effect.
  8376. */
  8377. set exposure(value: number);
  8378. private _toneMappingEnabled;
  8379. /**
  8380. * Gets wether the tone mapping effect is enabled.
  8381. */
  8382. get toneMappingEnabled(): boolean;
  8383. /**
  8384. * Sets wether the tone mapping effect is enabled.
  8385. */
  8386. set toneMappingEnabled(value: boolean);
  8387. private _toneMappingType;
  8388. /**
  8389. * Gets the type of tone mapping effect.
  8390. */
  8391. get toneMappingType(): number;
  8392. /**
  8393. * Sets the type of tone mapping effect used in BabylonJS.
  8394. */
  8395. set toneMappingType(value: number);
  8396. protected _contrast: number;
  8397. /**
  8398. * Gets the contrast used in the effect.
  8399. */
  8400. get contrast(): number;
  8401. /**
  8402. * Sets the contrast used in the effect.
  8403. */
  8404. set contrast(value: number);
  8405. /**
  8406. * Vignette stretch size.
  8407. */
  8408. vignetteStretch: number;
  8409. /**
  8410. * Vignette centre X Offset.
  8411. */
  8412. vignetteCentreX: number;
  8413. /**
  8414. * Vignette centre Y Offset.
  8415. */
  8416. vignetteCentreY: number;
  8417. /**
  8418. * Vignette weight or intensity of the vignette effect.
  8419. */
  8420. vignetteWeight: number;
  8421. /**
  8422. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8423. * if vignetteEnabled is set to true.
  8424. */
  8425. vignetteColor: Color4;
  8426. /**
  8427. * Camera field of view used by the Vignette effect.
  8428. */
  8429. vignetteCameraFov: number;
  8430. private _vignetteBlendMode;
  8431. /**
  8432. * Gets the vignette blend mode allowing different kind of effect.
  8433. */
  8434. get vignetteBlendMode(): number;
  8435. /**
  8436. * Sets the vignette blend mode allowing different kind of effect.
  8437. */
  8438. set vignetteBlendMode(value: number);
  8439. private _vignetteEnabled;
  8440. /**
  8441. * Gets wether the vignette effect is enabled.
  8442. */
  8443. get vignetteEnabled(): boolean;
  8444. /**
  8445. * Sets wether the vignette effect is enabled.
  8446. */
  8447. set vignetteEnabled(value: boolean);
  8448. private _applyByPostProcess;
  8449. /**
  8450. * Gets wether the image processing is applied through a post process or not.
  8451. */
  8452. get applyByPostProcess(): boolean;
  8453. /**
  8454. * Sets wether the image processing is applied through a post process or not.
  8455. */
  8456. set applyByPostProcess(value: boolean);
  8457. private _isEnabled;
  8458. /**
  8459. * Gets wether the image processing is enabled or not.
  8460. */
  8461. get isEnabled(): boolean;
  8462. /**
  8463. * Sets wether the image processing is enabled or not.
  8464. */
  8465. set isEnabled(value: boolean);
  8466. /**
  8467. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8468. */
  8469. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8470. /**
  8471. * Method called each time the image processing information changes requires to recompile the effect.
  8472. */
  8473. protected _updateParameters(): void;
  8474. /**
  8475. * Gets the current class name.
  8476. * @return "ImageProcessingConfiguration"
  8477. */
  8478. getClassName(): string;
  8479. /**
  8480. * Prepare the list of uniforms associated with the Image Processing effects.
  8481. * @param uniforms The list of uniforms used in the effect
  8482. * @param defines the list of defines currently in use
  8483. */
  8484. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8485. /**
  8486. * Prepare the list of samplers associated with the Image Processing effects.
  8487. * @param samplersList The list of uniforms used in the effect
  8488. * @param defines the list of defines currently in use
  8489. */
  8490. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8491. /**
  8492. * Prepare the list of defines associated to the shader.
  8493. * @param defines the list of defines to complete
  8494. * @param forPostProcess Define if we are currently in post process mode or not
  8495. */
  8496. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8497. /**
  8498. * Returns true if all the image processing information are ready.
  8499. * @returns True if ready, otherwise, false
  8500. */
  8501. isReady(): boolean;
  8502. /**
  8503. * Binds the image processing to the shader.
  8504. * @param effect The effect to bind to
  8505. * @param overrideAspectRatio Override the aspect ratio of the effect
  8506. */
  8507. bind(effect: Effect, overrideAspectRatio?: number): void;
  8508. /**
  8509. * Clones the current image processing instance.
  8510. * @return The cloned image processing
  8511. */
  8512. clone(): ImageProcessingConfiguration;
  8513. /**
  8514. * Serializes the current image processing instance to a json representation.
  8515. * @return a JSON representation
  8516. */
  8517. serialize(): any;
  8518. /**
  8519. * Parses the image processing from a json representation.
  8520. * @param source the JSON source to parse
  8521. * @return The parsed image processing
  8522. */
  8523. static Parse(source: any): ImageProcessingConfiguration;
  8524. private static _VIGNETTEMODE_MULTIPLY;
  8525. private static _VIGNETTEMODE_OPAQUE;
  8526. /**
  8527. * Used to apply the vignette as a mix with the pixel color.
  8528. */
  8529. static get VIGNETTEMODE_MULTIPLY(): number;
  8530. /**
  8531. * Used to apply the vignette as a replacement of the pixel color.
  8532. */
  8533. static get VIGNETTEMODE_OPAQUE(): number;
  8534. }
  8535. }
  8536. declare module "babylonjs/Shaders/postprocess.vertex" {
  8537. /** @hidden */
  8538. export var postprocessVertexShader: {
  8539. name: string;
  8540. shader: string;
  8541. };
  8542. }
  8543. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8544. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8545. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8546. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8547. module "babylonjs/Engines/thinEngine" {
  8548. interface ThinEngine {
  8549. /**
  8550. * Creates a new render target texture
  8551. * @param size defines the size of the texture
  8552. * @param options defines the options used to create the texture
  8553. * @returns a new render target texture stored in an InternalTexture
  8554. */
  8555. createRenderTargetTexture(size: number | {
  8556. width: number;
  8557. height: number;
  8558. layers?: number;
  8559. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8560. /**
  8561. * Creates a depth stencil texture.
  8562. * This is only available in WebGL 2 or with the depth texture extension available.
  8563. * @param size The size of face edge in the texture.
  8564. * @param options The options defining the texture.
  8565. * @returns The texture
  8566. */
  8567. createDepthStencilTexture(size: number | {
  8568. width: number;
  8569. height: number;
  8570. layers?: number;
  8571. }, options: DepthTextureCreationOptions): InternalTexture;
  8572. /** @hidden */
  8573. _createDepthStencilTexture(size: number | {
  8574. width: number;
  8575. height: number;
  8576. layers?: number;
  8577. }, options: DepthTextureCreationOptions): InternalTexture;
  8578. }
  8579. }
  8580. }
  8581. declare module "babylonjs/Maths/math.axis" {
  8582. import { Vector3 } from "babylonjs/Maths/math.vector";
  8583. /** Defines supported spaces */
  8584. export enum Space {
  8585. /** Local (object) space */
  8586. LOCAL = 0,
  8587. /** World space */
  8588. WORLD = 1,
  8589. /** Bone space */
  8590. BONE = 2
  8591. }
  8592. /** Defines the 3 main axes */
  8593. export class Axis {
  8594. /** X axis */
  8595. static X: Vector3;
  8596. /** Y axis */
  8597. static Y: Vector3;
  8598. /** Z axis */
  8599. static Z: Vector3;
  8600. }
  8601. }
  8602. declare module "babylonjs/Cameras/targetCamera" {
  8603. import { Nullable } from "babylonjs/types";
  8604. import { Camera } from "babylonjs/Cameras/camera";
  8605. import { Scene } from "babylonjs/scene";
  8606. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8607. /**
  8608. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8609. * This is the base of the follow, arc rotate cameras and Free camera
  8610. * @see http://doc.babylonjs.com/features/cameras
  8611. */
  8612. export class TargetCamera extends Camera {
  8613. private static _RigCamTransformMatrix;
  8614. private static _TargetTransformMatrix;
  8615. private static _TargetFocalPoint;
  8616. /**
  8617. * Define the current direction the camera is moving to
  8618. */
  8619. cameraDirection: Vector3;
  8620. /**
  8621. * Define the current rotation the camera is rotating to
  8622. */
  8623. cameraRotation: Vector2;
  8624. /**
  8625. * When set, the up vector of the camera will be updated by the rotation of the camera
  8626. */
  8627. updateUpVectorFromRotation: boolean;
  8628. private _tmpQuaternion;
  8629. /**
  8630. * Define the current rotation of the camera
  8631. */
  8632. rotation: Vector3;
  8633. /**
  8634. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8635. */
  8636. rotationQuaternion: Quaternion;
  8637. /**
  8638. * Define the current speed of the camera
  8639. */
  8640. speed: number;
  8641. /**
  8642. * Add constraint to the camera to prevent it to move freely in all directions and
  8643. * around all axis.
  8644. */
  8645. noRotationConstraint: boolean;
  8646. /**
  8647. * Define the current target of the camera as an object or a position.
  8648. */
  8649. lockedTarget: any;
  8650. /** @hidden */
  8651. _currentTarget: Vector3;
  8652. /** @hidden */
  8653. _initialFocalDistance: number;
  8654. /** @hidden */
  8655. _viewMatrix: Matrix;
  8656. /** @hidden */
  8657. _camMatrix: Matrix;
  8658. /** @hidden */
  8659. _cameraTransformMatrix: Matrix;
  8660. /** @hidden */
  8661. _cameraRotationMatrix: Matrix;
  8662. /** @hidden */
  8663. _referencePoint: Vector3;
  8664. /** @hidden */
  8665. _transformedReferencePoint: Vector3;
  8666. protected _globalCurrentTarget: Vector3;
  8667. protected _globalCurrentUpVector: Vector3;
  8668. /** @hidden */
  8669. _reset: () => void;
  8670. private _defaultUp;
  8671. /**
  8672. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8673. * This is the base of the follow, arc rotate cameras and Free camera
  8674. * @see http://doc.babylonjs.com/features/cameras
  8675. * @param name Defines the name of the camera in the scene
  8676. * @param position Defines the start position of the camera in the scene
  8677. * @param scene Defines the scene the camera belongs to
  8678. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8679. */
  8680. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8681. /**
  8682. * Gets the position in front of the camera at a given distance.
  8683. * @param distance The distance from the camera we want the position to be
  8684. * @returns the position
  8685. */
  8686. getFrontPosition(distance: number): Vector3;
  8687. /** @hidden */
  8688. _getLockedTargetPosition(): Nullable<Vector3>;
  8689. private _storedPosition;
  8690. private _storedRotation;
  8691. private _storedRotationQuaternion;
  8692. /**
  8693. * Store current camera state of the camera (fov, position, rotation, etc..)
  8694. * @returns the camera
  8695. */
  8696. storeState(): Camera;
  8697. /**
  8698. * Restored camera state. You must call storeState() first
  8699. * @returns whether it was successful or not
  8700. * @hidden
  8701. */
  8702. _restoreStateValues(): boolean;
  8703. /** @hidden */
  8704. _initCache(): void;
  8705. /** @hidden */
  8706. _updateCache(ignoreParentClass?: boolean): void;
  8707. /** @hidden */
  8708. _isSynchronizedViewMatrix(): boolean;
  8709. /** @hidden */
  8710. _computeLocalCameraSpeed(): number;
  8711. /**
  8712. * Defines the target the camera should look at.
  8713. * @param target Defines the new target as a Vector or a mesh
  8714. */
  8715. setTarget(target: Vector3): void;
  8716. /**
  8717. * Return the current target position of the camera. This value is expressed in local space.
  8718. * @returns the target position
  8719. */
  8720. getTarget(): Vector3;
  8721. /** @hidden */
  8722. _decideIfNeedsToMove(): boolean;
  8723. /** @hidden */
  8724. _updatePosition(): void;
  8725. /** @hidden */
  8726. _checkInputs(): void;
  8727. protected _updateCameraRotationMatrix(): void;
  8728. /**
  8729. * 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)
  8730. * @returns the current camera
  8731. */
  8732. private _rotateUpVectorWithCameraRotationMatrix;
  8733. private _cachedRotationZ;
  8734. private _cachedQuaternionRotationZ;
  8735. /** @hidden */
  8736. _getViewMatrix(): Matrix;
  8737. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8738. /**
  8739. * @hidden
  8740. */
  8741. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8742. /**
  8743. * @hidden
  8744. */
  8745. _updateRigCameras(): void;
  8746. private _getRigCamPositionAndTarget;
  8747. /**
  8748. * Gets the current object class name.
  8749. * @return the class name
  8750. */
  8751. getClassName(): string;
  8752. }
  8753. }
  8754. declare module "babylonjs/Events/keyboardEvents" {
  8755. /**
  8756. * Gather the list of keyboard event types as constants.
  8757. */
  8758. export class KeyboardEventTypes {
  8759. /**
  8760. * The keydown event is fired when a key becomes active (pressed).
  8761. */
  8762. static readonly KEYDOWN: number;
  8763. /**
  8764. * The keyup event is fired when a key has been released.
  8765. */
  8766. static readonly KEYUP: number;
  8767. }
  8768. /**
  8769. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8770. */
  8771. export class KeyboardInfo {
  8772. /**
  8773. * Defines the type of event (KeyboardEventTypes)
  8774. */
  8775. type: number;
  8776. /**
  8777. * Defines the related dom event
  8778. */
  8779. event: KeyboardEvent;
  8780. /**
  8781. * Instantiates a new keyboard info.
  8782. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8783. * @param type Defines the type of event (KeyboardEventTypes)
  8784. * @param event Defines the related dom event
  8785. */
  8786. constructor(
  8787. /**
  8788. * Defines the type of event (KeyboardEventTypes)
  8789. */
  8790. type: number,
  8791. /**
  8792. * Defines the related dom event
  8793. */
  8794. event: KeyboardEvent);
  8795. }
  8796. /**
  8797. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8798. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8799. */
  8800. export class KeyboardInfoPre extends KeyboardInfo {
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number;
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent;
  8809. /**
  8810. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8811. */
  8812. skipOnPointerObservable: boolean;
  8813. /**
  8814. * Instantiates a new keyboard pre info.
  8815. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8816. * @param type Defines the type of event (KeyboardEventTypes)
  8817. * @param event Defines the related dom event
  8818. */
  8819. constructor(
  8820. /**
  8821. * Defines the type of event (KeyboardEventTypes)
  8822. */
  8823. type: number,
  8824. /**
  8825. * Defines the related dom event
  8826. */
  8827. event: KeyboardEvent);
  8828. }
  8829. }
  8830. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8831. import { Nullable } from "babylonjs/types";
  8832. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8833. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8834. /**
  8835. * Manage the keyboard inputs to control the movement of a free camera.
  8836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8837. */
  8838. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8839. /**
  8840. * Defines the camera the input is attached to.
  8841. */
  8842. camera: FreeCamera;
  8843. /**
  8844. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8845. */
  8846. keysUp: number[];
  8847. /**
  8848. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8849. */
  8850. keysDown: number[];
  8851. /**
  8852. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8853. */
  8854. keysLeft: number[];
  8855. /**
  8856. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8857. */
  8858. keysRight: number[];
  8859. private _keys;
  8860. private _onCanvasBlurObserver;
  8861. private _onKeyboardObserver;
  8862. private _engine;
  8863. private _scene;
  8864. /**
  8865. * Attach the input controls to a specific dom element to get the input from.
  8866. * @param element Defines the element the controls should be listened from
  8867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8868. */
  8869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8870. /**
  8871. * Detach the current controls from the specified dom element.
  8872. * @param element Defines the element to stop listening the inputs from
  8873. */
  8874. detachControl(element: Nullable<HTMLElement>): void;
  8875. /**
  8876. * Update the current camera state depending on the inputs that have been used this frame.
  8877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8878. */
  8879. checkInputs(): void;
  8880. /**
  8881. * Gets the class name of the current intput.
  8882. * @returns the class name
  8883. */
  8884. getClassName(): string;
  8885. /** @hidden */
  8886. _onLostFocus(): void;
  8887. /**
  8888. * Get the friendly name associated with the input class.
  8889. * @returns the input friendly name
  8890. */
  8891. getSimpleName(): string;
  8892. }
  8893. }
  8894. declare module "babylonjs/Lights/shadowLight" {
  8895. import { Camera } from "babylonjs/Cameras/camera";
  8896. import { Scene } from "babylonjs/scene";
  8897. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8899. import { Light } from "babylonjs/Lights/light";
  8900. /**
  8901. * Interface describing all the common properties and methods a shadow light needs to implement.
  8902. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8903. * as well as binding the different shadow properties to the effects.
  8904. */
  8905. export interface IShadowLight extends Light {
  8906. /**
  8907. * The light id in the scene (used in scene.findLighById for instance)
  8908. */
  8909. id: string;
  8910. /**
  8911. * The position the shdow will be casted from.
  8912. */
  8913. position: Vector3;
  8914. /**
  8915. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8916. */
  8917. direction: Vector3;
  8918. /**
  8919. * The transformed position. Position of the light in world space taking parenting in account.
  8920. */
  8921. transformedPosition: Vector3;
  8922. /**
  8923. * The transformed direction. Direction of the light in world space taking parenting in account.
  8924. */
  8925. transformedDirection: Vector3;
  8926. /**
  8927. * The friendly name of the light in the scene.
  8928. */
  8929. name: string;
  8930. /**
  8931. * Defines the shadow projection clipping minimum z value.
  8932. */
  8933. shadowMinZ: number;
  8934. /**
  8935. * Defines the shadow projection clipping maximum z value.
  8936. */
  8937. shadowMaxZ: number;
  8938. /**
  8939. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8940. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8941. */
  8942. computeTransformedInformation(): boolean;
  8943. /**
  8944. * Gets the scene the light belongs to.
  8945. * @returns The scene
  8946. */
  8947. getScene(): Scene;
  8948. /**
  8949. * Callback defining a custom Projection Matrix Builder.
  8950. * This can be used to override the default projection matrix computation.
  8951. */
  8952. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8953. /**
  8954. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8955. * @param matrix The materix to updated with the projection information
  8956. * @param viewMatrix The transform matrix of the light
  8957. * @param renderList The list of mesh to render in the map
  8958. * @returns The current light
  8959. */
  8960. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8961. /**
  8962. * Gets the current depth scale used in ESM.
  8963. * @returns The scale
  8964. */
  8965. getDepthScale(): number;
  8966. /**
  8967. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8968. * @returns true if a cube texture needs to be use
  8969. */
  8970. needCube(): boolean;
  8971. /**
  8972. * Detects if the projection matrix requires to be recomputed this frame.
  8973. * @returns true if it requires to be recomputed otherwise, false.
  8974. */
  8975. needProjectionMatrixCompute(): boolean;
  8976. /**
  8977. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8978. */
  8979. forceProjectionMatrixCompute(): void;
  8980. /**
  8981. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8982. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8983. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8984. */
  8985. getShadowDirection(faceIndex?: number): Vector3;
  8986. /**
  8987. * Gets the minZ used for shadow according to both the scene and the light.
  8988. * @param activeCamera The camera we are returning the min for
  8989. * @returns the depth min z
  8990. */
  8991. getDepthMinZ(activeCamera: Camera): number;
  8992. /**
  8993. * Gets the maxZ used for shadow according to both the scene and the light.
  8994. * @param activeCamera The camera we are returning the max for
  8995. * @returns the depth max z
  8996. */
  8997. getDepthMaxZ(activeCamera: Camera): number;
  8998. }
  8999. /**
  9000. * Base implementation IShadowLight
  9001. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9002. */
  9003. export abstract class ShadowLight extends Light implements IShadowLight {
  9004. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9005. protected _position: Vector3;
  9006. protected _setPosition(value: Vector3): void;
  9007. /**
  9008. * Sets the position the shadow will be casted from. Also use as the light position for both
  9009. * point and spot lights.
  9010. */
  9011. get position(): Vector3;
  9012. /**
  9013. * Sets the position the shadow will be casted from. Also use as the light position for both
  9014. * point and spot lights.
  9015. */
  9016. set position(value: Vector3);
  9017. protected _direction: Vector3;
  9018. protected _setDirection(value: Vector3): void;
  9019. /**
  9020. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9021. * Also use as the light direction on spot and directional lights.
  9022. */
  9023. get direction(): Vector3;
  9024. /**
  9025. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9026. * Also use as the light direction on spot and directional lights.
  9027. */
  9028. set direction(value: Vector3);
  9029. protected _shadowMinZ: number;
  9030. /**
  9031. * Gets the shadow projection clipping minimum z value.
  9032. */
  9033. get shadowMinZ(): number;
  9034. /**
  9035. * Sets the shadow projection clipping minimum z value.
  9036. */
  9037. set shadowMinZ(value: number);
  9038. protected _shadowMaxZ: number;
  9039. /**
  9040. * Sets the shadow projection clipping maximum z value.
  9041. */
  9042. get shadowMaxZ(): number;
  9043. /**
  9044. * Gets the shadow projection clipping maximum z value.
  9045. */
  9046. set shadowMaxZ(value: number);
  9047. /**
  9048. * Callback defining a custom Projection Matrix Builder.
  9049. * This can be used to override the default projection matrix computation.
  9050. */
  9051. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9052. /**
  9053. * The transformed position. Position of the light in world space taking parenting in account.
  9054. */
  9055. transformedPosition: Vector3;
  9056. /**
  9057. * The transformed direction. Direction of the light in world space taking parenting in account.
  9058. */
  9059. transformedDirection: Vector3;
  9060. private _needProjectionMatrixCompute;
  9061. /**
  9062. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9063. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9064. */
  9065. computeTransformedInformation(): boolean;
  9066. /**
  9067. * Return the depth scale used for the shadow map.
  9068. * @returns the depth scale.
  9069. */
  9070. getDepthScale(): number;
  9071. /**
  9072. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9073. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9074. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9075. */
  9076. getShadowDirection(faceIndex?: number): Vector3;
  9077. /**
  9078. * Returns the ShadowLight absolute position in the World.
  9079. * @returns the position vector in world space
  9080. */
  9081. getAbsolutePosition(): Vector3;
  9082. /**
  9083. * Sets the ShadowLight direction toward the passed target.
  9084. * @param target The point to target in local space
  9085. * @returns the updated ShadowLight direction
  9086. */
  9087. setDirectionToTarget(target: Vector3): Vector3;
  9088. /**
  9089. * Returns the light rotation in euler definition.
  9090. * @returns the x y z rotation in local space.
  9091. */
  9092. getRotation(): Vector3;
  9093. /**
  9094. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9095. * @returns true if a cube texture needs to be use
  9096. */
  9097. needCube(): boolean;
  9098. /**
  9099. * Detects if the projection matrix requires to be recomputed this frame.
  9100. * @returns true if it requires to be recomputed otherwise, false.
  9101. */
  9102. needProjectionMatrixCompute(): boolean;
  9103. /**
  9104. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9105. */
  9106. forceProjectionMatrixCompute(): void;
  9107. /** @hidden */
  9108. _initCache(): void;
  9109. /** @hidden */
  9110. _isSynchronized(): boolean;
  9111. /**
  9112. * Computes the world matrix of the node
  9113. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9114. * @returns the world matrix
  9115. */
  9116. computeWorldMatrix(force?: boolean): Matrix;
  9117. /**
  9118. * Gets the minZ used for shadow according to both the scene and the light.
  9119. * @param activeCamera The camera we are returning the min for
  9120. * @returns the depth min z
  9121. */
  9122. getDepthMinZ(activeCamera: Camera): number;
  9123. /**
  9124. * Gets the maxZ used for shadow according to both the scene and the light.
  9125. * @param activeCamera The camera we are returning the max for
  9126. * @returns the depth max z
  9127. */
  9128. getDepthMaxZ(activeCamera: Camera): number;
  9129. /**
  9130. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9131. * @param matrix The materix to updated with the projection information
  9132. * @param viewMatrix The transform matrix of the light
  9133. * @param renderList The list of mesh to render in the map
  9134. * @returns The current light
  9135. */
  9136. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9137. }
  9138. }
  9139. declare module "babylonjs/Materials/effectFallbacks" {
  9140. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9141. import { Effect } from "babylonjs/Materials/effect";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. /**
  9144. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9145. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9146. */
  9147. export class EffectFallbacks implements IEffectFallbacks {
  9148. private _defines;
  9149. private _currentRank;
  9150. private _maxRank;
  9151. private _mesh;
  9152. /**
  9153. * Removes the fallback from the bound mesh.
  9154. */
  9155. unBindMesh(): void;
  9156. /**
  9157. * Adds a fallback on the specified property.
  9158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9159. * @param define The name of the define in the shader
  9160. */
  9161. addFallback(rank: number, define: string): void;
  9162. /**
  9163. * Sets the mesh to use CPU skinning when needing to fallback.
  9164. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9165. * @param mesh The mesh to use the fallbacks.
  9166. */
  9167. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9168. /**
  9169. * Checks to see if more fallbacks are still availible.
  9170. */
  9171. get hasMoreFallbacks(): boolean;
  9172. /**
  9173. * Removes the defines that should be removed when falling back.
  9174. * @param currentDefines defines the current define statements for the shader.
  9175. * @param effect defines the current effect we try to compile
  9176. * @returns The resulting defines with defines of the current rank removed.
  9177. */
  9178. reduce(currentDefines: string, effect: Effect): string;
  9179. }
  9180. }
  9181. declare module "babylonjs/Materials/materialHelper" {
  9182. import { Nullable } from "babylonjs/types";
  9183. import { Scene } from "babylonjs/scene";
  9184. import { Engine } from "babylonjs/Engines/engine";
  9185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9186. import { Light } from "babylonjs/Lights/light";
  9187. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9188. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9190. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9191. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9192. /**
  9193. * "Static Class" containing the most commonly used helper while dealing with material for
  9194. * rendering purpose.
  9195. *
  9196. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9197. *
  9198. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9199. */
  9200. export class MaterialHelper {
  9201. /**
  9202. * Bind the current view position to an effect.
  9203. * @param effect The effect to be bound
  9204. * @param scene The scene the eyes position is used from
  9205. */
  9206. static BindEyePosition(effect: Effect, scene: Scene): void;
  9207. /**
  9208. * Helps preparing the defines values about the UVs in used in the effect.
  9209. * UVs are shared as much as we can accross channels in the shaders.
  9210. * @param texture The texture we are preparing the UVs for
  9211. * @param defines The defines to update
  9212. * @param key The channel key "diffuse", "specular"... used in the shader
  9213. */
  9214. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9215. /**
  9216. * Binds a texture matrix value to its corrsponding uniform
  9217. * @param texture The texture to bind the matrix for
  9218. * @param uniformBuffer The uniform buffer receivin the data
  9219. * @param key The channel key "diffuse", "specular"... used in the shader
  9220. */
  9221. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9222. /**
  9223. * Gets the current status of the fog (should it be enabled?)
  9224. * @param mesh defines the mesh to evaluate for fog support
  9225. * @param scene defines the hosting scene
  9226. * @returns true if fog must be enabled
  9227. */
  9228. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9229. /**
  9230. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9231. * @param mesh defines the current mesh
  9232. * @param scene defines the current scene
  9233. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9234. * @param pointsCloud defines if point cloud rendering has to be turned on
  9235. * @param fogEnabled defines if fog has to be turned on
  9236. * @param alphaTest defines if alpha testing has to be turned on
  9237. * @param defines defines the current list of defines
  9238. */
  9239. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9240. /**
  9241. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9242. * @param scene defines the current scene
  9243. * @param engine defines the current engine
  9244. * @param defines specifies the list of active defines
  9245. * @param useInstances defines if instances have to be turned on
  9246. * @param useClipPlane defines if clip plane have to be turned on
  9247. */
  9248. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9249. /**
  9250. * Prepares the defines for bones
  9251. * @param mesh The mesh containing the geometry data we will draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9255. /**
  9256. * Prepares the defines for morph targets
  9257. * @param mesh The mesh containing the geometry data we will draw
  9258. * @param defines The defines to update
  9259. */
  9260. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9261. /**
  9262. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9263. * @param mesh The mesh containing the geometry data we will draw
  9264. * @param defines The defines to update
  9265. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9266. * @param useBones Precise whether bones should be used or not (override mesh info)
  9267. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9268. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9269. * @returns false if defines are considered not dirty and have not been checked
  9270. */
  9271. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9272. /**
  9273. * Prepares the defines related to multiview
  9274. * @param scene The scene we are intending to draw
  9275. * @param defines The defines to update
  9276. */
  9277. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9278. /**
  9279. * Prepares the defines related to the light information passed in parameter
  9280. * @param scene The scene we are intending to draw
  9281. * @param mesh The mesh the effect is compiling for
  9282. * @param light The light the effect is compiling for
  9283. * @param lightIndex The index of the light
  9284. * @param defines The defines to update
  9285. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9286. * @param state Defines the current state regarding what is needed (normals, etc...)
  9287. */
  9288. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9289. needNormals: boolean;
  9290. needRebuild: boolean;
  9291. shadowEnabled: boolean;
  9292. specularEnabled: boolean;
  9293. lightmapMode: boolean;
  9294. }): void;
  9295. /**
  9296. * Prepares the defines related to the light information passed in parameter
  9297. * @param scene The scene we are intending to draw
  9298. * @param mesh The mesh the effect is compiling for
  9299. * @param defines The defines to update
  9300. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9301. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9302. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9303. * @returns true if normals will be required for the rest of the effect
  9304. */
  9305. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9306. /**
  9307. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9308. * @param lightIndex defines the light index
  9309. * @param uniformsList The uniform list
  9310. * @param samplersList The sampler list
  9311. * @param projectedLightTexture defines if projected texture must be used
  9312. * @param uniformBuffersList defines an optional list of uniform buffers
  9313. */
  9314. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9315. /**
  9316. * Prepares the uniforms and samplers list to be used in the effect
  9317. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9318. * @param samplersList The sampler list
  9319. * @param defines The defines helping in the list generation
  9320. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9321. */
  9322. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9323. /**
  9324. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9325. * @param defines The defines to update while falling back
  9326. * @param fallbacks The authorized effect fallbacks
  9327. * @param maxSimultaneousLights The maximum number of lights allowed
  9328. * @param rank the current rank of the Effect
  9329. * @returns The newly affected rank
  9330. */
  9331. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9332. private static _TmpMorphInfluencers;
  9333. /**
  9334. * Prepares the list of attributes required for morph targets according to the effect defines.
  9335. * @param attribs The current list of supported attribs
  9336. * @param mesh The mesh to prepare the morph targets attributes for
  9337. * @param influencers The number of influencers
  9338. */
  9339. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9340. /**
  9341. * Prepares the list of attributes required for morph targets according to the effect defines.
  9342. * @param attribs The current list of supported attribs
  9343. * @param mesh The mesh to prepare the morph targets attributes for
  9344. * @param defines The current Defines of the effect
  9345. */
  9346. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9347. /**
  9348. * Prepares the list of attributes required for bones according to the effect defines.
  9349. * @param attribs The current list of supported attribs
  9350. * @param mesh The mesh to prepare the bones attributes for
  9351. * @param defines The current Defines of the effect
  9352. * @param fallbacks The current efffect fallback strategy
  9353. */
  9354. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9355. /**
  9356. * Check and prepare the list of attributes required for instances according to the effect defines.
  9357. * @param attribs The current list of supported attribs
  9358. * @param defines The current MaterialDefines of the effect
  9359. */
  9360. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9361. /**
  9362. * Add the list of attributes required for instances to the attribs array.
  9363. * @param attribs The current list of supported attribs
  9364. */
  9365. static PushAttributesForInstances(attribs: string[]): void;
  9366. /**
  9367. * Binds the light information to the effect.
  9368. * @param light The light containing the generator
  9369. * @param effect The effect we are binding the data to
  9370. * @param lightIndex The light index in the effect used to render
  9371. */
  9372. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9373. /**
  9374. * Binds the lights information from the scene to the effect for the given mesh.
  9375. * @param light Light to bind
  9376. * @param lightIndex Light index
  9377. * @param scene The scene where the light belongs to
  9378. * @param effect The effect we are binding the data to
  9379. * @param useSpecular Defines if specular is supported
  9380. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9381. */
  9382. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9383. /**
  9384. * Binds the lights information from the scene to the effect for the given mesh.
  9385. * @param scene The scene the lights belongs to
  9386. * @param mesh The mesh we are binding the information to render
  9387. * @param effect The effect we are binding the data to
  9388. * @param defines The generated defines for the effect
  9389. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9390. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9391. */
  9392. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9393. private static _tempFogColor;
  9394. /**
  9395. * Binds the fog information from the scene to the effect for the given mesh.
  9396. * @param scene The scene the lights belongs to
  9397. * @param mesh The mesh we are binding the information to render
  9398. * @param effect The effect we are binding the data to
  9399. * @param linearSpace Defines if the fog effect is applied in linear space
  9400. */
  9401. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9402. /**
  9403. * Binds the bones information from the mesh to the effect.
  9404. * @param mesh The mesh we are binding the information to render
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9408. /**
  9409. * Binds the morph targets information from the mesh to the effect.
  9410. * @param abstractMesh The mesh we are binding the information to render
  9411. * @param effect The effect we are binding the data to
  9412. */
  9413. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9414. /**
  9415. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9416. * @param defines The generated defines used in the effect
  9417. * @param effect The effect we are binding the data to
  9418. * @param scene The scene we are willing to render with logarithmic scale for
  9419. */
  9420. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9421. /**
  9422. * Binds the clip plane information from the scene to the effect.
  9423. * @param scene The scene the clip plane information are extracted from
  9424. * @param effect The effect we are binding the data to
  9425. */
  9426. static BindClipPlane(effect: Effect, scene: Scene): void;
  9427. }
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9430. /** @hidden */
  9431. export var packingFunctions: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9437. /** @hidden */
  9438. export var clipPlaneFragmentDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9444. /** @hidden */
  9445. export var clipPlaneFragment: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9451. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9452. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9453. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9454. /** @hidden */
  9455. export var shadowMapPixelShader: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9461. /** @hidden */
  9462. export var bonesDeclaration: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9468. /** @hidden */
  9469. export var morphTargetsVertexGlobalDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9475. /** @hidden */
  9476. export var morphTargetsVertexDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9482. /** @hidden */
  9483. export var instancesDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9489. /** @hidden */
  9490. export var helperFunctions: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9496. /** @hidden */
  9497. export var clipPlaneVertexDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9503. /** @hidden */
  9504. export var morphTargetsVertex: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9510. /** @hidden */
  9511. export var instancesVertex: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9517. /** @hidden */
  9518. export var bonesVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9524. /** @hidden */
  9525. export var clipPlaneVertex: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9531. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9533. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9534. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9535. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9538. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9539. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9540. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9541. /** @hidden */
  9542. export var shadowMapVertexShader: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9548. /** @hidden */
  9549. export var depthBoxBlurPixelShader: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module "babylonjs/Culling/ray" {
  9555. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9556. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9558. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9559. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9560. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9561. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9562. import { Plane } from "babylonjs/Maths/math.plane";
  9563. /**
  9564. * Class representing a ray with position and direction
  9565. */
  9566. export class Ray {
  9567. /** origin point */
  9568. origin: Vector3;
  9569. /** direction */
  9570. direction: Vector3;
  9571. /** length of the ray */
  9572. length: number;
  9573. private static readonly TmpVector3;
  9574. private _tmpRay;
  9575. /**
  9576. * Creates a new ray
  9577. * @param origin origin point
  9578. * @param direction direction
  9579. * @param length length of the ray
  9580. */
  9581. constructor(
  9582. /** origin point */
  9583. origin: Vector3,
  9584. /** direction */
  9585. direction: Vector3,
  9586. /** length of the ray */
  9587. length?: number);
  9588. /**
  9589. * Checks if the ray intersects a box
  9590. * @param minimum bound of the box
  9591. * @param maximum bound of the box
  9592. * @param intersectionTreshold extra extend to be added to the box in all direction
  9593. * @returns if the box was hit
  9594. */
  9595. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9596. /**
  9597. * Checks if the ray intersects a box
  9598. * @param box the bounding box to check
  9599. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9600. * @returns if the box was hit
  9601. */
  9602. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9603. /**
  9604. * If the ray hits a sphere
  9605. * @param sphere the bounding sphere to check
  9606. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9607. * @returns true if it hits the sphere
  9608. */
  9609. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9610. /**
  9611. * If the ray hits a triange
  9612. * @param vertex0 triangle vertex
  9613. * @param vertex1 triangle vertex
  9614. * @param vertex2 triangle vertex
  9615. * @returns intersection information if hit
  9616. */
  9617. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9618. /**
  9619. * Checks if ray intersects a plane
  9620. * @param plane the plane to check
  9621. * @returns the distance away it was hit
  9622. */
  9623. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9624. /**
  9625. * Calculate the intercept of a ray on a given axis
  9626. * @param axis to check 'x' | 'y' | 'z'
  9627. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9628. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9629. */
  9630. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9631. /**
  9632. * Checks if ray intersects a mesh
  9633. * @param mesh the mesh to check
  9634. * @param fastCheck if only the bounding box should checked
  9635. * @returns picking info of the intersecton
  9636. */
  9637. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9638. /**
  9639. * Checks if ray intersects a mesh
  9640. * @param meshes the meshes to check
  9641. * @param fastCheck if only the bounding box should checked
  9642. * @param results array to store result in
  9643. * @returns Array of picking infos
  9644. */
  9645. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9646. private _comparePickingInfo;
  9647. private static smallnum;
  9648. private static rayl;
  9649. /**
  9650. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9651. * @param sega the first point of the segment to test the intersection against
  9652. * @param segb the second point of the segment to test the intersection against
  9653. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9654. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9655. */
  9656. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9657. /**
  9658. * Update the ray from viewport position
  9659. * @param x position
  9660. * @param y y position
  9661. * @param viewportWidth viewport width
  9662. * @param viewportHeight viewport height
  9663. * @param world world matrix
  9664. * @param view view matrix
  9665. * @param projection projection matrix
  9666. * @returns this ray updated
  9667. */
  9668. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9669. /**
  9670. * Creates a ray with origin and direction of 0,0,0
  9671. * @returns the new ray
  9672. */
  9673. static Zero(): Ray;
  9674. /**
  9675. * Creates a new ray from screen space and viewport
  9676. * @param x position
  9677. * @param y y position
  9678. * @param viewportWidth viewport width
  9679. * @param viewportHeight viewport height
  9680. * @param world world matrix
  9681. * @param view view matrix
  9682. * @param projection projection matrix
  9683. * @returns new ray
  9684. */
  9685. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9686. /**
  9687. * 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
  9688. * transformed to the given world matrix.
  9689. * @param origin The origin point
  9690. * @param end The end point
  9691. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9692. * @returns the new ray
  9693. */
  9694. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9695. /**
  9696. * Transforms a ray by a matrix
  9697. * @param ray ray to transform
  9698. * @param matrix matrix to apply
  9699. * @returns the resulting new ray
  9700. */
  9701. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9702. /**
  9703. * Transforms a ray by a matrix
  9704. * @param ray ray to transform
  9705. * @param matrix matrix to apply
  9706. * @param result ray to store result in
  9707. */
  9708. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9709. /**
  9710. * Unproject a ray from screen space to object space
  9711. * @param sourceX defines the screen space x coordinate to use
  9712. * @param sourceY defines the screen space y coordinate to use
  9713. * @param viewportWidth defines the current width of the viewport
  9714. * @param viewportHeight defines the current height of the viewport
  9715. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9716. * @param view defines the view matrix to use
  9717. * @param projection defines the projection matrix to use
  9718. */
  9719. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9720. }
  9721. /**
  9722. * Type used to define predicate used to select faces when a mesh intersection is detected
  9723. */
  9724. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9725. module "babylonjs/scene" {
  9726. interface Scene {
  9727. /** @hidden */
  9728. _tempPickingRay: Nullable<Ray>;
  9729. /** @hidden */
  9730. _cachedRayForTransform: Ray;
  9731. /** @hidden */
  9732. _pickWithRayInverseMatrix: Matrix;
  9733. /** @hidden */
  9734. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9735. /** @hidden */
  9736. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9737. }
  9738. }
  9739. }
  9740. declare module "babylonjs/sceneComponent" {
  9741. import { Scene } from "babylonjs/scene";
  9742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9743. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9744. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9745. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9746. import { Nullable } from "babylonjs/types";
  9747. import { Camera } from "babylonjs/Cameras/camera";
  9748. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9749. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9750. import { AbstractScene } from "babylonjs/abstractScene";
  9751. import { Mesh } from "babylonjs/Meshes/mesh";
  9752. /**
  9753. * Groups all the scene component constants in one place to ease maintenance.
  9754. * @hidden
  9755. */
  9756. export class SceneComponentConstants {
  9757. static readonly NAME_EFFECTLAYER: string;
  9758. static readonly NAME_LAYER: string;
  9759. static readonly NAME_LENSFLARESYSTEM: string;
  9760. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9761. static readonly NAME_PARTICLESYSTEM: string;
  9762. static readonly NAME_GAMEPAD: string;
  9763. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9764. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9765. static readonly NAME_DEPTHRENDERER: string;
  9766. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9767. static readonly NAME_SPRITE: string;
  9768. static readonly NAME_OUTLINERENDERER: string;
  9769. static readonly NAME_PROCEDURALTEXTURE: string;
  9770. static readonly NAME_SHADOWGENERATOR: string;
  9771. static readonly NAME_OCTREE: string;
  9772. static readonly NAME_PHYSICSENGINE: string;
  9773. static readonly NAME_AUDIO: string;
  9774. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9775. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9776. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9777. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9778. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9779. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9780. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9781. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9782. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9783. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9784. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9785. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9786. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9787. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9788. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9789. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9790. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9791. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9792. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9793. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9794. static readonly STEP_AFTERRENDER_AUDIO: number;
  9795. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9796. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9797. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9798. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9799. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9800. static readonly STEP_POINTERMOVE_SPRITE: number;
  9801. static readonly STEP_POINTERDOWN_SPRITE: number;
  9802. static readonly STEP_POINTERUP_SPRITE: number;
  9803. }
  9804. /**
  9805. * This represents a scene component.
  9806. *
  9807. * This is used to decouple the dependency the scene is having on the different workloads like
  9808. * layers, post processes...
  9809. */
  9810. export interface ISceneComponent {
  9811. /**
  9812. * The name of the component. Each component must have a unique name.
  9813. */
  9814. name: string;
  9815. /**
  9816. * The scene the component belongs to.
  9817. */
  9818. scene: Scene;
  9819. /**
  9820. * Register the component to one instance of a scene.
  9821. */
  9822. register(): void;
  9823. /**
  9824. * Rebuilds the elements related to this component in case of
  9825. * context lost for instance.
  9826. */
  9827. rebuild(): void;
  9828. /**
  9829. * Disposes the component and the associated ressources.
  9830. */
  9831. dispose(): void;
  9832. }
  9833. /**
  9834. * This represents a SERIALIZABLE scene component.
  9835. *
  9836. * This extends Scene Component to add Serialization methods on top.
  9837. */
  9838. export interface ISceneSerializableComponent extends ISceneComponent {
  9839. /**
  9840. * Adds all the elements from the container to the scene
  9841. * @param container the container holding the elements
  9842. */
  9843. addFromContainer(container: AbstractScene): void;
  9844. /**
  9845. * Removes all the elements in the container from the scene
  9846. * @param container contains the elements to remove
  9847. * @param dispose if the removed element should be disposed (default: false)
  9848. */
  9849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9850. /**
  9851. * Serializes the component data to the specified json object
  9852. * @param serializationObject The object to serialize to
  9853. */
  9854. serialize(serializationObject: any): void;
  9855. }
  9856. /**
  9857. * Strong typing of a Mesh related stage step action
  9858. */
  9859. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9860. /**
  9861. * Strong typing of a Evaluate Sub Mesh related stage step action
  9862. */
  9863. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9864. /**
  9865. * Strong typing of a Active Mesh related stage step action
  9866. */
  9867. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9868. /**
  9869. * Strong typing of a Camera related stage step action
  9870. */
  9871. export type CameraStageAction = (camera: Camera) => void;
  9872. /**
  9873. * Strong typing of a Camera Frame buffer related stage step action
  9874. */
  9875. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9876. /**
  9877. * Strong typing of a Render Target related stage step action
  9878. */
  9879. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9880. /**
  9881. * Strong typing of a RenderingGroup related stage step action
  9882. */
  9883. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9884. /**
  9885. * Strong typing of a Mesh Render related stage step action
  9886. */
  9887. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9888. /**
  9889. * Strong typing of a simple stage step action
  9890. */
  9891. export type SimpleStageAction = () => void;
  9892. /**
  9893. * Strong typing of a render target action.
  9894. */
  9895. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9896. /**
  9897. * Strong typing of a pointer move action.
  9898. */
  9899. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9900. /**
  9901. * Strong typing of a pointer up/down action.
  9902. */
  9903. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9904. /**
  9905. * Representation of a stage in the scene (Basically a list of ordered steps)
  9906. * @hidden
  9907. */
  9908. export class Stage<T extends Function> extends Array<{
  9909. index: number;
  9910. component: ISceneComponent;
  9911. action: T;
  9912. }> {
  9913. /**
  9914. * Hide ctor from the rest of the world.
  9915. * @param items The items to add.
  9916. */
  9917. private constructor();
  9918. /**
  9919. * Creates a new Stage.
  9920. * @returns A new instance of a Stage
  9921. */
  9922. static Create<T extends Function>(): Stage<T>;
  9923. /**
  9924. * Registers a step in an ordered way in the targeted stage.
  9925. * @param index Defines the position to register the step in
  9926. * @param component Defines the component attached to the step
  9927. * @param action Defines the action to launch during the step
  9928. */
  9929. registerStep(index: number, component: ISceneComponent, action: T): void;
  9930. /**
  9931. * Clears all the steps from the stage.
  9932. */
  9933. clear(): void;
  9934. }
  9935. }
  9936. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9937. import { Nullable } from "babylonjs/types";
  9938. import { Observable } from "babylonjs/Misc/observable";
  9939. import { Scene } from "babylonjs/scene";
  9940. import { Sprite } from "babylonjs/Sprites/sprite";
  9941. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9942. import { Ray } from "babylonjs/Culling/ray";
  9943. import { Camera } from "babylonjs/Cameras/camera";
  9944. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9945. import { ISceneComponent } from "babylonjs/sceneComponent";
  9946. module "babylonjs/scene" {
  9947. interface Scene {
  9948. /** @hidden */
  9949. _pointerOverSprite: Nullable<Sprite>;
  9950. /** @hidden */
  9951. _pickedDownSprite: Nullable<Sprite>;
  9952. /** @hidden */
  9953. _tempSpritePickingRay: Nullable<Ray>;
  9954. /**
  9955. * All of the sprite managers added to this scene
  9956. * @see http://doc.babylonjs.com/babylon101/sprites
  9957. */
  9958. spriteManagers: Array<ISpriteManager>;
  9959. /**
  9960. * An event triggered when sprites rendering is about to start
  9961. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9962. */
  9963. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9964. /**
  9965. * An event triggered when sprites rendering is done
  9966. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9967. */
  9968. onAfterSpritesRenderingObservable: Observable<Scene>;
  9969. /** @hidden */
  9970. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9971. /** Launch a ray to try to pick a sprite in the scene
  9972. * @param x position on screen
  9973. * @param y position on screen
  9974. * @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
  9975. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9976. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9977. * @returns a PickingInfo
  9978. */
  9979. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9980. /** Use the given ray to pick a sprite in the scene
  9981. * @param ray The ray (in world space) to use to pick meshes
  9982. * @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
  9983. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9984. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9985. * @returns a PickingInfo
  9986. */
  9987. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9988. /** @hidden */
  9989. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9990. /** Launch a ray to try to pick sprites in the scene
  9991. * @param x position on screen
  9992. * @param y position on screen
  9993. * @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
  9994. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9995. * @returns a PickingInfo array
  9996. */
  9997. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9998. /** Use the given ray to pick sprites in the scene
  9999. * @param ray The ray (in world space) to use to pick meshes
  10000. * @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
  10001. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10002. * @returns a PickingInfo array
  10003. */
  10004. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10005. /**
  10006. * Force the sprite under the pointer
  10007. * @param sprite defines the sprite to use
  10008. */
  10009. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10010. /**
  10011. * Gets the sprite under the pointer
  10012. * @returns a Sprite or null if no sprite is under the pointer
  10013. */
  10014. getPointerOverSprite(): Nullable<Sprite>;
  10015. }
  10016. }
  10017. /**
  10018. * Defines the sprite scene component responsible to manage sprites
  10019. * in a given scene.
  10020. */
  10021. export class SpriteSceneComponent implements ISceneComponent {
  10022. /**
  10023. * The component name helpfull to identify the component in the list of scene components.
  10024. */
  10025. readonly name: string;
  10026. /**
  10027. * The scene the component belongs to.
  10028. */
  10029. scene: Scene;
  10030. /** @hidden */
  10031. private _spritePredicate;
  10032. /**
  10033. * Creates a new instance of the component for the given scene
  10034. * @param scene Defines the scene to register the component in
  10035. */
  10036. constructor(scene: Scene);
  10037. /**
  10038. * Registers the component in a given scene
  10039. */
  10040. register(): void;
  10041. /**
  10042. * Rebuilds the elements related to this component in case of
  10043. * context lost for instance.
  10044. */
  10045. rebuild(): void;
  10046. /**
  10047. * Disposes the component and the associated ressources.
  10048. */
  10049. dispose(): void;
  10050. private _pickSpriteButKeepRay;
  10051. private _pointerMove;
  10052. private _pointerDown;
  10053. private _pointerUp;
  10054. }
  10055. }
  10056. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10057. /** @hidden */
  10058. export var fogFragmentDeclaration: {
  10059. name: string;
  10060. shader: string;
  10061. };
  10062. }
  10063. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10064. /** @hidden */
  10065. export var fogFragment: {
  10066. name: string;
  10067. shader: string;
  10068. };
  10069. }
  10070. declare module "babylonjs/Shaders/sprites.fragment" {
  10071. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10072. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10073. /** @hidden */
  10074. export var spritesPixelShader: {
  10075. name: string;
  10076. shader: string;
  10077. };
  10078. }
  10079. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10080. /** @hidden */
  10081. export var fogVertexDeclaration: {
  10082. name: string;
  10083. shader: string;
  10084. };
  10085. }
  10086. declare module "babylonjs/Shaders/sprites.vertex" {
  10087. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10088. /** @hidden */
  10089. export var spritesVertexShader: {
  10090. name: string;
  10091. shader: string;
  10092. };
  10093. }
  10094. declare module "babylonjs/Sprites/spriteManager" {
  10095. import { IDisposable, Scene } from "babylonjs/scene";
  10096. import { Nullable } from "babylonjs/types";
  10097. import { Observable } from "babylonjs/Misc/observable";
  10098. import { Sprite } from "babylonjs/Sprites/sprite";
  10099. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10100. import { Camera } from "babylonjs/Cameras/camera";
  10101. import { Texture } from "babylonjs/Materials/Textures/texture";
  10102. import "babylonjs/Shaders/sprites.fragment";
  10103. import "babylonjs/Shaders/sprites.vertex";
  10104. import { Ray } from "babylonjs/Culling/ray";
  10105. /**
  10106. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10107. */
  10108. export interface ISpriteManager extends IDisposable {
  10109. /**
  10110. * Restricts the camera to viewing objects with the same layerMask.
  10111. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10112. */
  10113. layerMask: number;
  10114. /**
  10115. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10116. */
  10117. isPickable: boolean;
  10118. /**
  10119. * Specifies the rendering group id for this mesh (0 by default)
  10120. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10121. */
  10122. renderingGroupId: number;
  10123. /**
  10124. * Defines the list of sprites managed by the manager.
  10125. */
  10126. sprites: Array<Sprite>;
  10127. /**
  10128. * Tests the intersection of a sprite with a specific ray.
  10129. * @param ray The ray we are sending to test the collision
  10130. * @param camera The camera space we are sending rays in
  10131. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10132. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10133. * @returns picking info or null.
  10134. */
  10135. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10136. /**
  10137. * Intersects the sprites with a ray
  10138. * @param ray defines the ray to intersect with
  10139. * @param camera defines the current active camera
  10140. * @param predicate defines a predicate used to select candidate sprites
  10141. * @returns null if no hit or a PickingInfo array
  10142. */
  10143. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10144. /**
  10145. * Renders the list of sprites on screen.
  10146. */
  10147. render(): void;
  10148. }
  10149. /**
  10150. * Class used to manage multiple sprites on the same spritesheet
  10151. * @see http://doc.babylonjs.com/babylon101/sprites
  10152. */
  10153. export class SpriteManager implements ISpriteManager {
  10154. /** defines the manager's name */
  10155. name: string;
  10156. /** Gets the list of sprites */
  10157. sprites: Sprite[];
  10158. /** Gets or sets the rendering group id (0 by default) */
  10159. renderingGroupId: number;
  10160. /** Gets or sets camera layer mask */
  10161. layerMask: number;
  10162. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10163. fogEnabled: boolean;
  10164. /** Gets or sets a boolean indicating if the sprites are pickable */
  10165. isPickable: boolean;
  10166. /** Defines the default width of a cell in the spritesheet */
  10167. cellWidth: number;
  10168. /** Defines the default height of a cell in the spritesheet */
  10169. cellHeight: number;
  10170. /** Associative array from JSON sprite data file */
  10171. private _cellData;
  10172. /** Array of sprite names from JSON sprite data file */
  10173. private _spriteMap;
  10174. /** True when packed cell data from JSON file is ready*/
  10175. private _packedAndReady;
  10176. /**
  10177. * An event triggered when the manager is disposed.
  10178. */
  10179. onDisposeObservable: Observable<SpriteManager>;
  10180. private _onDisposeObserver;
  10181. /**
  10182. * Callback called when the manager is disposed
  10183. */
  10184. set onDispose(callback: () => void);
  10185. private _capacity;
  10186. private _fromPacked;
  10187. private _spriteTexture;
  10188. private _epsilon;
  10189. private _scene;
  10190. private _vertexData;
  10191. private _buffer;
  10192. private _vertexBuffers;
  10193. private _indexBuffer;
  10194. private _effectBase;
  10195. private _effectFog;
  10196. /**
  10197. * Gets or sets the spritesheet texture
  10198. */
  10199. get texture(): Texture;
  10200. set texture(value: Texture);
  10201. private _blendMode;
  10202. /**
  10203. * Blend mode use to render the particle, it can be any of
  10204. * the static Constants.ALPHA_x properties provided in this class.
  10205. * Default value is Constants.ALPHA_COMBINE
  10206. */
  10207. get blendMode(): number;
  10208. set blendMode(blendMode: number);
  10209. /** Disables writing to the depth buffer when rendering the sprites.
  10210. * It can be handy to disable depth writing when using textures without alpha channel
  10211. * and setting some specific blend modes.
  10212. */
  10213. disableDepthWrite: boolean;
  10214. /**
  10215. * Creates a new sprite manager
  10216. * @param name defines the manager's name
  10217. * @param imgUrl defines the sprite sheet url
  10218. * @param capacity defines the maximum allowed number of sprites
  10219. * @param cellSize defines the size of a sprite cell
  10220. * @param scene defines the hosting scene
  10221. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10222. * @param samplingMode defines the smapling mode to use with spritesheet
  10223. * @param fromPacked set to false; do not alter
  10224. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10225. */
  10226. constructor(
  10227. /** defines the manager's name */
  10228. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10229. private _makePacked;
  10230. private _appendSpriteVertex;
  10231. /**
  10232. * Intersects the sprites with a ray
  10233. * @param ray defines the ray to intersect with
  10234. * @param camera defines the current active camera
  10235. * @param predicate defines a predicate used to select candidate sprites
  10236. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10237. * @returns null if no hit or a PickingInfo
  10238. */
  10239. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10240. /**
  10241. * Intersects the sprites with a ray
  10242. * @param ray defines the ray to intersect with
  10243. * @param camera defines the current active camera
  10244. * @param predicate defines a predicate used to select candidate sprites
  10245. * @returns null if no hit or a PickingInfo array
  10246. */
  10247. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10248. /**
  10249. * Render all child sprites
  10250. */
  10251. render(): void;
  10252. /**
  10253. * Release associated resources
  10254. */
  10255. dispose(): void;
  10256. }
  10257. }
  10258. declare module "babylonjs/Misc/gradients" {
  10259. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10260. /** Interface used by value gradients (color, factor, ...) */
  10261. export interface IValueGradient {
  10262. /**
  10263. * Gets or sets the gradient value (between 0 and 1)
  10264. */
  10265. gradient: number;
  10266. }
  10267. /** Class used to store color4 gradient */
  10268. export class ColorGradient implements IValueGradient {
  10269. /**
  10270. * Gets or sets the gradient value (between 0 and 1)
  10271. */
  10272. gradient: number;
  10273. /**
  10274. * Gets or sets first associated color
  10275. */
  10276. color1: Color4;
  10277. /**
  10278. * Gets or sets second associated color
  10279. */
  10280. color2?: Color4;
  10281. /**
  10282. * Will get a color picked randomly between color1 and color2.
  10283. * If color2 is undefined then color1 will be used
  10284. * @param result defines the target Color4 to store the result in
  10285. */
  10286. getColorToRef(result: Color4): void;
  10287. }
  10288. /** Class used to store color 3 gradient */
  10289. export class Color3Gradient implements IValueGradient {
  10290. /**
  10291. * Gets or sets the gradient value (between 0 and 1)
  10292. */
  10293. gradient: number;
  10294. /**
  10295. * Gets or sets the associated color
  10296. */
  10297. color: Color3;
  10298. }
  10299. /** Class used to store factor gradient */
  10300. export class FactorGradient implements IValueGradient {
  10301. /**
  10302. * Gets or sets the gradient value (between 0 and 1)
  10303. */
  10304. gradient: number;
  10305. /**
  10306. * Gets or sets first associated factor
  10307. */
  10308. factor1: number;
  10309. /**
  10310. * Gets or sets second associated factor
  10311. */
  10312. factor2?: number;
  10313. /**
  10314. * Will get a number picked randomly between factor1 and factor2.
  10315. * If factor2 is undefined then factor1 will be used
  10316. * @returns the picked number
  10317. */
  10318. getFactor(): number;
  10319. }
  10320. /**
  10321. * Helper used to simplify some generic gradient tasks
  10322. */
  10323. export class GradientHelper {
  10324. /**
  10325. * Gets the current gradient from an array of IValueGradient
  10326. * @param ratio defines the current ratio to get
  10327. * @param gradients defines the array of IValueGradient
  10328. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10329. */
  10330. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10331. }
  10332. }
  10333. declare module "babylonjs/Maths/math.size" {
  10334. /**
  10335. * Interface for the size containing width and height
  10336. */
  10337. export interface ISize {
  10338. /**
  10339. * Width
  10340. */
  10341. width: number;
  10342. /**
  10343. * Heighht
  10344. */
  10345. height: number;
  10346. }
  10347. /**
  10348. * Size containing widht and height
  10349. */
  10350. export class Size implements ISize {
  10351. /**
  10352. * Width
  10353. */
  10354. width: number;
  10355. /**
  10356. * Height
  10357. */
  10358. height: number;
  10359. /**
  10360. * Creates a Size object from the given width and height (floats).
  10361. * @param width width of the new size
  10362. * @param height height of the new size
  10363. */
  10364. constructor(width: number, height: number);
  10365. /**
  10366. * Returns a string with the Size width and height
  10367. * @returns a string with the Size width and height
  10368. */
  10369. toString(): string;
  10370. /**
  10371. * "Size"
  10372. * @returns the string "Size"
  10373. */
  10374. getClassName(): string;
  10375. /**
  10376. * Returns the Size hash code.
  10377. * @returns a hash code for a unique width and height
  10378. */
  10379. getHashCode(): number;
  10380. /**
  10381. * Updates the current size from the given one.
  10382. * @param src the given size
  10383. */
  10384. copyFrom(src: Size): void;
  10385. /**
  10386. * Updates in place the current Size from the given floats.
  10387. * @param width width of the new size
  10388. * @param height height of the new size
  10389. * @returns the updated Size.
  10390. */
  10391. copyFromFloats(width: number, height: number): Size;
  10392. /**
  10393. * Updates in place the current Size from the given floats.
  10394. * @param width width to set
  10395. * @param height height to set
  10396. * @returns the updated Size.
  10397. */
  10398. set(width: number, height: number): Size;
  10399. /**
  10400. * Multiplies the width and height by numbers
  10401. * @param w factor to multiple the width by
  10402. * @param h factor to multiple the height by
  10403. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10404. */
  10405. multiplyByFloats(w: number, h: number): Size;
  10406. /**
  10407. * Clones the size
  10408. * @returns a new Size copied from the given one.
  10409. */
  10410. clone(): Size;
  10411. /**
  10412. * True if the current Size and the given one width and height are strictly equal.
  10413. * @param other the other size to compare against
  10414. * @returns True if the current Size and the given one width and height are strictly equal.
  10415. */
  10416. equals(other: Size): boolean;
  10417. /**
  10418. * The surface of the Size : width * height (float).
  10419. */
  10420. get surface(): number;
  10421. /**
  10422. * Create a new size of zero
  10423. * @returns a new Size set to (0.0, 0.0)
  10424. */
  10425. static Zero(): Size;
  10426. /**
  10427. * Sums the width and height of two sizes
  10428. * @param otherSize size to add to this size
  10429. * @returns a new Size set as the addition result of the current Size and the given one.
  10430. */
  10431. add(otherSize: Size): Size;
  10432. /**
  10433. * Subtracts the width and height of two
  10434. * @param otherSize size to subtract to this size
  10435. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10436. */
  10437. subtract(otherSize: Size): Size;
  10438. /**
  10439. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10440. * @param start starting size to lerp between
  10441. * @param end end size to lerp between
  10442. * @param amount amount to lerp between the start and end values
  10443. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10444. */
  10445. static Lerp(start: Size, end: Size, amount: number): Size;
  10446. }
  10447. }
  10448. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10450. import { Nullable } from "babylonjs/types";
  10451. module "babylonjs/Engines/thinEngine" {
  10452. interface ThinEngine {
  10453. /**
  10454. * Creates a dynamic texture
  10455. * @param width defines the width of the texture
  10456. * @param height defines the height of the texture
  10457. * @param generateMipMaps defines if the engine should generate the mip levels
  10458. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10459. * @returns the dynamic texture inside an InternalTexture
  10460. */
  10461. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10462. /**
  10463. * Update the content of a dynamic texture
  10464. * @param texture defines the texture to update
  10465. * @param canvas defines the canvas containing the source
  10466. * @param invertY defines if data must be stored with Y axis inverted
  10467. * @param premulAlpha defines if alpha is stored as premultiplied
  10468. * @param format defines the format of the data
  10469. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10470. */
  10471. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10472. }
  10473. }
  10474. }
  10475. declare module "babylonjs/Misc/canvasGenerator" {
  10476. /**
  10477. * Helper class used to generate a canvas to manipulate images
  10478. */
  10479. export class CanvasGenerator {
  10480. /**
  10481. * Create a new canvas (or offscreen canvas depending on the context)
  10482. * @param width defines the expected width
  10483. * @param height defines the expected height
  10484. * @return a new canvas or offscreen canvas
  10485. */
  10486. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10487. }
  10488. }
  10489. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10490. import { Scene } from "babylonjs/scene";
  10491. import { Texture } from "babylonjs/Materials/Textures/texture";
  10492. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10493. /**
  10494. * A class extending Texture allowing drawing on a texture
  10495. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10496. */
  10497. export class DynamicTexture extends Texture {
  10498. private _generateMipMaps;
  10499. private _canvas;
  10500. private _context;
  10501. private _engine;
  10502. /**
  10503. * Creates a DynamicTexture
  10504. * @param name defines the name of the texture
  10505. * @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
  10506. * @param scene defines the scene where you want the texture
  10507. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10508. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10509. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10510. */
  10511. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10512. /**
  10513. * Get the current class name of the texture useful for serialization or dynamic coding.
  10514. * @returns "DynamicTexture"
  10515. */
  10516. getClassName(): string;
  10517. /**
  10518. * Gets the current state of canRescale
  10519. */
  10520. get canRescale(): boolean;
  10521. private _recreate;
  10522. /**
  10523. * Scales the texture
  10524. * @param ratio the scale factor to apply to both width and height
  10525. */
  10526. scale(ratio: number): void;
  10527. /**
  10528. * Resizes the texture
  10529. * @param width the new width
  10530. * @param height the new height
  10531. */
  10532. scaleTo(width: number, height: number): void;
  10533. /**
  10534. * Gets the context of the canvas used by the texture
  10535. * @returns the canvas context of the dynamic texture
  10536. */
  10537. getContext(): CanvasRenderingContext2D;
  10538. /**
  10539. * Clears the texture
  10540. */
  10541. clear(): void;
  10542. /**
  10543. * Updates the texture
  10544. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10545. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10546. */
  10547. update(invertY?: boolean, premulAlpha?: boolean): void;
  10548. /**
  10549. * Draws text onto the texture
  10550. * @param text defines the text to be drawn
  10551. * @param x defines the placement of the text from the left
  10552. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10553. * @param font defines the font to be used with font-style, font-size, font-name
  10554. * @param color defines the color used for the text
  10555. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10556. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10557. * @param update defines whether texture is immediately update (default is true)
  10558. */
  10559. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10560. /**
  10561. * Clones the texture
  10562. * @returns the clone of the texture.
  10563. */
  10564. clone(): DynamicTexture;
  10565. /**
  10566. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10567. * @returns a serialized dynamic texture object
  10568. */
  10569. serialize(): any;
  10570. /** @hidden */
  10571. _rebuild(): void;
  10572. }
  10573. }
  10574. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10575. import { Nullable } from "babylonjs/types";
  10576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10577. import { Scene } from "babylonjs/scene";
  10578. module "babylonjs/Engines/engine" {
  10579. interface Engine {
  10580. /**
  10581. * Creates a raw texture
  10582. * @param data defines the data to store in the texture
  10583. * @param width defines the width of the texture
  10584. * @param height defines the height of the texture
  10585. * @param format defines the format of the data
  10586. * @param generateMipMaps defines if the engine should generate the mip levels
  10587. * @param invertY defines if data must be stored with Y axis inverted
  10588. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10589. * @param compression defines the compression used (null by default)
  10590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10591. * @returns the raw texture inside an InternalTexture
  10592. */
  10593. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10594. /**
  10595. * Update a raw texture
  10596. * @param texture defines the texture to update
  10597. * @param data defines the data to store in the texture
  10598. * @param format defines the format of the data
  10599. * @param invertY defines if data must be stored with Y axis inverted
  10600. */
  10601. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10602. /**
  10603. * Update a raw texture
  10604. * @param texture defines the texture to update
  10605. * @param data defines the data to store in the texture
  10606. * @param format defines the format of the data
  10607. * @param invertY defines if data must be stored with Y axis inverted
  10608. * @param compression defines the compression used (null by default)
  10609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10610. */
  10611. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10612. /**
  10613. * Creates a new raw cube texture
  10614. * @param data defines the array of data to use to create each face
  10615. * @param size defines the size of the textures
  10616. * @param format defines the format of the data
  10617. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10618. * @param generateMipMaps defines if the engine should generate the mip levels
  10619. * @param invertY defines if data must be stored with Y axis inverted
  10620. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10621. * @param compression defines the compression used (null by default)
  10622. * @returns the cube texture as an InternalTexture
  10623. */
  10624. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10625. /**
  10626. * Update a raw cube texture
  10627. * @param texture defines the texture to udpdate
  10628. * @param data defines the data to store
  10629. * @param format defines the data format
  10630. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10631. * @param invertY defines if data must be stored with Y axis inverted
  10632. */
  10633. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10634. /**
  10635. * Update a raw cube texture
  10636. * @param texture defines the texture to udpdate
  10637. * @param data defines the data to store
  10638. * @param format defines the data format
  10639. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10640. * @param invertY defines if data must be stored with Y axis inverted
  10641. * @param compression defines the compression used (null by default)
  10642. */
  10643. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10644. /**
  10645. * Update a raw cube texture
  10646. * @param texture defines the texture to udpdate
  10647. * @param data defines the data to store
  10648. * @param format defines the data format
  10649. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10650. * @param invertY defines if data must be stored with Y axis inverted
  10651. * @param compression defines the compression used (null by default)
  10652. * @param level defines which level of the texture to update
  10653. */
  10654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10655. /**
  10656. * Creates a new raw cube texture from a specified url
  10657. * @param url defines the url where the data is located
  10658. * @param scene defines the current scene
  10659. * @param size defines the size of the textures
  10660. * @param format defines the format of the data
  10661. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10662. * @param noMipmap defines if the engine should avoid generating the mip levels
  10663. * @param callback defines a callback used to extract texture data from loaded data
  10664. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10665. * @param onLoad defines a callback called when texture is loaded
  10666. * @param onError defines a callback called if there is an error
  10667. * @returns the cube texture as an InternalTexture
  10668. */
  10669. 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;
  10670. /**
  10671. * Creates a new raw cube texture from a specified url
  10672. * @param url defines the url where the data is located
  10673. * @param scene defines the current scene
  10674. * @param size defines the size of the textures
  10675. * @param format defines the format of the data
  10676. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10677. * @param noMipmap defines if the engine should avoid generating the mip levels
  10678. * @param callback defines a callback used to extract texture data from loaded data
  10679. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10680. * @param onLoad defines a callback called when texture is loaded
  10681. * @param onError defines a callback called if there is an error
  10682. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10683. * @param invertY defines if data must be stored with Y axis inverted
  10684. * @returns the cube texture as an InternalTexture
  10685. */
  10686. 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;
  10687. /**
  10688. * Creates a new raw 3D texture
  10689. * @param data defines the data used to create the texture
  10690. * @param width defines the width of the texture
  10691. * @param height defines the height of the texture
  10692. * @param depth defines the depth of the texture
  10693. * @param format defines the format of the texture
  10694. * @param generateMipMaps defines if the engine must generate mip levels
  10695. * @param invertY defines if data must be stored with Y axis inverted
  10696. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10697. * @param compression defines the compressed used (can be null)
  10698. * @param textureType defines the compressed used (can be null)
  10699. * @returns a new raw 3D texture (stored in an InternalTexture)
  10700. */
  10701. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10702. /**
  10703. * Update a raw 3D texture
  10704. * @param texture defines the texture to update
  10705. * @param data defines the data to store
  10706. * @param format defines the data format
  10707. * @param invertY defines if data must be stored with Y axis inverted
  10708. */
  10709. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10710. /**
  10711. * Update a raw 3D texture
  10712. * @param texture defines the texture to update
  10713. * @param data defines the data to store
  10714. * @param format defines the data format
  10715. * @param invertY defines if data must be stored with Y axis inverted
  10716. * @param compression defines the used compression (can be null)
  10717. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10718. */
  10719. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10720. /**
  10721. * Creates a new raw 2D array texture
  10722. * @param data defines the data used to create the texture
  10723. * @param width defines the width of the texture
  10724. * @param height defines the height of the texture
  10725. * @param depth defines the number of layers of the texture
  10726. * @param format defines the format of the texture
  10727. * @param generateMipMaps defines if the engine must generate mip levels
  10728. * @param invertY defines if data must be stored with Y axis inverted
  10729. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10730. * @param compression defines the compressed used (can be null)
  10731. * @param textureType defines the compressed used (can be null)
  10732. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10733. */
  10734. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10735. /**
  10736. * Update a raw 2D array texture
  10737. * @param texture defines the texture to update
  10738. * @param data defines the data to store
  10739. * @param format defines the data format
  10740. * @param invertY defines if data must be stored with Y axis inverted
  10741. */
  10742. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10743. /**
  10744. * Update a raw 2D array texture
  10745. * @param texture defines the texture to update
  10746. * @param data defines the data to store
  10747. * @param format defines the data format
  10748. * @param invertY defines if data must be stored with Y axis inverted
  10749. * @param compression defines the used compression (can be null)
  10750. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10751. */
  10752. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10753. }
  10754. }
  10755. }
  10756. declare module "babylonjs/Materials/Textures/rawTexture" {
  10757. import { Scene } from "babylonjs/scene";
  10758. import { Texture } from "babylonjs/Materials/Textures/texture";
  10759. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10760. /**
  10761. * Raw texture can help creating a texture directly from an array of data.
  10762. * This can be super useful if you either get the data from an uncompressed source or
  10763. * if you wish to create your texture pixel by pixel.
  10764. */
  10765. export class RawTexture extends Texture {
  10766. /**
  10767. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10768. */
  10769. format: number;
  10770. private _engine;
  10771. /**
  10772. * Instantiates a new RawTexture.
  10773. * Raw texture can help creating a texture directly from an array of data.
  10774. * This can be super useful if you either get the data from an uncompressed source or
  10775. * if you wish to create your texture pixel by pixel.
  10776. * @param data define the array of data to use to create the texture
  10777. * @param width define the width of the texture
  10778. * @param height define the height of the texture
  10779. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10780. * @param scene define the scene the texture belongs to
  10781. * @param generateMipMaps define whether mip maps should be generated or not
  10782. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10783. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10784. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10785. */
  10786. constructor(data: ArrayBufferView, width: number, height: number,
  10787. /**
  10788. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10789. */
  10790. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10791. /**
  10792. * Updates the texture underlying data.
  10793. * @param data Define the new data of the texture
  10794. */
  10795. update(data: ArrayBufferView): void;
  10796. /**
  10797. * Creates a luminance texture from some data.
  10798. * @param data Define the texture data
  10799. * @param width Define the width of the texture
  10800. * @param height Define the height of the texture
  10801. * @param scene Define the scene the texture belongs to
  10802. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10803. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10804. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10805. * @returns the luminance texture
  10806. */
  10807. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10808. /**
  10809. * Creates a luminance alpha texture from some data.
  10810. * @param data Define the texture data
  10811. * @param width Define the width of the texture
  10812. * @param height Define the height of the texture
  10813. * @param scene Define the scene the texture belongs to
  10814. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10817. * @returns the luminance alpha texture
  10818. */
  10819. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10820. /**
  10821. * Creates an alpha texture from some data.
  10822. * @param data Define the texture data
  10823. * @param width Define the width of the texture
  10824. * @param height Define the height of the texture
  10825. * @param scene Define the scene the texture belongs to
  10826. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10827. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10828. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10829. * @returns the alpha texture
  10830. */
  10831. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10832. /**
  10833. * Creates a RGB texture from some data.
  10834. * @param data Define the texture data
  10835. * @param width Define the width of the texture
  10836. * @param height Define the height of the texture
  10837. * @param scene Define the scene the texture belongs to
  10838. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10839. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10840. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10841. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10842. * @returns the RGB alpha texture
  10843. */
  10844. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10845. /**
  10846. * Creates a RGBA texture from some data.
  10847. * @param data Define the texture data
  10848. * @param width Define the width of the texture
  10849. * @param height Define the height of the texture
  10850. * @param scene Define the scene the texture belongs to
  10851. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10855. * @returns the RGBA texture
  10856. */
  10857. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10858. /**
  10859. * Creates a R texture from some data.
  10860. * @param data Define the texture data
  10861. * @param width Define the width of the texture
  10862. * @param height Define the height of the texture
  10863. * @param scene Define the scene the texture belongs to
  10864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10867. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10868. * @returns the R texture
  10869. */
  10870. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10871. }
  10872. }
  10873. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10874. import { Scene } from "babylonjs/scene";
  10875. import { ISceneComponent } from "babylonjs/sceneComponent";
  10876. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10877. module "babylonjs/abstractScene" {
  10878. interface AbstractScene {
  10879. /**
  10880. * The list of procedural textures added to the scene
  10881. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10882. */
  10883. proceduralTextures: Array<ProceduralTexture>;
  10884. }
  10885. }
  10886. /**
  10887. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10888. * in a given scene.
  10889. */
  10890. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10891. /**
  10892. * The component name helpfull to identify the component in the list of scene components.
  10893. */
  10894. readonly name: string;
  10895. /**
  10896. * The scene the component belongs to.
  10897. */
  10898. scene: Scene;
  10899. /**
  10900. * Creates a new instance of the component for the given scene
  10901. * @param scene Defines the scene to register the component in
  10902. */
  10903. constructor(scene: Scene);
  10904. /**
  10905. * Registers the component in a given scene
  10906. */
  10907. register(): void;
  10908. /**
  10909. * Rebuilds the elements related to this component in case of
  10910. * context lost for instance.
  10911. */
  10912. rebuild(): void;
  10913. /**
  10914. * Disposes the component and the associated ressources.
  10915. */
  10916. dispose(): void;
  10917. private _beforeClear;
  10918. }
  10919. }
  10920. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10921. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10922. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10923. module "babylonjs/Engines/thinEngine" {
  10924. interface ThinEngine {
  10925. /**
  10926. * Creates a new render target cube texture
  10927. * @param size defines the size of the texture
  10928. * @param options defines the options used to create the texture
  10929. * @returns a new render target cube texture stored in an InternalTexture
  10930. */
  10931. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10932. }
  10933. }
  10934. }
  10935. declare module "babylonjs/Shaders/procedural.vertex" {
  10936. /** @hidden */
  10937. export var proceduralVertexShader: {
  10938. name: string;
  10939. shader: string;
  10940. };
  10941. }
  10942. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10943. import { Observable } from "babylonjs/Misc/observable";
  10944. import { Nullable } from "babylonjs/types";
  10945. import { Scene } from "babylonjs/scene";
  10946. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10947. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10948. import { Effect } from "babylonjs/Materials/effect";
  10949. import { Texture } from "babylonjs/Materials/Textures/texture";
  10950. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10951. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10952. import "babylonjs/Shaders/procedural.vertex";
  10953. /**
  10954. * 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.
  10955. * This is the base class of any Procedural texture and contains most of the shareable code.
  10956. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10957. */
  10958. export class ProceduralTexture extends Texture {
  10959. isCube: boolean;
  10960. /**
  10961. * Define if the texture is enabled or not (disabled texture will not render)
  10962. */
  10963. isEnabled: boolean;
  10964. /**
  10965. * Define if the texture must be cleared before rendering (default is true)
  10966. */
  10967. autoClear: boolean;
  10968. /**
  10969. * Callback called when the texture is generated
  10970. */
  10971. onGenerated: () => void;
  10972. /**
  10973. * Event raised when the texture is generated
  10974. */
  10975. onGeneratedObservable: Observable<ProceduralTexture>;
  10976. /** @hidden */
  10977. _generateMipMaps: boolean;
  10978. /** @hidden **/
  10979. _effect: Effect;
  10980. /** @hidden */
  10981. _textures: {
  10982. [key: string]: Texture;
  10983. };
  10984. private _size;
  10985. private _currentRefreshId;
  10986. private _frameId;
  10987. private _refreshRate;
  10988. private _vertexBuffers;
  10989. private _indexBuffer;
  10990. private _uniforms;
  10991. private _samplers;
  10992. private _fragment;
  10993. private _floats;
  10994. private _ints;
  10995. private _floatsArrays;
  10996. private _colors3;
  10997. private _colors4;
  10998. private _vectors2;
  10999. private _vectors3;
  11000. private _matrices;
  11001. private _fallbackTexture;
  11002. private _fallbackTextureUsed;
  11003. private _engine;
  11004. private _cachedDefines;
  11005. private _contentUpdateId;
  11006. private _contentData;
  11007. /**
  11008. * Instantiates a new procedural texture.
  11009. * 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.
  11010. * This is the base class of any Procedural texture and contains most of the shareable code.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11012. * @param name Define the name of the texture
  11013. * @param size Define the size of the texture to create
  11014. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11015. * @param scene Define the scene the texture belongs to
  11016. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11017. * @param generateMipMaps Define if the texture should creates mip maps or not
  11018. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11019. */
  11020. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11021. /**
  11022. * The effect that is created when initializing the post process.
  11023. * @returns The created effect corresponding the the postprocess.
  11024. */
  11025. getEffect(): Effect;
  11026. /**
  11027. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11028. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11029. */
  11030. getContent(): Nullable<ArrayBufferView>;
  11031. private _createIndexBuffer;
  11032. /** @hidden */
  11033. _rebuild(): void;
  11034. /**
  11035. * Resets the texture in order to recreate its associated resources.
  11036. * This can be called in case of context loss
  11037. */
  11038. reset(): void;
  11039. protected _getDefines(): string;
  11040. /**
  11041. * Is the texture ready to be used ? (rendered at least once)
  11042. * @returns true if ready, otherwise, false.
  11043. */
  11044. isReady(): boolean;
  11045. /**
  11046. * Resets the refresh counter of the texture and start bak from scratch.
  11047. * Could be useful to regenerate the texture if it is setup to render only once.
  11048. */
  11049. resetRefreshCounter(): void;
  11050. /**
  11051. * Set the fragment shader to use in order to render the texture.
  11052. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11053. */
  11054. setFragment(fragment: any): void;
  11055. /**
  11056. * Define the refresh rate of the texture or the rendering frequency.
  11057. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11058. */
  11059. get refreshRate(): number;
  11060. set refreshRate(value: number);
  11061. /** @hidden */
  11062. _shouldRender(): boolean;
  11063. /**
  11064. * Get the size the texture is rendering at.
  11065. * @returns the size (texture is always squared)
  11066. */
  11067. getRenderSize(): number;
  11068. /**
  11069. * Resize the texture to new value.
  11070. * @param size Define the new size the texture should have
  11071. * @param generateMipMaps Define whether the new texture should create mip maps
  11072. */
  11073. resize(size: number, generateMipMaps: boolean): void;
  11074. private _checkUniform;
  11075. /**
  11076. * Set a texture in the shader program used to render.
  11077. * @param name Define the name of the uniform samplers as defined in the shader
  11078. * @param texture Define the texture to bind to this sampler
  11079. * @return the texture itself allowing "fluent" like uniform updates
  11080. */
  11081. setTexture(name: string, texture: Texture): ProceduralTexture;
  11082. /**
  11083. * Set a float in the shader.
  11084. * @param name Define the name of the uniform as defined in the shader
  11085. * @param value Define the value to give to the uniform
  11086. * @return the texture itself allowing "fluent" like uniform updates
  11087. */
  11088. setFloat(name: string, value: number): ProceduralTexture;
  11089. /**
  11090. * Set a int in the shader.
  11091. * @param name Define the name of the uniform as defined in the shader
  11092. * @param value Define the value to give to the uniform
  11093. * @return the texture itself allowing "fluent" like uniform updates
  11094. */
  11095. setInt(name: string, value: number): ProceduralTexture;
  11096. /**
  11097. * Set an array of floats in the shader.
  11098. * @param name Define the name of the uniform as defined in the shader
  11099. * @param value Define the value to give to the uniform
  11100. * @return the texture itself allowing "fluent" like uniform updates
  11101. */
  11102. setFloats(name: string, value: number[]): ProceduralTexture;
  11103. /**
  11104. * Set a vec3 in the shader from a Color3.
  11105. * @param name Define the name of the uniform as defined in the shader
  11106. * @param value Define the value to give to the uniform
  11107. * @return the texture itself allowing "fluent" like uniform updates
  11108. */
  11109. setColor3(name: string, value: Color3): ProceduralTexture;
  11110. /**
  11111. * Set a vec4 in the shader from a Color4.
  11112. * @param name Define the name of the uniform as defined in the shader
  11113. * @param value Define the value to give to the uniform
  11114. * @return the texture itself allowing "fluent" like uniform updates
  11115. */
  11116. setColor4(name: string, value: Color4): ProceduralTexture;
  11117. /**
  11118. * Set a vec2 in the shader from a Vector2.
  11119. * @param name Define the name of the uniform as defined in the shader
  11120. * @param value Define the value to give to the uniform
  11121. * @return the texture itself allowing "fluent" like uniform updates
  11122. */
  11123. setVector2(name: string, value: Vector2): ProceduralTexture;
  11124. /**
  11125. * Set a vec3 in the shader from a Vector3.
  11126. * @param name Define the name of the uniform as defined in the shader
  11127. * @param value Define the value to give to the uniform
  11128. * @return the texture itself allowing "fluent" like uniform updates
  11129. */
  11130. setVector3(name: string, value: Vector3): ProceduralTexture;
  11131. /**
  11132. * Set a mat4 in the shader from a MAtrix.
  11133. * @param name Define the name of the uniform as defined in the shader
  11134. * @param value Define the value to give to the uniform
  11135. * @return the texture itself allowing "fluent" like uniform updates
  11136. */
  11137. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11138. /**
  11139. * Render the texture to its associated render target.
  11140. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11141. */
  11142. render(useCameraPostProcess?: boolean): void;
  11143. /**
  11144. * Clone the texture.
  11145. * @returns the cloned texture
  11146. */
  11147. clone(): ProceduralTexture;
  11148. /**
  11149. * Dispose the texture and release its asoociated resources.
  11150. */
  11151. dispose(): void;
  11152. }
  11153. }
  11154. declare module "babylonjs/Particles/baseParticleSystem" {
  11155. import { Nullable } from "babylonjs/types";
  11156. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11158. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11159. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11160. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11161. import { Scene } from "babylonjs/scene";
  11162. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11163. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11164. import { Texture } from "babylonjs/Materials/Textures/texture";
  11165. import { Color4 } from "babylonjs/Maths/math.color";
  11166. import { Animation } from "babylonjs/Animations/animation";
  11167. /**
  11168. * This represents the base class for particle system in Babylon.
  11169. * 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.
  11170. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11171. * @example https://doc.babylonjs.com/babylon101/particles
  11172. */
  11173. export class BaseParticleSystem {
  11174. /**
  11175. * Source color is added to the destination color without alpha affecting the result
  11176. */
  11177. static BLENDMODE_ONEONE: number;
  11178. /**
  11179. * Blend current color and particle color using particle’s alpha
  11180. */
  11181. static BLENDMODE_STANDARD: number;
  11182. /**
  11183. * Add current color and particle color multiplied by particle’s alpha
  11184. */
  11185. static BLENDMODE_ADD: number;
  11186. /**
  11187. * Multiply current color with particle color
  11188. */
  11189. static BLENDMODE_MULTIPLY: number;
  11190. /**
  11191. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11192. */
  11193. static BLENDMODE_MULTIPLYADD: number;
  11194. /**
  11195. * List of animations used by the particle system.
  11196. */
  11197. animations: Animation[];
  11198. /**
  11199. * The id of the Particle system.
  11200. */
  11201. id: string;
  11202. /**
  11203. * The friendly name of the Particle system.
  11204. */
  11205. name: string;
  11206. /**
  11207. * The rendering group used by the Particle system to chose when to render.
  11208. */
  11209. renderingGroupId: number;
  11210. /**
  11211. * The emitter represents the Mesh or position we are attaching the particle system to.
  11212. */
  11213. emitter: Nullable<AbstractMesh | Vector3>;
  11214. /**
  11215. * The maximum number of particles to emit per frame
  11216. */
  11217. emitRate: number;
  11218. /**
  11219. * If you want to launch only a few particles at once, that can be done, as well.
  11220. */
  11221. manualEmitCount: number;
  11222. /**
  11223. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11224. */
  11225. updateSpeed: number;
  11226. /**
  11227. * The amount of time the particle system is running (depends of the overall update speed).
  11228. */
  11229. targetStopDuration: number;
  11230. /**
  11231. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11232. */
  11233. disposeOnStop: boolean;
  11234. /**
  11235. * Minimum power of emitting particles.
  11236. */
  11237. minEmitPower: number;
  11238. /**
  11239. * Maximum power of emitting particles.
  11240. */
  11241. maxEmitPower: number;
  11242. /**
  11243. * Minimum life time of emitting particles.
  11244. */
  11245. minLifeTime: number;
  11246. /**
  11247. * Maximum life time of emitting particles.
  11248. */
  11249. maxLifeTime: number;
  11250. /**
  11251. * Minimum Size of emitting particles.
  11252. */
  11253. minSize: number;
  11254. /**
  11255. * Maximum Size of emitting particles.
  11256. */
  11257. maxSize: number;
  11258. /**
  11259. * Minimum scale of emitting particles on X axis.
  11260. */
  11261. minScaleX: number;
  11262. /**
  11263. * Maximum scale of emitting particles on X axis.
  11264. */
  11265. maxScaleX: number;
  11266. /**
  11267. * Minimum scale of emitting particles on Y axis.
  11268. */
  11269. minScaleY: number;
  11270. /**
  11271. * Maximum scale of emitting particles on Y axis.
  11272. */
  11273. maxScaleY: number;
  11274. /**
  11275. * Gets or sets the minimal initial rotation in radians.
  11276. */
  11277. minInitialRotation: number;
  11278. /**
  11279. * Gets or sets the maximal initial rotation in radians.
  11280. */
  11281. maxInitialRotation: number;
  11282. /**
  11283. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11284. */
  11285. minAngularSpeed: number;
  11286. /**
  11287. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11288. */
  11289. maxAngularSpeed: number;
  11290. /**
  11291. * The texture used to render each particle. (this can be a spritesheet)
  11292. */
  11293. particleTexture: Nullable<Texture>;
  11294. /**
  11295. * The layer mask we are rendering the particles through.
  11296. */
  11297. layerMask: number;
  11298. /**
  11299. * This can help using your own shader to render the particle system.
  11300. * The according effect will be created
  11301. */
  11302. customShader: any;
  11303. /**
  11304. * By default particle system starts as soon as they are created. This prevents the
  11305. * automatic start to happen and let you decide when to start emitting particles.
  11306. */
  11307. preventAutoStart: boolean;
  11308. private _noiseTexture;
  11309. /**
  11310. * Gets or sets a texture used to add random noise to particle positions
  11311. */
  11312. get noiseTexture(): Nullable<ProceduralTexture>;
  11313. set noiseTexture(value: Nullable<ProceduralTexture>);
  11314. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11315. noiseStrength: Vector3;
  11316. /**
  11317. * Callback triggered when the particle animation is ending.
  11318. */
  11319. onAnimationEnd: Nullable<() => void>;
  11320. /**
  11321. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11322. */
  11323. blendMode: number;
  11324. /**
  11325. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11326. * to override the particles.
  11327. */
  11328. forceDepthWrite: boolean;
  11329. /** 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 */
  11330. preWarmCycles: number;
  11331. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11332. preWarmStepOffset: number;
  11333. /**
  11334. * 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)
  11335. */
  11336. spriteCellChangeSpeed: number;
  11337. /**
  11338. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11339. */
  11340. startSpriteCellID: number;
  11341. /**
  11342. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11343. */
  11344. endSpriteCellID: number;
  11345. /**
  11346. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11347. */
  11348. spriteCellWidth: number;
  11349. /**
  11350. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11351. */
  11352. spriteCellHeight: number;
  11353. /**
  11354. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11355. */
  11356. spriteRandomStartCell: boolean;
  11357. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11358. translationPivot: Vector2;
  11359. /** @hidden */
  11360. protected _isAnimationSheetEnabled: boolean;
  11361. /**
  11362. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11363. */
  11364. beginAnimationOnStart: boolean;
  11365. /**
  11366. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11367. */
  11368. beginAnimationFrom: number;
  11369. /**
  11370. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11371. */
  11372. beginAnimationTo: number;
  11373. /**
  11374. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11375. */
  11376. beginAnimationLoop: boolean;
  11377. /**
  11378. * Gets or sets a world offset applied to all particles
  11379. */
  11380. worldOffset: Vector3;
  11381. /**
  11382. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11383. */
  11384. get isAnimationSheetEnabled(): boolean;
  11385. set isAnimationSheetEnabled(value: boolean);
  11386. /**
  11387. * Get hosting scene
  11388. * @returns the scene
  11389. */
  11390. getScene(): Scene;
  11391. /**
  11392. * You can use gravity if you want to give an orientation to your particles.
  11393. */
  11394. gravity: Vector3;
  11395. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11396. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11397. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11399. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11400. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11401. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11402. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11403. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11404. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11405. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11406. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11407. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11408. /**
  11409. * Defines the delay in milliseconds before starting the system (0 by default)
  11410. */
  11411. startDelay: number;
  11412. /**
  11413. * Gets the current list of drag gradients.
  11414. * You must use addDragGradient and removeDragGradient to udpate this list
  11415. * @returns the list of drag gradients
  11416. */
  11417. getDragGradients(): Nullable<Array<FactorGradient>>;
  11418. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11419. limitVelocityDamping: number;
  11420. /**
  11421. * Gets the current list of limit velocity gradients.
  11422. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11423. * @returns the list of limit velocity gradients
  11424. */
  11425. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11426. /**
  11427. * Gets the current list of color gradients.
  11428. * You must use addColorGradient and removeColorGradient to udpate this list
  11429. * @returns the list of color gradients
  11430. */
  11431. getColorGradients(): Nullable<Array<ColorGradient>>;
  11432. /**
  11433. * Gets the current list of size gradients.
  11434. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11435. * @returns the list of size gradients
  11436. */
  11437. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11438. /**
  11439. * Gets the current list of color remap gradients.
  11440. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11441. * @returns the list of color remap gradients
  11442. */
  11443. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11444. /**
  11445. * Gets the current list of alpha remap gradients.
  11446. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11447. * @returns the list of alpha remap gradients
  11448. */
  11449. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11450. /**
  11451. * Gets the current list of life time gradients.
  11452. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11453. * @returns the list of life time gradients
  11454. */
  11455. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11456. /**
  11457. * Gets the current list of angular speed gradients.
  11458. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11459. * @returns the list of angular speed gradients
  11460. */
  11461. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11462. /**
  11463. * Gets the current list of velocity gradients.
  11464. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11465. * @returns the list of velocity gradients
  11466. */
  11467. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11468. /**
  11469. * Gets the current list of start size gradients.
  11470. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11471. * @returns the list of start size gradients
  11472. */
  11473. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11474. /**
  11475. * Gets the current list of emit rate gradients.
  11476. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11477. * @returns the list of emit rate gradients
  11478. */
  11479. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11480. /**
  11481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11483. */
  11484. get direction1(): Vector3;
  11485. set direction1(value: Vector3);
  11486. /**
  11487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11489. */
  11490. get direction2(): Vector3;
  11491. set direction2(value: Vector3);
  11492. /**
  11493. * 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.
  11494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11495. */
  11496. get minEmitBox(): Vector3;
  11497. set minEmitBox(value: Vector3);
  11498. /**
  11499. * 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.
  11500. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11501. */
  11502. get maxEmitBox(): Vector3;
  11503. set maxEmitBox(value: Vector3);
  11504. /**
  11505. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11506. */
  11507. color1: Color4;
  11508. /**
  11509. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11510. */
  11511. color2: Color4;
  11512. /**
  11513. * Color the particle will have at the end of its lifetime
  11514. */
  11515. colorDead: Color4;
  11516. /**
  11517. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11518. */
  11519. textureMask: Color4;
  11520. /**
  11521. * The particle emitter type defines the emitter used by the particle system.
  11522. * It can be for example box, sphere, or cone...
  11523. */
  11524. particleEmitterType: IParticleEmitterType;
  11525. /** @hidden */
  11526. _isSubEmitter: boolean;
  11527. /**
  11528. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11529. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11530. */
  11531. billboardMode: number;
  11532. protected _isBillboardBased: boolean;
  11533. /**
  11534. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11535. */
  11536. get isBillboardBased(): boolean;
  11537. set isBillboardBased(value: boolean);
  11538. /**
  11539. * The scene the particle system belongs to.
  11540. */
  11541. protected _scene: Scene;
  11542. /**
  11543. * Local cache of defines for image processing.
  11544. */
  11545. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11546. /**
  11547. * Default configuration related to image processing available in the standard Material.
  11548. */
  11549. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11550. /**
  11551. * Gets the image processing configuration used either in this material.
  11552. */
  11553. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11554. /**
  11555. * Sets the Default image processing configuration used either in the this material.
  11556. *
  11557. * If sets to null, the scene one is in use.
  11558. */
  11559. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11560. /**
  11561. * Attaches a new image processing configuration to the Standard Material.
  11562. * @param configuration
  11563. */
  11564. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11565. /** @hidden */
  11566. protected _reset(): void;
  11567. /** @hidden */
  11568. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11569. /**
  11570. * Instantiates a particle system.
  11571. * 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.
  11572. * @param name The name of the particle system
  11573. */
  11574. constructor(name: string);
  11575. /**
  11576. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11579. * @returns the emitter
  11580. */
  11581. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11582. /**
  11583. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11584. * @param radius The radius of the hemisphere to emit from
  11585. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11586. * @returns the emitter
  11587. */
  11588. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11589. /**
  11590. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11591. * @param radius The radius of the sphere to emit from
  11592. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11593. * @returns the emitter
  11594. */
  11595. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11596. /**
  11597. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11598. * @param radius The radius of the sphere to emit from
  11599. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11600. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11601. * @returns the emitter
  11602. */
  11603. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11604. /**
  11605. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11606. * @param radius The radius of the emission cylinder
  11607. * @param height The height of the emission cylinder
  11608. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11609. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11610. * @returns the emitter
  11611. */
  11612. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11613. /**
  11614. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11615. * @param radius The radius of the cylinder to emit from
  11616. * @param height The height of the emission cylinder
  11617. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11618. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11619. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11620. * @returns the emitter
  11621. */
  11622. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11623. /**
  11624. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11625. * @param radius The radius of the cone to emit from
  11626. * @param angle The base angle of the cone
  11627. * @returns the emitter
  11628. */
  11629. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11630. /**
  11631. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11634. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11635. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11636. * @returns the emitter
  11637. */
  11638. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11639. }
  11640. }
  11641. declare module "babylonjs/Particles/subEmitter" {
  11642. import { Scene } from "babylonjs/scene";
  11643. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11644. /**
  11645. * Type of sub emitter
  11646. */
  11647. export enum SubEmitterType {
  11648. /**
  11649. * Attached to the particle over it's lifetime
  11650. */
  11651. ATTACHED = 0,
  11652. /**
  11653. * Created when the particle dies
  11654. */
  11655. END = 1
  11656. }
  11657. /**
  11658. * Sub emitter class used to emit particles from an existing particle
  11659. */
  11660. export class SubEmitter {
  11661. /**
  11662. * the particle system to be used by the sub emitter
  11663. */
  11664. particleSystem: ParticleSystem;
  11665. /**
  11666. * Type of the submitter (Default: END)
  11667. */
  11668. type: SubEmitterType;
  11669. /**
  11670. * 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)
  11671. * Note: This only is supported when using an emitter of type Mesh
  11672. */
  11673. inheritDirection: boolean;
  11674. /**
  11675. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11676. */
  11677. inheritedVelocityAmount: number;
  11678. /**
  11679. * Creates a sub emitter
  11680. * @param particleSystem the particle system to be used by the sub emitter
  11681. */
  11682. constructor(
  11683. /**
  11684. * the particle system to be used by the sub emitter
  11685. */
  11686. particleSystem: ParticleSystem);
  11687. /**
  11688. * Clones the sub emitter
  11689. * @returns the cloned sub emitter
  11690. */
  11691. clone(): SubEmitter;
  11692. /**
  11693. * Serialize current object to a JSON object
  11694. * @returns the serialized object
  11695. */
  11696. serialize(): any;
  11697. /** @hidden */
  11698. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11699. /**
  11700. * Creates a new SubEmitter from a serialized JSON version
  11701. * @param serializationObject defines the JSON object to read from
  11702. * @param scene defines the hosting scene
  11703. * @param rootUrl defines the rootUrl for data loading
  11704. * @returns a new SubEmitter
  11705. */
  11706. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11707. /** Release associated resources */
  11708. dispose(): void;
  11709. }
  11710. }
  11711. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11712. /** @hidden */
  11713. export var imageProcessingDeclaration: {
  11714. name: string;
  11715. shader: string;
  11716. };
  11717. }
  11718. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11719. /** @hidden */
  11720. export var imageProcessingFunctions: {
  11721. name: string;
  11722. shader: string;
  11723. };
  11724. }
  11725. declare module "babylonjs/Shaders/particles.fragment" {
  11726. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11727. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11728. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11729. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11730. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11731. /** @hidden */
  11732. export var particlesPixelShader: {
  11733. name: string;
  11734. shader: string;
  11735. };
  11736. }
  11737. declare module "babylonjs/Shaders/particles.vertex" {
  11738. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11739. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11740. /** @hidden */
  11741. export var particlesVertexShader: {
  11742. name: string;
  11743. shader: string;
  11744. };
  11745. }
  11746. declare module "babylonjs/Particles/particleSystem" {
  11747. import { Nullable } from "babylonjs/types";
  11748. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11749. import { Observable } from "babylonjs/Misc/observable";
  11750. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11751. import { Effect } from "babylonjs/Materials/effect";
  11752. import { Scene, IDisposable } from "babylonjs/scene";
  11753. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11754. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11755. import { Particle } from "babylonjs/Particles/particle";
  11756. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11757. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11758. import "babylonjs/Shaders/particles.fragment";
  11759. import "babylonjs/Shaders/particles.vertex";
  11760. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11761. /**
  11762. * This represents a particle system in Babylon.
  11763. * 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.
  11764. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11765. * @example https://doc.babylonjs.com/babylon101/particles
  11766. */
  11767. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11768. /**
  11769. * Billboard mode will only apply to Y axis
  11770. */
  11771. static readonly BILLBOARDMODE_Y: number;
  11772. /**
  11773. * Billboard mode will apply to all axes
  11774. */
  11775. static readonly BILLBOARDMODE_ALL: number;
  11776. /**
  11777. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11778. */
  11779. static readonly BILLBOARDMODE_STRETCHED: number;
  11780. /**
  11781. * This function can be defined to provide custom update for active particles.
  11782. * This function will be called instead of regular update (age, position, color, etc.).
  11783. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11784. */
  11785. updateFunction: (particles: Particle[]) => void;
  11786. private _emitterWorldMatrix;
  11787. /**
  11788. * This function can be defined to specify initial direction for every new particle.
  11789. * It by default use the emitterType defined function
  11790. */
  11791. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11792. /**
  11793. * This function can be defined to specify initial position for every new particle.
  11794. * It by default use the emitterType defined function
  11795. */
  11796. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11797. /**
  11798. * @hidden
  11799. */
  11800. _inheritedVelocityOffset: Vector3;
  11801. /**
  11802. * An event triggered when the system is disposed
  11803. */
  11804. onDisposeObservable: Observable<ParticleSystem>;
  11805. private _onDisposeObserver;
  11806. /**
  11807. * Sets a callback that will be triggered when the system is disposed
  11808. */
  11809. set onDispose(callback: () => void);
  11810. private _particles;
  11811. private _epsilon;
  11812. private _capacity;
  11813. private _stockParticles;
  11814. private _newPartsExcess;
  11815. private _vertexData;
  11816. private _vertexBuffer;
  11817. private _vertexBuffers;
  11818. private _spriteBuffer;
  11819. private _indexBuffer;
  11820. private _effect;
  11821. private _customEffect;
  11822. private _cachedDefines;
  11823. private _scaledColorStep;
  11824. private _colorDiff;
  11825. private _scaledDirection;
  11826. private _scaledGravity;
  11827. private _currentRenderId;
  11828. private _alive;
  11829. private _useInstancing;
  11830. private _started;
  11831. private _stopped;
  11832. private _actualFrame;
  11833. private _scaledUpdateSpeed;
  11834. private _vertexBufferSize;
  11835. /** @hidden */
  11836. _currentEmitRateGradient: Nullable<FactorGradient>;
  11837. /** @hidden */
  11838. _currentEmitRate1: number;
  11839. /** @hidden */
  11840. _currentEmitRate2: number;
  11841. /** @hidden */
  11842. _currentStartSizeGradient: Nullable<FactorGradient>;
  11843. /** @hidden */
  11844. _currentStartSize1: number;
  11845. /** @hidden */
  11846. _currentStartSize2: number;
  11847. private readonly _rawTextureWidth;
  11848. private _rampGradientsTexture;
  11849. private _useRampGradients;
  11850. /** Gets or sets a boolean indicating that ramp gradients must be used
  11851. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11852. */
  11853. get useRampGradients(): boolean;
  11854. set useRampGradients(value: boolean);
  11855. /**
  11856. * 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.
  11857. * 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: [])
  11858. */
  11859. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11860. private _subEmitters;
  11861. /**
  11862. * @hidden
  11863. * If the particle systems emitter should be disposed when the particle system is disposed
  11864. */
  11865. _disposeEmitterOnDispose: boolean;
  11866. /**
  11867. * The current active Sub-systems, this property is used by the root particle system only.
  11868. */
  11869. activeSubSystems: Array<ParticleSystem>;
  11870. /**
  11871. * Specifies if the particles are updated in emitter local space or world space
  11872. */
  11873. isLocal: boolean;
  11874. private _rootParticleSystem;
  11875. /**
  11876. * Gets the current list of active particles
  11877. */
  11878. get particles(): Particle[];
  11879. /**
  11880. * Returns the string "ParticleSystem"
  11881. * @returns a string containing the class name
  11882. */
  11883. getClassName(): string;
  11884. /**
  11885. * Instantiates a particle system.
  11886. * 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.
  11887. * @param name The name of the particle system
  11888. * @param capacity The max number of particles alive at the same time
  11889. * @param scene The scene the particle system belongs to
  11890. * @param customEffect a custom effect used to change the way particles are rendered by default
  11891. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11892. * @param epsilon Offset used to render the particles
  11893. */
  11894. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11895. private _addFactorGradient;
  11896. private _removeFactorGradient;
  11897. /**
  11898. * Adds a new life time gradient
  11899. * @param gradient defines the gradient to use (between 0 and 1)
  11900. * @param factor defines the life time factor to affect to the specified gradient
  11901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11902. * @returns the current particle system
  11903. */
  11904. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11905. /**
  11906. * Remove a specific life time gradient
  11907. * @param gradient defines the gradient to remove
  11908. * @returns the current particle system
  11909. */
  11910. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11911. /**
  11912. * Adds a new size gradient
  11913. * @param gradient defines the gradient to use (between 0 and 1)
  11914. * @param factor defines the size factor to affect to the specified gradient
  11915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11916. * @returns the current particle system
  11917. */
  11918. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11919. /**
  11920. * Remove a specific size gradient
  11921. * @param gradient defines the gradient to remove
  11922. * @returns the current particle system
  11923. */
  11924. removeSizeGradient(gradient: number): IParticleSystem;
  11925. /**
  11926. * Adds a new color remap gradient
  11927. * @param gradient defines the gradient to use (between 0 and 1)
  11928. * @param min defines the color remap minimal range
  11929. * @param max defines the color remap maximal range
  11930. * @returns the current particle system
  11931. */
  11932. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11933. /**
  11934. * Remove a specific color remap gradient
  11935. * @param gradient defines the gradient to remove
  11936. * @returns the current particle system
  11937. */
  11938. removeColorRemapGradient(gradient: number): IParticleSystem;
  11939. /**
  11940. * Adds a new alpha remap gradient
  11941. * @param gradient defines the gradient to use (between 0 and 1)
  11942. * @param min defines the alpha remap minimal range
  11943. * @param max defines the alpha remap maximal range
  11944. * @returns the current particle system
  11945. */
  11946. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11947. /**
  11948. * Remove a specific alpha remap gradient
  11949. * @param gradient defines the gradient to remove
  11950. * @returns the current particle system
  11951. */
  11952. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11953. /**
  11954. * Adds a new angular speed gradient
  11955. * @param gradient defines the gradient to use (between 0 and 1)
  11956. * @param factor defines the angular speed to affect to the specified gradient
  11957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11958. * @returns the current particle system
  11959. */
  11960. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11961. /**
  11962. * Remove a specific angular speed gradient
  11963. * @param gradient defines the gradient to remove
  11964. * @returns the current particle system
  11965. */
  11966. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11967. /**
  11968. * Adds a new velocity gradient
  11969. * @param gradient defines the gradient to use (between 0 and 1)
  11970. * @param factor defines the velocity to affect to the specified gradient
  11971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11972. * @returns the current particle system
  11973. */
  11974. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11975. /**
  11976. * Remove a specific velocity gradient
  11977. * @param gradient defines the gradient to remove
  11978. * @returns the current particle system
  11979. */
  11980. removeVelocityGradient(gradient: number): IParticleSystem;
  11981. /**
  11982. * Adds a new limit velocity gradient
  11983. * @param gradient defines the gradient to use (between 0 and 1)
  11984. * @param factor defines the limit velocity value to affect to the specified gradient
  11985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11986. * @returns the current particle system
  11987. */
  11988. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11989. /**
  11990. * Remove a specific limit velocity gradient
  11991. * @param gradient defines the gradient to remove
  11992. * @returns the current particle system
  11993. */
  11994. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11995. /**
  11996. * Adds a new drag gradient
  11997. * @param gradient defines the gradient to use (between 0 and 1)
  11998. * @param factor defines the drag value to affect to the specified gradient
  11999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12000. * @returns the current particle system
  12001. */
  12002. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12003. /**
  12004. * Remove a specific drag gradient
  12005. * @param gradient defines the gradient to remove
  12006. * @returns the current particle system
  12007. */
  12008. removeDragGradient(gradient: number): IParticleSystem;
  12009. /**
  12010. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12011. * @param gradient defines the gradient to use (between 0 and 1)
  12012. * @param factor defines the emit rate value to affect to the specified gradient
  12013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12014. * @returns the current particle system
  12015. */
  12016. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12017. /**
  12018. * Remove a specific emit rate gradient
  12019. * @param gradient defines the gradient to remove
  12020. * @returns the current particle system
  12021. */
  12022. removeEmitRateGradient(gradient: number): IParticleSystem;
  12023. /**
  12024. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12025. * @param gradient defines the gradient to use (between 0 and 1)
  12026. * @param factor defines the start size value to affect to the specified gradient
  12027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12028. * @returns the current particle system
  12029. */
  12030. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12031. /**
  12032. * Remove a specific start size gradient
  12033. * @param gradient defines the gradient to remove
  12034. * @returns the current particle system
  12035. */
  12036. removeStartSizeGradient(gradient: number): IParticleSystem;
  12037. private _createRampGradientTexture;
  12038. /**
  12039. * Gets the current list of ramp gradients.
  12040. * You must use addRampGradient and removeRampGradient to udpate this list
  12041. * @returns the list of ramp gradients
  12042. */
  12043. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12044. /**
  12045. * Adds a new ramp gradient used to remap particle colors
  12046. * @param gradient defines the gradient to use (between 0 and 1)
  12047. * @param color defines the color to affect to the specified gradient
  12048. * @returns the current particle system
  12049. */
  12050. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12051. /**
  12052. * Remove a specific ramp gradient
  12053. * @param gradient defines the gradient to remove
  12054. * @returns the current particle system
  12055. */
  12056. removeRampGradient(gradient: number): ParticleSystem;
  12057. /**
  12058. * Adds a new color gradient
  12059. * @param gradient defines the gradient to use (between 0 and 1)
  12060. * @param color1 defines the color to affect to the specified gradient
  12061. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12062. * @returns this particle system
  12063. */
  12064. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12065. /**
  12066. * Remove a specific color gradient
  12067. * @param gradient defines the gradient to remove
  12068. * @returns this particle system
  12069. */
  12070. removeColorGradient(gradient: number): IParticleSystem;
  12071. private _fetchR;
  12072. protected _reset(): void;
  12073. private _resetEffect;
  12074. private _createVertexBuffers;
  12075. private _createIndexBuffer;
  12076. /**
  12077. * Gets the maximum number of particles active at the same time.
  12078. * @returns The max number of active particles.
  12079. */
  12080. getCapacity(): number;
  12081. /**
  12082. * Gets whether there are still active particles in the system.
  12083. * @returns True if it is alive, otherwise false.
  12084. */
  12085. isAlive(): boolean;
  12086. /**
  12087. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12088. * @returns True if it has been started, otherwise false.
  12089. */
  12090. isStarted(): boolean;
  12091. private _prepareSubEmitterInternalArray;
  12092. /**
  12093. * Starts the particle system and begins to emit
  12094. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12095. */
  12096. start(delay?: number): void;
  12097. /**
  12098. * Stops the particle system.
  12099. * @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.
  12100. */
  12101. stop(stopSubEmitters?: boolean): void;
  12102. /**
  12103. * Remove all active particles
  12104. */
  12105. reset(): void;
  12106. /**
  12107. * @hidden (for internal use only)
  12108. */
  12109. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12110. /**
  12111. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12112. * Its lifetime will start back at 0.
  12113. */
  12114. recycleParticle: (particle: Particle) => void;
  12115. private _stopSubEmitters;
  12116. private _createParticle;
  12117. private _removeFromRoot;
  12118. private _emitFromParticle;
  12119. private _update;
  12120. /** @hidden */
  12121. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12122. /** @hidden */
  12123. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12124. /** @hidden */
  12125. private _getEffect;
  12126. /**
  12127. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12128. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12129. */
  12130. animate(preWarmOnly?: boolean): void;
  12131. private _appendParticleVertices;
  12132. /**
  12133. * Rebuilds the particle system.
  12134. */
  12135. rebuild(): void;
  12136. /**
  12137. * Is this system ready to be used/rendered
  12138. * @return true if the system is ready
  12139. */
  12140. isReady(): boolean;
  12141. private _render;
  12142. /**
  12143. * Renders the particle system in its current state.
  12144. * @returns the current number of particles
  12145. */
  12146. render(): number;
  12147. /**
  12148. * Disposes the particle system and free the associated resources
  12149. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12150. */
  12151. dispose(disposeTexture?: boolean): void;
  12152. /**
  12153. * Clones the particle system.
  12154. * @param name The name of the cloned object
  12155. * @param newEmitter The new emitter to use
  12156. * @returns the cloned particle system
  12157. */
  12158. clone(name: string, newEmitter: any): ParticleSystem;
  12159. /**
  12160. * Serializes the particle system to a JSON object.
  12161. * @returns the JSON object
  12162. */
  12163. serialize(): any;
  12164. /** @hidden */
  12165. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12166. /** @hidden */
  12167. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12168. /**
  12169. * Parses a JSON object to create a particle system.
  12170. * @param parsedParticleSystem The JSON object to parse
  12171. * @param scene The scene to create the particle system in
  12172. * @param rootUrl The root url to use to load external dependencies like texture
  12173. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12174. * @returns the Parsed particle system
  12175. */
  12176. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12177. }
  12178. }
  12179. declare module "babylonjs/Particles/particle" {
  12180. import { Nullable } from "babylonjs/types";
  12181. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12182. import { Color4 } from "babylonjs/Maths/math.color";
  12183. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12184. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12185. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12186. /**
  12187. * A particle represents one of the element emitted by a particle system.
  12188. * This is mainly define by its coordinates, direction, velocity and age.
  12189. */
  12190. export class Particle {
  12191. /**
  12192. * The particle system the particle belongs to.
  12193. */
  12194. particleSystem: ParticleSystem;
  12195. private static _Count;
  12196. /**
  12197. * Unique ID of the particle
  12198. */
  12199. id: number;
  12200. /**
  12201. * The world position of the particle in the scene.
  12202. */
  12203. position: Vector3;
  12204. /**
  12205. * The world direction of the particle in the scene.
  12206. */
  12207. direction: Vector3;
  12208. /**
  12209. * The color of the particle.
  12210. */
  12211. color: Color4;
  12212. /**
  12213. * The color change of the particle per step.
  12214. */
  12215. colorStep: Color4;
  12216. /**
  12217. * Defines how long will the life of the particle be.
  12218. */
  12219. lifeTime: number;
  12220. /**
  12221. * The current age of the particle.
  12222. */
  12223. age: number;
  12224. /**
  12225. * The current size of the particle.
  12226. */
  12227. size: number;
  12228. /**
  12229. * The current scale of the particle.
  12230. */
  12231. scale: Vector2;
  12232. /**
  12233. * The current angle of the particle.
  12234. */
  12235. angle: number;
  12236. /**
  12237. * Defines how fast is the angle changing.
  12238. */
  12239. angularSpeed: number;
  12240. /**
  12241. * Defines the cell index used by the particle to be rendered from a sprite.
  12242. */
  12243. cellIndex: number;
  12244. /**
  12245. * The information required to support color remapping
  12246. */
  12247. remapData: Vector4;
  12248. /** @hidden */
  12249. _randomCellOffset?: number;
  12250. /** @hidden */
  12251. _initialDirection: Nullable<Vector3>;
  12252. /** @hidden */
  12253. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12254. /** @hidden */
  12255. _initialStartSpriteCellID: number;
  12256. /** @hidden */
  12257. _initialEndSpriteCellID: number;
  12258. /** @hidden */
  12259. _currentColorGradient: Nullable<ColorGradient>;
  12260. /** @hidden */
  12261. _currentColor1: Color4;
  12262. /** @hidden */
  12263. _currentColor2: Color4;
  12264. /** @hidden */
  12265. _currentSizeGradient: Nullable<FactorGradient>;
  12266. /** @hidden */
  12267. _currentSize1: number;
  12268. /** @hidden */
  12269. _currentSize2: number;
  12270. /** @hidden */
  12271. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12272. /** @hidden */
  12273. _currentAngularSpeed1: number;
  12274. /** @hidden */
  12275. _currentAngularSpeed2: number;
  12276. /** @hidden */
  12277. _currentVelocityGradient: Nullable<FactorGradient>;
  12278. /** @hidden */
  12279. _currentVelocity1: number;
  12280. /** @hidden */
  12281. _currentVelocity2: number;
  12282. /** @hidden */
  12283. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12284. /** @hidden */
  12285. _currentLimitVelocity1: number;
  12286. /** @hidden */
  12287. _currentLimitVelocity2: number;
  12288. /** @hidden */
  12289. _currentDragGradient: Nullable<FactorGradient>;
  12290. /** @hidden */
  12291. _currentDrag1: number;
  12292. /** @hidden */
  12293. _currentDrag2: number;
  12294. /** @hidden */
  12295. _randomNoiseCoordinates1: Vector3;
  12296. /** @hidden */
  12297. _randomNoiseCoordinates2: Vector3;
  12298. /** @hidden */
  12299. _localPosition?: Vector3;
  12300. /**
  12301. * Creates a new instance Particle
  12302. * @param particleSystem the particle system the particle belongs to
  12303. */
  12304. constructor(
  12305. /**
  12306. * The particle system the particle belongs to.
  12307. */
  12308. particleSystem: ParticleSystem);
  12309. private updateCellInfoFromSystem;
  12310. /**
  12311. * Defines how the sprite cell index is updated for the particle
  12312. */
  12313. updateCellIndex(): void;
  12314. /** @hidden */
  12315. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12316. /** @hidden */
  12317. _inheritParticleInfoToSubEmitters(): void;
  12318. /** @hidden */
  12319. _reset(): void;
  12320. /**
  12321. * Copy the properties of particle to another one.
  12322. * @param other the particle to copy the information to.
  12323. */
  12324. copyTo(other: Particle): void;
  12325. }
  12326. }
  12327. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12328. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12329. import { Effect } from "babylonjs/Materials/effect";
  12330. import { Particle } from "babylonjs/Particles/particle";
  12331. import { Scene } from "babylonjs/scene";
  12332. /**
  12333. * Particle emitter represents a volume emitting particles.
  12334. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12335. */
  12336. export interface IParticleEmitterType {
  12337. /**
  12338. * Called by the particle System when the direction is computed for the created particle.
  12339. * @param worldMatrix is the world matrix of the particle system
  12340. * @param directionToUpdate is the direction vector to update with the result
  12341. * @param particle is the particle we are computed the direction for
  12342. * @param isLocal defines if the direction should be set in local space
  12343. */
  12344. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12345. /**
  12346. * Called by the particle System when the position is computed for the created particle.
  12347. * @param worldMatrix is the world matrix of the particle system
  12348. * @param positionToUpdate is the position vector to update with the result
  12349. * @param particle is the particle we are computed the position for
  12350. * @param isLocal defines if the position should be set in local space
  12351. */
  12352. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12353. /**
  12354. * Clones the current emitter and returns a copy of it
  12355. * @returns the new emitter
  12356. */
  12357. clone(): IParticleEmitterType;
  12358. /**
  12359. * Called by the GPUParticleSystem to setup the update shader
  12360. * @param effect defines the update shader
  12361. */
  12362. applyToShader(effect: Effect): void;
  12363. /**
  12364. * Returns a string to use to update the GPU particles update shader
  12365. * @returns the effect defines string
  12366. */
  12367. getEffectDefines(): string;
  12368. /**
  12369. * Returns a string representing the class name
  12370. * @returns a string containing the class name
  12371. */
  12372. getClassName(): string;
  12373. /**
  12374. * Serializes the particle system to a JSON object.
  12375. * @returns the JSON object
  12376. */
  12377. serialize(): any;
  12378. /**
  12379. * Parse properties from a JSON object
  12380. * @param serializationObject defines the JSON object
  12381. * @param scene defines the hosting scene
  12382. */
  12383. parse(serializationObject: any, scene: Scene): void;
  12384. }
  12385. }
  12386. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12387. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12388. import { Effect } from "babylonjs/Materials/effect";
  12389. import { Particle } from "babylonjs/Particles/particle";
  12390. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12391. /**
  12392. * Particle emitter emitting particles from the inside of a box.
  12393. * It emits the particles randomly between 2 given directions.
  12394. */
  12395. export class BoxParticleEmitter implements IParticleEmitterType {
  12396. /**
  12397. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12398. */
  12399. direction1: Vector3;
  12400. /**
  12401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12402. */
  12403. direction2: Vector3;
  12404. /**
  12405. * 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.
  12406. */
  12407. minEmitBox: Vector3;
  12408. /**
  12409. * 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.
  12410. */
  12411. maxEmitBox: Vector3;
  12412. /**
  12413. * Creates a new instance BoxParticleEmitter
  12414. */
  12415. constructor();
  12416. /**
  12417. * Called by the particle System when the direction is computed for the created particle.
  12418. * @param worldMatrix is the world matrix of the particle system
  12419. * @param directionToUpdate is the direction vector to update with the result
  12420. * @param particle is the particle we are computed the direction for
  12421. * @param isLocal defines if the direction should be set in local space
  12422. */
  12423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12424. /**
  12425. * Called by the particle System when the position is computed for the created particle.
  12426. * @param worldMatrix is the world matrix of the particle system
  12427. * @param positionToUpdate is the position vector to update with the result
  12428. * @param particle is the particle we are computed the position for
  12429. * @param isLocal defines if the position should be set in local space
  12430. */
  12431. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12432. /**
  12433. * Clones the current emitter and returns a copy of it
  12434. * @returns the new emitter
  12435. */
  12436. clone(): BoxParticleEmitter;
  12437. /**
  12438. * Called by the GPUParticleSystem to setup the update shader
  12439. * @param effect defines the update shader
  12440. */
  12441. applyToShader(effect: Effect): void;
  12442. /**
  12443. * Returns a string to use to update the GPU particles update shader
  12444. * @returns a string containng the defines string
  12445. */
  12446. getEffectDefines(): string;
  12447. /**
  12448. * Returns the string "BoxParticleEmitter"
  12449. * @returns a string containing the class name
  12450. */
  12451. getClassName(): string;
  12452. /**
  12453. * Serializes the particle system to a JSON object.
  12454. * @returns the JSON object
  12455. */
  12456. serialize(): any;
  12457. /**
  12458. * Parse properties from a JSON object
  12459. * @param serializationObject defines the JSON object
  12460. */
  12461. parse(serializationObject: any): void;
  12462. }
  12463. }
  12464. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12465. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12466. import { Effect } from "babylonjs/Materials/effect";
  12467. import { Particle } from "babylonjs/Particles/particle";
  12468. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12469. /**
  12470. * Particle emitter emitting particles from the inside of a cone.
  12471. * It emits the particles alongside the cone volume from the base to the particle.
  12472. * The emission direction might be randomized.
  12473. */
  12474. export class ConeParticleEmitter implements IParticleEmitterType {
  12475. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12476. directionRandomizer: number;
  12477. private _radius;
  12478. private _angle;
  12479. private _height;
  12480. /**
  12481. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12482. */
  12483. radiusRange: number;
  12484. /**
  12485. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12486. */
  12487. heightRange: number;
  12488. /**
  12489. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12490. */
  12491. emitFromSpawnPointOnly: boolean;
  12492. /**
  12493. * Gets or sets the radius of the emission cone
  12494. */
  12495. get radius(): number;
  12496. set radius(value: number);
  12497. /**
  12498. * Gets or sets the angle of the emission cone
  12499. */
  12500. get angle(): number;
  12501. set angle(value: number);
  12502. private _buildHeight;
  12503. /**
  12504. * Creates a new instance ConeParticleEmitter
  12505. * @param radius the radius of the emission cone (1 by default)
  12506. * @param angle the cone base angle (PI by default)
  12507. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12508. */
  12509. constructor(radius?: number, angle?: number,
  12510. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12511. directionRandomizer?: number);
  12512. /**
  12513. * Called by the particle System when the direction is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param directionToUpdate is the direction vector to update with the result
  12516. * @param particle is the particle we are computed the direction for
  12517. * @param isLocal defines if the direction should be set in local space
  12518. */
  12519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12520. /**
  12521. * Called by the particle System when the position is computed for the created particle.
  12522. * @param worldMatrix is the world matrix of the particle system
  12523. * @param positionToUpdate is the position vector to update with the result
  12524. * @param particle is the particle we are computed the position for
  12525. * @param isLocal defines if the position should be set in local space
  12526. */
  12527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): ConeParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "ConeParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. }
  12560. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12561. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12562. import { Effect } from "babylonjs/Materials/effect";
  12563. import { Particle } from "babylonjs/Particles/particle";
  12564. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12565. /**
  12566. * Particle emitter emitting particles from the inside of a cylinder.
  12567. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12568. */
  12569. export class CylinderParticleEmitter implements IParticleEmitterType {
  12570. /**
  12571. * The radius of the emission cylinder.
  12572. */
  12573. radius: number;
  12574. /**
  12575. * The height of the emission cylinder.
  12576. */
  12577. height: number;
  12578. /**
  12579. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12580. */
  12581. radiusRange: number;
  12582. /**
  12583. * How much to randomize the particle direction [0-1].
  12584. */
  12585. directionRandomizer: number;
  12586. /**
  12587. * Creates a new instance CylinderParticleEmitter
  12588. * @param radius the radius of the emission cylinder (1 by default)
  12589. * @param height the height of the emission cylinder (1 by default)
  12590. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12591. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12592. */
  12593. constructor(
  12594. /**
  12595. * The radius of the emission cylinder.
  12596. */
  12597. radius?: number,
  12598. /**
  12599. * The height of the emission cylinder.
  12600. */
  12601. height?: number,
  12602. /**
  12603. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12604. */
  12605. radiusRange?: number,
  12606. /**
  12607. * How much to randomize the particle direction [0-1].
  12608. */
  12609. directionRandomizer?: number);
  12610. /**
  12611. * Called by the particle System when the direction is computed for the created particle.
  12612. * @param worldMatrix is the world matrix of the particle system
  12613. * @param directionToUpdate is the direction vector to update with the result
  12614. * @param particle is the particle we are computed the direction for
  12615. * @param isLocal defines if the direction should be set in local space
  12616. */
  12617. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12618. /**
  12619. * Called by the particle System when the position is computed for the created particle.
  12620. * @param worldMatrix is the world matrix of the particle system
  12621. * @param positionToUpdate is the position vector to update with the result
  12622. * @param particle is the particle we are computed the position for
  12623. * @param isLocal defines if the position should be set in local space
  12624. */
  12625. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12626. /**
  12627. * Clones the current emitter and returns a copy of it
  12628. * @returns the new emitter
  12629. */
  12630. clone(): CylinderParticleEmitter;
  12631. /**
  12632. * Called by the GPUParticleSystem to setup the update shader
  12633. * @param effect defines the update shader
  12634. */
  12635. applyToShader(effect: Effect): void;
  12636. /**
  12637. * Returns a string to use to update the GPU particles update shader
  12638. * @returns a string containng the defines string
  12639. */
  12640. getEffectDefines(): string;
  12641. /**
  12642. * Returns the string "CylinderParticleEmitter"
  12643. * @returns a string containing the class name
  12644. */
  12645. getClassName(): string;
  12646. /**
  12647. * Serializes the particle system to a JSON object.
  12648. * @returns the JSON object
  12649. */
  12650. serialize(): any;
  12651. /**
  12652. * Parse properties from a JSON object
  12653. * @param serializationObject defines the JSON object
  12654. */
  12655. parse(serializationObject: any): void;
  12656. }
  12657. /**
  12658. * Particle emitter emitting particles from the inside of a cylinder.
  12659. * It emits the particles randomly between two vectors.
  12660. */
  12661. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12662. /**
  12663. * The min limit of the emission direction.
  12664. */
  12665. direction1: Vector3;
  12666. /**
  12667. * The max limit of the emission direction.
  12668. */
  12669. direction2: Vector3;
  12670. /**
  12671. * Creates a new instance CylinderDirectedParticleEmitter
  12672. * @param radius the radius of the emission cylinder (1 by default)
  12673. * @param height the height of the emission cylinder (1 by default)
  12674. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12675. * @param direction1 the min limit of the emission direction (up vector by default)
  12676. * @param direction2 the max limit of the emission direction (up vector by default)
  12677. */
  12678. constructor(radius?: number, height?: number, radiusRange?: number,
  12679. /**
  12680. * The min limit of the emission direction.
  12681. */
  12682. direction1?: Vector3,
  12683. /**
  12684. * The max limit of the emission direction.
  12685. */
  12686. direction2?: Vector3);
  12687. /**
  12688. * Called by the particle System when the direction is computed for the created particle.
  12689. * @param worldMatrix is the world matrix of the particle system
  12690. * @param directionToUpdate is the direction vector to update with the result
  12691. * @param particle is the particle we are computed the direction for
  12692. */
  12693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12694. /**
  12695. * Clones the current emitter and returns a copy of it
  12696. * @returns the new emitter
  12697. */
  12698. clone(): CylinderDirectedParticleEmitter;
  12699. /**
  12700. * Called by the GPUParticleSystem to setup the update shader
  12701. * @param effect defines the update shader
  12702. */
  12703. applyToShader(effect: Effect): void;
  12704. /**
  12705. * Returns a string to use to update the GPU particles update shader
  12706. * @returns a string containng the defines string
  12707. */
  12708. getEffectDefines(): string;
  12709. /**
  12710. * Returns the string "CylinderDirectedParticleEmitter"
  12711. * @returns a string containing the class name
  12712. */
  12713. getClassName(): string;
  12714. /**
  12715. * Serializes the particle system to a JSON object.
  12716. * @returns the JSON object
  12717. */
  12718. serialize(): any;
  12719. /**
  12720. * Parse properties from a JSON object
  12721. * @param serializationObject defines the JSON object
  12722. */
  12723. parse(serializationObject: any): void;
  12724. }
  12725. }
  12726. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12727. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12728. import { Effect } from "babylonjs/Materials/effect";
  12729. import { Particle } from "babylonjs/Particles/particle";
  12730. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12731. /**
  12732. * Particle emitter emitting particles from the inside of a hemisphere.
  12733. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12734. */
  12735. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12736. /**
  12737. * The radius of the emission hemisphere.
  12738. */
  12739. radius: number;
  12740. /**
  12741. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12742. */
  12743. radiusRange: number;
  12744. /**
  12745. * How much to randomize the particle direction [0-1].
  12746. */
  12747. directionRandomizer: number;
  12748. /**
  12749. * Creates a new instance HemisphericParticleEmitter
  12750. * @param radius the radius of the emission hemisphere (1 by default)
  12751. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12752. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12753. */
  12754. constructor(
  12755. /**
  12756. * The radius of the emission hemisphere.
  12757. */
  12758. radius?: number,
  12759. /**
  12760. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12761. */
  12762. radiusRange?: number,
  12763. /**
  12764. * How much to randomize the particle direction [0-1].
  12765. */
  12766. directionRandomizer?: number);
  12767. /**
  12768. * Called by the particle System when the direction is computed for the created particle.
  12769. * @param worldMatrix is the world matrix of the particle system
  12770. * @param directionToUpdate is the direction vector to update with the result
  12771. * @param particle is the particle we are computed the direction for
  12772. * @param isLocal defines if the direction should be set in local space
  12773. */
  12774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12775. /**
  12776. * Called by the particle System when the position is computed for the created particle.
  12777. * @param worldMatrix is the world matrix of the particle system
  12778. * @param positionToUpdate is the position vector to update with the result
  12779. * @param particle is the particle we are computed the position for
  12780. * @param isLocal defines if the position should be set in local space
  12781. */
  12782. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12783. /**
  12784. * Clones the current emitter and returns a copy of it
  12785. * @returns the new emitter
  12786. */
  12787. clone(): HemisphericParticleEmitter;
  12788. /**
  12789. * Called by the GPUParticleSystem to setup the update shader
  12790. * @param effect defines the update shader
  12791. */
  12792. applyToShader(effect: Effect): void;
  12793. /**
  12794. * Returns a string to use to update the GPU particles update shader
  12795. * @returns a string containng the defines string
  12796. */
  12797. getEffectDefines(): string;
  12798. /**
  12799. * Returns the string "HemisphericParticleEmitter"
  12800. * @returns a string containing the class name
  12801. */
  12802. getClassName(): string;
  12803. /**
  12804. * Serializes the particle system to a JSON object.
  12805. * @returns the JSON object
  12806. */
  12807. serialize(): any;
  12808. /**
  12809. * Parse properties from a JSON object
  12810. * @param serializationObject defines the JSON object
  12811. */
  12812. parse(serializationObject: any): void;
  12813. }
  12814. }
  12815. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12816. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12817. import { Effect } from "babylonjs/Materials/effect";
  12818. import { Particle } from "babylonjs/Particles/particle";
  12819. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12820. /**
  12821. * Particle emitter emitting particles from a point.
  12822. * It emits the particles randomly between 2 given directions.
  12823. */
  12824. export class PointParticleEmitter implements IParticleEmitterType {
  12825. /**
  12826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12827. */
  12828. direction1: Vector3;
  12829. /**
  12830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12831. */
  12832. direction2: Vector3;
  12833. /**
  12834. * Creates a new instance PointParticleEmitter
  12835. */
  12836. constructor();
  12837. /**
  12838. * Called by the particle System when the direction is computed for the created particle.
  12839. * @param worldMatrix is the world matrix of the particle system
  12840. * @param directionToUpdate is the direction vector to update with the result
  12841. * @param particle is the particle we are computed the direction for
  12842. * @param isLocal defines if the direction should be set in local space
  12843. */
  12844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12845. /**
  12846. * Called by the particle System when the position is computed for the created particle.
  12847. * @param worldMatrix is the world matrix of the particle system
  12848. * @param positionToUpdate is the position vector to update with the result
  12849. * @param particle is the particle we are computed the position for
  12850. * @param isLocal defines if the position should be set in local space
  12851. */
  12852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12853. /**
  12854. * Clones the current emitter and returns a copy of it
  12855. * @returns the new emitter
  12856. */
  12857. clone(): PointParticleEmitter;
  12858. /**
  12859. * Called by the GPUParticleSystem to setup the update shader
  12860. * @param effect defines the update shader
  12861. */
  12862. applyToShader(effect: Effect): void;
  12863. /**
  12864. * Returns a string to use to update the GPU particles update shader
  12865. * @returns a string containng the defines string
  12866. */
  12867. getEffectDefines(): string;
  12868. /**
  12869. * Returns the string "PointParticleEmitter"
  12870. * @returns a string containing the class name
  12871. */
  12872. getClassName(): string;
  12873. /**
  12874. * Serializes the particle system to a JSON object.
  12875. * @returns the JSON object
  12876. */
  12877. serialize(): any;
  12878. /**
  12879. * Parse properties from a JSON object
  12880. * @param serializationObject defines the JSON object
  12881. */
  12882. parse(serializationObject: any): void;
  12883. }
  12884. }
  12885. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12886. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12887. import { Effect } from "babylonjs/Materials/effect";
  12888. import { Particle } from "babylonjs/Particles/particle";
  12889. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12890. /**
  12891. * Particle emitter emitting particles from the inside of a sphere.
  12892. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12893. */
  12894. export class SphereParticleEmitter implements IParticleEmitterType {
  12895. /**
  12896. * The radius of the emission sphere.
  12897. */
  12898. radius: number;
  12899. /**
  12900. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12901. */
  12902. radiusRange: number;
  12903. /**
  12904. * How much to randomize the particle direction [0-1].
  12905. */
  12906. directionRandomizer: number;
  12907. /**
  12908. * Creates a new instance SphereParticleEmitter
  12909. * @param radius the radius of the emission sphere (1 by default)
  12910. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12911. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12912. */
  12913. constructor(
  12914. /**
  12915. * The radius of the emission sphere.
  12916. */
  12917. radius?: number,
  12918. /**
  12919. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12920. */
  12921. radiusRange?: number,
  12922. /**
  12923. * How much to randomize the particle direction [0-1].
  12924. */
  12925. directionRandomizer?: number);
  12926. /**
  12927. * Called by the particle System when the direction is computed for the created particle.
  12928. * @param worldMatrix is the world matrix of the particle system
  12929. * @param directionToUpdate is the direction vector to update with the result
  12930. * @param particle is the particle we are computed the direction for
  12931. * @param isLocal defines if the direction should be set in local space
  12932. */
  12933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12934. /**
  12935. * Called by the particle System when the position is computed for the created particle.
  12936. * @param worldMatrix is the world matrix of the particle system
  12937. * @param positionToUpdate is the position vector to update with the result
  12938. * @param particle is the particle we are computed the position for
  12939. * @param isLocal defines if the position should be set in local space
  12940. */
  12941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12942. /**
  12943. * Clones the current emitter and returns a copy of it
  12944. * @returns the new emitter
  12945. */
  12946. clone(): SphereParticleEmitter;
  12947. /**
  12948. * Called by the GPUParticleSystem to setup the update shader
  12949. * @param effect defines the update shader
  12950. */
  12951. applyToShader(effect: Effect): void;
  12952. /**
  12953. * Returns a string to use to update the GPU particles update shader
  12954. * @returns a string containng the defines string
  12955. */
  12956. getEffectDefines(): string;
  12957. /**
  12958. * Returns the string "SphereParticleEmitter"
  12959. * @returns a string containing the class name
  12960. */
  12961. getClassName(): string;
  12962. /**
  12963. * Serializes the particle system to a JSON object.
  12964. * @returns the JSON object
  12965. */
  12966. serialize(): any;
  12967. /**
  12968. * Parse properties from a JSON object
  12969. * @param serializationObject defines the JSON object
  12970. */
  12971. parse(serializationObject: any): void;
  12972. }
  12973. /**
  12974. * Particle emitter emitting particles from the inside of a sphere.
  12975. * It emits the particles randomly between two vectors.
  12976. */
  12977. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12978. /**
  12979. * The min limit of the emission direction.
  12980. */
  12981. direction1: Vector3;
  12982. /**
  12983. * The max limit of the emission direction.
  12984. */
  12985. direction2: Vector3;
  12986. /**
  12987. * Creates a new instance SphereDirectedParticleEmitter
  12988. * @param radius the radius of the emission sphere (1 by default)
  12989. * @param direction1 the min limit of the emission direction (up vector by default)
  12990. * @param direction2 the max limit of the emission direction (up vector by default)
  12991. */
  12992. constructor(radius?: number,
  12993. /**
  12994. * The min limit of the emission direction.
  12995. */
  12996. direction1?: Vector3,
  12997. /**
  12998. * The max limit of the emission direction.
  12999. */
  13000. direction2?: Vector3);
  13001. /**
  13002. * Called by the particle System when the direction is computed for the created particle.
  13003. * @param worldMatrix is the world matrix of the particle system
  13004. * @param directionToUpdate is the direction vector to update with the result
  13005. * @param particle is the particle we are computed the direction for
  13006. */
  13007. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13008. /**
  13009. * Clones the current emitter and returns a copy of it
  13010. * @returns the new emitter
  13011. */
  13012. clone(): SphereDirectedParticleEmitter;
  13013. /**
  13014. * Called by the GPUParticleSystem to setup the update shader
  13015. * @param effect defines the update shader
  13016. */
  13017. applyToShader(effect: Effect): void;
  13018. /**
  13019. * Returns a string to use to update the GPU particles update shader
  13020. * @returns a string containng the defines string
  13021. */
  13022. getEffectDefines(): string;
  13023. /**
  13024. * Returns the string "SphereDirectedParticleEmitter"
  13025. * @returns a string containing the class name
  13026. */
  13027. getClassName(): string;
  13028. /**
  13029. * Serializes the particle system to a JSON object.
  13030. * @returns the JSON object
  13031. */
  13032. serialize(): any;
  13033. /**
  13034. * Parse properties from a JSON object
  13035. * @param serializationObject defines the JSON object
  13036. */
  13037. parse(serializationObject: any): void;
  13038. }
  13039. }
  13040. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13041. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13042. import { Effect } from "babylonjs/Materials/effect";
  13043. import { Particle } from "babylonjs/Particles/particle";
  13044. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13045. import { Nullable } from "babylonjs/types";
  13046. /**
  13047. * Particle emitter emitting particles from a custom list of positions.
  13048. */
  13049. export class CustomParticleEmitter implements IParticleEmitterType {
  13050. /**
  13051. * Gets or sets the position generator that will create the inital position of each particle.
  13052. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13053. */
  13054. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13055. /**
  13056. * Gets or sets the destination generator that will create the final destination of each particle.
  13057. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13058. */
  13059. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13060. /**
  13061. * Creates a new instance CustomParticleEmitter
  13062. */
  13063. constructor();
  13064. /**
  13065. * Called by the particle System when the direction is computed for the created particle.
  13066. * @param worldMatrix is the world matrix of the particle system
  13067. * @param directionToUpdate is the direction vector to update with the result
  13068. * @param particle is the particle we are computed the direction for
  13069. * @param isLocal defines if the direction should be set in local space
  13070. */
  13071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13072. /**
  13073. * Called by the particle System when the position is computed for the created particle.
  13074. * @param worldMatrix is the world matrix of the particle system
  13075. * @param positionToUpdate is the position vector to update with the result
  13076. * @param particle is the particle we are computed the position for
  13077. * @param isLocal defines if the position should be set in local space
  13078. */
  13079. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13080. /**
  13081. * Clones the current emitter and returns a copy of it
  13082. * @returns the new emitter
  13083. */
  13084. clone(): CustomParticleEmitter;
  13085. /**
  13086. * Called by the GPUParticleSystem to setup the update shader
  13087. * @param effect defines the update shader
  13088. */
  13089. applyToShader(effect: Effect): void;
  13090. /**
  13091. * Returns a string to use to update the GPU particles update shader
  13092. * @returns a string containng the defines string
  13093. */
  13094. getEffectDefines(): string;
  13095. /**
  13096. * Returns the string "PointParticleEmitter"
  13097. * @returns a string containing the class name
  13098. */
  13099. getClassName(): string;
  13100. /**
  13101. * Serializes the particle system to a JSON object.
  13102. * @returns the JSON object
  13103. */
  13104. serialize(): any;
  13105. /**
  13106. * Parse properties from a JSON object
  13107. * @param serializationObject defines the JSON object
  13108. */
  13109. parse(serializationObject: any): void;
  13110. }
  13111. }
  13112. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13113. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13114. import { Effect } from "babylonjs/Materials/effect";
  13115. import { Particle } from "babylonjs/Particles/particle";
  13116. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13117. import { Scene } from "babylonjs/scene";
  13118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13119. /**
  13120. * Particle emitter emitting particles from the inside of a box.
  13121. * It emits the particles randomly between 2 given directions.
  13122. */
  13123. export class MeshParticleEmitter implements IParticleEmitterType {
  13124. /** Defines the mesh to use as source */
  13125. mesh?: AbstractMesh | undefined;
  13126. private _indices;
  13127. private _positions;
  13128. private _normals;
  13129. private _storedNormal;
  13130. /**
  13131. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13132. */
  13133. direction1: Vector3;
  13134. /**
  13135. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13136. */
  13137. direction2: Vector3;
  13138. /**
  13139. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13140. */
  13141. useMeshNormalsForDirection: boolean;
  13142. /**
  13143. * Creates a new instance MeshParticleEmitter
  13144. * @param mesh defines the mesh to use as source
  13145. */
  13146. constructor(
  13147. /** Defines the mesh to use as source */
  13148. mesh?: AbstractMesh | undefined);
  13149. /**
  13150. * Called by the particle System when the direction is computed for the created particle.
  13151. * @param worldMatrix is the world matrix of the particle system
  13152. * @param directionToUpdate is the direction vector to update with the result
  13153. * @param particle is the particle we are computed the direction for
  13154. * @param isLocal defines if the direction should be set in local space
  13155. */
  13156. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13157. /**
  13158. * Called by the particle System when the position is computed for the created particle.
  13159. * @param worldMatrix is the world matrix of the particle system
  13160. * @param positionToUpdate is the position vector to update with the result
  13161. * @param particle is the particle we are computed the position for
  13162. * @param isLocal defines if the position should be set in local space
  13163. */
  13164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13165. /**
  13166. * Clones the current emitter and returns a copy of it
  13167. * @returns the new emitter
  13168. */
  13169. clone(): MeshParticleEmitter;
  13170. /**
  13171. * Called by the GPUParticleSystem to setup the update shader
  13172. * @param effect defines the update shader
  13173. */
  13174. applyToShader(effect: Effect): void;
  13175. /**
  13176. * Returns a string to use to update the GPU particles update shader
  13177. * @returns a string containng the defines string
  13178. */
  13179. getEffectDefines(): string;
  13180. /**
  13181. * Returns the string "BoxParticleEmitter"
  13182. * @returns a string containing the class name
  13183. */
  13184. getClassName(): string;
  13185. /**
  13186. * Serializes the particle system to a JSON object.
  13187. * @returns the JSON object
  13188. */
  13189. serialize(): any;
  13190. /**
  13191. * Parse properties from a JSON object
  13192. * @param serializationObject defines the JSON object
  13193. * @param scene defines the hosting scene
  13194. */
  13195. parse(serializationObject: any, scene: Scene): void;
  13196. }
  13197. }
  13198. declare module "babylonjs/Particles/EmitterTypes/index" {
  13199. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13200. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13201. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13202. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13203. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13204. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13205. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13206. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13207. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13208. }
  13209. declare module "babylonjs/Particles/IParticleSystem" {
  13210. import { Nullable } from "babylonjs/types";
  13211. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13212. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13215. import { Texture } from "babylonjs/Materials/Textures/texture";
  13216. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13217. import { Scene } from "babylonjs/scene";
  13218. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13219. import { Animation } from "babylonjs/Animations/animation";
  13220. /**
  13221. * Interface representing a particle system in Babylon.js.
  13222. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13223. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13224. */
  13225. export interface IParticleSystem {
  13226. /**
  13227. * List of animations used by the particle system.
  13228. */
  13229. animations: Animation[];
  13230. /**
  13231. * The id of the Particle system.
  13232. */
  13233. id: string;
  13234. /**
  13235. * The name of the Particle system.
  13236. */
  13237. name: string;
  13238. /**
  13239. * The emitter represents the Mesh or position we are attaching the particle system to.
  13240. */
  13241. emitter: Nullable<AbstractMesh | Vector3>;
  13242. /**
  13243. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13244. */
  13245. isBillboardBased: boolean;
  13246. /**
  13247. * The rendering group used by the Particle system to chose when to render.
  13248. */
  13249. renderingGroupId: number;
  13250. /**
  13251. * The layer mask we are rendering the particles through.
  13252. */
  13253. layerMask: number;
  13254. /**
  13255. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13256. */
  13257. updateSpeed: number;
  13258. /**
  13259. * The amount of time the particle system is running (depends of the overall update speed).
  13260. */
  13261. targetStopDuration: number;
  13262. /**
  13263. * The texture used to render each particle. (this can be a spritesheet)
  13264. */
  13265. particleTexture: Nullable<Texture>;
  13266. /**
  13267. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13268. */
  13269. blendMode: number;
  13270. /**
  13271. * Minimum life time of emitting particles.
  13272. */
  13273. minLifeTime: number;
  13274. /**
  13275. * Maximum life time of emitting particles.
  13276. */
  13277. maxLifeTime: number;
  13278. /**
  13279. * Minimum Size of emitting particles.
  13280. */
  13281. minSize: number;
  13282. /**
  13283. * Maximum Size of emitting particles.
  13284. */
  13285. maxSize: number;
  13286. /**
  13287. * Minimum scale of emitting particles on X axis.
  13288. */
  13289. minScaleX: number;
  13290. /**
  13291. * Maximum scale of emitting particles on X axis.
  13292. */
  13293. maxScaleX: number;
  13294. /**
  13295. * Minimum scale of emitting particles on Y axis.
  13296. */
  13297. minScaleY: number;
  13298. /**
  13299. * Maximum scale of emitting particles on Y axis.
  13300. */
  13301. maxScaleY: number;
  13302. /**
  13303. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13304. */
  13305. color1: Color4;
  13306. /**
  13307. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13308. */
  13309. color2: Color4;
  13310. /**
  13311. * Color the particle will have at the end of its lifetime.
  13312. */
  13313. colorDead: Color4;
  13314. /**
  13315. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13316. */
  13317. emitRate: number;
  13318. /**
  13319. * You can use gravity if you want to give an orientation to your particles.
  13320. */
  13321. gravity: Vector3;
  13322. /**
  13323. * Minimum power of emitting particles.
  13324. */
  13325. minEmitPower: number;
  13326. /**
  13327. * Maximum power of emitting particles.
  13328. */
  13329. maxEmitPower: number;
  13330. /**
  13331. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13332. */
  13333. minAngularSpeed: number;
  13334. /**
  13335. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13336. */
  13337. maxAngularSpeed: number;
  13338. /**
  13339. * Gets or sets the minimal initial rotation in radians.
  13340. */
  13341. minInitialRotation: number;
  13342. /**
  13343. * Gets or sets the maximal initial rotation in radians.
  13344. */
  13345. maxInitialRotation: number;
  13346. /**
  13347. * The particle emitter type defines the emitter used by the particle system.
  13348. * It can be for example box, sphere, or cone...
  13349. */
  13350. particleEmitterType: Nullable<IParticleEmitterType>;
  13351. /**
  13352. * Defines the delay in milliseconds before starting the system (0 by default)
  13353. */
  13354. startDelay: number;
  13355. /**
  13356. * 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
  13357. */
  13358. preWarmCycles: number;
  13359. /**
  13360. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13361. */
  13362. preWarmStepOffset: number;
  13363. /**
  13364. * 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)
  13365. */
  13366. spriteCellChangeSpeed: number;
  13367. /**
  13368. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13369. */
  13370. startSpriteCellID: number;
  13371. /**
  13372. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13373. */
  13374. endSpriteCellID: number;
  13375. /**
  13376. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13377. */
  13378. spriteCellWidth: number;
  13379. /**
  13380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13381. */
  13382. spriteCellHeight: number;
  13383. /**
  13384. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13385. */
  13386. spriteRandomStartCell: boolean;
  13387. /**
  13388. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13389. */
  13390. isAnimationSheetEnabled: boolean;
  13391. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13392. translationPivot: Vector2;
  13393. /**
  13394. * Gets or sets a texture used to add random noise to particle positions
  13395. */
  13396. noiseTexture: Nullable<BaseTexture>;
  13397. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13398. noiseStrength: Vector3;
  13399. /**
  13400. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13401. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13402. */
  13403. billboardMode: number;
  13404. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13405. limitVelocityDamping: number;
  13406. /**
  13407. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13408. */
  13409. beginAnimationOnStart: boolean;
  13410. /**
  13411. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13412. */
  13413. beginAnimationFrom: number;
  13414. /**
  13415. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13416. */
  13417. beginAnimationTo: number;
  13418. /**
  13419. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13420. */
  13421. beginAnimationLoop: boolean;
  13422. /**
  13423. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13424. */
  13425. disposeOnStop: boolean;
  13426. /**
  13427. * Specifies if the particles are updated in emitter local space or world space
  13428. */
  13429. isLocal: boolean;
  13430. /**
  13431. * Gets the maximum number of particles active at the same time.
  13432. * @returns The max number of active particles.
  13433. */
  13434. getCapacity(): number;
  13435. /**
  13436. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13437. * @returns True if it has been started, otherwise false.
  13438. */
  13439. isStarted(): boolean;
  13440. /**
  13441. * Animates the particle system for this frame.
  13442. */
  13443. animate(): void;
  13444. /**
  13445. * Renders the particle system in its current state.
  13446. * @returns the current number of particles
  13447. */
  13448. render(): number;
  13449. /**
  13450. * Dispose the particle system and frees its associated resources.
  13451. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13452. */
  13453. dispose(disposeTexture?: boolean): void;
  13454. /**
  13455. * Clones the particle system.
  13456. * @param name The name of the cloned object
  13457. * @param newEmitter The new emitter to use
  13458. * @returns the cloned particle system
  13459. */
  13460. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13461. /**
  13462. * Serializes the particle system to a JSON object.
  13463. * @returns the JSON object
  13464. */
  13465. serialize(): any;
  13466. /**
  13467. * Rebuild the particle system
  13468. */
  13469. rebuild(): void;
  13470. /**
  13471. * Starts the particle system and begins to emit
  13472. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13473. */
  13474. start(delay?: number): void;
  13475. /**
  13476. * Stops the particle system.
  13477. */
  13478. stop(): void;
  13479. /**
  13480. * Remove all active particles
  13481. */
  13482. reset(): void;
  13483. /**
  13484. * Is this system ready to be used/rendered
  13485. * @return true if the system is ready
  13486. */
  13487. isReady(): boolean;
  13488. /**
  13489. * Returns the string "ParticleSystem"
  13490. * @returns a string containing the class name
  13491. */
  13492. getClassName(): string;
  13493. /**
  13494. * Adds a new color gradient
  13495. * @param gradient defines the gradient to use (between 0 and 1)
  13496. * @param color1 defines the color to affect to the specified gradient
  13497. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13498. * @returns the current particle system
  13499. */
  13500. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13501. /**
  13502. * Remove a specific color gradient
  13503. * @param gradient defines the gradient to remove
  13504. * @returns the current particle system
  13505. */
  13506. removeColorGradient(gradient: number): IParticleSystem;
  13507. /**
  13508. * Adds a new size gradient
  13509. * @param gradient defines the gradient to use (between 0 and 1)
  13510. * @param factor defines the size factor to affect to the specified gradient
  13511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13512. * @returns the current particle system
  13513. */
  13514. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13515. /**
  13516. * Remove a specific size gradient
  13517. * @param gradient defines the gradient to remove
  13518. * @returns the current particle system
  13519. */
  13520. removeSizeGradient(gradient: number): IParticleSystem;
  13521. /**
  13522. * Gets the current list of color gradients.
  13523. * You must use addColorGradient and removeColorGradient to udpate this list
  13524. * @returns the list of color gradients
  13525. */
  13526. getColorGradients(): Nullable<Array<ColorGradient>>;
  13527. /**
  13528. * Gets the current list of size gradients.
  13529. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13530. * @returns the list of size gradients
  13531. */
  13532. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13533. /**
  13534. * Gets the current list of angular speed gradients.
  13535. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13536. * @returns the list of angular speed gradients
  13537. */
  13538. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13539. /**
  13540. * Adds a new angular speed gradient
  13541. * @param gradient defines the gradient to use (between 0 and 1)
  13542. * @param factor defines the angular speed to affect to the specified gradient
  13543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13544. * @returns the current particle system
  13545. */
  13546. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13547. /**
  13548. * Remove a specific angular speed gradient
  13549. * @param gradient defines the gradient to remove
  13550. * @returns the current particle system
  13551. */
  13552. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13553. /**
  13554. * Gets the current list of velocity gradients.
  13555. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13556. * @returns the list of velocity gradients
  13557. */
  13558. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13559. /**
  13560. * Adds a new velocity gradient
  13561. * @param gradient defines the gradient to use (between 0 and 1)
  13562. * @param factor defines the velocity to affect to the specified gradient
  13563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13564. * @returns the current particle system
  13565. */
  13566. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13567. /**
  13568. * Remove a specific velocity gradient
  13569. * @param gradient defines the gradient to remove
  13570. * @returns the current particle system
  13571. */
  13572. removeVelocityGradient(gradient: number): IParticleSystem;
  13573. /**
  13574. * Gets the current list of limit velocity gradients.
  13575. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13576. * @returns the list of limit velocity gradients
  13577. */
  13578. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13579. /**
  13580. * Adds a new limit velocity gradient
  13581. * @param gradient defines the gradient to use (between 0 and 1)
  13582. * @param factor defines the limit velocity to affect to the specified gradient
  13583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13584. * @returns the current particle system
  13585. */
  13586. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13587. /**
  13588. * Remove a specific limit velocity gradient
  13589. * @param gradient defines the gradient to remove
  13590. * @returns the current particle system
  13591. */
  13592. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13593. /**
  13594. * Adds a new drag gradient
  13595. * @param gradient defines the gradient to use (between 0 and 1)
  13596. * @param factor defines the drag to affect to the specified gradient
  13597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13598. * @returns the current particle system
  13599. */
  13600. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13601. /**
  13602. * Remove a specific drag gradient
  13603. * @param gradient defines the gradient to remove
  13604. * @returns the current particle system
  13605. */
  13606. removeDragGradient(gradient: number): IParticleSystem;
  13607. /**
  13608. * Gets the current list of drag gradients.
  13609. * You must use addDragGradient and removeDragGradient to udpate this list
  13610. * @returns the list of drag gradients
  13611. */
  13612. getDragGradients(): Nullable<Array<FactorGradient>>;
  13613. /**
  13614. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13615. * @param gradient defines the gradient to use (between 0 and 1)
  13616. * @param factor defines the emit rate to affect to the specified gradient
  13617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13618. * @returns the current particle system
  13619. */
  13620. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13621. /**
  13622. * Remove a specific emit rate gradient
  13623. * @param gradient defines the gradient to remove
  13624. * @returns the current particle system
  13625. */
  13626. removeEmitRateGradient(gradient: number): IParticleSystem;
  13627. /**
  13628. * Gets the current list of emit rate gradients.
  13629. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13630. * @returns the list of emit rate gradients
  13631. */
  13632. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13633. /**
  13634. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13635. * @param gradient defines the gradient to use (between 0 and 1)
  13636. * @param factor defines the start size to affect to the specified gradient
  13637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13638. * @returns the current particle system
  13639. */
  13640. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13641. /**
  13642. * Remove a specific start size gradient
  13643. * @param gradient defines the gradient to remove
  13644. * @returns the current particle system
  13645. */
  13646. removeStartSizeGradient(gradient: number): IParticleSystem;
  13647. /**
  13648. * Gets the current list of start size gradients.
  13649. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13650. * @returns the list of start size gradients
  13651. */
  13652. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13653. /**
  13654. * Adds a new life time gradient
  13655. * @param gradient defines the gradient to use (between 0 and 1)
  13656. * @param factor defines the life time factor to affect to the specified gradient
  13657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13658. * @returns the current particle system
  13659. */
  13660. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13661. /**
  13662. * Remove a specific life time gradient
  13663. * @param gradient defines the gradient to remove
  13664. * @returns the current particle system
  13665. */
  13666. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13667. /**
  13668. * Gets the current list of life time gradients.
  13669. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13670. * @returns the list of life time gradients
  13671. */
  13672. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13673. /**
  13674. * Gets the current list of color gradients.
  13675. * You must use addColorGradient and removeColorGradient to udpate this list
  13676. * @returns the list of color gradients
  13677. */
  13678. getColorGradients(): Nullable<Array<ColorGradient>>;
  13679. /**
  13680. * Adds a new ramp gradient used to remap particle colors
  13681. * @param gradient defines the gradient to use (between 0 and 1)
  13682. * @param color defines the color to affect to the specified gradient
  13683. * @returns the current particle system
  13684. */
  13685. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13686. /**
  13687. * Gets the current list of ramp gradients.
  13688. * You must use addRampGradient and removeRampGradient to udpate this list
  13689. * @returns the list of ramp gradients
  13690. */
  13691. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13692. /** Gets or sets a boolean indicating that ramp gradients must be used
  13693. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13694. */
  13695. useRampGradients: boolean;
  13696. /**
  13697. * Adds a new color remap gradient
  13698. * @param gradient defines the gradient to use (between 0 and 1)
  13699. * @param min defines the color remap minimal range
  13700. * @param max defines the color remap maximal range
  13701. * @returns the current particle system
  13702. */
  13703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13704. /**
  13705. * Gets the current list of color remap gradients.
  13706. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13707. * @returns the list of color remap gradients
  13708. */
  13709. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13710. /**
  13711. * Adds a new alpha remap gradient
  13712. * @param gradient defines the gradient to use (between 0 and 1)
  13713. * @param min defines the alpha remap minimal range
  13714. * @param max defines the alpha remap maximal range
  13715. * @returns the current particle system
  13716. */
  13717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13718. /**
  13719. * Gets the current list of alpha remap gradients.
  13720. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13721. * @returns the list of alpha remap gradients
  13722. */
  13723. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13724. /**
  13725. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13728. * @returns the emitter
  13729. */
  13730. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13731. /**
  13732. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13733. * @param radius The radius of the hemisphere to emit from
  13734. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13735. * @returns the emitter
  13736. */
  13737. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13738. /**
  13739. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13740. * @param radius The radius of the sphere to emit from
  13741. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13742. * @returns the emitter
  13743. */
  13744. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13745. /**
  13746. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13747. * @param radius The radius of the sphere to emit from
  13748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13750. * @returns the emitter
  13751. */
  13752. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13753. /**
  13754. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13755. * @param radius The radius of the emission cylinder
  13756. * @param height The height of the emission cylinder
  13757. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13758. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13759. * @returns the emitter
  13760. */
  13761. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13762. /**
  13763. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13764. * @param radius The radius of the cylinder to emit from
  13765. * @param height The height of the emission cylinder
  13766. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13769. * @returns the emitter
  13770. */
  13771. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13772. /**
  13773. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13774. * @param radius The radius of the cone to emit from
  13775. * @param angle The base angle of the cone
  13776. * @returns the emitter
  13777. */
  13778. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13779. /**
  13780. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13781. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13782. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13783. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13784. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13785. * @returns the emitter
  13786. */
  13787. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13788. /**
  13789. * Get hosting scene
  13790. * @returns the scene
  13791. */
  13792. getScene(): Scene;
  13793. }
  13794. }
  13795. declare module "babylonjs/Meshes/transformNode" {
  13796. import { DeepImmutable } from "babylonjs/types";
  13797. import { Observable } from "babylonjs/Misc/observable";
  13798. import { Nullable } from "babylonjs/types";
  13799. import { Camera } from "babylonjs/Cameras/camera";
  13800. import { Scene } from "babylonjs/scene";
  13801. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13802. import { Node } from "babylonjs/node";
  13803. import { Bone } from "babylonjs/Bones/bone";
  13804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13805. import { Space } from "babylonjs/Maths/math.axis";
  13806. /**
  13807. * 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.
  13808. * @see https://doc.babylonjs.com/how_to/transformnode
  13809. */
  13810. export class TransformNode extends Node {
  13811. /**
  13812. * Object will not rotate to face the camera
  13813. */
  13814. static BILLBOARDMODE_NONE: number;
  13815. /**
  13816. * Object will rotate to face the camera but only on the x axis
  13817. */
  13818. static BILLBOARDMODE_X: number;
  13819. /**
  13820. * Object will rotate to face the camera but only on the y axis
  13821. */
  13822. static BILLBOARDMODE_Y: number;
  13823. /**
  13824. * Object will rotate to face the camera but only on the z axis
  13825. */
  13826. static BILLBOARDMODE_Z: number;
  13827. /**
  13828. * Object will rotate to face the camera
  13829. */
  13830. static BILLBOARDMODE_ALL: number;
  13831. /**
  13832. * Object will rotate to face the camera's position instead of orientation
  13833. */
  13834. static BILLBOARDMODE_USE_POSITION: number;
  13835. private _forward;
  13836. private _forwardInverted;
  13837. private _up;
  13838. private _right;
  13839. private _rightInverted;
  13840. private _position;
  13841. private _rotation;
  13842. private _rotationQuaternion;
  13843. protected _scaling: Vector3;
  13844. protected _isDirty: boolean;
  13845. private _transformToBoneReferal;
  13846. private _isAbsoluteSynced;
  13847. private _billboardMode;
  13848. /**
  13849. * Gets or sets the billboard mode. Default is 0.
  13850. *
  13851. * | Value | Type | Description |
  13852. * | --- | --- | --- |
  13853. * | 0 | BILLBOARDMODE_NONE | |
  13854. * | 1 | BILLBOARDMODE_X | |
  13855. * | 2 | BILLBOARDMODE_Y | |
  13856. * | 4 | BILLBOARDMODE_Z | |
  13857. * | 7 | BILLBOARDMODE_ALL | |
  13858. *
  13859. */
  13860. get billboardMode(): number;
  13861. set billboardMode(value: number);
  13862. private _preserveParentRotationForBillboard;
  13863. /**
  13864. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13865. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13866. */
  13867. get preserveParentRotationForBillboard(): boolean;
  13868. set preserveParentRotationForBillboard(value: boolean);
  13869. /**
  13870. * 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
  13871. */
  13872. scalingDeterminant: number;
  13873. private _infiniteDistance;
  13874. /**
  13875. * Gets or sets the distance of the object to max, often used by skybox
  13876. */
  13877. get infiniteDistance(): boolean;
  13878. set infiniteDistance(value: boolean);
  13879. /**
  13880. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13881. * By default the system will update normals to compensate
  13882. */
  13883. ignoreNonUniformScaling: boolean;
  13884. /**
  13885. * 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
  13886. */
  13887. reIntegrateRotationIntoRotationQuaternion: boolean;
  13888. /** @hidden */
  13889. _poseMatrix: Nullable<Matrix>;
  13890. /** @hidden */
  13891. _localMatrix: Matrix;
  13892. private _usePivotMatrix;
  13893. private _absolutePosition;
  13894. private _absoluteScaling;
  13895. private _absoluteRotationQuaternion;
  13896. private _pivotMatrix;
  13897. private _pivotMatrixInverse;
  13898. protected _postMultiplyPivotMatrix: boolean;
  13899. protected _isWorldMatrixFrozen: boolean;
  13900. /** @hidden */
  13901. _indexInSceneTransformNodesArray: number;
  13902. /**
  13903. * An event triggered after the world matrix is updated
  13904. */
  13905. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13906. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13907. /**
  13908. * Gets a string identifying the name of the class
  13909. * @returns "TransformNode" string
  13910. */
  13911. getClassName(): string;
  13912. /**
  13913. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13914. */
  13915. get position(): Vector3;
  13916. set position(newPosition: Vector3);
  13917. /**
  13918. * 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)).
  13919. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13920. */
  13921. get rotation(): Vector3;
  13922. set rotation(newRotation: Vector3);
  13923. /**
  13924. * 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)).
  13925. */
  13926. get scaling(): Vector3;
  13927. set scaling(newScaling: Vector3);
  13928. /**
  13929. * 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).
  13930. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13931. */
  13932. get rotationQuaternion(): Nullable<Quaternion>;
  13933. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13934. /**
  13935. * The forward direction of that transform in world space.
  13936. */
  13937. get forward(): Vector3;
  13938. /**
  13939. * The up direction of that transform in world space.
  13940. */
  13941. get up(): Vector3;
  13942. /**
  13943. * The right direction of that transform in world space.
  13944. */
  13945. get right(): Vector3;
  13946. /**
  13947. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13948. * @param matrix the matrix to copy the pose from
  13949. * @returns this TransformNode.
  13950. */
  13951. updatePoseMatrix(matrix: Matrix): TransformNode;
  13952. /**
  13953. * Returns the mesh Pose matrix.
  13954. * @returns the pose matrix
  13955. */
  13956. getPoseMatrix(): Matrix;
  13957. /** @hidden */
  13958. _isSynchronized(): boolean;
  13959. /** @hidden */
  13960. _initCache(): void;
  13961. /**
  13962. * Flag the transform node as dirty (Forcing it to update everything)
  13963. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13964. * @returns this transform node
  13965. */
  13966. markAsDirty(property: string): TransformNode;
  13967. /**
  13968. * Returns the current mesh absolute position.
  13969. * Returns a Vector3.
  13970. */
  13971. get absolutePosition(): Vector3;
  13972. /**
  13973. * Returns the current mesh absolute scaling.
  13974. * Returns a Vector3.
  13975. */
  13976. get absoluteScaling(): Vector3;
  13977. /**
  13978. * Returns the current mesh absolute rotation.
  13979. * Returns a Quaternion.
  13980. */
  13981. get absoluteRotationQuaternion(): Quaternion;
  13982. /**
  13983. * Sets a new matrix to apply before all other transformation
  13984. * @param matrix defines the transform matrix
  13985. * @returns the current TransformNode
  13986. */
  13987. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13988. /**
  13989. * Sets a new pivot matrix to the current node
  13990. * @param matrix defines the new pivot matrix to use
  13991. * @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
  13992. * @returns the current TransformNode
  13993. */
  13994. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13995. /**
  13996. * Returns the mesh pivot matrix.
  13997. * Default : Identity.
  13998. * @returns the matrix
  13999. */
  14000. getPivotMatrix(): Matrix;
  14001. /**
  14002. * Instantiate (when possible) or clone that node with its hierarchy
  14003. * @param newParent defines the new parent to use for the instance (or clone)
  14004. * @param options defines options to configure how copy is done
  14005. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14006. * @returns an instance (or a clone) of the current node with its hiearchy
  14007. */
  14008. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14009. doNotInstantiate: boolean;
  14010. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14011. /**
  14012. * Prevents the World matrix to be computed any longer
  14013. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14014. * @returns the TransformNode.
  14015. */
  14016. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14017. /**
  14018. * Allows back the World matrix computation.
  14019. * @returns the TransformNode.
  14020. */
  14021. unfreezeWorldMatrix(): this;
  14022. /**
  14023. * True if the World matrix has been frozen.
  14024. */
  14025. get isWorldMatrixFrozen(): boolean;
  14026. /**
  14027. * Retuns the mesh absolute position in the World.
  14028. * @returns a Vector3.
  14029. */
  14030. getAbsolutePosition(): Vector3;
  14031. /**
  14032. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14033. * @param absolutePosition the absolute position to set
  14034. * @returns the TransformNode.
  14035. */
  14036. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14037. /**
  14038. * Sets the mesh position in its local space.
  14039. * @param vector3 the position to set in localspace
  14040. * @returns the TransformNode.
  14041. */
  14042. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14043. /**
  14044. * Returns the mesh position in the local space from the current World matrix values.
  14045. * @returns a new Vector3.
  14046. */
  14047. getPositionExpressedInLocalSpace(): Vector3;
  14048. /**
  14049. * Translates the mesh along the passed Vector3 in its local space.
  14050. * @param vector3 the distance to translate in localspace
  14051. * @returns the TransformNode.
  14052. */
  14053. locallyTranslate(vector3: Vector3): TransformNode;
  14054. private static _lookAtVectorCache;
  14055. /**
  14056. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14057. * @param targetPoint the position (must be in same space as current mesh) to look at
  14058. * @param yawCor optional yaw (y-axis) correction in radians
  14059. * @param pitchCor optional pitch (x-axis) correction in radians
  14060. * @param rollCor optional roll (z-axis) correction in radians
  14061. * @param space the choosen space of the target
  14062. * @returns the TransformNode.
  14063. */
  14064. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14065. /**
  14066. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14067. * This Vector3 is expressed in the World space.
  14068. * @param localAxis axis to rotate
  14069. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14070. */
  14071. getDirection(localAxis: Vector3): Vector3;
  14072. /**
  14073. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14074. * localAxis is expressed in the mesh local space.
  14075. * result is computed in the Wordl space from the mesh World matrix.
  14076. * @param localAxis axis to rotate
  14077. * @param result the resulting transformnode
  14078. * @returns this TransformNode.
  14079. */
  14080. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14081. /**
  14082. * Sets this transform node rotation to the given local axis.
  14083. * @param localAxis the axis in local space
  14084. * @param yawCor optional yaw (y-axis) correction in radians
  14085. * @param pitchCor optional pitch (x-axis) correction in radians
  14086. * @param rollCor optional roll (z-axis) correction in radians
  14087. * @returns this TransformNode
  14088. */
  14089. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14090. /**
  14091. * Sets a new pivot point to the current node
  14092. * @param point defines the new pivot point to use
  14093. * @param space defines if the point is in world or local space (local by default)
  14094. * @returns the current TransformNode
  14095. */
  14096. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14097. /**
  14098. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14099. * @returns the pivot point
  14100. */
  14101. getPivotPoint(): Vector3;
  14102. /**
  14103. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14104. * @param result the vector3 to store the result
  14105. * @returns this TransformNode.
  14106. */
  14107. getPivotPointToRef(result: Vector3): TransformNode;
  14108. /**
  14109. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14110. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14111. */
  14112. getAbsolutePivotPoint(): Vector3;
  14113. /**
  14114. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14115. * @param result vector3 to store the result
  14116. * @returns this TransformNode.
  14117. */
  14118. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14119. /**
  14120. * Defines the passed node as the parent of the current node.
  14121. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14122. * @see https://doc.babylonjs.com/how_to/parenting
  14123. * @param node the node ot set as the parent
  14124. * @returns this TransformNode.
  14125. */
  14126. setParent(node: Nullable<Node>): TransformNode;
  14127. private _nonUniformScaling;
  14128. /**
  14129. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14130. */
  14131. get nonUniformScaling(): boolean;
  14132. /** @hidden */
  14133. _updateNonUniformScalingState(value: boolean): boolean;
  14134. /**
  14135. * Attach the current TransformNode to another TransformNode associated with a bone
  14136. * @param bone Bone affecting the TransformNode
  14137. * @param affectedTransformNode TransformNode associated with the bone
  14138. * @returns this object
  14139. */
  14140. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14141. /**
  14142. * Detach the transform node if its associated with a bone
  14143. * @returns this object
  14144. */
  14145. detachFromBone(): TransformNode;
  14146. private static _rotationAxisCache;
  14147. /**
  14148. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14149. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14150. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14151. * The passed axis is also normalized.
  14152. * @param axis the axis to rotate around
  14153. * @param amount the amount to rotate in radians
  14154. * @param space Space to rotate in (Default: local)
  14155. * @returns the TransformNode.
  14156. */
  14157. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14158. /**
  14159. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14160. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14161. * The passed axis is also normalized. .
  14162. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14163. * @param point the point to rotate around
  14164. * @param axis the axis to rotate around
  14165. * @param amount the amount to rotate in radians
  14166. * @returns the TransformNode
  14167. */
  14168. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14169. /**
  14170. * Translates the mesh along the axis vector for the passed distance in the given space.
  14171. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14172. * @param axis the axis to translate in
  14173. * @param distance the distance to translate
  14174. * @param space Space to rotate in (Default: local)
  14175. * @returns the TransformNode.
  14176. */
  14177. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14178. /**
  14179. * Adds a rotation step to the mesh current rotation.
  14180. * x, y, z are Euler angles expressed in radians.
  14181. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14182. * This means this rotation is made in the mesh local space only.
  14183. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14184. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14185. * ```javascript
  14186. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14187. * ```
  14188. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14189. * 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.
  14190. * @param x Rotation to add
  14191. * @param y Rotation to add
  14192. * @param z Rotation to add
  14193. * @returns the TransformNode.
  14194. */
  14195. addRotation(x: number, y: number, z: number): TransformNode;
  14196. /**
  14197. * @hidden
  14198. */
  14199. protected _getEffectiveParent(): Nullable<Node>;
  14200. /**
  14201. * Computes the world matrix of the node
  14202. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14203. * @returns the world matrix
  14204. */
  14205. computeWorldMatrix(force?: boolean): Matrix;
  14206. /**
  14207. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14208. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14209. */
  14210. resetLocalMatrix(independentOfChildren?: boolean): void;
  14211. protected _afterComputeWorldMatrix(): void;
  14212. /**
  14213. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14214. * @param func callback function to add
  14215. *
  14216. * @returns the TransformNode.
  14217. */
  14218. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14219. /**
  14220. * Removes a registered callback function.
  14221. * @param func callback function to remove
  14222. * @returns the TransformNode.
  14223. */
  14224. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14225. /**
  14226. * Gets the position of the current mesh in camera space
  14227. * @param camera defines the camera to use
  14228. * @returns a position
  14229. */
  14230. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14231. /**
  14232. * Returns the distance from the mesh to the active camera
  14233. * @param camera defines the camera to use
  14234. * @returns the distance
  14235. */
  14236. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14237. /**
  14238. * Clone the current transform node
  14239. * @param name Name of the new clone
  14240. * @param newParent New parent for the clone
  14241. * @param doNotCloneChildren Do not clone children hierarchy
  14242. * @returns the new transform node
  14243. */
  14244. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14245. /**
  14246. * Serializes the objects information.
  14247. * @param currentSerializationObject defines the object to serialize in
  14248. * @returns the serialized object
  14249. */
  14250. serialize(currentSerializationObject?: any): any;
  14251. /**
  14252. * Returns a new TransformNode object parsed from the source provided.
  14253. * @param parsedTransformNode is the source.
  14254. * @param scene the scne the object belongs to
  14255. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14256. * @returns a new TransformNode object parsed from the source provided.
  14257. */
  14258. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14259. /**
  14260. * Get all child-transformNodes of this node
  14261. * @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
  14262. * @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
  14263. * @returns an array of TransformNode
  14264. */
  14265. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14266. /**
  14267. * Releases resources associated with this transform node.
  14268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14270. */
  14271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14272. /**
  14273. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14274. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14275. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14276. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14277. * @returns the current mesh
  14278. */
  14279. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14280. private _syncAbsoluteScalingAndRotation;
  14281. }
  14282. }
  14283. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14284. /**
  14285. * Class used to override all child animations of a given target
  14286. */
  14287. export class AnimationPropertiesOverride {
  14288. /**
  14289. * Gets or sets a value indicating if animation blending must be used
  14290. */
  14291. enableBlending: boolean;
  14292. /**
  14293. * Gets or sets the blending speed to use when enableBlending is true
  14294. */
  14295. blendingSpeed: number;
  14296. /**
  14297. * Gets or sets the default loop mode to use
  14298. */
  14299. loopMode: number;
  14300. }
  14301. }
  14302. declare module "babylonjs/Bones/bone" {
  14303. import { Skeleton } from "babylonjs/Bones/skeleton";
  14304. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14305. import { Nullable } from "babylonjs/types";
  14306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14307. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14308. import { Node } from "babylonjs/node";
  14309. import { Space } from "babylonjs/Maths/math.axis";
  14310. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14311. /**
  14312. * Class used to store bone information
  14313. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14314. */
  14315. export class Bone extends Node {
  14316. /**
  14317. * defines the bone name
  14318. */
  14319. name: string;
  14320. private static _tmpVecs;
  14321. private static _tmpQuat;
  14322. private static _tmpMats;
  14323. /**
  14324. * Gets the list of child bones
  14325. */
  14326. children: Bone[];
  14327. /** Gets the animations associated with this bone */
  14328. animations: import("babylonjs/Animations/animation").Animation[];
  14329. /**
  14330. * Gets or sets bone length
  14331. */
  14332. length: number;
  14333. /**
  14334. * @hidden Internal only
  14335. * Set this value to map this bone to a different index in the transform matrices
  14336. * Set this value to -1 to exclude the bone from the transform matrices
  14337. */
  14338. _index: Nullable<number>;
  14339. private _skeleton;
  14340. private _localMatrix;
  14341. private _restPose;
  14342. private _baseMatrix;
  14343. private _absoluteTransform;
  14344. private _invertedAbsoluteTransform;
  14345. private _parent;
  14346. private _scalingDeterminant;
  14347. private _worldTransform;
  14348. private _localScaling;
  14349. private _localRotation;
  14350. private _localPosition;
  14351. private _needToDecompose;
  14352. private _needToCompose;
  14353. /** @hidden */
  14354. _linkedTransformNode: Nullable<TransformNode>;
  14355. /** @hidden */
  14356. _waitingTransformNodeId: Nullable<string>;
  14357. /** @hidden */
  14358. get _matrix(): Matrix;
  14359. /** @hidden */
  14360. set _matrix(value: Matrix);
  14361. /**
  14362. * Create a new bone
  14363. * @param name defines the bone name
  14364. * @param skeleton defines the parent skeleton
  14365. * @param parentBone defines the parent (can be null if the bone is the root)
  14366. * @param localMatrix defines the local matrix
  14367. * @param restPose defines the rest pose matrix
  14368. * @param baseMatrix defines the base matrix
  14369. * @param index defines index of the bone in the hiearchy
  14370. */
  14371. constructor(
  14372. /**
  14373. * defines the bone name
  14374. */
  14375. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14376. /**
  14377. * Gets the current object class name.
  14378. * @return the class name
  14379. */
  14380. getClassName(): string;
  14381. /**
  14382. * Gets the parent skeleton
  14383. * @returns a skeleton
  14384. */
  14385. getSkeleton(): Skeleton;
  14386. /**
  14387. * Gets parent bone
  14388. * @returns a bone or null if the bone is the root of the bone hierarchy
  14389. */
  14390. getParent(): Nullable<Bone>;
  14391. /**
  14392. * Returns an array containing the root bones
  14393. * @returns an array containing the root bones
  14394. */
  14395. getChildren(): Array<Bone>;
  14396. /**
  14397. * Gets the node index in matrix array generated for rendering
  14398. * @returns the node index
  14399. */
  14400. getIndex(): number;
  14401. /**
  14402. * Sets the parent bone
  14403. * @param parent defines the parent (can be null if the bone is the root)
  14404. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14405. */
  14406. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14407. /**
  14408. * Gets the local matrix
  14409. * @returns a matrix
  14410. */
  14411. getLocalMatrix(): Matrix;
  14412. /**
  14413. * Gets the base matrix (initial matrix which remains unchanged)
  14414. * @returns a matrix
  14415. */
  14416. getBaseMatrix(): Matrix;
  14417. /**
  14418. * Gets the rest pose matrix
  14419. * @returns a matrix
  14420. */
  14421. getRestPose(): Matrix;
  14422. /**
  14423. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14424. */
  14425. getWorldMatrix(): Matrix;
  14426. /**
  14427. * Sets the local matrix to rest pose matrix
  14428. */
  14429. returnToRest(): void;
  14430. /**
  14431. * Gets the inverse of the absolute transform matrix.
  14432. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14433. * @returns a matrix
  14434. */
  14435. getInvertedAbsoluteTransform(): Matrix;
  14436. /**
  14437. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14438. * @returns a matrix
  14439. */
  14440. getAbsoluteTransform(): Matrix;
  14441. /**
  14442. * Links with the given transform node.
  14443. * The local matrix of this bone is copied from the transform node every frame.
  14444. * @param transformNode defines the transform node to link to
  14445. */
  14446. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14447. /**
  14448. * Gets the node used to drive the bone's transformation
  14449. * @returns a transform node or null
  14450. */
  14451. getTransformNode(): Nullable<TransformNode>;
  14452. /** Gets or sets current position (in local space) */
  14453. get position(): Vector3;
  14454. set position(newPosition: Vector3);
  14455. /** Gets or sets current rotation (in local space) */
  14456. get rotation(): Vector3;
  14457. set rotation(newRotation: Vector3);
  14458. /** Gets or sets current rotation quaternion (in local space) */
  14459. get rotationQuaternion(): Quaternion;
  14460. set rotationQuaternion(newRotation: Quaternion);
  14461. /** Gets or sets current scaling (in local space) */
  14462. get scaling(): Vector3;
  14463. set scaling(newScaling: Vector3);
  14464. /**
  14465. * Gets the animation properties override
  14466. */
  14467. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14468. private _decompose;
  14469. private _compose;
  14470. /**
  14471. * Update the base and local matrices
  14472. * @param matrix defines the new base or local matrix
  14473. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14474. * @param updateLocalMatrix defines if the local matrix should be updated
  14475. */
  14476. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14477. /** @hidden */
  14478. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14479. /**
  14480. * Flag the bone as dirty (Forcing it to update everything)
  14481. */
  14482. markAsDirty(): void;
  14483. /** @hidden */
  14484. _markAsDirtyAndCompose(): void;
  14485. private _markAsDirtyAndDecompose;
  14486. /**
  14487. * Translate the bone in local or world space
  14488. * @param vec The amount to translate the bone
  14489. * @param space The space that the translation is in
  14490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14491. */
  14492. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14493. /**
  14494. * Set the postion of the bone in local or world space
  14495. * @param position The position to set the bone
  14496. * @param space The space that the position is in
  14497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14498. */
  14499. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14500. /**
  14501. * Set the absolute position of the bone (world space)
  14502. * @param position The position to set the bone
  14503. * @param mesh The mesh that this bone is attached to
  14504. */
  14505. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14506. /**
  14507. * Scale the bone on the x, y and z axes (in local space)
  14508. * @param x The amount to scale the bone on the x axis
  14509. * @param y The amount to scale the bone on the y axis
  14510. * @param z The amount to scale the bone on the z axis
  14511. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14512. */
  14513. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14514. /**
  14515. * Set the bone scaling in local space
  14516. * @param scale defines the scaling vector
  14517. */
  14518. setScale(scale: Vector3): void;
  14519. /**
  14520. * Gets the current scaling in local space
  14521. * @returns the current scaling vector
  14522. */
  14523. getScale(): Vector3;
  14524. /**
  14525. * Gets the current scaling in local space and stores it in a target vector
  14526. * @param result defines the target vector
  14527. */
  14528. getScaleToRef(result: Vector3): void;
  14529. /**
  14530. * Set the yaw, pitch, and roll of the bone in local or world space
  14531. * @param yaw The rotation of the bone on the y axis
  14532. * @param pitch The rotation of the bone on the x axis
  14533. * @param roll The rotation of the bone on the z axis
  14534. * @param space The space that the axes of rotation are in
  14535. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14536. */
  14537. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14538. /**
  14539. * Add a rotation to the bone on an axis in local or world space
  14540. * @param axis The axis to rotate the bone on
  14541. * @param amount The amount to rotate the bone
  14542. * @param space The space that the axis is in
  14543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14544. */
  14545. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14546. /**
  14547. * Set the rotation of the bone to a particular axis angle in local or world space
  14548. * @param axis The axis to rotate the bone on
  14549. * @param angle The angle that the bone should be rotated to
  14550. * @param space The space that the axis is in
  14551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14552. */
  14553. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14554. /**
  14555. * Set the euler rotation of the bone in local of world space
  14556. * @param rotation The euler rotation that the bone should be set to
  14557. * @param space The space that the rotation is in
  14558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14559. */
  14560. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14561. /**
  14562. * Set the quaternion rotation of the bone in local of world space
  14563. * @param quat The quaternion rotation that the bone should be set to
  14564. * @param space The space that the rotation is in
  14565. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14566. */
  14567. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14568. /**
  14569. * Set the rotation matrix of the bone in local of world space
  14570. * @param rotMat The rotation matrix that the bone should be set to
  14571. * @param space The space that the rotation is in
  14572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14573. */
  14574. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14575. private _rotateWithMatrix;
  14576. private _getNegativeRotationToRef;
  14577. /**
  14578. * Get the position of the bone in local or world space
  14579. * @param space The space that the returned position is in
  14580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14581. * @returns The position of the bone
  14582. */
  14583. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14584. /**
  14585. * Copy the position of the bone to a vector3 in local or world space
  14586. * @param space The space that the returned position is in
  14587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14588. * @param result The vector3 to copy the position to
  14589. */
  14590. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14591. /**
  14592. * Get the absolute position of the bone (world space)
  14593. * @param mesh The mesh that this bone is attached to
  14594. * @returns The absolute position of the bone
  14595. */
  14596. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14597. /**
  14598. * Copy the absolute position of the bone (world space) to the result param
  14599. * @param mesh The mesh that this bone is attached to
  14600. * @param result The vector3 to copy the absolute position to
  14601. */
  14602. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14603. /**
  14604. * Compute the absolute transforms of this bone and its children
  14605. */
  14606. computeAbsoluteTransforms(): void;
  14607. /**
  14608. * Get the world direction from an axis that is in the local space of the bone
  14609. * @param localAxis The local direction that is used to compute the world direction
  14610. * @param mesh The mesh that this bone is attached to
  14611. * @returns The world direction
  14612. */
  14613. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14614. /**
  14615. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14616. * @param localAxis The local direction that is used to compute the world direction
  14617. * @param mesh The mesh that this bone is attached to
  14618. * @param result The vector3 that the world direction will be copied to
  14619. */
  14620. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14621. /**
  14622. * Get the euler rotation of the bone in local or world space
  14623. * @param space The space that the rotation should be in
  14624. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14625. * @returns The euler rotation
  14626. */
  14627. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14628. /**
  14629. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14630. * @param space The space that the rotation should be in
  14631. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14632. * @param result The vector3 that the rotation should be copied to
  14633. */
  14634. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14635. /**
  14636. * Get the quaternion rotation of the bone in either local or world space
  14637. * @param space The space that the rotation should be in
  14638. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14639. * @returns The quaternion rotation
  14640. */
  14641. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14642. /**
  14643. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14644. * @param space The space that the rotation should be in
  14645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14646. * @param result The quaternion that the rotation should be copied to
  14647. */
  14648. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14649. /**
  14650. * Get the rotation matrix of the bone in local or world space
  14651. * @param space The space that the rotation should be in
  14652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14653. * @returns The rotation matrix
  14654. */
  14655. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14656. /**
  14657. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14658. * @param space The space that the rotation should be in
  14659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14660. * @param result The quaternion that the rotation should be copied to
  14661. */
  14662. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14663. /**
  14664. * Get the world position of a point that is in the local space of the bone
  14665. * @param position The local position
  14666. * @param mesh The mesh that this bone is attached to
  14667. * @returns The world position
  14668. */
  14669. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14670. /**
  14671. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14672. * @param position The local position
  14673. * @param mesh The mesh that this bone is attached to
  14674. * @param result The vector3 that the world position should be copied to
  14675. */
  14676. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14677. /**
  14678. * Get the local position of a point that is in world space
  14679. * @param position The world position
  14680. * @param mesh The mesh that this bone is attached to
  14681. * @returns The local position
  14682. */
  14683. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14684. /**
  14685. * Get the local position of a point that is in world space and copy it to the result param
  14686. * @param position The world position
  14687. * @param mesh The mesh that this bone is attached to
  14688. * @param result The vector3 that the local position should be copied to
  14689. */
  14690. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14691. }
  14692. }
  14693. declare module "babylonjs/Animations/runtimeAnimation" {
  14694. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14695. import { Animatable } from "babylonjs/Animations/animatable";
  14696. import { Scene } from "babylonjs/scene";
  14697. /**
  14698. * Defines a runtime animation
  14699. */
  14700. export class RuntimeAnimation {
  14701. private _events;
  14702. /**
  14703. * The current frame of the runtime animation
  14704. */
  14705. private _currentFrame;
  14706. /**
  14707. * The animation used by the runtime animation
  14708. */
  14709. private _animation;
  14710. /**
  14711. * The target of the runtime animation
  14712. */
  14713. private _target;
  14714. /**
  14715. * The initiating animatable
  14716. */
  14717. private _host;
  14718. /**
  14719. * The original value of the runtime animation
  14720. */
  14721. private _originalValue;
  14722. /**
  14723. * The original blend value of the runtime animation
  14724. */
  14725. private _originalBlendValue;
  14726. /**
  14727. * The offsets cache of the runtime animation
  14728. */
  14729. private _offsetsCache;
  14730. /**
  14731. * The high limits cache of the runtime animation
  14732. */
  14733. private _highLimitsCache;
  14734. /**
  14735. * Specifies if the runtime animation has been stopped
  14736. */
  14737. private _stopped;
  14738. /**
  14739. * The blending factor of the runtime animation
  14740. */
  14741. private _blendingFactor;
  14742. /**
  14743. * The BabylonJS scene
  14744. */
  14745. private _scene;
  14746. /**
  14747. * The current value of the runtime animation
  14748. */
  14749. private _currentValue;
  14750. /** @hidden */
  14751. _animationState: _IAnimationState;
  14752. /**
  14753. * The active target of the runtime animation
  14754. */
  14755. private _activeTargets;
  14756. private _currentActiveTarget;
  14757. private _directTarget;
  14758. /**
  14759. * The target path of the runtime animation
  14760. */
  14761. private _targetPath;
  14762. /**
  14763. * The weight of the runtime animation
  14764. */
  14765. private _weight;
  14766. /**
  14767. * The ratio offset of the runtime animation
  14768. */
  14769. private _ratioOffset;
  14770. /**
  14771. * The previous delay of the runtime animation
  14772. */
  14773. private _previousDelay;
  14774. /**
  14775. * The previous ratio of the runtime animation
  14776. */
  14777. private _previousRatio;
  14778. private _enableBlending;
  14779. private _keys;
  14780. private _minFrame;
  14781. private _maxFrame;
  14782. private _minValue;
  14783. private _maxValue;
  14784. private _targetIsArray;
  14785. /**
  14786. * Gets the current frame of the runtime animation
  14787. */
  14788. get currentFrame(): number;
  14789. /**
  14790. * Gets the weight of the runtime animation
  14791. */
  14792. get weight(): number;
  14793. /**
  14794. * Gets the current value of the runtime animation
  14795. */
  14796. get currentValue(): any;
  14797. /**
  14798. * Gets the target path of the runtime animation
  14799. */
  14800. get targetPath(): string;
  14801. /**
  14802. * Gets the actual target of the runtime animation
  14803. */
  14804. get target(): any;
  14805. /** @hidden */
  14806. _onLoop: () => void;
  14807. /**
  14808. * Create a new RuntimeAnimation object
  14809. * @param target defines the target of the animation
  14810. * @param animation defines the source animation object
  14811. * @param scene defines the hosting scene
  14812. * @param host defines the initiating Animatable
  14813. */
  14814. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14815. private _preparePath;
  14816. /**
  14817. * Gets the animation from the runtime animation
  14818. */
  14819. get animation(): Animation;
  14820. /**
  14821. * Resets the runtime animation to the beginning
  14822. * @param restoreOriginal defines whether to restore the target property to the original value
  14823. */
  14824. reset(restoreOriginal?: boolean): void;
  14825. /**
  14826. * Specifies if the runtime animation is stopped
  14827. * @returns Boolean specifying if the runtime animation is stopped
  14828. */
  14829. isStopped(): boolean;
  14830. /**
  14831. * Disposes of the runtime animation
  14832. */
  14833. dispose(): void;
  14834. /**
  14835. * Apply the interpolated value to the target
  14836. * @param currentValue defines the value computed by the animation
  14837. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14838. */
  14839. setValue(currentValue: any, weight: number): void;
  14840. private _getOriginalValues;
  14841. private _setValue;
  14842. /**
  14843. * Gets the loop pmode of the runtime animation
  14844. * @returns Loop Mode
  14845. */
  14846. private _getCorrectLoopMode;
  14847. /**
  14848. * Move the current animation to a given frame
  14849. * @param frame defines the frame to move to
  14850. */
  14851. goToFrame(frame: number): void;
  14852. /**
  14853. * @hidden Internal use only
  14854. */
  14855. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14856. /**
  14857. * Execute the current animation
  14858. * @param delay defines the delay to add to the current frame
  14859. * @param from defines the lower bound of the animation range
  14860. * @param to defines the upper bound of the animation range
  14861. * @param loop defines if the current animation must loop
  14862. * @param speedRatio defines the current speed ratio
  14863. * @param weight defines the weight of the animation (default is -1 so no weight)
  14864. * @param onLoop optional callback called when animation loops
  14865. * @returns a boolean indicating if the animation is running
  14866. */
  14867. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14868. }
  14869. }
  14870. declare module "babylonjs/Animations/animatable" {
  14871. import { Animation } from "babylonjs/Animations/animation";
  14872. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14873. import { Nullable } from "babylonjs/types";
  14874. import { Observable } from "babylonjs/Misc/observable";
  14875. import { Scene } from "babylonjs/scene";
  14876. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14877. import { Node } from "babylonjs/node";
  14878. /**
  14879. * Class used to store an actual running animation
  14880. */
  14881. export class Animatable {
  14882. /** defines the target object */
  14883. target: any;
  14884. /** defines the starting frame number (default is 0) */
  14885. fromFrame: number;
  14886. /** defines the ending frame number (default is 100) */
  14887. toFrame: number;
  14888. /** defines if the animation must loop (default is false) */
  14889. loopAnimation: boolean;
  14890. /** defines a callback to call when animation ends if it is not looping */
  14891. onAnimationEnd?: (() => void) | null | undefined;
  14892. /** defines a callback to call when animation loops */
  14893. onAnimationLoop?: (() => void) | null | undefined;
  14894. private _localDelayOffset;
  14895. private _pausedDelay;
  14896. private _runtimeAnimations;
  14897. private _paused;
  14898. private _scene;
  14899. private _speedRatio;
  14900. private _weight;
  14901. private _syncRoot;
  14902. /**
  14903. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14904. * This will only apply for non looping animation (default is true)
  14905. */
  14906. disposeOnEnd: boolean;
  14907. /**
  14908. * Gets a boolean indicating if the animation has started
  14909. */
  14910. animationStarted: boolean;
  14911. /**
  14912. * Observer raised when the animation ends
  14913. */
  14914. onAnimationEndObservable: Observable<Animatable>;
  14915. /**
  14916. * Observer raised when the animation loops
  14917. */
  14918. onAnimationLoopObservable: Observable<Animatable>;
  14919. /**
  14920. * Gets the root Animatable used to synchronize and normalize animations
  14921. */
  14922. get syncRoot(): Nullable<Animatable>;
  14923. /**
  14924. * Gets the current frame of the first RuntimeAnimation
  14925. * Used to synchronize Animatables
  14926. */
  14927. get masterFrame(): number;
  14928. /**
  14929. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14930. */
  14931. get weight(): number;
  14932. set weight(value: number);
  14933. /**
  14934. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14935. */
  14936. get speedRatio(): number;
  14937. set speedRatio(value: number);
  14938. /**
  14939. * Creates a new Animatable
  14940. * @param scene defines the hosting scene
  14941. * @param target defines the target object
  14942. * @param fromFrame defines the starting frame number (default is 0)
  14943. * @param toFrame defines the ending frame number (default is 100)
  14944. * @param loopAnimation defines if the animation must loop (default is false)
  14945. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14946. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14947. * @param animations defines a group of animation to add to the new Animatable
  14948. * @param onAnimationLoop defines a callback to call when animation loops
  14949. */
  14950. constructor(scene: Scene,
  14951. /** defines the target object */
  14952. target: any,
  14953. /** defines the starting frame number (default is 0) */
  14954. fromFrame?: number,
  14955. /** defines the ending frame number (default is 100) */
  14956. toFrame?: number,
  14957. /** defines if the animation must loop (default is false) */
  14958. loopAnimation?: boolean, speedRatio?: number,
  14959. /** defines a callback to call when animation ends if it is not looping */
  14960. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14961. /** defines a callback to call when animation loops */
  14962. onAnimationLoop?: (() => void) | null | undefined);
  14963. /**
  14964. * Synchronize and normalize current Animatable with a source Animatable
  14965. * This is useful when using animation weights and when animations are not of the same length
  14966. * @param root defines the root Animatable to synchronize with
  14967. * @returns the current Animatable
  14968. */
  14969. syncWith(root: Animatable): Animatable;
  14970. /**
  14971. * Gets the list of runtime animations
  14972. * @returns an array of RuntimeAnimation
  14973. */
  14974. getAnimations(): RuntimeAnimation[];
  14975. /**
  14976. * Adds more animations to the current animatable
  14977. * @param target defines the target of the animations
  14978. * @param animations defines the new animations to add
  14979. */
  14980. appendAnimations(target: any, animations: Animation[]): void;
  14981. /**
  14982. * Gets the source animation for a specific property
  14983. * @param property defines the propertyu to look for
  14984. * @returns null or the source animation for the given property
  14985. */
  14986. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14987. /**
  14988. * Gets the runtime animation for a specific property
  14989. * @param property defines the propertyu to look for
  14990. * @returns null or the runtime animation for the given property
  14991. */
  14992. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14993. /**
  14994. * Resets the animatable to its original state
  14995. */
  14996. reset(): void;
  14997. /**
  14998. * Allows the animatable to blend with current running animations
  14999. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15000. * @param blendingSpeed defines the blending speed to use
  15001. */
  15002. enableBlending(blendingSpeed: number): void;
  15003. /**
  15004. * Disable animation blending
  15005. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15006. */
  15007. disableBlending(): void;
  15008. /**
  15009. * Jump directly to a given frame
  15010. * @param frame defines the frame to jump to
  15011. */
  15012. goToFrame(frame: number): void;
  15013. /**
  15014. * Pause the animation
  15015. */
  15016. pause(): void;
  15017. /**
  15018. * Restart the animation
  15019. */
  15020. restart(): void;
  15021. private _raiseOnAnimationEnd;
  15022. /**
  15023. * Stop and delete the current animation
  15024. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15025. * @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)
  15026. */
  15027. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15028. /**
  15029. * Wait asynchronously for the animation to end
  15030. * @returns a promise which will be fullfilled when the animation ends
  15031. */
  15032. waitAsync(): Promise<Animatable>;
  15033. /** @hidden */
  15034. _animate(delay: number): boolean;
  15035. }
  15036. module "babylonjs/scene" {
  15037. interface Scene {
  15038. /** @hidden */
  15039. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15040. /** @hidden */
  15041. _processLateAnimationBindingsForMatrices(holder: {
  15042. totalWeight: number;
  15043. animations: RuntimeAnimation[];
  15044. originalValue: Matrix;
  15045. }): any;
  15046. /** @hidden */
  15047. _processLateAnimationBindingsForQuaternions(holder: {
  15048. totalWeight: number;
  15049. animations: RuntimeAnimation[];
  15050. originalValue: Quaternion;
  15051. }, refQuaternion: Quaternion): Quaternion;
  15052. /** @hidden */
  15053. _processLateAnimationBindings(): void;
  15054. /**
  15055. * Will start the animation sequence of a given target
  15056. * @param target defines the target
  15057. * @param from defines from which frame should animation start
  15058. * @param to defines until which frame should animation run.
  15059. * @param weight defines the weight to apply to the animation (1.0 by default)
  15060. * @param loop defines if the animation loops
  15061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15062. * @param onAnimationEnd defines the function to be executed when the animation ends
  15063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15064. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15065. * @param onAnimationLoop defines the callback to call when an animation loops
  15066. * @returns the animatable object created for this animation
  15067. */
  15068. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15069. /**
  15070. * Will start the animation sequence of a given target
  15071. * @param target defines the target
  15072. * @param from defines from which frame should animation start
  15073. * @param to defines until which frame should animation run.
  15074. * @param loop defines if the animation loops
  15075. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15076. * @param onAnimationEnd defines the function to be executed when the animation ends
  15077. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15078. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15079. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15080. * @param onAnimationLoop defines the callback to call when an animation loops
  15081. * @returns the animatable object created for this animation
  15082. */
  15083. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15084. /**
  15085. * Will start the animation sequence of a given target and its hierarchy
  15086. * @param target defines the target
  15087. * @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.
  15088. * @param from defines from which frame should animation start
  15089. * @param to defines until which frame should animation run.
  15090. * @param loop defines if the animation loops
  15091. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15092. * @param onAnimationEnd defines the function to be executed when the animation ends
  15093. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15094. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15095. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15096. * @param onAnimationLoop defines the callback to call when an animation loops
  15097. * @returns the list of created animatables
  15098. */
  15099. 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[];
  15100. /**
  15101. * Begin a new animation on a given node
  15102. * @param target defines the target where the animation will take place
  15103. * @param animations defines the list of animations to start
  15104. * @param from defines the initial value
  15105. * @param to defines the final value
  15106. * @param loop defines if you want animation to loop (off by default)
  15107. * @param speedRatio defines the speed ratio to apply to all animations
  15108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15109. * @param onAnimationLoop defines the callback to call when an animation loops
  15110. * @returns the list of created animatables
  15111. */
  15112. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15113. /**
  15114. * Begin a new animation on a given node and its hierarchy
  15115. * @param target defines the root node where the animation will take place
  15116. * @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.
  15117. * @param animations defines the list of animations to start
  15118. * @param from defines the initial value
  15119. * @param to defines the final value
  15120. * @param loop defines if you want animation to loop (off by default)
  15121. * @param speedRatio defines the speed ratio to apply to all animations
  15122. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15123. * @param onAnimationLoop defines the callback to call when an animation loops
  15124. * @returns the list of animatables created for all nodes
  15125. */
  15126. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15127. /**
  15128. * Gets the animatable associated with a specific target
  15129. * @param target defines the target of the animatable
  15130. * @returns the required animatable if found
  15131. */
  15132. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15133. /**
  15134. * Gets all animatables associated with a given target
  15135. * @param target defines the target to look animatables for
  15136. * @returns an array of Animatables
  15137. */
  15138. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15139. /**
  15140. * Stops and removes all animations that have been applied to the scene
  15141. */
  15142. stopAllAnimations(): void;
  15143. /**
  15144. * Gets the current delta time used by animation engine
  15145. */
  15146. deltaTime: number;
  15147. }
  15148. }
  15149. module "babylonjs/Bones/bone" {
  15150. interface Bone {
  15151. /**
  15152. * Copy an animation range from another bone
  15153. * @param source defines the source bone
  15154. * @param rangeName defines the range name to copy
  15155. * @param frameOffset defines the frame offset
  15156. * @param rescaleAsRequired defines if rescaling must be applied if required
  15157. * @param skelDimensionsRatio defines the scaling ratio
  15158. * @returns true if operation was successful
  15159. */
  15160. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15161. }
  15162. }
  15163. }
  15164. declare module "babylonjs/Bones/skeleton" {
  15165. import { Bone } from "babylonjs/Bones/bone";
  15166. import { Observable } from "babylonjs/Misc/observable";
  15167. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15168. import { Scene } from "babylonjs/scene";
  15169. import { Nullable } from "babylonjs/types";
  15170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15171. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15172. import { Animatable } from "babylonjs/Animations/animatable";
  15173. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15174. import { Animation } from "babylonjs/Animations/animation";
  15175. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15176. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15177. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15178. /**
  15179. * Class used to handle skinning animations
  15180. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15181. */
  15182. export class Skeleton implements IAnimatable {
  15183. /** defines the skeleton name */
  15184. name: string;
  15185. /** defines the skeleton Id */
  15186. id: string;
  15187. /**
  15188. * Defines the list of child bones
  15189. */
  15190. bones: Bone[];
  15191. /**
  15192. * Defines an estimate of the dimension of the skeleton at rest
  15193. */
  15194. dimensionsAtRest: Vector3;
  15195. /**
  15196. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15197. */
  15198. needInitialSkinMatrix: boolean;
  15199. /**
  15200. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15201. */
  15202. overrideMesh: Nullable<AbstractMesh>;
  15203. /**
  15204. * Gets the list of animations attached to this skeleton
  15205. */
  15206. animations: Array<Animation>;
  15207. private _scene;
  15208. private _isDirty;
  15209. private _transformMatrices;
  15210. private _transformMatrixTexture;
  15211. private _meshesWithPoseMatrix;
  15212. private _animatables;
  15213. private _identity;
  15214. private _synchronizedWithMesh;
  15215. private _ranges;
  15216. private _lastAbsoluteTransformsUpdateId;
  15217. private _canUseTextureForBones;
  15218. private _uniqueId;
  15219. /** @hidden */
  15220. _numBonesWithLinkedTransformNode: number;
  15221. /** @hidden */
  15222. _hasWaitingData: Nullable<boolean>;
  15223. /**
  15224. * Specifies if the skeleton should be serialized
  15225. */
  15226. doNotSerialize: boolean;
  15227. private _useTextureToStoreBoneMatrices;
  15228. /**
  15229. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15230. * Please note that this option is not available if the hardware does not support it
  15231. */
  15232. get useTextureToStoreBoneMatrices(): boolean;
  15233. set useTextureToStoreBoneMatrices(value: boolean);
  15234. private _animationPropertiesOverride;
  15235. /**
  15236. * Gets or sets the animation properties override
  15237. */
  15238. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15239. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15240. /**
  15241. * List of inspectable custom properties (used by the Inspector)
  15242. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15243. */
  15244. inspectableCustomProperties: IInspectable[];
  15245. /**
  15246. * An observable triggered before computing the skeleton's matrices
  15247. */
  15248. onBeforeComputeObservable: Observable<Skeleton>;
  15249. /**
  15250. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15251. */
  15252. get isUsingTextureForMatrices(): boolean;
  15253. /**
  15254. * Gets the unique ID of this skeleton
  15255. */
  15256. get uniqueId(): number;
  15257. /**
  15258. * Creates a new skeleton
  15259. * @param name defines the skeleton name
  15260. * @param id defines the skeleton Id
  15261. * @param scene defines the hosting scene
  15262. */
  15263. constructor(
  15264. /** defines the skeleton name */
  15265. name: string,
  15266. /** defines the skeleton Id */
  15267. id: string, scene: Scene);
  15268. /**
  15269. * Gets the current object class name.
  15270. * @return the class name
  15271. */
  15272. getClassName(): string;
  15273. /**
  15274. * Returns an array containing the root bones
  15275. * @returns an array containing the root bones
  15276. */
  15277. getChildren(): Array<Bone>;
  15278. /**
  15279. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15280. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15281. * @returns a Float32Array containing matrices data
  15282. */
  15283. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15284. /**
  15285. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15286. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15287. * @returns a raw texture containing the data
  15288. */
  15289. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15290. /**
  15291. * Gets the current hosting scene
  15292. * @returns a scene object
  15293. */
  15294. getScene(): Scene;
  15295. /**
  15296. * Gets a string representing the current skeleton data
  15297. * @param fullDetails defines a boolean indicating if we want a verbose version
  15298. * @returns a string representing the current skeleton data
  15299. */
  15300. toString(fullDetails?: boolean): string;
  15301. /**
  15302. * Get bone's index searching by name
  15303. * @param name defines bone's name to search for
  15304. * @return the indice of the bone. Returns -1 if not found
  15305. */
  15306. getBoneIndexByName(name: string): number;
  15307. /**
  15308. * Creater a new animation range
  15309. * @param name defines the name of the range
  15310. * @param from defines the start key
  15311. * @param to defines the end key
  15312. */
  15313. createAnimationRange(name: string, from: number, to: number): void;
  15314. /**
  15315. * Delete a specific animation range
  15316. * @param name defines the name of the range
  15317. * @param deleteFrames defines if frames must be removed as well
  15318. */
  15319. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15320. /**
  15321. * Gets a specific animation range
  15322. * @param name defines the name of the range to look for
  15323. * @returns the requested animation range or null if not found
  15324. */
  15325. getAnimationRange(name: string): Nullable<AnimationRange>;
  15326. /**
  15327. * Gets the list of all animation ranges defined on this skeleton
  15328. * @returns an array
  15329. */
  15330. getAnimationRanges(): Nullable<AnimationRange>[];
  15331. /**
  15332. * Copy animation range from a source skeleton.
  15333. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15334. * @param source defines the source skeleton
  15335. * @param name defines the name of the range to copy
  15336. * @param rescaleAsRequired defines if rescaling must be applied if required
  15337. * @returns true if operation was successful
  15338. */
  15339. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15340. /**
  15341. * Forces the skeleton to go to rest pose
  15342. */
  15343. returnToRest(): void;
  15344. private _getHighestAnimationFrame;
  15345. /**
  15346. * Begin a specific animation range
  15347. * @param name defines the name of the range to start
  15348. * @param loop defines if looping must be turned on (false by default)
  15349. * @param speedRatio defines the speed ratio to apply (1 by default)
  15350. * @param onAnimationEnd defines a callback which will be called when animation will end
  15351. * @returns a new animatable
  15352. */
  15353. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15354. /** @hidden */
  15355. _markAsDirty(): void;
  15356. /** @hidden */
  15357. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15358. /** @hidden */
  15359. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15360. private _computeTransformMatrices;
  15361. /**
  15362. * Build all resources required to render a skeleton
  15363. */
  15364. prepare(): void;
  15365. /**
  15366. * Gets the list of animatables currently running for this skeleton
  15367. * @returns an array of animatables
  15368. */
  15369. getAnimatables(): IAnimatable[];
  15370. /**
  15371. * Clone the current skeleton
  15372. * @param name defines the name of the new skeleton
  15373. * @param id defines the id of the new skeleton
  15374. * @returns the new skeleton
  15375. */
  15376. clone(name: string, id?: string): Skeleton;
  15377. /**
  15378. * Enable animation blending for this skeleton
  15379. * @param blendingSpeed defines the blending speed to apply
  15380. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15381. */
  15382. enableBlending(blendingSpeed?: number): void;
  15383. /**
  15384. * Releases all resources associated with the current skeleton
  15385. */
  15386. dispose(): void;
  15387. /**
  15388. * Serialize the skeleton in a JSON object
  15389. * @returns a JSON object
  15390. */
  15391. serialize(): any;
  15392. /**
  15393. * Creates a new skeleton from serialized data
  15394. * @param parsedSkeleton defines the serialized data
  15395. * @param scene defines the hosting scene
  15396. * @returns a new skeleton
  15397. */
  15398. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15399. /**
  15400. * Compute all node absolute transforms
  15401. * @param forceUpdate defines if computation must be done even if cache is up to date
  15402. */
  15403. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15404. /**
  15405. * Gets the root pose matrix
  15406. * @returns a matrix
  15407. */
  15408. getPoseMatrix(): Nullable<Matrix>;
  15409. /**
  15410. * Sorts bones per internal index
  15411. */
  15412. sortBones(): void;
  15413. private _sortBones;
  15414. }
  15415. }
  15416. declare module "babylonjs/Meshes/instancedMesh" {
  15417. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15418. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15419. import { Camera } from "babylonjs/Cameras/camera";
  15420. import { Node } from "babylonjs/node";
  15421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15422. import { Mesh } from "babylonjs/Meshes/mesh";
  15423. import { Material } from "babylonjs/Materials/material";
  15424. import { Skeleton } from "babylonjs/Bones/skeleton";
  15425. import { Light } from "babylonjs/Lights/light";
  15426. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15427. /**
  15428. * Creates an instance based on a source mesh.
  15429. */
  15430. export class InstancedMesh extends AbstractMesh {
  15431. private _sourceMesh;
  15432. private _currentLOD;
  15433. /** @hidden */
  15434. _indexInSourceMeshInstanceArray: number;
  15435. constructor(name: string, source: Mesh);
  15436. /**
  15437. * Returns the string "InstancedMesh".
  15438. */
  15439. getClassName(): string;
  15440. /** Gets the list of lights affecting that mesh */
  15441. get lightSources(): Light[];
  15442. _resyncLightSources(): void;
  15443. _resyncLightSource(light: Light): void;
  15444. _removeLightSource(light: Light, dispose: boolean): void;
  15445. /**
  15446. * If the source mesh receives shadows
  15447. */
  15448. get receiveShadows(): boolean;
  15449. /**
  15450. * The material of the source mesh
  15451. */
  15452. get material(): Nullable<Material>;
  15453. /**
  15454. * Visibility of the source mesh
  15455. */
  15456. get visibility(): number;
  15457. /**
  15458. * Skeleton of the source mesh
  15459. */
  15460. get skeleton(): Nullable<Skeleton>;
  15461. /**
  15462. * Rendering ground id of the source mesh
  15463. */
  15464. get renderingGroupId(): number;
  15465. set renderingGroupId(value: number);
  15466. /**
  15467. * Returns the total number of vertices (integer).
  15468. */
  15469. getTotalVertices(): number;
  15470. /**
  15471. * Returns a positive integer : the total number of indices in this mesh geometry.
  15472. * @returns the numner of indices or zero if the mesh has no geometry.
  15473. */
  15474. getTotalIndices(): number;
  15475. /**
  15476. * The source mesh of the instance
  15477. */
  15478. get sourceMesh(): Mesh;
  15479. /**
  15480. * Is this node ready to be used/rendered
  15481. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15482. * @return {boolean} is it ready
  15483. */
  15484. isReady(completeCheck?: boolean): boolean;
  15485. /**
  15486. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15487. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15488. * @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.
  15489. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15490. */
  15491. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15492. /**
  15493. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15494. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15495. * The `data` are either a numeric array either a Float32Array.
  15496. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15497. * 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).
  15498. * Note that a new underlying VertexBuffer object is created each call.
  15499. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15500. *
  15501. * Possible `kind` values :
  15502. * - VertexBuffer.PositionKind
  15503. * - VertexBuffer.UVKind
  15504. * - VertexBuffer.UV2Kind
  15505. * - VertexBuffer.UV3Kind
  15506. * - VertexBuffer.UV4Kind
  15507. * - VertexBuffer.UV5Kind
  15508. * - VertexBuffer.UV6Kind
  15509. * - VertexBuffer.ColorKind
  15510. * - VertexBuffer.MatricesIndicesKind
  15511. * - VertexBuffer.MatricesIndicesExtraKind
  15512. * - VertexBuffer.MatricesWeightsKind
  15513. * - VertexBuffer.MatricesWeightsExtraKind
  15514. *
  15515. * Returns the Mesh.
  15516. */
  15517. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15518. /**
  15519. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15520. * If the mesh has no geometry, it is simply returned as it is.
  15521. * The `data` are either a numeric array either a Float32Array.
  15522. * No new underlying VertexBuffer object is created.
  15523. * 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.
  15524. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15525. *
  15526. * Possible `kind` values :
  15527. * - VertexBuffer.PositionKind
  15528. * - VertexBuffer.UVKind
  15529. * - VertexBuffer.UV2Kind
  15530. * - VertexBuffer.UV3Kind
  15531. * - VertexBuffer.UV4Kind
  15532. * - VertexBuffer.UV5Kind
  15533. * - VertexBuffer.UV6Kind
  15534. * - VertexBuffer.ColorKind
  15535. * - VertexBuffer.MatricesIndicesKind
  15536. * - VertexBuffer.MatricesIndicesExtraKind
  15537. * - VertexBuffer.MatricesWeightsKind
  15538. * - VertexBuffer.MatricesWeightsExtraKind
  15539. *
  15540. * Returns the Mesh.
  15541. */
  15542. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15543. /**
  15544. * Sets the mesh indices.
  15545. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15546. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15547. * This method creates a new index buffer each call.
  15548. * Returns the Mesh.
  15549. */
  15550. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15551. /**
  15552. * Boolean : True if the mesh owns the requested kind of data.
  15553. */
  15554. isVerticesDataPresent(kind: string): boolean;
  15555. /**
  15556. * Returns an array of indices (IndicesArray).
  15557. */
  15558. getIndices(): Nullable<IndicesArray>;
  15559. get _positions(): Nullable<Vector3[]>;
  15560. /**
  15561. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15562. * This means the mesh underlying bounding box and sphere are recomputed.
  15563. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15564. * @returns the current mesh
  15565. */
  15566. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15567. /** @hidden */
  15568. _preActivate(): InstancedMesh;
  15569. /** @hidden */
  15570. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15571. /** @hidden */
  15572. _postActivate(): void;
  15573. getWorldMatrix(): Matrix;
  15574. get isAnInstance(): boolean;
  15575. /**
  15576. * Returns the current associated LOD AbstractMesh.
  15577. */
  15578. getLOD(camera: Camera): AbstractMesh;
  15579. /** @hidden */
  15580. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15581. /** @hidden */
  15582. _syncSubMeshes(): InstancedMesh;
  15583. /** @hidden */
  15584. _generatePointsArray(): boolean;
  15585. /**
  15586. * Creates a new InstancedMesh from the current mesh.
  15587. * - name (string) : the cloned mesh name
  15588. * - newParent (optional Node) : the optional Node to parent the clone to.
  15589. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15590. *
  15591. * Returns the clone.
  15592. */
  15593. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15594. /**
  15595. * Disposes the InstancedMesh.
  15596. * Returns nothing.
  15597. */
  15598. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15599. }
  15600. module "babylonjs/Meshes/mesh" {
  15601. interface Mesh {
  15602. /**
  15603. * Register a custom buffer that will be instanced
  15604. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15605. * @param kind defines the buffer kind
  15606. * @param stride defines the stride in floats
  15607. */
  15608. registerInstancedBuffer(kind: string, stride: number): void;
  15609. /** @hidden */
  15610. _userInstancedBuffersStorage: {
  15611. data: {
  15612. [key: string]: Float32Array;
  15613. };
  15614. sizes: {
  15615. [key: string]: number;
  15616. };
  15617. vertexBuffers: {
  15618. [key: string]: Nullable<VertexBuffer>;
  15619. };
  15620. strides: {
  15621. [key: string]: number;
  15622. };
  15623. };
  15624. }
  15625. }
  15626. module "babylonjs/Meshes/abstractMesh" {
  15627. interface AbstractMesh {
  15628. /**
  15629. * Object used to store instanced buffers defined by user
  15630. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15631. */
  15632. instancedBuffers: {
  15633. [key: string]: any;
  15634. };
  15635. }
  15636. }
  15637. }
  15638. declare module "babylonjs/Materials/shaderMaterial" {
  15639. import { Scene } from "babylonjs/scene";
  15640. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15642. import { Mesh } from "babylonjs/Meshes/mesh";
  15643. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15644. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15645. import { Texture } from "babylonjs/Materials/Textures/texture";
  15646. import { Material } from "babylonjs/Materials/material";
  15647. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15648. /**
  15649. * Defines the options associated with the creation of a shader material.
  15650. */
  15651. export interface IShaderMaterialOptions {
  15652. /**
  15653. * Does the material work in alpha blend mode
  15654. */
  15655. needAlphaBlending: boolean;
  15656. /**
  15657. * Does the material work in alpha test mode
  15658. */
  15659. needAlphaTesting: boolean;
  15660. /**
  15661. * The list of attribute names used in the shader
  15662. */
  15663. attributes: string[];
  15664. /**
  15665. * The list of unifrom names used in the shader
  15666. */
  15667. uniforms: string[];
  15668. /**
  15669. * The list of UBO names used in the shader
  15670. */
  15671. uniformBuffers: string[];
  15672. /**
  15673. * The list of sampler names used in the shader
  15674. */
  15675. samplers: string[];
  15676. /**
  15677. * The list of defines used in the shader
  15678. */
  15679. defines: string[];
  15680. }
  15681. /**
  15682. * 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.
  15683. *
  15684. * This returned material effects how the mesh will look based on the code in the shaders.
  15685. *
  15686. * @see http://doc.babylonjs.com/how_to/shader_material
  15687. */
  15688. export class ShaderMaterial extends Material {
  15689. private _shaderPath;
  15690. private _options;
  15691. private _textures;
  15692. private _textureArrays;
  15693. private _floats;
  15694. private _ints;
  15695. private _floatsArrays;
  15696. private _colors3;
  15697. private _colors3Arrays;
  15698. private _colors4;
  15699. private _colors4Arrays;
  15700. private _vectors2;
  15701. private _vectors3;
  15702. private _vectors4;
  15703. private _matrices;
  15704. private _matrixArrays;
  15705. private _matrices3x3;
  15706. private _matrices2x2;
  15707. private _vectors2Arrays;
  15708. private _vectors3Arrays;
  15709. private _vectors4Arrays;
  15710. private _cachedWorldViewMatrix;
  15711. private _cachedWorldViewProjectionMatrix;
  15712. private _renderId;
  15713. private _multiview;
  15714. /**
  15715. * Instantiate a new shader material.
  15716. * 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.
  15717. * This returned material effects how the mesh will look based on the code in the shaders.
  15718. * @see http://doc.babylonjs.com/how_to/shader_material
  15719. * @param name Define the name of the material in the scene
  15720. * @param scene Define the scene the material belongs to
  15721. * @param shaderPath Defines the route to the shader code in one of three ways:
  15722. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15723. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15724. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15725. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15726. * @param options Define the options used to create the shader
  15727. */
  15728. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15729. /**
  15730. * Gets the shader path used to define the shader code
  15731. * It can be modified to trigger a new compilation
  15732. */
  15733. get shaderPath(): any;
  15734. /**
  15735. * Sets the shader path used to define the shader code
  15736. * It can be modified to trigger a new compilation
  15737. */
  15738. set shaderPath(shaderPath: any);
  15739. /**
  15740. * Gets the options used to compile the shader.
  15741. * They can be modified to trigger a new compilation
  15742. */
  15743. get options(): IShaderMaterialOptions;
  15744. /**
  15745. * Gets the current class name of the material e.g. "ShaderMaterial"
  15746. * Mainly use in serialization.
  15747. * @returns the class name
  15748. */
  15749. getClassName(): string;
  15750. /**
  15751. * Specifies if the material will require alpha blending
  15752. * @returns a boolean specifying if alpha blending is needed
  15753. */
  15754. needAlphaBlending(): boolean;
  15755. /**
  15756. * Specifies if this material should be rendered in alpha test mode
  15757. * @returns a boolean specifying if an alpha test is needed.
  15758. */
  15759. needAlphaTesting(): boolean;
  15760. private _checkUniform;
  15761. /**
  15762. * Set a texture in the shader.
  15763. * @param name Define the name of the uniform samplers as defined in the shader
  15764. * @param texture Define the texture to bind to this sampler
  15765. * @return the material itself allowing "fluent" like uniform updates
  15766. */
  15767. setTexture(name: string, texture: Texture): ShaderMaterial;
  15768. /**
  15769. * Set a texture array in the shader.
  15770. * @param name Define the name of the uniform sampler array as defined in the shader
  15771. * @param textures Define the list of textures to bind to this sampler
  15772. * @return the material itself allowing "fluent" like uniform updates
  15773. */
  15774. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15775. /**
  15776. * Set a float in the shader.
  15777. * @param name Define the name of the uniform as defined in the shader
  15778. * @param value Define the value to give to the uniform
  15779. * @return the material itself allowing "fluent" like uniform updates
  15780. */
  15781. setFloat(name: string, value: number): ShaderMaterial;
  15782. /**
  15783. * Set a int in the shader.
  15784. * @param name Define the name of the uniform as defined in the shader
  15785. * @param value Define the value to give to the uniform
  15786. * @return the material itself allowing "fluent" like uniform updates
  15787. */
  15788. setInt(name: string, value: number): ShaderMaterial;
  15789. /**
  15790. * Set an array of floats in the shader.
  15791. * @param name Define the name of the uniform as defined in the shader
  15792. * @param value Define the value to give to the uniform
  15793. * @return the material itself allowing "fluent" like uniform updates
  15794. */
  15795. setFloats(name: string, value: number[]): ShaderMaterial;
  15796. /**
  15797. * Set a vec3 in the shader from a Color3.
  15798. * @param name Define the name of the uniform as defined in the shader
  15799. * @param value Define the value to give to the uniform
  15800. * @return the material itself allowing "fluent" like uniform updates
  15801. */
  15802. setColor3(name: string, value: Color3): ShaderMaterial;
  15803. /**
  15804. * Set a vec3 array in the shader from a Color3 array.
  15805. * @param name Define the name of the uniform as defined in the shader
  15806. * @param value Define the value to give to the uniform
  15807. * @return the material itself allowing "fluent" like uniform updates
  15808. */
  15809. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15810. /**
  15811. * Set a vec4 in the shader from a Color4.
  15812. * @param name Define the name of the uniform as defined in the shader
  15813. * @param value Define the value to give to the uniform
  15814. * @return the material itself allowing "fluent" like uniform updates
  15815. */
  15816. setColor4(name: string, value: Color4): ShaderMaterial;
  15817. /**
  15818. * Set a vec4 array in the shader from a Color4 array.
  15819. * @param name Define the name of the uniform as defined in the shader
  15820. * @param value Define the value to give to the uniform
  15821. * @return the material itself allowing "fluent" like uniform updates
  15822. */
  15823. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15824. /**
  15825. * Set a vec2 in the shader from a Vector2.
  15826. * @param name Define the name of the uniform as defined in the shader
  15827. * @param value Define the value to give to the uniform
  15828. * @return the material itself allowing "fluent" like uniform updates
  15829. */
  15830. setVector2(name: string, value: Vector2): ShaderMaterial;
  15831. /**
  15832. * Set a vec3 in the shader from a Vector3.
  15833. * @param name Define the name of the uniform as defined in the shader
  15834. * @param value Define the value to give to the uniform
  15835. * @return the material itself allowing "fluent" like uniform updates
  15836. */
  15837. setVector3(name: string, value: Vector3): ShaderMaterial;
  15838. /**
  15839. * Set a vec4 in the shader from a Vector4.
  15840. * @param name Define the name of the uniform as defined in the shader
  15841. * @param value Define the value to give to the uniform
  15842. * @return the material itself allowing "fluent" like uniform updates
  15843. */
  15844. setVector4(name: string, value: Vector4): ShaderMaterial;
  15845. /**
  15846. * Set a mat4 in the shader from a Matrix.
  15847. * @param name Define the name of the uniform as defined in the shader
  15848. * @param value Define the value to give to the uniform
  15849. * @return the material itself allowing "fluent" like uniform updates
  15850. */
  15851. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15852. /**
  15853. * Set a float32Array in the shader from a matrix array.
  15854. * @param name Define the name of the uniform as defined in the shader
  15855. * @param value Define the value to give to the uniform
  15856. * @return the material itself allowing "fluent" like uniform updates
  15857. */
  15858. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15859. /**
  15860. * Set a mat3 in the shader from a Float32Array.
  15861. * @param name Define the name of the uniform as defined in the shader
  15862. * @param value Define the value to give to the uniform
  15863. * @return the material itself allowing "fluent" like uniform updates
  15864. */
  15865. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15866. /**
  15867. * Set a mat2 in the shader from a Float32Array.
  15868. * @param name Define the name of the uniform as defined in the shader
  15869. * @param value Define the value to give to the uniform
  15870. * @return the material itself allowing "fluent" like uniform updates
  15871. */
  15872. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15873. /**
  15874. * Set a vec2 array in the shader from a number array.
  15875. * @param name Define the name of the uniform as defined in the shader
  15876. * @param value Define the value to give to the uniform
  15877. * @return the material itself allowing "fluent" like uniform updates
  15878. */
  15879. setArray2(name: string, value: number[]): ShaderMaterial;
  15880. /**
  15881. * Set a vec3 array in the shader from a number array.
  15882. * @param name Define the name of the uniform as defined in the shader
  15883. * @param value Define the value to give to the uniform
  15884. * @return the material itself allowing "fluent" like uniform updates
  15885. */
  15886. setArray3(name: string, value: number[]): ShaderMaterial;
  15887. /**
  15888. * Set a vec4 array in the shader from a number array.
  15889. * @param name Define the name of the uniform as defined in the shader
  15890. * @param value Define the value to give to the uniform
  15891. * @return the material itself allowing "fluent" like uniform updates
  15892. */
  15893. setArray4(name: string, value: number[]): ShaderMaterial;
  15894. private _checkCache;
  15895. /**
  15896. * Specifies that the submesh is ready to be used
  15897. * @param mesh defines the mesh to check
  15898. * @param subMesh defines which submesh to check
  15899. * @param useInstances specifies that instances should be used
  15900. * @returns a boolean indicating that the submesh is ready or not
  15901. */
  15902. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15903. /**
  15904. * Checks if the material is ready to render the requested mesh
  15905. * @param mesh Define the mesh to render
  15906. * @param useInstances Define whether or not the material is used with instances
  15907. * @returns true if ready, otherwise false
  15908. */
  15909. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15910. /**
  15911. * Binds the world matrix to the material
  15912. * @param world defines the world transformation matrix
  15913. */
  15914. bindOnlyWorldMatrix(world: Matrix): void;
  15915. /**
  15916. * Binds the material to the mesh
  15917. * @param world defines the world transformation matrix
  15918. * @param mesh defines the mesh to bind the material to
  15919. */
  15920. bind(world: Matrix, mesh?: Mesh): void;
  15921. /**
  15922. * Gets the active textures from the material
  15923. * @returns an array of textures
  15924. */
  15925. getActiveTextures(): BaseTexture[];
  15926. /**
  15927. * Specifies if the material uses a texture
  15928. * @param texture defines the texture to check against the material
  15929. * @returns a boolean specifying if the material uses the texture
  15930. */
  15931. hasTexture(texture: BaseTexture): boolean;
  15932. /**
  15933. * Makes a duplicate of the material, and gives it a new name
  15934. * @param name defines the new name for the duplicated material
  15935. * @returns the cloned material
  15936. */
  15937. clone(name: string): ShaderMaterial;
  15938. /**
  15939. * Disposes the material
  15940. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15941. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15942. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15943. */
  15944. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15945. /**
  15946. * Serializes this material in a JSON representation
  15947. * @returns the serialized material object
  15948. */
  15949. serialize(): any;
  15950. /**
  15951. * Creates a shader material from parsed shader material data
  15952. * @param source defines the JSON represnetation of the material
  15953. * @param scene defines the hosting scene
  15954. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15955. * @returns a new material
  15956. */
  15957. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15958. }
  15959. }
  15960. declare module "babylonjs/Shaders/color.fragment" {
  15961. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15962. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15963. /** @hidden */
  15964. export var colorPixelShader: {
  15965. name: string;
  15966. shader: string;
  15967. };
  15968. }
  15969. declare module "babylonjs/Shaders/color.vertex" {
  15970. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15971. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15972. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15973. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15974. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15975. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15976. /** @hidden */
  15977. export var colorVertexShader: {
  15978. name: string;
  15979. shader: string;
  15980. };
  15981. }
  15982. declare module "babylonjs/Meshes/linesMesh" {
  15983. import { Nullable } from "babylonjs/types";
  15984. import { Scene } from "babylonjs/scene";
  15985. import { Color3 } from "babylonjs/Maths/math.color";
  15986. import { Node } from "babylonjs/node";
  15987. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15988. import { Mesh } from "babylonjs/Meshes/mesh";
  15989. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15990. import { Effect } from "babylonjs/Materials/effect";
  15991. import { Material } from "babylonjs/Materials/material";
  15992. import "babylonjs/Shaders/color.fragment";
  15993. import "babylonjs/Shaders/color.vertex";
  15994. /**
  15995. * Line mesh
  15996. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15997. */
  15998. export class LinesMesh extends Mesh {
  15999. /**
  16000. * If vertex color should be applied to the mesh
  16001. */
  16002. readonly useVertexColor?: boolean | undefined;
  16003. /**
  16004. * If vertex alpha should be applied to the mesh
  16005. */
  16006. readonly useVertexAlpha?: boolean | undefined;
  16007. /**
  16008. * Color of the line (Default: White)
  16009. */
  16010. color: Color3;
  16011. /**
  16012. * Alpha of the line (Default: 1)
  16013. */
  16014. alpha: number;
  16015. /**
  16016. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16017. * This margin is expressed in world space coordinates, so its value may vary.
  16018. * Default value is 0.1
  16019. */
  16020. intersectionThreshold: number;
  16021. private _colorShader;
  16022. private color4;
  16023. /**
  16024. * Creates a new LinesMesh
  16025. * @param name defines the name
  16026. * @param scene defines the hosting scene
  16027. * @param parent defines the parent mesh if any
  16028. * @param source defines the optional source LinesMesh used to clone data from
  16029. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16030. * When false, achieved by calling a clone(), also passing False.
  16031. * This will make creation of children, recursive.
  16032. * @param useVertexColor defines if this LinesMesh supports vertex color
  16033. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16034. */
  16035. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16036. /**
  16037. * If vertex color should be applied to the mesh
  16038. */
  16039. useVertexColor?: boolean | undefined,
  16040. /**
  16041. * If vertex alpha should be applied to the mesh
  16042. */
  16043. useVertexAlpha?: boolean | undefined);
  16044. private _addClipPlaneDefine;
  16045. private _removeClipPlaneDefine;
  16046. isReady(): boolean;
  16047. /**
  16048. * Returns the string "LineMesh"
  16049. */
  16050. getClassName(): string;
  16051. /**
  16052. * @hidden
  16053. */
  16054. get material(): Material;
  16055. /**
  16056. * @hidden
  16057. */
  16058. set material(value: Material);
  16059. /**
  16060. * @hidden
  16061. */
  16062. get checkCollisions(): boolean;
  16063. /** @hidden */
  16064. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16065. /** @hidden */
  16066. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16067. /**
  16068. * Disposes of the line mesh
  16069. * @param doNotRecurse If children should be disposed
  16070. */
  16071. dispose(doNotRecurse?: boolean): void;
  16072. /**
  16073. * Returns a new LineMesh object cloned from the current one.
  16074. */
  16075. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16076. /**
  16077. * Creates a new InstancedLinesMesh object from the mesh model.
  16078. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16079. * @param name defines the name of the new instance
  16080. * @returns a new InstancedLinesMesh
  16081. */
  16082. createInstance(name: string): InstancedLinesMesh;
  16083. }
  16084. /**
  16085. * Creates an instance based on a source LinesMesh
  16086. */
  16087. export class InstancedLinesMesh extends InstancedMesh {
  16088. /**
  16089. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16090. * This margin is expressed in world space coordinates, so its value may vary.
  16091. * Initilized with the intersectionThreshold value of the source LinesMesh
  16092. */
  16093. intersectionThreshold: number;
  16094. constructor(name: string, source: LinesMesh);
  16095. /**
  16096. * Returns the string "InstancedLinesMesh".
  16097. */
  16098. getClassName(): string;
  16099. }
  16100. }
  16101. declare module "babylonjs/Shaders/line.fragment" {
  16102. /** @hidden */
  16103. export var linePixelShader: {
  16104. name: string;
  16105. shader: string;
  16106. };
  16107. }
  16108. declare module "babylonjs/Shaders/line.vertex" {
  16109. /** @hidden */
  16110. export var lineVertexShader: {
  16111. name: string;
  16112. shader: string;
  16113. };
  16114. }
  16115. declare module "babylonjs/Rendering/edgesRenderer" {
  16116. import { Nullable } from "babylonjs/types";
  16117. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16119. import { Vector3 } from "babylonjs/Maths/math.vector";
  16120. import { IDisposable } from "babylonjs/scene";
  16121. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16122. import "babylonjs/Shaders/line.fragment";
  16123. import "babylonjs/Shaders/line.vertex";
  16124. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16125. module "babylonjs/Meshes/abstractMesh" {
  16126. interface AbstractMesh {
  16127. /**
  16128. * Gets the edgesRenderer associated with the mesh
  16129. */
  16130. edgesRenderer: Nullable<EdgesRenderer>;
  16131. }
  16132. }
  16133. module "babylonjs/Meshes/linesMesh" {
  16134. interface LinesMesh {
  16135. /**
  16136. * Enables the edge rendering mode on the mesh.
  16137. * This mode makes the mesh edges visible
  16138. * @param epsilon defines the maximal distance between two angles to detect a face
  16139. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16140. * @returns the currentAbstractMesh
  16141. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16142. */
  16143. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16144. }
  16145. }
  16146. module "babylonjs/Meshes/linesMesh" {
  16147. interface InstancedLinesMesh {
  16148. /**
  16149. * Enables the edge rendering mode on the mesh.
  16150. * This mode makes the mesh edges visible
  16151. * @param epsilon defines the maximal distance between two angles to detect a face
  16152. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16153. * @returns the current InstancedLinesMesh
  16154. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16155. */
  16156. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16157. }
  16158. }
  16159. /**
  16160. * Defines the minimum contract an Edges renderer should follow.
  16161. */
  16162. export interface IEdgesRenderer extends IDisposable {
  16163. /**
  16164. * Gets or sets a boolean indicating if the edgesRenderer is active
  16165. */
  16166. isEnabled: boolean;
  16167. /**
  16168. * Renders the edges of the attached mesh,
  16169. */
  16170. render(): void;
  16171. /**
  16172. * Checks wether or not the edges renderer is ready to render.
  16173. * @return true if ready, otherwise false.
  16174. */
  16175. isReady(): boolean;
  16176. }
  16177. /**
  16178. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16179. */
  16180. export class EdgesRenderer implements IEdgesRenderer {
  16181. /**
  16182. * Define the size of the edges with an orthographic camera
  16183. */
  16184. edgesWidthScalerForOrthographic: number;
  16185. /**
  16186. * Define the size of the edges with a perspective camera
  16187. */
  16188. edgesWidthScalerForPerspective: number;
  16189. protected _source: AbstractMesh;
  16190. protected _linesPositions: number[];
  16191. protected _linesNormals: number[];
  16192. protected _linesIndices: number[];
  16193. protected _epsilon: number;
  16194. protected _indicesCount: number;
  16195. protected _lineShader: ShaderMaterial;
  16196. protected _ib: DataBuffer;
  16197. protected _buffers: {
  16198. [key: string]: Nullable<VertexBuffer>;
  16199. };
  16200. protected _checkVerticesInsteadOfIndices: boolean;
  16201. private _meshRebuildObserver;
  16202. private _meshDisposeObserver;
  16203. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16204. isEnabled: boolean;
  16205. /**
  16206. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16207. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16208. * @param source Mesh used to create edges
  16209. * @param epsilon sum of angles in adjacency to check for edge
  16210. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16211. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16212. */
  16213. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16214. protected _prepareRessources(): void;
  16215. /** @hidden */
  16216. _rebuild(): void;
  16217. /**
  16218. * Releases the required resources for the edges renderer
  16219. */
  16220. dispose(): void;
  16221. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16222. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16223. /**
  16224. * Checks if the pair of p0 and p1 is en edge
  16225. * @param faceIndex
  16226. * @param edge
  16227. * @param faceNormals
  16228. * @param p0
  16229. * @param p1
  16230. * @private
  16231. */
  16232. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16233. /**
  16234. * push line into the position, normal and index buffer
  16235. * @protected
  16236. */
  16237. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16238. /**
  16239. * Generates lines edges from adjacencjes
  16240. * @private
  16241. */
  16242. _generateEdgesLines(): void;
  16243. /**
  16244. * Checks wether or not the edges renderer is ready to render.
  16245. * @return true if ready, otherwise false.
  16246. */
  16247. isReady(): boolean;
  16248. /**
  16249. * Renders the edges of the attached mesh,
  16250. */
  16251. render(): void;
  16252. }
  16253. /**
  16254. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16255. */
  16256. export class LineEdgesRenderer extends EdgesRenderer {
  16257. /**
  16258. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16259. * @param source LineMesh used to generate edges
  16260. * @param epsilon not important (specified angle for edge detection)
  16261. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16262. */
  16263. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16264. /**
  16265. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16266. */
  16267. _generateEdgesLines(): void;
  16268. }
  16269. }
  16270. declare module "babylonjs/Rendering/renderingGroup" {
  16271. import { SmartArray } from "babylonjs/Misc/smartArray";
  16272. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16274. import { Nullable } from "babylonjs/types";
  16275. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16276. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16277. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16278. import { Material } from "babylonjs/Materials/material";
  16279. import { Scene } from "babylonjs/scene";
  16280. /**
  16281. * This represents the object necessary to create a rendering group.
  16282. * This is exclusively used and created by the rendering manager.
  16283. * To modify the behavior, you use the available helpers in your scene or meshes.
  16284. * @hidden
  16285. */
  16286. export class RenderingGroup {
  16287. index: number;
  16288. private static _zeroVector;
  16289. private _scene;
  16290. private _opaqueSubMeshes;
  16291. private _transparentSubMeshes;
  16292. private _alphaTestSubMeshes;
  16293. private _depthOnlySubMeshes;
  16294. private _particleSystems;
  16295. private _spriteManagers;
  16296. private _opaqueSortCompareFn;
  16297. private _alphaTestSortCompareFn;
  16298. private _transparentSortCompareFn;
  16299. private _renderOpaque;
  16300. private _renderAlphaTest;
  16301. private _renderTransparent;
  16302. /** @hidden */
  16303. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16304. onBeforeTransparentRendering: () => void;
  16305. /**
  16306. * Set the opaque sort comparison function.
  16307. * If null the sub meshes will be render in the order they were created
  16308. */
  16309. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16310. /**
  16311. * Set the alpha test sort comparison function.
  16312. * If null the sub meshes will be render in the order they were created
  16313. */
  16314. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16315. /**
  16316. * Set the transparent sort comparison function.
  16317. * If null the sub meshes will be render in the order they were created
  16318. */
  16319. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16320. /**
  16321. * Creates a new rendering group.
  16322. * @param index The rendering group index
  16323. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16324. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16325. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16326. */
  16327. 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>);
  16328. /**
  16329. * Render all the sub meshes contained in the group.
  16330. * @param customRenderFunction Used to override the default render behaviour of the group.
  16331. * @returns true if rendered some submeshes.
  16332. */
  16333. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16334. /**
  16335. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16336. * @param subMeshes The submeshes to render
  16337. */
  16338. private renderOpaqueSorted;
  16339. /**
  16340. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16341. * @param subMeshes The submeshes to render
  16342. */
  16343. private renderAlphaTestSorted;
  16344. /**
  16345. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16346. * @param subMeshes The submeshes to render
  16347. */
  16348. private renderTransparentSorted;
  16349. /**
  16350. * Renders the submeshes in a specified order.
  16351. * @param subMeshes The submeshes to sort before render
  16352. * @param sortCompareFn The comparison function use to sort
  16353. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16354. * @param transparent Specifies to activate blending if true
  16355. */
  16356. private static renderSorted;
  16357. /**
  16358. * Renders the submeshes in the order they were dispatched (no sort applied).
  16359. * @param subMeshes The submeshes to render
  16360. */
  16361. private static renderUnsorted;
  16362. /**
  16363. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16364. * are rendered back to front if in the same alpha index.
  16365. *
  16366. * @param a The first submesh
  16367. * @param b The second submesh
  16368. * @returns The result of the comparison
  16369. */
  16370. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16371. /**
  16372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16373. * are rendered back to front.
  16374. *
  16375. * @param a The first submesh
  16376. * @param b The second submesh
  16377. * @returns The result of the comparison
  16378. */
  16379. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16380. /**
  16381. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16382. * are rendered front to back (prevent overdraw).
  16383. *
  16384. * @param a The first submesh
  16385. * @param b The second submesh
  16386. * @returns The result of the comparison
  16387. */
  16388. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16389. /**
  16390. * Resets the different lists of submeshes to prepare a new frame.
  16391. */
  16392. prepare(): void;
  16393. dispose(): void;
  16394. /**
  16395. * Inserts the submesh in its correct queue depending on its material.
  16396. * @param subMesh The submesh to dispatch
  16397. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16398. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16399. */
  16400. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16401. dispatchSprites(spriteManager: ISpriteManager): void;
  16402. dispatchParticles(particleSystem: IParticleSystem): void;
  16403. private _renderParticles;
  16404. private _renderSprites;
  16405. }
  16406. }
  16407. declare module "babylonjs/Rendering/renderingManager" {
  16408. import { Nullable } from "babylonjs/types";
  16409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16410. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16411. import { SmartArray } from "babylonjs/Misc/smartArray";
  16412. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16413. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16414. import { Material } from "babylonjs/Materials/material";
  16415. import { Scene } from "babylonjs/scene";
  16416. import { Camera } from "babylonjs/Cameras/camera";
  16417. /**
  16418. * Interface describing the different options available in the rendering manager
  16419. * regarding Auto Clear between groups.
  16420. */
  16421. export interface IRenderingManagerAutoClearSetup {
  16422. /**
  16423. * Defines whether or not autoclear is enable.
  16424. */
  16425. autoClear: boolean;
  16426. /**
  16427. * Defines whether or not to autoclear the depth buffer.
  16428. */
  16429. depth: boolean;
  16430. /**
  16431. * Defines whether or not to autoclear the stencil buffer.
  16432. */
  16433. stencil: boolean;
  16434. }
  16435. /**
  16436. * This class is used by the onRenderingGroupObservable
  16437. */
  16438. export class RenderingGroupInfo {
  16439. /**
  16440. * The Scene that being rendered
  16441. */
  16442. scene: Scene;
  16443. /**
  16444. * The camera currently used for the rendering pass
  16445. */
  16446. camera: Nullable<Camera>;
  16447. /**
  16448. * The ID of the renderingGroup being processed
  16449. */
  16450. renderingGroupId: number;
  16451. }
  16452. /**
  16453. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16454. * It is enable to manage the different groups as well as the different necessary sort functions.
  16455. * This should not be used directly aside of the few static configurations
  16456. */
  16457. export class RenderingManager {
  16458. /**
  16459. * The max id used for rendering groups (not included)
  16460. */
  16461. static MAX_RENDERINGGROUPS: number;
  16462. /**
  16463. * The min id used for rendering groups (included)
  16464. */
  16465. static MIN_RENDERINGGROUPS: number;
  16466. /**
  16467. * Used to globally prevent autoclearing scenes.
  16468. */
  16469. static AUTOCLEAR: boolean;
  16470. /**
  16471. * @hidden
  16472. */
  16473. _useSceneAutoClearSetup: boolean;
  16474. private _scene;
  16475. private _renderingGroups;
  16476. private _depthStencilBufferAlreadyCleaned;
  16477. private _autoClearDepthStencil;
  16478. private _customOpaqueSortCompareFn;
  16479. private _customAlphaTestSortCompareFn;
  16480. private _customTransparentSortCompareFn;
  16481. private _renderingGroupInfo;
  16482. /**
  16483. * Instantiates a new rendering group for a particular scene
  16484. * @param scene Defines the scene the groups belongs to
  16485. */
  16486. constructor(scene: Scene);
  16487. private _clearDepthStencilBuffer;
  16488. /**
  16489. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16490. * @hidden
  16491. */
  16492. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16493. /**
  16494. * Resets the different information of the group to prepare a new frame
  16495. * @hidden
  16496. */
  16497. reset(): void;
  16498. /**
  16499. * Dispose and release the group and its associated resources.
  16500. * @hidden
  16501. */
  16502. dispose(): void;
  16503. /**
  16504. * Clear the info related to rendering groups preventing retention points during dispose.
  16505. */
  16506. freeRenderingGroups(): void;
  16507. private _prepareRenderingGroup;
  16508. /**
  16509. * Add a sprite manager to the rendering manager in order to render it this frame.
  16510. * @param spriteManager Define the sprite manager to render
  16511. */
  16512. dispatchSprites(spriteManager: ISpriteManager): void;
  16513. /**
  16514. * Add a particle system to the rendering manager in order to render it this frame.
  16515. * @param particleSystem Define the particle system to render
  16516. */
  16517. dispatchParticles(particleSystem: IParticleSystem): void;
  16518. /**
  16519. * Add a submesh to the manager in order to render it this frame
  16520. * @param subMesh The submesh to dispatch
  16521. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16522. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16523. */
  16524. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16525. /**
  16526. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16527. * This allowed control for front to back rendering or reversly depending of the special needs.
  16528. *
  16529. * @param renderingGroupId The rendering group id corresponding to its index
  16530. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16531. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16532. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16533. */
  16534. 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;
  16535. /**
  16536. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16537. *
  16538. * @param renderingGroupId The rendering group id corresponding to its index
  16539. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16540. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16541. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16542. */
  16543. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16544. /**
  16545. * Gets the current auto clear configuration for one rendering group of the rendering
  16546. * manager.
  16547. * @param index the rendering group index to get the information for
  16548. * @returns The auto clear setup for the requested rendering group
  16549. */
  16550. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16551. }
  16552. }
  16553. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16554. import { SmartArray } from "babylonjs/Misc/smartArray";
  16555. import { Nullable } from "babylonjs/types";
  16556. import { Scene } from "babylonjs/scene";
  16557. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16558. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16560. import { Mesh } from "babylonjs/Meshes/mesh";
  16561. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16562. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16563. import { Effect } from "babylonjs/Materials/effect";
  16564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16566. import "babylonjs/Shaders/shadowMap.fragment";
  16567. import "babylonjs/Shaders/shadowMap.vertex";
  16568. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16569. import { Observable } from "babylonjs/Misc/observable";
  16570. /**
  16571. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16572. */
  16573. export interface ICustomShaderOptions {
  16574. /**
  16575. * Gets or sets the custom shader name to use
  16576. */
  16577. shaderName: string;
  16578. /**
  16579. * The list of attribute names used in the shader
  16580. */
  16581. attributes?: string[];
  16582. /**
  16583. * The list of unifrom names used in the shader
  16584. */
  16585. uniforms?: string[];
  16586. /**
  16587. * The list of sampler names used in the shader
  16588. */
  16589. samplers?: string[];
  16590. /**
  16591. * The list of defines used in the shader
  16592. */
  16593. defines?: string[];
  16594. }
  16595. /**
  16596. * Interface to implement to create a shadow generator compatible with BJS.
  16597. */
  16598. export interface IShadowGenerator {
  16599. /**
  16600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16601. * @returns The render target texture if present otherwise, null
  16602. */
  16603. getShadowMap(): Nullable<RenderTargetTexture>;
  16604. /**
  16605. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16606. * @param subMesh The submesh we want to render in the shadow map
  16607. * @param useInstances Defines wether will draw in the map using instances
  16608. * @returns true if ready otherwise, false
  16609. */
  16610. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16611. /**
  16612. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16613. * @param defines Defines of the material we want to update
  16614. * @param lightIndex Index of the light in the enabled light list of the material
  16615. */
  16616. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16617. /**
  16618. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16619. * defined in the generator but impacting the effect).
  16620. * It implies the unifroms available on the materials are the standard BJS ones.
  16621. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16622. * @param effect The effect we are binfing the information for
  16623. */
  16624. bindShadowLight(lightIndex: string, effect: Effect): void;
  16625. /**
  16626. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16627. * (eq to shadow prjection matrix * light transform matrix)
  16628. * @returns The transform matrix used to create the shadow map
  16629. */
  16630. getTransformMatrix(): Matrix;
  16631. /**
  16632. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16633. * Cube and 2D textures for instance.
  16634. */
  16635. recreateShadowMap(): void;
  16636. /**
  16637. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16638. * @param onCompiled Callback triggered at the and of the effects compilation
  16639. * @param options Sets of optional options forcing the compilation with different modes
  16640. */
  16641. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16642. useInstances: boolean;
  16643. }>): void;
  16644. /**
  16645. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16646. * @param options Sets of optional options forcing the compilation with different modes
  16647. * @returns A promise that resolves when the compilation completes
  16648. */
  16649. forceCompilationAsync(options?: Partial<{
  16650. useInstances: boolean;
  16651. }>): Promise<void>;
  16652. /**
  16653. * Serializes the shadow generator setup to a json object.
  16654. * @returns The serialized JSON object
  16655. */
  16656. serialize(): any;
  16657. /**
  16658. * Disposes the Shadow map and related Textures and effects.
  16659. */
  16660. dispose(): void;
  16661. }
  16662. /**
  16663. * Default implementation IShadowGenerator.
  16664. * This is the main object responsible of generating shadows in the framework.
  16665. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16666. */
  16667. export class ShadowGenerator implements IShadowGenerator {
  16668. /**
  16669. * Name of the shadow generator class
  16670. */
  16671. static CLASSNAME: string;
  16672. /**
  16673. * Shadow generator mode None: no filtering applied.
  16674. */
  16675. static readonly FILTER_NONE: number;
  16676. /**
  16677. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16678. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16679. */
  16680. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16681. /**
  16682. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16683. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16684. */
  16685. static readonly FILTER_POISSONSAMPLING: number;
  16686. /**
  16687. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16688. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16689. */
  16690. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16691. /**
  16692. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16693. * edge artifacts on steep falloff.
  16694. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16695. */
  16696. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16697. /**
  16698. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16699. * edge artifacts on steep falloff.
  16700. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16701. */
  16702. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16703. /**
  16704. * Shadow generator mode PCF: Percentage Closer Filtering
  16705. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16706. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16707. */
  16708. static readonly FILTER_PCF: number;
  16709. /**
  16710. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16711. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16712. * Contact Hardening
  16713. */
  16714. static readonly FILTER_PCSS: number;
  16715. /**
  16716. * Reserved for PCF and PCSS
  16717. * Highest Quality.
  16718. *
  16719. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16720. *
  16721. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16722. */
  16723. static readonly QUALITY_HIGH: number;
  16724. /**
  16725. * Reserved for PCF and PCSS
  16726. * Good tradeoff for quality/perf cross devices
  16727. *
  16728. * Execute PCF on a 3*3 kernel.
  16729. *
  16730. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16731. */
  16732. static readonly QUALITY_MEDIUM: number;
  16733. /**
  16734. * Reserved for PCF and PCSS
  16735. * The lowest quality but the fastest.
  16736. *
  16737. * Execute PCF on a 1*1 kernel.
  16738. *
  16739. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16740. */
  16741. static readonly QUALITY_LOW: number;
  16742. /** Gets or sets the custom shader name to use */
  16743. customShaderOptions: ICustomShaderOptions;
  16744. /**
  16745. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16746. */
  16747. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16748. /**
  16749. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16750. */
  16751. onAfterShadowMapRenderObservable: Observable<Effect>;
  16752. /**
  16753. * Observable triggered before a mesh is rendered in the shadow map.
  16754. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16755. */
  16756. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16757. /**
  16758. * Observable triggered after a mesh is rendered in the shadow map.
  16759. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16760. */
  16761. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16762. protected _bias: number;
  16763. /**
  16764. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16765. */
  16766. get bias(): number;
  16767. /**
  16768. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16769. */
  16770. set bias(bias: number);
  16771. protected _normalBias: number;
  16772. /**
  16773. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16774. */
  16775. get normalBias(): number;
  16776. /**
  16777. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16778. */
  16779. set normalBias(normalBias: number);
  16780. protected _blurBoxOffset: number;
  16781. /**
  16782. * Gets the blur box offset: offset applied during the blur pass.
  16783. * Only useful if useKernelBlur = false
  16784. */
  16785. get blurBoxOffset(): number;
  16786. /**
  16787. * Sets the blur box offset: offset applied during the blur pass.
  16788. * Only useful if useKernelBlur = false
  16789. */
  16790. set blurBoxOffset(value: number);
  16791. protected _blurScale: number;
  16792. /**
  16793. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16794. * 2 means half of the size.
  16795. */
  16796. get blurScale(): number;
  16797. /**
  16798. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16799. * 2 means half of the size.
  16800. */
  16801. set blurScale(value: number);
  16802. protected _blurKernel: number;
  16803. /**
  16804. * Gets the blur kernel: kernel size of the blur pass.
  16805. * Only useful if useKernelBlur = true
  16806. */
  16807. get blurKernel(): number;
  16808. /**
  16809. * Sets the blur kernel: kernel size of the blur pass.
  16810. * Only useful if useKernelBlur = true
  16811. */
  16812. set blurKernel(value: number);
  16813. protected _useKernelBlur: boolean;
  16814. /**
  16815. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16816. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16817. */
  16818. get useKernelBlur(): boolean;
  16819. /**
  16820. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16821. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16822. */
  16823. set useKernelBlur(value: boolean);
  16824. protected _depthScale: number;
  16825. /**
  16826. * Gets the depth scale used in ESM mode.
  16827. */
  16828. get depthScale(): number;
  16829. /**
  16830. * Sets the depth scale used in ESM mode.
  16831. * This can override the scale stored on the light.
  16832. */
  16833. set depthScale(value: number);
  16834. protected _validateFilter(filter: number): number;
  16835. protected _filter: number;
  16836. /**
  16837. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16838. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16839. */
  16840. get filter(): number;
  16841. /**
  16842. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16843. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16844. */
  16845. set filter(value: number);
  16846. /**
  16847. * Gets if the current filter is set to Poisson Sampling.
  16848. */
  16849. get usePoissonSampling(): boolean;
  16850. /**
  16851. * Sets the current filter to Poisson Sampling.
  16852. */
  16853. set usePoissonSampling(value: boolean);
  16854. /**
  16855. * Gets if the current filter is set to ESM.
  16856. */
  16857. get useExponentialShadowMap(): boolean;
  16858. /**
  16859. * Sets the current filter is to ESM.
  16860. */
  16861. set useExponentialShadowMap(value: boolean);
  16862. /**
  16863. * Gets if the current filter is set to filtered ESM.
  16864. */
  16865. get useBlurExponentialShadowMap(): boolean;
  16866. /**
  16867. * Gets if the current filter is set to filtered ESM.
  16868. */
  16869. set useBlurExponentialShadowMap(value: boolean);
  16870. /**
  16871. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16872. * exponential to prevent steep falloff artifacts).
  16873. */
  16874. get useCloseExponentialShadowMap(): boolean;
  16875. /**
  16876. * Sets the current filter to "close ESM" (using the inverse of the
  16877. * exponential to prevent steep falloff artifacts).
  16878. */
  16879. set useCloseExponentialShadowMap(value: boolean);
  16880. /**
  16881. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16882. * exponential to prevent steep falloff artifacts).
  16883. */
  16884. get useBlurCloseExponentialShadowMap(): boolean;
  16885. /**
  16886. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16887. * exponential to prevent steep falloff artifacts).
  16888. */
  16889. set useBlurCloseExponentialShadowMap(value: boolean);
  16890. /**
  16891. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16892. */
  16893. get usePercentageCloserFiltering(): boolean;
  16894. /**
  16895. * Sets the current filter to "PCF" (percentage closer filtering).
  16896. */
  16897. set usePercentageCloserFiltering(value: boolean);
  16898. protected _filteringQuality: number;
  16899. /**
  16900. * Gets the PCF or PCSS Quality.
  16901. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16902. */
  16903. get filteringQuality(): number;
  16904. /**
  16905. * Sets the PCF or PCSS Quality.
  16906. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16907. */
  16908. set filteringQuality(filteringQuality: number);
  16909. /**
  16910. * Gets if the current filter is set to "PCSS" (contact hardening).
  16911. */
  16912. get useContactHardeningShadow(): boolean;
  16913. /**
  16914. * Sets the current filter to "PCSS" (contact hardening).
  16915. */
  16916. set useContactHardeningShadow(value: boolean);
  16917. protected _contactHardeningLightSizeUVRatio: number;
  16918. /**
  16919. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16920. * Using a ratio helps keeping shape stability independently of the map size.
  16921. *
  16922. * It does not account for the light projection as it was having too much
  16923. * instability during the light setup or during light position changes.
  16924. *
  16925. * Only valid if useContactHardeningShadow is true.
  16926. */
  16927. get contactHardeningLightSizeUVRatio(): number;
  16928. /**
  16929. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16930. * Using a ratio helps keeping shape stability independently of the map size.
  16931. *
  16932. * It does not account for the light projection as it was having too much
  16933. * instability during the light setup or during light position changes.
  16934. *
  16935. * Only valid if useContactHardeningShadow is true.
  16936. */
  16937. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16938. protected _darkness: number;
  16939. /** Gets or sets the actual darkness of a shadow */
  16940. get darkness(): number;
  16941. set darkness(value: number);
  16942. /**
  16943. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16944. * 0 means strongest and 1 would means no shadow.
  16945. * @returns the darkness.
  16946. */
  16947. getDarkness(): number;
  16948. /**
  16949. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16950. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16951. * @returns the shadow generator allowing fluent coding.
  16952. */
  16953. setDarkness(darkness: number): ShadowGenerator;
  16954. protected _transparencyShadow: boolean;
  16955. /** Gets or sets the ability to have transparent shadow */
  16956. get transparencyShadow(): boolean;
  16957. set transparencyShadow(value: boolean);
  16958. /**
  16959. * Sets the ability to have transparent shadow (boolean).
  16960. * @param transparent True if transparent else False
  16961. * @returns the shadow generator allowing fluent coding
  16962. */
  16963. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16964. protected _shadowMap: Nullable<RenderTargetTexture>;
  16965. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16966. /**
  16967. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16968. * @returns The render target texture if present otherwise, null
  16969. */
  16970. getShadowMap(): Nullable<RenderTargetTexture>;
  16971. /**
  16972. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16973. * @returns The render target texture if the shadow map is present otherwise, null
  16974. */
  16975. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16976. /**
  16977. * Gets the class name of that object
  16978. * @returns "ShadowGenerator"
  16979. */
  16980. getClassName(): string;
  16981. /**
  16982. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16983. * @param mesh Mesh to add
  16984. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16985. * @returns the Shadow Generator itself
  16986. */
  16987. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16988. /**
  16989. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16990. * @param mesh Mesh to remove
  16991. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16992. * @returns the Shadow Generator itself
  16993. */
  16994. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16995. /**
  16996. * Controls the extent to which the shadows fade out at the edge of the frustum
  16997. */
  16998. frustumEdgeFalloff: number;
  16999. protected _light: IShadowLight;
  17000. /**
  17001. * Returns the associated light object.
  17002. * @returns the light generating the shadow
  17003. */
  17004. getLight(): IShadowLight;
  17005. /**
  17006. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17007. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17008. * It might on the other hand introduce peter panning.
  17009. */
  17010. forceBackFacesOnly: boolean;
  17011. protected _scene: Scene;
  17012. protected _lightDirection: Vector3;
  17013. protected _effect: Effect;
  17014. protected _viewMatrix: Matrix;
  17015. protected _projectionMatrix: Matrix;
  17016. protected _transformMatrix: Matrix;
  17017. protected _cachedPosition: Vector3;
  17018. protected _cachedDirection: Vector3;
  17019. protected _cachedDefines: string;
  17020. protected _currentRenderID: number;
  17021. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17022. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17023. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17024. protected _blurPostProcesses: PostProcess[];
  17025. protected _mapSize: number;
  17026. protected _currentFaceIndex: number;
  17027. protected _currentFaceIndexCache: number;
  17028. protected _textureType: number;
  17029. protected _defaultTextureMatrix: Matrix;
  17030. protected _storedUniqueId: Nullable<number>;
  17031. /** @hidden */
  17032. static _SceneComponentInitialization: (scene: Scene) => void;
  17033. /**
  17034. * Creates a ShadowGenerator object.
  17035. * A ShadowGenerator is the required tool to use the shadows.
  17036. * Each light casting shadows needs to use its own ShadowGenerator.
  17037. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17038. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17039. * @param light The light object generating the shadows.
  17040. * @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.
  17041. */
  17042. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17043. protected _initializeGenerator(): void;
  17044. protected _createTargetRenderTexture(): void;
  17045. protected _initializeShadowMap(): void;
  17046. protected _initializeBlurRTTAndPostProcesses(): void;
  17047. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17048. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17049. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17050. protected _applyFilterValues(): void;
  17051. /**
  17052. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17053. * @param onCompiled Callback triggered at the and of the effects compilation
  17054. * @param options Sets of optional options forcing the compilation with different modes
  17055. */
  17056. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17057. useInstances: boolean;
  17058. }>): void;
  17059. /**
  17060. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17061. * @param options Sets of optional options forcing the compilation with different modes
  17062. * @returns A promise that resolves when the compilation completes
  17063. */
  17064. forceCompilationAsync(options?: Partial<{
  17065. useInstances: boolean;
  17066. }>): Promise<void>;
  17067. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17068. /**
  17069. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17070. * @param subMesh The submesh we want to render in the shadow map
  17071. * @param useInstances Defines wether will draw in the map using instances
  17072. * @returns true if ready otherwise, false
  17073. */
  17074. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17075. /**
  17076. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17077. * @param defines Defines of the material we want to update
  17078. * @param lightIndex Index of the light in the enabled light list of the material
  17079. */
  17080. prepareDefines(defines: any, lightIndex: number): void;
  17081. /**
  17082. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17083. * defined in the generator but impacting the effect).
  17084. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17085. * @param effect The effect we are binfing the information for
  17086. */
  17087. bindShadowLight(lightIndex: string, effect: Effect): void;
  17088. /**
  17089. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17090. * (eq to shadow prjection matrix * light transform matrix)
  17091. * @returns The transform matrix used to create the shadow map
  17092. */
  17093. getTransformMatrix(): Matrix;
  17094. /**
  17095. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17096. * Cube and 2D textures for instance.
  17097. */
  17098. recreateShadowMap(): void;
  17099. protected _disposeBlurPostProcesses(): void;
  17100. protected _disposeRTTandPostProcesses(): void;
  17101. /**
  17102. * Disposes the ShadowGenerator.
  17103. * Returns nothing.
  17104. */
  17105. dispose(): void;
  17106. /**
  17107. * Serializes the shadow generator setup to a json object.
  17108. * @returns The serialized JSON object
  17109. */
  17110. serialize(): any;
  17111. /**
  17112. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17113. * @param parsedShadowGenerator The JSON object to parse
  17114. * @param scene The scene to create the shadow map for
  17115. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17116. * @returns The parsed shadow generator
  17117. */
  17118. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17119. }
  17120. }
  17121. declare module "babylonjs/Lights/light" {
  17122. import { Nullable } from "babylonjs/types";
  17123. import { Scene } from "babylonjs/scene";
  17124. import { Vector3 } from "babylonjs/Maths/math.vector";
  17125. import { Color3 } from "babylonjs/Maths/math.color";
  17126. import { Node } from "babylonjs/node";
  17127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17128. import { Effect } from "babylonjs/Materials/effect";
  17129. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17130. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17131. /**
  17132. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17133. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17134. * 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.
  17135. */
  17136. export abstract class Light extends Node {
  17137. /**
  17138. * Falloff Default: light is falling off following the material specification:
  17139. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17140. */
  17141. static readonly FALLOFF_DEFAULT: number;
  17142. /**
  17143. * Falloff Physical: light is falling off following the inverse squared distance law.
  17144. */
  17145. static readonly FALLOFF_PHYSICAL: number;
  17146. /**
  17147. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17148. * to enhance interoperability with other engines.
  17149. */
  17150. static readonly FALLOFF_GLTF: number;
  17151. /**
  17152. * Falloff Standard: light is falling off like in the standard material
  17153. * to enhance interoperability with other materials.
  17154. */
  17155. static readonly FALLOFF_STANDARD: number;
  17156. /**
  17157. * If every light affecting the material is in this lightmapMode,
  17158. * material.lightmapTexture adds or multiplies
  17159. * (depends on material.useLightmapAsShadowmap)
  17160. * after every other light calculations.
  17161. */
  17162. static readonly LIGHTMAP_DEFAULT: number;
  17163. /**
  17164. * material.lightmapTexture as only diffuse lighting from this light
  17165. * adds only specular lighting from this light
  17166. * adds dynamic shadows
  17167. */
  17168. static readonly LIGHTMAP_SPECULAR: number;
  17169. /**
  17170. * material.lightmapTexture as only lighting
  17171. * no light calculation from this light
  17172. * only adds dynamic shadows from this light
  17173. */
  17174. static readonly LIGHTMAP_SHADOWSONLY: number;
  17175. /**
  17176. * Each light type uses the default quantity according to its type:
  17177. * point/spot lights use luminous intensity
  17178. * directional lights use illuminance
  17179. */
  17180. static readonly INTENSITYMODE_AUTOMATIC: number;
  17181. /**
  17182. * lumen (lm)
  17183. */
  17184. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17185. /**
  17186. * candela (lm/sr)
  17187. */
  17188. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17189. /**
  17190. * lux (lm/m^2)
  17191. */
  17192. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17193. /**
  17194. * nit (cd/m^2)
  17195. */
  17196. static readonly INTENSITYMODE_LUMINANCE: number;
  17197. /**
  17198. * Light type const id of the point light.
  17199. */
  17200. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17201. /**
  17202. * Light type const id of the directional light.
  17203. */
  17204. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17205. /**
  17206. * Light type const id of the spot light.
  17207. */
  17208. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17209. /**
  17210. * Light type const id of the hemispheric light.
  17211. */
  17212. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17213. /**
  17214. * Diffuse gives the basic color to an object.
  17215. */
  17216. diffuse: Color3;
  17217. /**
  17218. * Specular produces a highlight color on an object.
  17219. * Note: This is note affecting PBR materials.
  17220. */
  17221. specular: Color3;
  17222. /**
  17223. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17224. * falling off base on range or angle.
  17225. * This can be set to any values in Light.FALLOFF_x.
  17226. *
  17227. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17228. * other types of materials.
  17229. */
  17230. falloffType: number;
  17231. /**
  17232. * Strength of the light.
  17233. * Note: By default it is define in the framework own unit.
  17234. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17235. */
  17236. intensity: number;
  17237. private _range;
  17238. protected _inverseSquaredRange: number;
  17239. /**
  17240. * Defines how far from the source the light is impacting in scene units.
  17241. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17242. */
  17243. get range(): number;
  17244. /**
  17245. * Defines how far from the source the light is impacting in scene units.
  17246. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17247. */
  17248. set range(value: number);
  17249. /**
  17250. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17251. * of light.
  17252. */
  17253. private _photometricScale;
  17254. private _intensityMode;
  17255. /**
  17256. * Gets the photometric scale used to interpret the intensity.
  17257. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17258. */
  17259. get intensityMode(): number;
  17260. /**
  17261. * Sets the photometric scale used to interpret the intensity.
  17262. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17263. */
  17264. set intensityMode(value: number);
  17265. private _radius;
  17266. /**
  17267. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17268. */
  17269. get radius(): number;
  17270. /**
  17271. * sets the light radius used by PBR Materials to simulate soft area lights.
  17272. */
  17273. set radius(value: number);
  17274. private _renderPriority;
  17275. /**
  17276. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17277. * exceeding the number allowed of the materials.
  17278. */
  17279. renderPriority: number;
  17280. private _shadowEnabled;
  17281. /**
  17282. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17283. * the current shadow generator.
  17284. */
  17285. get shadowEnabled(): boolean;
  17286. /**
  17287. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17288. * the current shadow generator.
  17289. */
  17290. set shadowEnabled(value: boolean);
  17291. private _includedOnlyMeshes;
  17292. /**
  17293. * Gets the only meshes impacted by this light.
  17294. */
  17295. get includedOnlyMeshes(): AbstractMesh[];
  17296. /**
  17297. * Sets the only meshes impacted by this light.
  17298. */
  17299. set includedOnlyMeshes(value: AbstractMesh[]);
  17300. private _excludedMeshes;
  17301. /**
  17302. * Gets the meshes not impacted by this light.
  17303. */
  17304. get excludedMeshes(): AbstractMesh[];
  17305. /**
  17306. * Sets the meshes not impacted by this light.
  17307. */
  17308. set excludedMeshes(value: AbstractMesh[]);
  17309. private _excludeWithLayerMask;
  17310. /**
  17311. * Gets the layer id use to find what meshes are not impacted by the light.
  17312. * Inactive if 0
  17313. */
  17314. get excludeWithLayerMask(): number;
  17315. /**
  17316. * Sets the layer id use to find what meshes are not impacted by the light.
  17317. * Inactive if 0
  17318. */
  17319. set excludeWithLayerMask(value: number);
  17320. private _includeOnlyWithLayerMask;
  17321. /**
  17322. * Gets the layer id use to find what meshes are impacted by the light.
  17323. * Inactive if 0
  17324. */
  17325. get includeOnlyWithLayerMask(): number;
  17326. /**
  17327. * Sets the layer id use to find what meshes are impacted by the light.
  17328. * Inactive if 0
  17329. */
  17330. set includeOnlyWithLayerMask(value: number);
  17331. private _lightmapMode;
  17332. /**
  17333. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17334. */
  17335. get lightmapMode(): number;
  17336. /**
  17337. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17338. */
  17339. set lightmapMode(value: number);
  17340. /**
  17341. * Shadow generator associted to the light.
  17342. * @hidden Internal use only.
  17343. */
  17344. _shadowGenerator: Nullable<IShadowGenerator>;
  17345. /**
  17346. * @hidden Internal use only.
  17347. */
  17348. _excludedMeshesIds: string[];
  17349. /**
  17350. * @hidden Internal use only.
  17351. */
  17352. _includedOnlyMeshesIds: string[];
  17353. /**
  17354. * The current light unifom buffer.
  17355. * @hidden Internal use only.
  17356. */
  17357. _uniformBuffer: UniformBuffer;
  17358. /** @hidden */
  17359. _renderId: number;
  17360. /**
  17361. * Creates a Light object in the scene.
  17362. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17363. * @param name The firendly name of the light
  17364. * @param scene The scene the light belongs too
  17365. */
  17366. constructor(name: string, scene: Scene);
  17367. protected abstract _buildUniformLayout(): void;
  17368. /**
  17369. * Sets the passed Effect "effect" with the Light information.
  17370. * @param effect The effect to update
  17371. * @param lightIndex The index of the light in the effect to update
  17372. * @returns The light
  17373. */
  17374. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17375. /**
  17376. * Sets the passed Effect "effect" with the Light textures.
  17377. * @param effect The effect to update
  17378. * @param lightIndex The index of the light in the effect to update
  17379. * @returns The light
  17380. */
  17381. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17382. /**
  17383. * Binds the lights information from the scene to the effect for the given mesh.
  17384. * @param lightIndex Light index
  17385. * @param scene The scene where the light belongs to
  17386. * @param effect The effect we are binding the data to
  17387. * @param useSpecular Defines if specular is supported
  17388. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17389. */
  17390. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17391. /**
  17392. * Sets the passed Effect "effect" with the Light information.
  17393. * @param effect The effect to update
  17394. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17395. * @returns The light
  17396. */
  17397. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17398. /**
  17399. * Returns the string "Light".
  17400. * @returns the class name
  17401. */
  17402. getClassName(): string;
  17403. /** @hidden */
  17404. readonly _isLight: boolean;
  17405. /**
  17406. * Converts the light information to a readable string for debug purpose.
  17407. * @param fullDetails Supports for multiple levels of logging within scene loading
  17408. * @returns the human readable light info
  17409. */
  17410. toString(fullDetails?: boolean): string;
  17411. /** @hidden */
  17412. protected _syncParentEnabledState(): void;
  17413. /**
  17414. * Set the enabled state of this node.
  17415. * @param value - the new enabled state
  17416. */
  17417. setEnabled(value: boolean): void;
  17418. /**
  17419. * Returns the Light associated shadow generator if any.
  17420. * @return the associated shadow generator.
  17421. */
  17422. getShadowGenerator(): Nullable<IShadowGenerator>;
  17423. /**
  17424. * Returns a Vector3, the absolute light position in the World.
  17425. * @returns the world space position of the light
  17426. */
  17427. getAbsolutePosition(): Vector3;
  17428. /**
  17429. * Specifies if the light will affect the passed mesh.
  17430. * @param mesh The mesh to test against the light
  17431. * @return true the mesh is affected otherwise, false.
  17432. */
  17433. canAffectMesh(mesh: AbstractMesh): boolean;
  17434. /**
  17435. * Sort function to order lights for rendering.
  17436. * @param a First Light object to compare to second.
  17437. * @param b Second Light object to compare first.
  17438. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17439. */
  17440. static CompareLightsPriority(a: Light, b: Light): number;
  17441. /**
  17442. * Releases resources associated with this node.
  17443. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17444. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17445. */
  17446. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17447. /**
  17448. * Returns the light type ID (integer).
  17449. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17450. */
  17451. getTypeID(): number;
  17452. /**
  17453. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17454. * @returns the scaled intensity in intensity mode unit
  17455. */
  17456. getScaledIntensity(): number;
  17457. /**
  17458. * Returns a new Light object, named "name", from the current one.
  17459. * @param name The name of the cloned light
  17460. * @returns the new created light
  17461. */
  17462. clone(name: string): Nullable<Light>;
  17463. /**
  17464. * Serializes the current light into a Serialization object.
  17465. * @returns the serialized object.
  17466. */
  17467. serialize(): any;
  17468. /**
  17469. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17470. * This new light is named "name" and added to the passed scene.
  17471. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17472. * @param name The friendly name of the light
  17473. * @param scene The scene the new light will belong to
  17474. * @returns the constructor function
  17475. */
  17476. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17477. /**
  17478. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17479. * @param parsedLight The JSON representation of the light
  17480. * @param scene The scene to create the parsed light in
  17481. * @returns the created light after parsing
  17482. */
  17483. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17484. private _hookArrayForExcluded;
  17485. private _hookArrayForIncludedOnly;
  17486. private _resyncMeshes;
  17487. /**
  17488. * Forces the meshes to update their light related information in their rendering used effects
  17489. * @hidden Internal Use Only
  17490. */
  17491. _markMeshesAsLightDirty(): void;
  17492. /**
  17493. * Recomputes the cached photometric scale if needed.
  17494. */
  17495. private _computePhotometricScale;
  17496. /**
  17497. * Returns the Photometric Scale according to the light type and intensity mode.
  17498. */
  17499. private _getPhotometricScale;
  17500. /**
  17501. * Reorder the light in the scene according to their defined priority.
  17502. * @hidden Internal Use Only
  17503. */
  17504. _reorderLightsInScene(): void;
  17505. /**
  17506. * Prepares the list of defines specific to the light type.
  17507. * @param defines the list of defines
  17508. * @param lightIndex defines the index of the light for the effect
  17509. */
  17510. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17511. }
  17512. }
  17513. declare module "babylonjs/Actions/action" {
  17514. import { Observable } from "babylonjs/Misc/observable";
  17515. import { Condition } from "babylonjs/Actions/condition";
  17516. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17517. import { ActionManager } from "babylonjs/Actions/actionManager";
  17518. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17519. /**
  17520. * Interface used to define Action
  17521. */
  17522. export interface IAction {
  17523. /**
  17524. * Trigger for the action
  17525. */
  17526. trigger: number;
  17527. /** Options of the trigger */
  17528. triggerOptions: any;
  17529. /**
  17530. * Gets the trigger parameters
  17531. * @returns the trigger parameters
  17532. */
  17533. getTriggerParameter(): any;
  17534. /**
  17535. * Internal only - executes current action event
  17536. * @hidden
  17537. */
  17538. _executeCurrent(evt?: ActionEvent): void;
  17539. /**
  17540. * Serialize placeholder for child classes
  17541. * @param parent of child
  17542. * @returns the serialized object
  17543. */
  17544. serialize(parent: any): any;
  17545. /**
  17546. * Internal only
  17547. * @hidden
  17548. */
  17549. _prepare(): void;
  17550. /**
  17551. * Internal only - manager for action
  17552. * @hidden
  17553. */
  17554. _actionManager: AbstractActionManager;
  17555. /**
  17556. * Adds action to chain of actions, may be a DoNothingAction
  17557. * @param action defines the next action to execute
  17558. * @returns The action passed in
  17559. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17560. */
  17561. then(action: IAction): IAction;
  17562. }
  17563. /**
  17564. * The action to be carried out following a trigger
  17565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17566. */
  17567. export class Action implements IAction {
  17568. /** the trigger, with or without parameters, for the action */
  17569. triggerOptions: any;
  17570. /**
  17571. * Trigger for the action
  17572. */
  17573. trigger: number;
  17574. /**
  17575. * Internal only - manager for action
  17576. * @hidden
  17577. */
  17578. _actionManager: ActionManager;
  17579. private _nextActiveAction;
  17580. private _child;
  17581. private _condition?;
  17582. private _triggerParameter;
  17583. /**
  17584. * An event triggered prior to action being executed.
  17585. */
  17586. onBeforeExecuteObservable: Observable<Action>;
  17587. /**
  17588. * Creates a new Action
  17589. * @param triggerOptions the trigger, with or without parameters, for the action
  17590. * @param condition an optional determinant of action
  17591. */
  17592. constructor(
  17593. /** the trigger, with or without parameters, for the action */
  17594. triggerOptions: any, condition?: Condition);
  17595. /**
  17596. * Internal only
  17597. * @hidden
  17598. */
  17599. _prepare(): void;
  17600. /**
  17601. * Gets the trigger parameters
  17602. * @returns the trigger parameters
  17603. */
  17604. getTriggerParameter(): any;
  17605. /**
  17606. * Internal only - executes current action event
  17607. * @hidden
  17608. */
  17609. _executeCurrent(evt?: ActionEvent): void;
  17610. /**
  17611. * Execute placeholder for child classes
  17612. * @param evt optional action event
  17613. */
  17614. execute(evt?: ActionEvent): void;
  17615. /**
  17616. * Skips to next active action
  17617. */
  17618. skipToNextActiveAction(): void;
  17619. /**
  17620. * Adds action to chain of actions, may be a DoNothingAction
  17621. * @param action defines the next action to execute
  17622. * @returns The action passed in
  17623. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17624. */
  17625. then(action: Action): Action;
  17626. /**
  17627. * Internal only
  17628. * @hidden
  17629. */
  17630. _getProperty(propertyPath: string): string;
  17631. /**
  17632. * Internal only
  17633. * @hidden
  17634. */
  17635. _getEffectiveTarget(target: any, propertyPath: string): any;
  17636. /**
  17637. * Serialize placeholder for child classes
  17638. * @param parent of child
  17639. * @returns the serialized object
  17640. */
  17641. serialize(parent: any): any;
  17642. /**
  17643. * Internal only called by serialize
  17644. * @hidden
  17645. */
  17646. protected _serialize(serializedAction: any, parent?: any): any;
  17647. /**
  17648. * Internal only
  17649. * @hidden
  17650. */
  17651. static _SerializeValueAsString: (value: any) => string;
  17652. /**
  17653. * Internal only
  17654. * @hidden
  17655. */
  17656. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17657. name: string;
  17658. targetType: string;
  17659. value: string;
  17660. };
  17661. }
  17662. }
  17663. declare module "babylonjs/Actions/condition" {
  17664. import { ActionManager } from "babylonjs/Actions/actionManager";
  17665. /**
  17666. * A Condition applied to an Action
  17667. */
  17668. export class Condition {
  17669. /**
  17670. * Internal only - manager for action
  17671. * @hidden
  17672. */
  17673. _actionManager: ActionManager;
  17674. /**
  17675. * Internal only
  17676. * @hidden
  17677. */
  17678. _evaluationId: number;
  17679. /**
  17680. * Internal only
  17681. * @hidden
  17682. */
  17683. _currentResult: boolean;
  17684. /**
  17685. * Creates a new Condition
  17686. * @param actionManager the manager of the action the condition is applied to
  17687. */
  17688. constructor(actionManager: ActionManager);
  17689. /**
  17690. * Check if the current condition is valid
  17691. * @returns a boolean
  17692. */
  17693. isValid(): boolean;
  17694. /**
  17695. * Internal only
  17696. * @hidden
  17697. */
  17698. _getProperty(propertyPath: string): string;
  17699. /**
  17700. * Internal only
  17701. * @hidden
  17702. */
  17703. _getEffectiveTarget(target: any, propertyPath: string): any;
  17704. /**
  17705. * Serialize placeholder for child classes
  17706. * @returns the serialized object
  17707. */
  17708. serialize(): any;
  17709. /**
  17710. * Internal only
  17711. * @hidden
  17712. */
  17713. protected _serialize(serializedCondition: any): any;
  17714. }
  17715. /**
  17716. * Defines specific conditional operators as extensions of Condition
  17717. */
  17718. export class ValueCondition extends Condition {
  17719. /** path to specify the property of the target the conditional operator uses */
  17720. propertyPath: string;
  17721. /** the value compared by the conditional operator against the current value of the property */
  17722. value: any;
  17723. /** the conditional operator, default ValueCondition.IsEqual */
  17724. operator: number;
  17725. /**
  17726. * Internal only
  17727. * @hidden
  17728. */
  17729. private static _IsEqual;
  17730. /**
  17731. * Internal only
  17732. * @hidden
  17733. */
  17734. private static _IsDifferent;
  17735. /**
  17736. * Internal only
  17737. * @hidden
  17738. */
  17739. private static _IsGreater;
  17740. /**
  17741. * Internal only
  17742. * @hidden
  17743. */
  17744. private static _IsLesser;
  17745. /**
  17746. * returns the number for IsEqual
  17747. */
  17748. static get IsEqual(): number;
  17749. /**
  17750. * Returns the number for IsDifferent
  17751. */
  17752. static get IsDifferent(): number;
  17753. /**
  17754. * Returns the number for IsGreater
  17755. */
  17756. static get IsGreater(): number;
  17757. /**
  17758. * Returns the number for IsLesser
  17759. */
  17760. static get IsLesser(): number;
  17761. /**
  17762. * Internal only The action manager for the condition
  17763. * @hidden
  17764. */
  17765. _actionManager: ActionManager;
  17766. /**
  17767. * Internal only
  17768. * @hidden
  17769. */
  17770. private _target;
  17771. /**
  17772. * Internal only
  17773. * @hidden
  17774. */
  17775. private _effectiveTarget;
  17776. /**
  17777. * Internal only
  17778. * @hidden
  17779. */
  17780. private _property;
  17781. /**
  17782. * Creates a new ValueCondition
  17783. * @param actionManager manager for the action the condition applies to
  17784. * @param target for the action
  17785. * @param propertyPath path to specify the property of the target the conditional operator uses
  17786. * @param value the value compared by the conditional operator against the current value of the property
  17787. * @param operator the conditional operator, default ValueCondition.IsEqual
  17788. */
  17789. constructor(actionManager: ActionManager, target: any,
  17790. /** path to specify the property of the target the conditional operator uses */
  17791. propertyPath: string,
  17792. /** the value compared by the conditional operator against the current value of the property */
  17793. value: any,
  17794. /** the conditional operator, default ValueCondition.IsEqual */
  17795. operator?: number);
  17796. /**
  17797. * Compares the given value with the property value for the specified conditional operator
  17798. * @returns the result of the comparison
  17799. */
  17800. isValid(): boolean;
  17801. /**
  17802. * Serialize the ValueCondition into a JSON compatible object
  17803. * @returns serialization object
  17804. */
  17805. serialize(): any;
  17806. /**
  17807. * Gets the name of the conditional operator for the ValueCondition
  17808. * @param operator the conditional operator
  17809. * @returns the name
  17810. */
  17811. static GetOperatorName(operator: number): string;
  17812. }
  17813. /**
  17814. * Defines a predicate condition as an extension of Condition
  17815. */
  17816. export class PredicateCondition extends Condition {
  17817. /** defines the predicate function used to validate the condition */
  17818. predicate: () => boolean;
  17819. /**
  17820. * Internal only - manager for action
  17821. * @hidden
  17822. */
  17823. _actionManager: ActionManager;
  17824. /**
  17825. * Creates a new PredicateCondition
  17826. * @param actionManager manager for the action the condition applies to
  17827. * @param predicate defines the predicate function used to validate the condition
  17828. */
  17829. constructor(actionManager: ActionManager,
  17830. /** defines the predicate function used to validate the condition */
  17831. predicate: () => boolean);
  17832. /**
  17833. * @returns the validity of the predicate condition
  17834. */
  17835. isValid(): boolean;
  17836. }
  17837. /**
  17838. * Defines a state condition as an extension of Condition
  17839. */
  17840. export class StateCondition extends Condition {
  17841. /** Value to compare with target state */
  17842. value: string;
  17843. /**
  17844. * Internal only - manager for action
  17845. * @hidden
  17846. */
  17847. _actionManager: ActionManager;
  17848. /**
  17849. * Internal only
  17850. * @hidden
  17851. */
  17852. private _target;
  17853. /**
  17854. * Creates a new StateCondition
  17855. * @param actionManager manager for the action the condition applies to
  17856. * @param target of the condition
  17857. * @param value to compare with target state
  17858. */
  17859. constructor(actionManager: ActionManager, target: any,
  17860. /** Value to compare with target state */
  17861. value: string);
  17862. /**
  17863. * Gets a boolean indicating if the current condition is met
  17864. * @returns the validity of the state
  17865. */
  17866. isValid(): boolean;
  17867. /**
  17868. * Serialize the StateCondition into a JSON compatible object
  17869. * @returns serialization object
  17870. */
  17871. serialize(): any;
  17872. }
  17873. }
  17874. declare module "babylonjs/Actions/directActions" {
  17875. import { Action } from "babylonjs/Actions/action";
  17876. import { Condition } from "babylonjs/Actions/condition";
  17877. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17878. /**
  17879. * This defines an action responsible to toggle a boolean once triggered.
  17880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17881. */
  17882. export class SwitchBooleanAction extends Action {
  17883. /**
  17884. * The path to the boolean property in the target object
  17885. */
  17886. propertyPath: string;
  17887. private _target;
  17888. private _effectiveTarget;
  17889. private _property;
  17890. /**
  17891. * Instantiate the action
  17892. * @param triggerOptions defines the trigger options
  17893. * @param target defines the object containing the boolean
  17894. * @param propertyPath defines the path to the boolean property in the target object
  17895. * @param condition defines the trigger related conditions
  17896. */
  17897. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17898. /** @hidden */
  17899. _prepare(): void;
  17900. /**
  17901. * Execute the action toggle the boolean value.
  17902. */
  17903. execute(): void;
  17904. /**
  17905. * Serializes the actions and its related information.
  17906. * @param parent defines the object to serialize in
  17907. * @returns the serialized object
  17908. */
  17909. serialize(parent: any): any;
  17910. }
  17911. /**
  17912. * This defines an action responsible to set a the state field of the target
  17913. * to a desired value once triggered.
  17914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17915. */
  17916. export class SetStateAction extends Action {
  17917. /**
  17918. * The value to store in the state field.
  17919. */
  17920. value: string;
  17921. private _target;
  17922. /**
  17923. * Instantiate the action
  17924. * @param triggerOptions defines the trigger options
  17925. * @param target defines the object containing the state property
  17926. * @param value defines the value to store in the state field
  17927. * @param condition defines the trigger related conditions
  17928. */
  17929. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17930. /**
  17931. * Execute the action and store the value on the target state property.
  17932. */
  17933. execute(): void;
  17934. /**
  17935. * Serializes the actions and its related information.
  17936. * @param parent defines the object to serialize in
  17937. * @returns the serialized object
  17938. */
  17939. serialize(parent: any): any;
  17940. }
  17941. /**
  17942. * This defines an action responsible to set a property of the target
  17943. * to a desired value once triggered.
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17945. */
  17946. export class SetValueAction extends Action {
  17947. /**
  17948. * The path of the property to set in the target.
  17949. */
  17950. propertyPath: string;
  17951. /**
  17952. * The value to set in the property
  17953. */
  17954. value: any;
  17955. private _target;
  17956. private _effectiveTarget;
  17957. private _property;
  17958. /**
  17959. * Instantiate the action
  17960. * @param triggerOptions defines the trigger options
  17961. * @param target defines the object containing the property
  17962. * @param propertyPath defines the path of the property to set in the target
  17963. * @param value defines the value to set in the property
  17964. * @param condition defines the trigger related conditions
  17965. */
  17966. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17967. /** @hidden */
  17968. _prepare(): void;
  17969. /**
  17970. * Execute the action and set the targetted property to the desired value.
  17971. */
  17972. execute(): void;
  17973. /**
  17974. * Serializes the actions and its related information.
  17975. * @param parent defines the object to serialize in
  17976. * @returns the serialized object
  17977. */
  17978. serialize(parent: any): any;
  17979. }
  17980. /**
  17981. * This defines an action responsible to increment the target value
  17982. * to a desired value once triggered.
  17983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17984. */
  17985. export class IncrementValueAction extends Action {
  17986. /**
  17987. * The path of the property to increment in the target.
  17988. */
  17989. propertyPath: string;
  17990. /**
  17991. * The value we should increment the property by.
  17992. */
  17993. value: any;
  17994. private _target;
  17995. private _effectiveTarget;
  17996. private _property;
  17997. /**
  17998. * Instantiate the action
  17999. * @param triggerOptions defines the trigger options
  18000. * @param target defines the object containing the property
  18001. * @param propertyPath defines the path of the property to increment in the target
  18002. * @param value defines the value value we should increment the property by
  18003. * @param condition defines the trigger related conditions
  18004. */
  18005. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18006. /** @hidden */
  18007. _prepare(): void;
  18008. /**
  18009. * Execute the action and increment the target of the value amount.
  18010. */
  18011. execute(): void;
  18012. /**
  18013. * Serializes the actions and its related information.
  18014. * @param parent defines the object to serialize in
  18015. * @returns the serialized object
  18016. */
  18017. serialize(parent: any): any;
  18018. }
  18019. /**
  18020. * This defines an action responsible to start an animation once triggered.
  18021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18022. */
  18023. export class PlayAnimationAction extends Action {
  18024. /**
  18025. * Where the animation should start (animation frame)
  18026. */
  18027. from: number;
  18028. /**
  18029. * Where the animation should stop (animation frame)
  18030. */
  18031. to: number;
  18032. /**
  18033. * Define if the animation should loop or stop after the first play.
  18034. */
  18035. loop?: boolean;
  18036. private _target;
  18037. /**
  18038. * Instantiate the action
  18039. * @param triggerOptions defines the trigger options
  18040. * @param target defines the target animation or animation name
  18041. * @param from defines from where the animation should start (animation frame)
  18042. * @param end defines where the animation should stop (animation frame)
  18043. * @param loop defines if the animation should loop or stop after the first play
  18044. * @param condition defines the trigger related conditions
  18045. */
  18046. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18047. /** @hidden */
  18048. _prepare(): void;
  18049. /**
  18050. * Execute the action and play the animation.
  18051. */
  18052. execute(): void;
  18053. /**
  18054. * Serializes the actions and its related information.
  18055. * @param parent defines the object to serialize in
  18056. * @returns the serialized object
  18057. */
  18058. serialize(parent: any): any;
  18059. }
  18060. /**
  18061. * This defines an action responsible to stop an animation once triggered.
  18062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18063. */
  18064. export class StopAnimationAction extends Action {
  18065. private _target;
  18066. /**
  18067. * Instantiate the action
  18068. * @param triggerOptions defines the trigger options
  18069. * @param target defines the target animation or animation name
  18070. * @param condition defines the trigger related conditions
  18071. */
  18072. constructor(triggerOptions: any, target: any, condition?: Condition);
  18073. /** @hidden */
  18074. _prepare(): void;
  18075. /**
  18076. * Execute the action and stop the animation.
  18077. */
  18078. execute(): void;
  18079. /**
  18080. * Serializes the actions and its related information.
  18081. * @param parent defines the object to serialize in
  18082. * @returns the serialized object
  18083. */
  18084. serialize(parent: any): any;
  18085. }
  18086. /**
  18087. * This defines an action responsible that does nothing once triggered.
  18088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18089. */
  18090. export class DoNothingAction extends Action {
  18091. /**
  18092. * Instantiate the action
  18093. * @param triggerOptions defines the trigger options
  18094. * @param condition defines the trigger related conditions
  18095. */
  18096. constructor(triggerOptions?: any, condition?: Condition);
  18097. /**
  18098. * Execute the action and do nothing.
  18099. */
  18100. execute(): void;
  18101. /**
  18102. * Serializes the actions and its related information.
  18103. * @param parent defines the object to serialize in
  18104. * @returns the serialized object
  18105. */
  18106. serialize(parent: any): any;
  18107. }
  18108. /**
  18109. * This defines an action responsible to trigger several actions once triggered.
  18110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18111. */
  18112. export class CombineAction extends Action {
  18113. /**
  18114. * The list of aggregated animations to run.
  18115. */
  18116. children: Action[];
  18117. /**
  18118. * Instantiate the action
  18119. * @param triggerOptions defines the trigger options
  18120. * @param children defines the list of aggregated animations to run
  18121. * @param condition defines the trigger related conditions
  18122. */
  18123. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18124. /** @hidden */
  18125. _prepare(): void;
  18126. /**
  18127. * Execute the action and executes all the aggregated actions.
  18128. */
  18129. execute(evt: ActionEvent): void;
  18130. /**
  18131. * Serializes the actions and its related information.
  18132. * @param parent defines the object to serialize in
  18133. * @returns the serialized object
  18134. */
  18135. serialize(parent: any): any;
  18136. }
  18137. /**
  18138. * This defines an action responsible to run code (external event) once triggered.
  18139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18140. */
  18141. export class ExecuteCodeAction extends Action {
  18142. /**
  18143. * The callback function to run.
  18144. */
  18145. func: (evt: ActionEvent) => void;
  18146. /**
  18147. * Instantiate the action
  18148. * @param triggerOptions defines the trigger options
  18149. * @param func defines the callback function to run
  18150. * @param condition defines the trigger related conditions
  18151. */
  18152. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18153. /**
  18154. * Execute the action and run the attached code.
  18155. */
  18156. execute(evt: ActionEvent): void;
  18157. }
  18158. /**
  18159. * This defines an action responsible to set the parent property of the target once triggered.
  18160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18161. */
  18162. export class SetParentAction extends Action {
  18163. private _parent;
  18164. private _target;
  18165. /**
  18166. * Instantiate the action
  18167. * @param triggerOptions defines the trigger options
  18168. * @param target defines the target containing the parent property
  18169. * @param parent defines from where the animation should start (animation frame)
  18170. * @param condition defines the trigger related conditions
  18171. */
  18172. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18173. /** @hidden */
  18174. _prepare(): void;
  18175. /**
  18176. * Execute the action and set the parent property.
  18177. */
  18178. execute(): void;
  18179. /**
  18180. * Serializes the actions and its related information.
  18181. * @param parent defines the object to serialize in
  18182. * @returns the serialized object
  18183. */
  18184. serialize(parent: any): any;
  18185. }
  18186. }
  18187. declare module "babylonjs/Actions/actionManager" {
  18188. import { Nullable } from "babylonjs/types";
  18189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18190. import { Scene } from "babylonjs/scene";
  18191. import { IAction } from "babylonjs/Actions/action";
  18192. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18193. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18194. /**
  18195. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18196. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18198. */
  18199. export class ActionManager extends AbstractActionManager {
  18200. /**
  18201. * Nothing
  18202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18203. */
  18204. static readonly NothingTrigger: number;
  18205. /**
  18206. * On pick
  18207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18208. */
  18209. static readonly OnPickTrigger: number;
  18210. /**
  18211. * On left pick
  18212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18213. */
  18214. static readonly OnLeftPickTrigger: number;
  18215. /**
  18216. * On right pick
  18217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18218. */
  18219. static readonly OnRightPickTrigger: number;
  18220. /**
  18221. * On center pick
  18222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18223. */
  18224. static readonly OnCenterPickTrigger: number;
  18225. /**
  18226. * On pick down
  18227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18228. */
  18229. static readonly OnPickDownTrigger: number;
  18230. /**
  18231. * On double pick
  18232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18233. */
  18234. static readonly OnDoublePickTrigger: number;
  18235. /**
  18236. * On pick up
  18237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18238. */
  18239. static readonly OnPickUpTrigger: number;
  18240. /**
  18241. * On pick out.
  18242. * This trigger will only be raised if you also declared a OnPickDown
  18243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18244. */
  18245. static readonly OnPickOutTrigger: number;
  18246. /**
  18247. * On long press
  18248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18249. */
  18250. static readonly OnLongPressTrigger: number;
  18251. /**
  18252. * On pointer over
  18253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18254. */
  18255. static readonly OnPointerOverTrigger: number;
  18256. /**
  18257. * On pointer out
  18258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18259. */
  18260. static readonly OnPointerOutTrigger: number;
  18261. /**
  18262. * On every frame
  18263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18264. */
  18265. static readonly OnEveryFrameTrigger: number;
  18266. /**
  18267. * On intersection enter
  18268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18269. */
  18270. static readonly OnIntersectionEnterTrigger: number;
  18271. /**
  18272. * On intersection exit
  18273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18274. */
  18275. static readonly OnIntersectionExitTrigger: number;
  18276. /**
  18277. * On key down
  18278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18279. */
  18280. static readonly OnKeyDownTrigger: number;
  18281. /**
  18282. * On key up
  18283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18284. */
  18285. static readonly OnKeyUpTrigger: number;
  18286. private _scene;
  18287. /**
  18288. * Creates a new action manager
  18289. * @param scene defines the hosting scene
  18290. */
  18291. constructor(scene: Scene);
  18292. /**
  18293. * Releases all associated resources
  18294. */
  18295. dispose(): void;
  18296. /**
  18297. * Gets hosting scene
  18298. * @returns the hosting scene
  18299. */
  18300. getScene(): Scene;
  18301. /**
  18302. * Does this action manager handles actions of any of the given triggers
  18303. * @param triggers defines the triggers to be tested
  18304. * @return a boolean indicating whether one (or more) of the triggers is handled
  18305. */
  18306. hasSpecificTriggers(triggers: number[]): boolean;
  18307. /**
  18308. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18309. * speed.
  18310. * @param triggerA defines the trigger to be tested
  18311. * @param triggerB defines the trigger to be tested
  18312. * @return a boolean indicating whether one (or more) of the triggers is handled
  18313. */
  18314. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18315. /**
  18316. * Does this action manager handles actions of a given trigger
  18317. * @param trigger defines the trigger to be tested
  18318. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18319. * @return whether the trigger is handled
  18320. */
  18321. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18322. /**
  18323. * Does this action manager has pointer triggers
  18324. */
  18325. get hasPointerTriggers(): boolean;
  18326. /**
  18327. * Does this action manager has pick triggers
  18328. */
  18329. get hasPickTriggers(): boolean;
  18330. /**
  18331. * Registers an action to this action manager
  18332. * @param action defines the action to be registered
  18333. * @return the action amended (prepared) after registration
  18334. */
  18335. registerAction(action: IAction): Nullable<IAction>;
  18336. /**
  18337. * Unregisters an action to this action manager
  18338. * @param action defines the action to be unregistered
  18339. * @return a boolean indicating whether the action has been unregistered
  18340. */
  18341. unregisterAction(action: IAction): Boolean;
  18342. /**
  18343. * Process a specific trigger
  18344. * @param trigger defines the trigger to process
  18345. * @param evt defines the event details to be processed
  18346. */
  18347. processTrigger(trigger: number, evt?: IActionEvent): void;
  18348. /** @hidden */
  18349. _getEffectiveTarget(target: any, propertyPath: string): any;
  18350. /** @hidden */
  18351. _getProperty(propertyPath: string): string;
  18352. /**
  18353. * Serialize this manager to a JSON object
  18354. * @param name defines the property name to store this manager
  18355. * @returns a JSON representation of this manager
  18356. */
  18357. serialize(name: string): any;
  18358. /**
  18359. * Creates a new ActionManager from a JSON data
  18360. * @param parsedActions defines the JSON data to read from
  18361. * @param object defines the hosting mesh
  18362. * @param scene defines the hosting scene
  18363. */
  18364. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18365. /**
  18366. * Get a trigger name by index
  18367. * @param trigger defines the trigger index
  18368. * @returns a trigger name
  18369. */
  18370. static GetTriggerName(trigger: number): string;
  18371. }
  18372. }
  18373. declare module "babylonjs/Sprites/sprite" {
  18374. import { Vector3 } from "babylonjs/Maths/math.vector";
  18375. import { Nullable } from "babylonjs/types";
  18376. import { ActionManager } from "babylonjs/Actions/actionManager";
  18377. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18378. import { Color4 } from "babylonjs/Maths/math.color";
  18379. /**
  18380. * Class used to represent a sprite
  18381. * @see http://doc.babylonjs.com/babylon101/sprites
  18382. */
  18383. export class Sprite {
  18384. /** defines the name */
  18385. name: string;
  18386. /** Gets or sets the current world position */
  18387. position: Vector3;
  18388. /** Gets or sets the main color */
  18389. color: Color4;
  18390. /** Gets or sets the width */
  18391. width: number;
  18392. /** Gets or sets the height */
  18393. height: number;
  18394. /** Gets or sets rotation angle */
  18395. angle: number;
  18396. /** Gets or sets the cell index in the sprite sheet */
  18397. cellIndex: number;
  18398. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18399. cellRef: string;
  18400. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18401. invertU: number;
  18402. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18403. invertV: number;
  18404. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18405. disposeWhenFinishedAnimating: boolean;
  18406. /** Gets the list of attached animations */
  18407. animations: Animation[];
  18408. /** Gets or sets a boolean indicating if the sprite can be picked */
  18409. isPickable: boolean;
  18410. /**
  18411. * Gets or sets the associated action manager
  18412. */
  18413. actionManager: Nullable<ActionManager>;
  18414. private _animationStarted;
  18415. private _loopAnimation;
  18416. private _fromIndex;
  18417. private _toIndex;
  18418. private _delay;
  18419. private _direction;
  18420. private _manager;
  18421. private _time;
  18422. private _onAnimationEnd;
  18423. /**
  18424. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18425. */
  18426. isVisible: boolean;
  18427. /**
  18428. * Gets or sets the sprite size
  18429. */
  18430. get size(): number;
  18431. set size(value: number);
  18432. /**
  18433. * Creates a new Sprite
  18434. * @param name defines the name
  18435. * @param manager defines the manager
  18436. */
  18437. constructor(
  18438. /** defines the name */
  18439. name: string, manager: ISpriteManager);
  18440. /**
  18441. * Starts an animation
  18442. * @param from defines the initial key
  18443. * @param to defines the end key
  18444. * @param loop defines if the animation must loop
  18445. * @param delay defines the start delay (in ms)
  18446. * @param onAnimationEnd defines a callback to call when animation ends
  18447. */
  18448. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18449. /** Stops current animation (if any) */
  18450. stopAnimation(): void;
  18451. /** @hidden */
  18452. _animate(deltaTime: number): void;
  18453. /** Release associated resources */
  18454. dispose(): void;
  18455. }
  18456. }
  18457. declare module "babylonjs/Collisions/pickingInfo" {
  18458. import { Nullable } from "babylonjs/types";
  18459. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18461. import { Sprite } from "babylonjs/Sprites/sprite";
  18462. import { Ray } from "babylonjs/Culling/ray";
  18463. /**
  18464. * Information about the result of picking within a scene
  18465. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18466. */
  18467. export class PickingInfo {
  18468. /** @hidden */
  18469. _pickingUnavailable: boolean;
  18470. /**
  18471. * If the pick collided with an object
  18472. */
  18473. hit: boolean;
  18474. /**
  18475. * Distance away where the pick collided
  18476. */
  18477. distance: number;
  18478. /**
  18479. * The location of pick collision
  18480. */
  18481. pickedPoint: Nullable<Vector3>;
  18482. /**
  18483. * The mesh corresponding the the pick collision
  18484. */
  18485. pickedMesh: Nullable<AbstractMesh>;
  18486. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18487. bu: number;
  18488. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18489. bv: number;
  18490. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18491. faceId: number;
  18492. /** Id of the the submesh that was picked */
  18493. subMeshId: number;
  18494. /** If a sprite was picked, this will be the sprite the pick collided with */
  18495. pickedSprite: Nullable<Sprite>;
  18496. /**
  18497. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18498. */
  18499. originMesh: Nullable<AbstractMesh>;
  18500. /**
  18501. * The ray that was used to perform the picking.
  18502. */
  18503. ray: Nullable<Ray>;
  18504. /**
  18505. * Gets the normal correspodning to the face the pick collided with
  18506. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18507. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18508. * @returns The normal correspodning to the face the pick collided with
  18509. */
  18510. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18511. /**
  18512. * Gets the texture coordinates of where the pick occured
  18513. * @returns the vector containing the coordnates of the texture
  18514. */
  18515. getTextureCoordinates(): Nullable<Vector2>;
  18516. }
  18517. }
  18518. declare module "babylonjs/Events/pointerEvents" {
  18519. import { Nullable } from "babylonjs/types";
  18520. import { Vector2 } from "babylonjs/Maths/math.vector";
  18521. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18522. import { Ray } from "babylonjs/Culling/ray";
  18523. /**
  18524. * Gather the list of pointer event types as constants.
  18525. */
  18526. export class PointerEventTypes {
  18527. /**
  18528. * 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.
  18529. */
  18530. static readonly POINTERDOWN: number;
  18531. /**
  18532. * The pointerup event is fired when a pointer is no longer active.
  18533. */
  18534. static readonly POINTERUP: number;
  18535. /**
  18536. * The pointermove event is fired when a pointer changes coordinates.
  18537. */
  18538. static readonly POINTERMOVE: number;
  18539. /**
  18540. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18541. */
  18542. static readonly POINTERWHEEL: number;
  18543. /**
  18544. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18545. */
  18546. static readonly POINTERPICK: number;
  18547. /**
  18548. * The pointertap event is fired when a the object has been touched and released without drag.
  18549. */
  18550. static readonly POINTERTAP: number;
  18551. /**
  18552. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18553. */
  18554. static readonly POINTERDOUBLETAP: number;
  18555. }
  18556. /**
  18557. * Base class of pointer info types.
  18558. */
  18559. export class PointerInfoBase {
  18560. /**
  18561. * Defines the type of event (PointerEventTypes)
  18562. */
  18563. type: number;
  18564. /**
  18565. * Defines the related dom event
  18566. */
  18567. event: PointerEvent | MouseWheelEvent;
  18568. /**
  18569. * Instantiates the base class of pointers info.
  18570. * @param type Defines the type of event (PointerEventTypes)
  18571. * @param event Defines the related dom event
  18572. */
  18573. constructor(
  18574. /**
  18575. * Defines the type of event (PointerEventTypes)
  18576. */
  18577. type: number,
  18578. /**
  18579. * Defines the related dom event
  18580. */
  18581. event: PointerEvent | MouseWheelEvent);
  18582. }
  18583. /**
  18584. * This class is used to store pointer related info for the onPrePointerObservable event.
  18585. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18586. */
  18587. export class PointerInfoPre extends PointerInfoBase {
  18588. /**
  18589. * Ray from a pointer if availible (eg. 6dof controller)
  18590. */
  18591. ray: Nullable<Ray>;
  18592. /**
  18593. * Defines the local position of the pointer on the canvas.
  18594. */
  18595. localPosition: Vector2;
  18596. /**
  18597. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18598. */
  18599. skipOnPointerObservable: boolean;
  18600. /**
  18601. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18602. * @param type Defines the type of event (PointerEventTypes)
  18603. * @param event Defines the related dom event
  18604. * @param localX Defines the local x coordinates of the pointer when the event occured
  18605. * @param localY Defines the local y coordinates of the pointer when the event occured
  18606. */
  18607. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18608. }
  18609. /**
  18610. * This type contains all the data related to a pointer event in Babylon.js.
  18611. * 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.
  18612. */
  18613. export class PointerInfo extends PointerInfoBase {
  18614. /**
  18615. * Defines the picking info associated to the info (if any)\
  18616. */
  18617. pickInfo: Nullable<PickingInfo>;
  18618. /**
  18619. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18620. * @param type Defines the type of event (PointerEventTypes)
  18621. * @param event Defines the related dom event
  18622. * @param pickInfo Defines the picking info associated to the info (if any)\
  18623. */
  18624. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18625. /**
  18626. * Defines the picking info associated to the info (if any)\
  18627. */
  18628. pickInfo: Nullable<PickingInfo>);
  18629. }
  18630. /**
  18631. * Data relating to a touch event on the screen.
  18632. */
  18633. export interface PointerTouch {
  18634. /**
  18635. * X coordinate of touch.
  18636. */
  18637. x: number;
  18638. /**
  18639. * Y coordinate of touch.
  18640. */
  18641. y: number;
  18642. /**
  18643. * Id of touch. Unique for each finger.
  18644. */
  18645. pointerId: number;
  18646. /**
  18647. * Event type passed from DOM.
  18648. */
  18649. type: any;
  18650. }
  18651. }
  18652. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18653. import { Observable } from "babylonjs/Misc/observable";
  18654. import { Nullable } from "babylonjs/types";
  18655. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18657. /**
  18658. * Manage the mouse inputs to control the movement of a free camera.
  18659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18660. */
  18661. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18662. /**
  18663. * Define if touch is enabled in the mouse input
  18664. */
  18665. touchEnabled: boolean;
  18666. /**
  18667. * Defines the camera the input is attached to.
  18668. */
  18669. camera: FreeCamera;
  18670. /**
  18671. * Defines the buttons associated with the input to handle camera move.
  18672. */
  18673. buttons: number[];
  18674. /**
  18675. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18676. */
  18677. angularSensibility: number;
  18678. private _pointerInput;
  18679. private _onMouseMove;
  18680. private _observer;
  18681. private previousPosition;
  18682. /**
  18683. * Observable for when a pointer move event occurs containing the move offset
  18684. */
  18685. onPointerMovedObservable: Observable<{
  18686. offsetX: number;
  18687. offsetY: number;
  18688. }>;
  18689. /**
  18690. * @hidden
  18691. * If the camera should be rotated automatically based on pointer movement
  18692. */
  18693. _allowCameraRotation: boolean;
  18694. /**
  18695. * Manage the mouse inputs to control the movement of a free camera.
  18696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18697. * @param touchEnabled Defines if touch is enabled or not
  18698. */
  18699. constructor(
  18700. /**
  18701. * Define if touch is enabled in the mouse input
  18702. */
  18703. touchEnabled?: boolean);
  18704. /**
  18705. * Attach the input controls to a specific dom element to get the input from.
  18706. * @param element Defines the element the controls should be listened from
  18707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18708. */
  18709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18710. /**
  18711. * Called on JS contextmenu event.
  18712. * Override this method to provide functionality.
  18713. */
  18714. protected onContextMenu(evt: PointerEvent): void;
  18715. /**
  18716. * Detach the current controls from the specified dom element.
  18717. * @param element Defines the element to stop listening the inputs from
  18718. */
  18719. detachControl(element: Nullable<HTMLElement>): void;
  18720. /**
  18721. * Gets the class name of the current intput.
  18722. * @returns the class name
  18723. */
  18724. getClassName(): string;
  18725. /**
  18726. * Get the friendly name associated with the input class.
  18727. * @returns the input friendly name
  18728. */
  18729. getSimpleName(): string;
  18730. }
  18731. }
  18732. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18733. import { Nullable } from "babylonjs/types";
  18734. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18735. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18736. /**
  18737. * Manage the touch inputs to control the movement of a free camera.
  18738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18739. */
  18740. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18741. /**
  18742. * Defines the camera the input is attached to.
  18743. */
  18744. camera: FreeCamera;
  18745. /**
  18746. * Defines the touch sensibility for rotation.
  18747. * The higher the faster.
  18748. */
  18749. touchAngularSensibility: number;
  18750. /**
  18751. * Defines the touch sensibility for move.
  18752. * The higher the faster.
  18753. */
  18754. touchMoveSensibility: number;
  18755. private _offsetX;
  18756. private _offsetY;
  18757. private _pointerPressed;
  18758. private _pointerInput;
  18759. private _observer;
  18760. private _onLostFocus;
  18761. /**
  18762. * Attach the input controls to a specific dom element to get the input from.
  18763. * @param element Defines the element the controls should be listened from
  18764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18765. */
  18766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18767. /**
  18768. * Detach the current controls from the specified dom element.
  18769. * @param element Defines the element to stop listening the inputs from
  18770. */
  18771. detachControl(element: Nullable<HTMLElement>): void;
  18772. /**
  18773. * Update the current camera state depending on the inputs that have been used this frame.
  18774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18775. */
  18776. checkInputs(): void;
  18777. /**
  18778. * Gets the class name of the current intput.
  18779. * @returns the class name
  18780. */
  18781. getClassName(): string;
  18782. /**
  18783. * Get the friendly name associated with the input class.
  18784. * @returns the input friendly name
  18785. */
  18786. getSimpleName(): string;
  18787. }
  18788. }
  18789. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18790. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18791. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18792. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18793. import { Nullable } from "babylonjs/types";
  18794. /**
  18795. * Default Inputs manager for the FreeCamera.
  18796. * It groups all the default supported inputs for ease of use.
  18797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18798. */
  18799. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18800. /**
  18801. * @hidden
  18802. */
  18803. _mouseInput: Nullable<FreeCameraMouseInput>;
  18804. /**
  18805. * Instantiates a new FreeCameraInputsManager.
  18806. * @param camera Defines the camera the inputs belong to
  18807. */
  18808. constructor(camera: FreeCamera);
  18809. /**
  18810. * Add keyboard input support to the input manager.
  18811. * @returns the current input manager
  18812. */
  18813. addKeyboard(): FreeCameraInputsManager;
  18814. /**
  18815. * Add mouse input support to the input manager.
  18816. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18817. * @returns the current input manager
  18818. */
  18819. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18820. /**
  18821. * Removes the mouse input support from the manager
  18822. * @returns the current input manager
  18823. */
  18824. removeMouse(): FreeCameraInputsManager;
  18825. /**
  18826. * Add touch input support to the input manager.
  18827. * @returns the current input manager
  18828. */
  18829. addTouch(): FreeCameraInputsManager;
  18830. /**
  18831. * Remove all attached input methods from a camera
  18832. */
  18833. clear(): void;
  18834. }
  18835. }
  18836. declare module "babylonjs/Cameras/freeCamera" {
  18837. import { Vector3 } from "babylonjs/Maths/math.vector";
  18838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18839. import { Scene } from "babylonjs/scene";
  18840. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18841. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18842. /**
  18843. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18844. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18845. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18846. */
  18847. export class FreeCamera extends TargetCamera {
  18848. /**
  18849. * Define the collision ellipsoid of the camera.
  18850. * This is helpful to simulate a camera body like the player body around the camera
  18851. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18852. */
  18853. ellipsoid: Vector3;
  18854. /**
  18855. * Define an offset for the position of the ellipsoid around the camera.
  18856. * This can be helpful to determine the center of the body near the gravity center of the body
  18857. * instead of its head.
  18858. */
  18859. ellipsoidOffset: Vector3;
  18860. /**
  18861. * Enable or disable collisions of the camera with the rest of the scene objects.
  18862. */
  18863. checkCollisions: boolean;
  18864. /**
  18865. * Enable or disable gravity on the camera.
  18866. */
  18867. applyGravity: boolean;
  18868. /**
  18869. * Define the input manager associated to the camera.
  18870. */
  18871. inputs: FreeCameraInputsManager;
  18872. /**
  18873. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18874. * Higher values reduce sensitivity.
  18875. */
  18876. get angularSensibility(): number;
  18877. /**
  18878. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18879. * Higher values reduce sensitivity.
  18880. */
  18881. set angularSensibility(value: number);
  18882. /**
  18883. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18884. */
  18885. get keysUp(): number[];
  18886. set keysUp(value: number[]);
  18887. /**
  18888. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18889. */
  18890. get keysDown(): number[];
  18891. set keysDown(value: number[]);
  18892. /**
  18893. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18894. */
  18895. get keysLeft(): number[];
  18896. set keysLeft(value: number[]);
  18897. /**
  18898. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18899. */
  18900. get keysRight(): number[];
  18901. set keysRight(value: number[]);
  18902. /**
  18903. * Event raised when the camera collide with a mesh in the scene.
  18904. */
  18905. onCollide: (collidedMesh: AbstractMesh) => void;
  18906. private _collider;
  18907. private _needMoveForGravity;
  18908. private _oldPosition;
  18909. private _diffPosition;
  18910. private _newPosition;
  18911. /** @hidden */
  18912. _localDirection: Vector3;
  18913. /** @hidden */
  18914. _transformedDirection: Vector3;
  18915. /**
  18916. * Instantiates a Free Camera.
  18917. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18918. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18919. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18920. * @param name Define the name of the camera in the scene
  18921. * @param position Define the start position of the camera in the scene
  18922. * @param scene Define the scene the camera belongs to
  18923. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18924. */
  18925. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18926. /**
  18927. * Attached controls to the current camera.
  18928. * @param element Defines the element the controls should be listened from
  18929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18930. */
  18931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18932. /**
  18933. * Detach the current controls from the camera.
  18934. * The camera will stop reacting to inputs.
  18935. * @param element Defines the element to stop listening the inputs from
  18936. */
  18937. detachControl(element: HTMLElement): void;
  18938. private _collisionMask;
  18939. /**
  18940. * Define a collision mask to limit the list of object the camera can collide with
  18941. */
  18942. get collisionMask(): number;
  18943. set collisionMask(mask: number);
  18944. /** @hidden */
  18945. _collideWithWorld(displacement: Vector3): void;
  18946. private _onCollisionPositionChange;
  18947. /** @hidden */
  18948. _checkInputs(): void;
  18949. /** @hidden */
  18950. _decideIfNeedsToMove(): boolean;
  18951. /** @hidden */
  18952. _updatePosition(): void;
  18953. /**
  18954. * Destroy the camera and release the current resources hold by it.
  18955. */
  18956. dispose(): void;
  18957. /**
  18958. * Gets the current object class name.
  18959. * @return the class name
  18960. */
  18961. getClassName(): string;
  18962. }
  18963. }
  18964. declare module "babylonjs/Gamepads/gamepad" {
  18965. import { Observable } from "babylonjs/Misc/observable";
  18966. /**
  18967. * Represents a gamepad control stick position
  18968. */
  18969. export class StickValues {
  18970. /**
  18971. * The x component of the control stick
  18972. */
  18973. x: number;
  18974. /**
  18975. * The y component of the control stick
  18976. */
  18977. y: number;
  18978. /**
  18979. * Initializes the gamepad x and y control stick values
  18980. * @param x The x component of the gamepad control stick value
  18981. * @param y The y component of the gamepad control stick value
  18982. */
  18983. constructor(
  18984. /**
  18985. * The x component of the control stick
  18986. */
  18987. x: number,
  18988. /**
  18989. * The y component of the control stick
  18990. */
  18991. y: number);
  18992. }
  18993. /**
  18994. * An interface which manages callbacks for gamepad button changes
  18995. */
  18996. export interface GamepadButtonChanges {
  18997. /**
  18998. * Called when a gamepad has been changed
  18999. */
  19000. changed: boolean;
  19001. /**
  19002. * Called when a gamepad press event has been triggered
  19003. */
  19004. pressChanged: boolean;
  19005. /**
  19006. * Called when a touch event has been triggered
  19007. */
  19008. touchChanged: boolean;
  19009. /**
  19010. * Called when a value has changed
  19011. */
  19012. valueChanged: boolean;
  19013. }
  19014. /**
  19015. * Represents a gamepad
  19016. */
  19017. export class Gamepad {
  19018. /**
  19019. * The id of the gamepad
  19020. */
  19021. id: string;
  19022. /**
  19023. * The index of the gamepad
  19024. */
  19025. index: number;
  19026. /**
  19027. * The browser gamepad
  19028. */
  19029. browserGamepad: any;
  19030. /**
  19031. * Specifies what type of gamepad this represents
  19032. */
  19033. type: number;
  19034. private _leftStick;
  19035. private _rightStick;
  19036. /** @hidden */
  19037. _isConnected: boolean;
  19038. private _leftStickAxisX;
  19039. private _leftStickAxisY;
  19040. private _rightStickAxisX;
  19041. private _rightStickAxisY;
  19042. /**
  19043. * Triggered when the left control stick has been changed
  19044. */
  19045. private _onleftstickchanged;
  19046. /**
  19047. * Triggered when the right control stick has been changed
  19048. */
  19049. private _onrightstickchanged;
  19050. /**
  19051. * Represents a gamepad controller
  19052. */
  19053. static GAMEPAD: number;
  19054. /**
  19055. * Represents a generic controller
  19056. */
  19057. static GENERIC: number;
  19058. /**
  19059. * Represents an XBox controller
  19060. */
  19061. static XBOX: number;
  19062. /**
  19063. * Represents a pose-enabled controller
  19064. */
  19065. static POSE_ENABLED: number;
  19066. /**
  19067. * Represents an Dual Shock controller
  19068. */
  19069. static DUALSHOCK: number;
  19070. /**
  19071. * Specifies whether the left control stick should be Y-inverted
  19072. */
  19073. protected _invertLeftStickY: boolean;
  19074. /**
  19075. * Specifies if the gamepad has been connected
  19076. */
  19077. get isConnected(): boolean;
  19078. /**
  19079. * Initializes the gamepad
  19080. * @param id The id of the gamepad
  19081. * @param index The index of the gamepad
  19082. * @param browserGamepad The browser gamepad
  19083. * @param leftStickX The x component of the left joystick
  19084. * @param leftStickY The y component of the left joystick
  19085. * @param rightStickX The x component of the right joystick
  19086. * @param rightStickY The y component of the right joystick
  19087. */
  19088. constructor(
  19089. /**
  19090. * The id of the gamepad
  19091. */
  19092. id: string,
  19093. /**
  19094. * The index of the gamepad
  19095. */
  19096. index: number,
  19097. /**
  19098. * The browser gamepad
  19099. */
  19100. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19101. /**
  19102. * Callback triggered when the left joystick has changed
  19103. * @param callback
  19104. */
  19105. onleftstickchanged(callback: (values: StickValues) => void): void;
  19106. /**
  19107. * Callback triggered when the right joystick has changed
  19108. * @param callback
  19109. */
  19110. onrightstickchanged(callback: (values: StickValues) => void): void;
  19111. /**
  19112. * Gets the left joystick
  19113. */
  19114. get leftStick(): StickValues;
  19115. /**
  19116. * Sets the left joystick values
  19117. */
  19118. set leftStick(newValues: StickValues);
  19119. /**
  19120. * Gets the right joystick
  19121. */
  19122. get rightStick(): StickValues;
  19123. /**
  19124. * Sets the right joystick value
  19125. */
  19126. set rightStick(newValues: StickValues);
  19127. /**
  19128. * Updates the gamepad joystick positions
  19129. */
  19130. update(): void;
  19131. /**
  19132. * Disposes the gamepad
  19133. */
  19134. dispose(): void;
  19135. }
  19136. /**
  19137. * Represents a generic gamepad
  19138. */
  19139. export class GenericPad extends Gamepad {
  19140. private _buttons;
  19141. private _onbuttondown;
  19142. private _onbuttonup;
  19143. /**
  19144. * Observable triggered when a button has been pressed
  19145. */
  19146. onButtonDownObservable: Observable<number>;
  19147. /**
  19148. * Observable triggered when a button has been released
  19149. */
  19150. onButtonUpObservable: Observable<number>;
  19151. /**
  19152. * Callback triggered when a button has been pressed
  19153. * @param callback Called when a button has been pressed
  19154. */
  19155. onbuttondown(callback: (buttonPressed: number) => void): void;
  19156. /**
  19157. * Callback triggered when a button has been released
  19158. * @param callback Called when a button has been released
  19159. */
  19160. onbuttonup(callback: (buttonReleased: number) => void): void;
  19161. /**
  19162. * Initializes the generic gamepad
  19163. * @param id The id of the generic gamepad
  19164. * @param index The index of the generic gamepad
  19165. * @param browserGamepad The browser gamepad
  19166. */
  19167. constructor(id: string, index: number, browserGamepad: any);
  19168. private _setButtonValue;
  19169. /**
  19170. * Updates the generic gamepad
  19171. */
  19172. update(): void;
  19173. /**
  19174. * Disposes the generic gamepad
  19175. */
  19176. dispose(): void;
  19177. }
  19178. }
  19179. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19180. import { Observable } from "babylonjs/Misc/observable";
  19181. import { Nullable } from "babylonjs/types";
  19182. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19183. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19185. import { Ray } from "babylonjs/Culling/ray";
  19186. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19187. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19188. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19189. /**
  19190. * Defines the types of pose enabled controllers that are supported
  19191. */
  19192. export enum PoseEnabledControllerType {
  19193. /**
  19194. * HTC Vive
  19195. */
  19196. VIVE = 0,
  19197. /**
  19198. * Oculus Rift
  19199. */
  19200. OCULUS = 1,
  19201. /**
  19202. * Windows mixed reality
  19203. */
  19204. WINDOWS = 2,
  19205. /**
  19206. * Samsung gear VR
  19207. */
  19208. GEAR_VR = 3,
  19209. /**
  19210. * Google Daydream
  19211. */
  19212. DAYDREAM = 4,
  19213. /**
  19214. * Generic
  19215. */
  19216. GENERIC = 5
  19217. }
  19218. /**
  19219. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19220. */
  19221. export interface MutableGamepadButton {
  19222. /**
  19223. * Value of the button/trigger
  19224. */
  19225. value: number;
  19226. /**
  19227. * If the button/trigger is currently touched
  19228. */
  19229. touched: boolean;
  19230. /**
  19231. * If the button/trigger is currently pressed
  19232. */
  19233. pressed: boolean;
  19234. }
  19235. /**
  19236. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19237. * @hidden
  19238. */
  19239. export interface ExtendedGamepadButton extends GamepadButton {
  19240. /**
  19241. * If the button/trigger is currently pressed
  19242. */
  19243. readonly pressed: boolean;
  19244. /**
  19245. * If the button/trigger is currently touched
  19246. */
  19247. readonly touched: boolean;
  19248. /**
  19249. * Value of the button/trigger
  19250. */
  19251. readonly value: number;
  19252. }
  19253. /** @hidden */
  19254. export interface _GamePadFactory {
  19255. /**
  19256. * Returns whether or not the current gamepad can be created for this type of controller.
  19257. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19258. * @returns true if it can be created, otherwise false
  19259. */
  19260. canCreate(gamepadInfo: any): boolean;
  19261. /**
  19262. * Creates a new instance of the Gamepad.
  19263. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19264. * @returns the new gamepad instance
  19265. */
  19266. create(gamepadInfo: any): Gamepad;
  19267. }
  19268. /**
  19269. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19270. */
  19271. export class PoseEnabledControllerHelper {
  19272. /** @hidden */
  19273. static _ControllerFactories: _GamePadFactory[];
  19274. /** @hidden */
  19275. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19276. /**
  19277. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19278. * @param vrGamepad the gamepad to initialized
  19279. * @returns a vr controller of the type the gamepad identified as
  19280. */
  19281. static InitiateController(vrGamepad: any): Gamepad;
  19282. }
  19283. /**
  19284. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19285. */
  19286. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19287. /**
  19288. * If the controller is used in a webXR session
  19289. */
  19290. isXR: boolean;
  19291. private _deviceRoomPosition;
  19292. private _deviceRoomRotationQuaternion;
  19293. /**
  19294. * The device position in babylon space
  19295. */
  19296. devicePosition: Vector3;
  19297. /**
  19298. * The device rotation in babylon space
  19299. */
  19300. deviceRotationQuaternion: Quaternion;
  19301. /**
  19302. * The scale factor of the device in babylon space
  19303. */
  19304. deviceScaleFactor: number;
  19305. /**
  19306. * (Likely devicePosition should be used instead) The device position in its room space
  19307. */
  19308. position: Vector3;
  19309. /**
  19310. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19311. */
  19312. rotationQuaternion: Quaternion;
  19313. /**
  19314. * The type of controller (Eg. Windows mixed reality)
  19315. */
  19316. controllerType: PoseEnabledControllerType;
  19317. protected _calculatedPosition: Vector3;
  19318. private _calculatedRotation;
  19319. /**
  19320. * The raw pose from the device
  19321. */
  19322. rawPose: DevicePose;
  19323. private _trackPosition;
  19324. private _maxRotationDistFromHeadset;
  19325. private _draggedRoomRotation;
  19326. /**
  19327. * @hidden
  19328. */
  19329. _disableTrackPosition(fixedPosition: Vector3): void;
  19330. /**
  19331. * Internal, the mesh attached to the controller
  19332. * @hidden
  19333. */
  19334. _mesh: Nullable<AbstractMesh>;
  19335. private _poseControlledCamera;
  19336. private _leftHandSystemQuaternion;
  19337. /**
  19338. * Internal, matrix used to convert room space to babylon space
  19339. * @hidden
  19340. */
  19341. _deviceToWorld: Matrix;
  19342. /**
  19343. * Node to be used when casting a ray from the controller
  19344. * @hidden
  19345. */
  19346. _pointingPoseNode: Nullable<TransformNode>;
  19347. /**
  19348. * Name of the child mesh that can be used to cast a ray from the controller
  19349. */
  19350. static readonly POINTING_POSE: string;
  19351. /**
  19352. * Creates a new PoseEnabledController from a gamepad
  19353. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19354. */
  19355. constructor(browserGamepad: any);
  19356. private _workingMatrix;
  19357. /**
  19358. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19359. */
  19360. update(): void;
  19361. /**
  19362. * Updates only the pose device and mesh without doing any button event checking
  19363. */
  19364. protected _updatePoseAndMesh(): void;
  19365. /**
  19366. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19367. * @param poseData raw pose fromthe device
  19368. */
  19369. updateFromDevice(poseData: DevicePose): void;
  19370. /**
  19371. * @hidden
  19372. */
  19373. _meshAttachedObservable: Observable<AbstractMesh>;
  19374. /**
  19375. * Attaches a mesh to the controller
  19376. * @param mesh the mesh to be attached
  19377. */
  19378. attachToMesh(mesh: AbstractMesh): void;
  19379. /**
  19380. * Attaches the controllers mesh to a camera
  19381. * @param camera the camera the mesh should be attached to
  19382. */
  19383. attachToPoseControlledCamera(camera: TargetCamera): void;
  19384. /**
  19385. * Disposes of the controller
  19386. */
  19387. dispose(): void;
  19388. /**
  19389. * The mesh that is attached to the controller
  19390. */
  19391. get mesh(): Nullable<AbstractMesh>;
  19392. /**
  19393. * Gets the ray of the controller in the direction the controller is pointing
  19394. * @param length the length the resulting ray should be
  19395. * @returns a ray in the direction the controller is pointing
  19396. */
  19397. getForwardRay(length?: number): Ray;
  19398. }
  19399. }
  19400. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19401. import { Observable } from "babylonjs/Misc/observable";
  19402. import { Scene } from "babylonjs/scene";
  19403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19404. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19405. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19406. import { Nullable } from "babylonjs/types";
  19407. /**
  19408. * Defines the WebVRController object that represents controllers tracked in 3D space
  19409. */
  19410. export abstract class WebVRController extends PoseEnabledController {
  19411. /**
  19412. * Internal, the default controller model for the controller
  19413. */
  19414. protected _defaultModel: Nullable<AbstractMesh>;
  19415. /**
  19416. * Fired when the trigger state has changed
  19417. */
  19418. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19419. /**
  19420. * Fired when the main button state has changed
  19421. */
  19422. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19423. /**
  19424. * Fired when the secondary button state has changed
  19425. */
  19426. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19427. /**
  19428. * Fired when the pad state has changed
  19429. */
  19430. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19431. /**
  19432. * Fired when controllers stick values have changed
  19433. */
  19434. onPadValuesChangedObservable: Observable<StickValues>;
  19435. /**
  19436. * Array of button availible on the controller
  19437. */
  19438. protected _buttons: Array<MutableGamepadButton>;
  19439. private _onButtonStateChange;
  19440. /**
  19441. * Fired when a controller button's state has changed
  19442. * @param callback the callback containing the button that was modified
  19443. */
  19444. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19445. /**
  19446. * X and Y axis corresponding to the controllers joystick
  19447. */
  19448. pad: StickValues;
  19449. /**
  19450. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19451. */
  19452. hand: string;
  19453. /**
  19454. * The default controller model for the controller
  19455. */
  19456. get defaultModel(): Nullable<AbstractMesh>;
  19457. /**
  19458. * Creates a new WebVRController from a gamepad
  19459. * @param vrGamepad the gamepad that the WebVRController should be created from
  19460. */
  19461. constructor(vrGamepad: any);
  19462. /**
  19463. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19464. */
  19465. update(): void;
  19466. /**
  19467. * Function to be called when a button is modified
  19468. */
  19469. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19470. /**
  19471. * Loads a mesh and attaches it to the controller
  19472. * @param scene the scene the mesh should be added to
  19473. * @param meshLoaded callback for when the mesh has been loaded
  19474. */
  19475. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19476. private _setButtonValue;
  19477. private _changes;
  19478. private _checkChanges;
  19479. /**
  19480. * Disposes of th webVRCOntroller
  19481. */
  19482. dispose(): void;
  19483. }
  19484. }
  19485. declare module "babylonjs/Lights/hemisphericLight" {
  19486. import { Nullable } from "babylonjs/types";
  19487. import { Scene } from "babylonjs/scene";
  19488. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19489. import { Color3 } from "babylonjs/Maths/math.color";
  19490. import { Effect } from "babylonjs/Materials/effect";
  19491. import { Light } from "babylonjs/Lights/light";
  19492. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19493. /**
  19494. * The HemisphericLight simulates the ambient environment light,
  19495. * so the passed direction is the light reflection direction, not the incoming direction.
  19496. */
  19497. export class HemisphericLight extends Light {
  19498. /**
  19499. * The groundColor is the light in the opposite direction to the one specified during creation.
  19500. * 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.
  19501. */
  19502. groundColor: Color3;
  19503. /**
  19504. * The light reflection direction, not the incoming direction.
  19505. */
  19506. direction: Vector3;
  19507. /**
  19508. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19509. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19510. * The HemisphericLight can't cast shadows.
  19511. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19512. * @param name The friendly name of the light
  19513. * @param direction The direction of the light reflection
  19514. * @param scene The scene the light belongs to
  19515. */
  19516. constructor(name: string, direction: Vector3, scene: Scene);
  19517. protected _buildUniformLayout(): void;
  19518. /**
  19519. * Returns the string "HemisphericLight".
  19520. * @return The class name
  19521. */
  19522. getClassName(): string;
  19523. /**
  19524. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19525. * Returns the updated direction.
  19526. * @param target The target the direction should point to
  19527. * @return The computed direction
  19528. */
  19529. setDirectionToTarget(target: Vector3): Vector3;
  19530. /**
  19531. * Returns the shadow generator associated to the light.
  19532. * @returns Always null for hemispheric lights because it does not support shadows.
  19533. */
  19534. getShadowGenerator(): Nullable<IShadowGenerator>;
  19535. /**
  19536. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19537. * @param effect The effect to update
  19538. * @param lightIndex The index of the light in the effect to update
  19539. * @returns The hemispheric light
  19540. */
  19541. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19542. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19543. /**
  19544. * Computes the world matrix of the node
  19545. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19546. * @param useWasUpdatedFlag defines a reserved property
  19547. * @returns the world matrix
  19548. */
  19549. computeWorldMatrix(): Matrix;
  19550. /**
  19551. * Returns the integer 3.
  19552. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19553. */
  19554. getTypeID(): number;
  19555. /**
  19556. * Prepares the list of defines specific to the light type.
  19557. * @param defines the list of defines
  19558. * @param lightIndex defines the index of the light for the effect
  19559. */
  19560. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19561. }
  19562. }
  19563. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19564. /** @hidden */
  19565. export var vrMultiviewToSingleviewPixelShader: {
  19566. name: string;
  19567. shader: string;
  19568. };
  19569. }
  19570. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19571. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19572. import { Scene } from "babylonjs/scene";
  19573. /**
  19574. * Renders to multiple views with a single draw call
  19575. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19576. */
  19577. export class MultiviewRenderTarget extends RenderTargetTexture {
  19578. /**
  19579. * Creates a multiview render target
  19580. * @param scene scene used with the render target
  19581. * @param size the size of the render target (used for each view)
  19582. */
  19583. constructor(scene: Scene, size?: number | {
  19584. width: number;
  19585. height: number;
  19586. } | {
  19587. ratio: number;
  19588. });
  19589. /**
  19590. * @hidden
  19591. * @param faceIndex the face index, if its a cube texture
  19592. */
  19593. _bindFrameBuffer(faceIndex?: number): void;
  19594. /**
  19595. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19596. * @returns the view count
  19597. */
  19598. getViewCount(): number;
  19599. }
  19600. }
  19601. declare module "babylonjs/Maths/math.frustum" {
  19602. import { Matrix } from "babylonjs/Maths/math.vector";
  19603. import { DeepImmutable } from "babylonjs/types";
  19604. import { Plane } from "babylonjs/Maths/math.plane";
  19605. /**
  19606. * Represents a camera frustum
  19607. */
  19608. export class Frustum {
  19609. /**
  19610. * Gets the planes representing the frustum
  19611. * @param transform matrix to be applied to the returned planes
  19612. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19613. */
  19614. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19615. /**
  19616. * Gets the near frustum plane transformed by the transform matrix
  19617. * @param transform transformation matrix to be applied to the resulting frustum plane
  19618. * @param frustumPlane the resuling frustum plane
  19619. */
  19620. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19621. /**
  19622. * Gets the far frustum plane transformed by the transform matrix
  19623. * @param transform transformation matrix to be applied to the resulting frustum plane
  19624. * @param frustumPlane the resuling frustum plane
  19625. */
  19626. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19627. /**
  19628. * Gets the left frustum plane transformed by the transform matrix
  19629. * @param transform transformation matrix to be applied to the resulting frustum plane
  19630. * @param frustumPlane the resuling frustum plane
  19631. */
  19632. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19633. /**
  19634. * Gets the right frustum plane transformed by the transform matrix
  19635. * @param transform transformation matrix to be applied to the resulting frustum plane
  19636. * @param frustumPlane the resuling frustum plane
  19637. */
  19638. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19639. /**
  19640. * Gets the top frustum plane transformed by the transform matrix
  19641. * @param transform transformation matrix to be applied to the resulting frustum plane
  19642. * @param frustumPlane the resuling frustum plane
  19643. */
  19644. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19645. /**
  19646. * Gets the bottom frustum plane transformed by the transform matrix
  19647. * @param transform transformation matrix to be applied to the resulting frustum plane
  19648. * @param frustumPlane the resuling frustum plane
  19649. */
  19650. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19651. /**
  19652. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19653. * @param transform transformation matrix to be applied to the resulting frustum planes
  19654. * @param frustumPlanes the resuling frustum planes
  19655. */
  19656. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19657. }
  19658. }
  19659. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19660. import { Camera } from "babylonjs/Cameras/camera";
  19661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19662. import { Nullable } from "babylonjs/types";
  19663. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19664. import { Matrix } from "babylonjs/Maths/math.vector";
  19665. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19666. module "babylonjs/Engines/engine" {
  19667. interface Engine {
  19668. /**
  19669. * Creates a new multiview render target
  19670. * @param width defines the width of the texture
  19671. * @param height defines the height of the texture
  19672. * @returns the created multiview texture
  19673. */
  19674. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19675. /**
  19676. * Binds a multiview framebuffer to be drawn to
  19677. * @param multiviewTexture texture to bind
  19678. */
  19679. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19680. }
  19681. }
  19682. module "babylonjs/Cameras/camera" {
  19683. interface Camera {
  19684. /**
  19685. * @hidden
  19686. * 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)
  19687. */
  19688. _useMultiviewToSingleView: boolean;
  19689. /**
  19690. * @hidden
  19691. * 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)
  19692. */
  19693. _multiviewTexture: Nullable<RenderTargetTexture>;
  19694. /**
  19695. * @hidden
  19696. * ensures the multiview texture of the camera exists and has the specified width/height
  19697. * @param width height to set on the multiview texture
  19698. * @param height width to set on the multiview texture
  19699. */
  19700. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19701. }
  19702. }
  19703. module "babylonjs/scene" {
  19704. interface Scene {
  19705. /** @hidden */
  19706. _transformMatrixR: Matrix;
  19707. /** @hidden */
  19708. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19709. /** @hidden */
  19710. _createMultiviewUbo(): void;
  19711. /** @hidden */
  19712. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19713. /** @hidden */
  19714. _renderMultiviewToSingleView(camera: Camera): void;
  19715. }
  19716. }
  19717. }
  19718. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19719. import { Camera } from "babylonjs/Cameras/camera";
  19720. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19721. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19722. import "babylonjs/Engines/Extensions/engine.multiview";
  19723. /**
  19724. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19725. * This will not be used for webXR as it supports displaying texture arrays directly
  19726. */
  19727. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19728. /**
  19729. * Initializes a VRMultiviewToSingleview
  19730. * @param name name of the post process
  19731. * @param camera camera to be applied to
  19732. * @param scaleFactor scaling factor to the size of the output texture
  19733. */
  19734. constructor(name: string, camera: Camera, scaleFactor: number);
  19735. }
  19736. }
  19737. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19738. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19739. import { Nullable } from "babylonjs/types";
  19740. import { Size } from "babylonjs/Maths/math.size";
  19741. import { Observable } from "babylonjs/Misc/observable";
  19742. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19743. /**
  19744. * Interface used to define additional presentation attributes
  19745. */
  19746. export interface IVRPresentationAttributes {
  19747. /**
  19748. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19749. */
  19750. highRefreshRate: boolean;
  19751. /**
  19752. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19753. */
  19754. foveationLevel: number;
  19755. }
  19756. module "babylonjs/Engines/engine" {
  19757. interface Engine {
  19758. /** @hidden */
  19759. _vrDisplay: any;
  19760. /** @hidden */
  19761. _vrSupported: boolean;
  19762. /** @hidden */
  19763. _oldSize: Size;
  19764. /** @hidden */
  19765. _oldHardwareScaleFactor: number;
  19766. /** @hidden */
  19767. _vrExclusivePointerMode: boolean;
  19768. /** @hidden */
  19769. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19770. /** @hidden */
  19771. _onVRDisplayPointerRestricted: () => void;
  19772. /** @hidden */
  19773. _onVRDisplayPointerUnrestricted: () => void;
  19774. /** @hidden */
  19775. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19776. /** @hidden */
  19777. _onVrDisplayDisconnect: Nullable<() => void>;
  19778. /** @hidden */
  19779. _onVrDisplayPresentChange: Nullable<() => void>;
  19780. /**
  19781. * Observable signaled when VR display mode changes
  19782. */
  19783. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19784. /**
  19785. * Observable signaled when VR request present is complete
  19786. */
  19787. onVRRequestPresentComplete: Observable<boolean>;
  19788. /**
  19789. * Observable signaled when VR request present starts
  19790. */
  19791. onVRRequestPresentStart: Observable<Engine>;
  19792. /**
  19793. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19794. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19795. */
  19796. isInVRExclusivePointerMode: boolean;
  19797. /**
  19798. * Gets a boolean indicating if a webVR device was detected
  19799. * @returns true if a webVR device was detected
  19800. */
  19801. isVRDevicePresent(): boolean;
  19802. /**
  19803. * Gets the current webVR device
  19804. * @returns the current webVR device (or null)
  19805. */
  19806. getVRDevice(): any;
  19807. /**
  19808. * Initializes a webVR display and starts listening to display change events
  19809. * The onVRDisplayChangedObservable will be notified upon these changes
  19810. * @returns A promise containing a VRDisplay and if vr is supported
  19811. */
  19812. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19813. /** @hidden */
  19814. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19815. /**
  19816. * Gets or sets the presentation attributes used to configure VR rendering
  19817. */
  19818. vrPresentationAttributes?: IVRPresentationAttributes;
  19819. /**
  19820. * Call this function to switch to webVR mode
  19821. * Will do nothing if webVR is not supported or if there is no webVR device
  19822. * @param options the webvr options provided to the camera. mainly used for multiview
  19823. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19824. */
  19825. enableVR(options: WebVROptions): void;
  19826. /** @hidden */
  19827. _onVRFullScreenTriggered(): void;
  19828. }
  19829. }
  19830. }
  19831. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19832. import { Nullable } from "babylonjs/types";
  19833. import { Observable } from "babylonjs/Misc/observable";
  19834. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19835. import { Scene } from "babylonjs/scene";
  19836. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19837. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19838. import { Node } from "babylonjs/node";
  19839. import { Ray } from "babylonjs/Culling/ray";
  19840. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19841. import "babylonjs/Engines/Extensions/engine.webVR";
  19842. /**
  19843. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19844. * IMPORTANT!! The data is right-hand data.
  19845. * @export
  19846. * @interface DevicePose
  19847. */
  19848. export interface DevicePose {
  19849. /**
  19850. * The position of the device, values in array are [x,y,z].
  19851. */
  19852. readonly position: Nullable<Float32Array>;
  19853. /**
  19854. * The linearVelocity of the device, values in array are [x,y,z].
  19855. */
  19856. readonly linearVelocity: Nullable<Float32Array>;
  19857. /**
  19858. * The linearAcceleration of the device, values in array are [x,y,z].
  19859. */
  19860. readonly linearAcceleration: Nullable<Float32Array>;
  19861. /**
  19862. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19863. */
  19864. readonly orientation: Nullable<Float32Array>;
  19865. /**
  19866. * The angularVelocity of the device, values in array are [x,y,z].
  19867. */
  19868. readonly angularVelocity: Nullable<Float32Array>;
  19869. /**
  19870. * The angularAcceleration of the device, values in array are [x,y,z].
  19871. */
  19872. readonly angularAcceleration: Nullable<Float32Array>;
  19873. }
  19874. /**
  19875. * Interface representing a pose controlled object in Babylon.
  19876. * A pose controlled object has both regular pose values as well as pose values
  19877. * from an external device such as a VR head mounted display
  19878. */
  19879. export interface PoseControlled {
  19880. /**
  19881. * The position of the object in babylon space.
  19882. */
  19883. position: Vector3;
  19884. /**
  19885. * The rotation quaternion of the object in babylon space.
  19886. */
  19887. rotationQuaternion: Quaternion;
  19888. /**
  19889. * The position of the device in babylon space.
  19890. */
  19891. devicePosition?: Vector3;
  19892. /**
  19893. * The rotation quaternion of the device in babylon space.
  19894. */
  19895. deviceRotationQuaternion: Quaternion;
  19896. /**
  19897. * The raw pose coming from the device.
  19898. */
  19899. rawPose: Nullable<DevicePose>;
  19900. /**
  19901. * The scale of the device to be used when translating from device space to babylon space.
  19902. */
  19903. deviceScaleFactor: number;
  19904. /**
  19905. * Updates the poseControlled values based on the input device pose.
  19906. * @param poseData the pose data to update the object with
  19907. */
  19908. updateFromDevice(poseData: DevicePose): void;
  19909. }
  19910. /**
  19911. * Set of options to customize the webVRCamera
  19912. */
  19913. export interface WebVROptions {
  19914. /**
  19915. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19916. */
  19917. trackPosition?: boolean;
  19918. /**
  19919. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19920. */
  19921. positionScale?: number;
  19922. /**
  19923. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19924. */
  19925. displayName?: string;
  19926. /**
  19927. * Should the native controller meshes be initialized. (default: true)
  19928. */
  19929. controllerMeshes?: boolean;
  19930. /**
  19931. * Creating a default HemiLight only on controllers. (default: true)
  19932. */
  19933. defaultLightingOnControllers?: boolean;
  19934. /**
  19935. * If you don't want to use the default VR button of the helper. (default: false)
  19936. */
  19937. useCustomVRButton?: boolean;
  19938. /**
  19939. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19940. */
  19941. customVRButton?: HTMLButtonElement;
  19942. /**
  19943. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19944. */
  19945. rayLength?: number;
  19946. /**
  19947. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19948. */
  19949. defaultHeight?: number;
  19950. /**
  19951. * If multiview should be used if availible (default: false)
  19952. */
  19953. useMultiview?: boolean;
  19954. }
  19955. /**
  19956. * This represents a WebVR camera.
  19957. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19958. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19959. */
  19960. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19961. private webVROptions;
  19962. /**
  19963. * @hidden
  19964. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19965. */
  19966. _vrDevice: any;
  19967. /**
  19968. * The rawPose of the vrDevice.
  19969. */
  19970. rawPose: Nullable<DevicePose>;
  19971. private _onVREnabled;
  19972. private _specsVersion;
  19973. private _attached;
  19974. private _frameData;
  19975. protected _descendants: Array<Node>;
  19976. private _deviceRoomPosition;
  19977. /** @hidden */
  19978. _deviceRoomRotationQuaternion: Quaternion;
  19979. private _standingMatrix;
  19980. /**
  19981. * Represents device position in babylon space.
  19982. */
  19983. devicePosition: Vector3;
  19984. /**
  19985. * Represents device rotation in babylon space.
  19986. */
  19987. deviceRotationQuaternion: Quaternion;
  19988. /**
  19989. * The scale of the device to be used when translating from device space to babylon space.
  19990. */
  19991. deviceScaleFactor: number;
  19992. private _deviceToWorld;
  19993. private _worldToDevice;
  19994. /**
  19995. * References to the webVR controllers for the vrDevice.
  19996. */
  19997. controllers: Array<WebVRController>;
  19998. /**
  19999. * Emits an event when a controller is attached.
  20000. */
  20001. onControllersAttachedObservable: Observable<WebVRController[]>;
  20002. /**
  20003. * Emits an event when a controller's mesh has been loaded;
  20004. */
  20005. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20006. /**
  20007. * Emits an event when the HMD's pose has been updated.
  20008. */
  20009. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20010. private _poseSet;
  20011. /**
  20012. * If the rig cameras be used as parent instead of this camera.
  20013. */
  20014. rigParenting: boolean;
  20015. private _lightOnControllers;
  20016. private _defaultHeight?;
  20017. /**
  20018. * Instantiates a WebVRFreeCamera.
  20019. * @param name The name of the WebVRFreeCamera
  20020. * @param position The starting anchor position for the camera
  20021. * @param scene The scene the camera belongs to
  20022. * @param webVROptions a set of customizable options for the webVRCamera
  20023. */
  20024. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20025. /**
  20026. * Gets the device distance from the ground in meters.
  20027. * @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.
  20028. */
  20029. deviceDistanceToRoomGround(): number;
  20030. /**
  20031. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20032. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20033. */
  20034. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20035. /**
  20036. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20037. * @returns A promise with a boolean set to if the standing matrix is supported.
  20038. */
  20039. useStandingMatrixAsync(): Promise<boolean>;
  20040. /**
  20041. * Disposes the camera
  20042. */
  20043. dispose(): void;
  20044. /**
  20045. * Gets a vrController by name.
  20046. * @param name The name of the controller to retreive
  20047. * @returns the controller matching the name specified or null if not found
  20048. */
  20049. getControllerByName(name: string): Nullable<WebVRController>;
  20050. private _leftController;
  20051. /**
  20052. * The controller corresponding to the users left hand.
  20053. */
  20054. get leftController(): Nullable<WebVRController>;
  20055. private _rightController;
  20056. /**
  20057. * The controller corresponding to the users right hand.
  20058. */
  20059. get rightController(): Nullable<WebVRController>;
  20060. /**
  20061. * Casts a ray forward from the vrCamera's gaze.
  20062. * @param length Length of the ray (default: 100)
  20063. * @returns the ray corresponding to the gaze
  20064. */
  20065. getForwardRay(length?: number): Ray;
  20066. /**
  20067. * @hidden
  20068. * Updates the camera based on device's frame data
  20069. */
  20070. _checkInputs(): void;
  20071. /**
  20072. * Updates the poseControlled values based on the input device pose.
  20073. * @param poseData Pose coming from the device
  20074. */
  20075. updateFromDevice(poseData: DevicePose): void;
  20076. private _htmlElementAttached;
  20077. private _detachIfAttached;
  20078. /**
  20079. * WebVR's attach control will start broadcasting frames to the device.
  20080. * Note that in certain browsers (chrome for example) this function must be called
  20081. * within a user-interaction callback. Example:
  20082. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20083. *
  20084. * @param element html element to attach the vrDevice to
  20085. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20086. */
  20087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20088. /**
  20089. * Detaches the camera from the html element and disables VR
  20090. *
  20091. * @param element html element to detach from
  20092. */
  20093. detachControl(element: HTMLElement): void;
  20094. /**
  20095. * @returns the name of this class
  20096. */
  20097. getClassName(): string;
  20098. /**
  20099. * Calls resetPose on the vrDisplay
  20100. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20101. */
  20102. resetToCurrentRotation(): void;
  20103. /**
  20104. * @hidden
  20105. * Updates the rig cameras (left and right eye)
  20106. */
  20107. _updateRigCameras(): void;
  20108. private _workingVector;
  20109. private _oneVector;
  20110. private _workingMatrix;
  20111. private updateCacheCalled;
  20112. private _correctPositionIfNotTrackPosition;
  20113. /**
  20114. * @hidden
  20115. * Updates the cached values of the camera
  20116. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20117. */
  20118. _updateCache(ignoreParentClass?: boolean): void;
  20119. /**
  20120. * @hidden
  20121. * Get current device position in babylon world
  20122. */
  20123. _computeDevicePosition(): void;
  20124. /**
  20125. * Updates the current device position and rotation in the babylon world
  20126. */
  20127. update(): void;
  20128. /**
  20129. * @hidden
  20130. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20131. * @returns an identity matrix
  20132. */
  20133. _getViewMatrix(): Matrix;
  20134. private _tmpMatrix;
  20135. /**
  20136. * This function is called by the two RIG cameras.
  20137. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20138. * @hidden
  20139. */
  20140. _getWebVRViewMatrix(): Matrix;
  20141. /** @hidden */
  20142. _getWebVRProjectionMatrix(): Matrix;
  20143. private _onGamepadConnectedObserver;
  20144. private _onGamepadDisconnectedObserver;
  20145. private _updateCacheWhenTrackingDisabledObserver;
  20146. /**
  20147. * Initializes the controllers and their meshes
  20148. */
  20149. initControllers(): void;
  20150. }
  20151. }
  20152. declare module "babylonjs/PostProcesses/postProcess" {
  20153. import { Nullable } from "babylonjs/types";
  20154. import { SmartArray } from "babylonjs/Misc/smartArray";
  20155. import { Observable } from "babylonjs/Misc/observable";
  20156. import { Vector2 } from "babylonjs/Maths/math.vector";
  20157. import { Camera } from "babylonjs/Cameras/camera";
  20158. import { Effect } from "babylonjs/Materials/effect";
  20159. import "babylonjs/Shaders/postprocess.vertex";
  20160. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20161. import { Engine } from "babylonjs/Engines/engine";
  20162. import { Color4 } from "babylonjs/Maths/math.color";
  20163. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20164. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20165. /**
  20166. * Size options for a post process
  20167. */
  20168. export type PostProcessOptions = {
  20169. width: number;
  20170. height: number;
  20171. };
  20172. /**
  20173. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20174. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20175. */
  20176. export class PostProcess {
  20177. /** Name of the PostProcess. */
  20178. name: string;
  20179. /**
  20180. * Gets or sets the unique id of the post process
  20181. */
  20182. uniqueId: number;
  20183. /**
  20184. * Width of the texture to apply the post process on
  20185. */
  20186. width: number;
  20187. /**
  20188. * Height of the texture to apply the post process on
  20189. */
  20190. height: number;
  20191. /**
  20192. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20193. * @hidden
  20194. */
  20195. _outputTexture: Nullable<InternalTexture>;
  20196. /**
  20197. * Sampling mode used by the shader
  20198. * See https://doc.babylonjs.com/classes/3.1/texture
  20199. */
  20200. renderTargetSamplingMode: number;
  20201. /**
  20202. * Clear color to use when screen clearing
  20203. */
  20204. clearColor: Color4;
  20205. /**
  20206. * If the buffer needs to be cleared before applying the post process. (default: true)
  20207. * Should be set to false if shader will overwrite all previous pixels.
  20208. */
  20209. autoClear: boolean;
  20210. /**
  20211. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20212. */
  20213. alphaMode: number;
  20214. /**
  20215. * Sets the setAlphaBlendConstants of the babylon engine
  20216. */
  20217. alphaConstants: Color4;
  20218. /**
  20219. * Animations to be used for the post processing
  20220. */
  20221. animations: import("babylonjs/Animations/animation").Animation[];
  20222. /**
  20223. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20224. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20225. */
  20226. enablePixelPerfectMode: boolean;
  20227. /**
  20228. * Force the postprocess to be applied without taking in account viewport
  20229. */
  20230. forceFullscreenViewport: boolean;
  20231. /**
  20232. * List of inspectable custom properties (used by the Inspector)
  20233. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20234. */
  20235. inspectableCustomProperties: IInspectable[];
  20236. /**
  20237. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20238. *
  20239. * | Value | Type | Description |
  20240. * | ----- | ----------------------------------- | ----------- |
  20241. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20242. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20243. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20244. *
  20245. */
  20246. scaleMode: number;
  20247. /**
  20248. * Force textures to be a power of two (default: false)
  20249. */
  20250. alwaysForcePOT: boolean;
  20251. private _samples;
  20252. /**
  20253. * Number of sample textures (default: 1)
  20254. */
  20255. get samples(): number;
  20256. set samples(n: number);
  20257. /**
  20258. * Modify the scale of the post process to be the same as the viewport (default: false)
  20259. */
  20260. adaptScaleToCurrentViewport: boolean;
  20261. private _camera;
  20262. private _scene;
  20263. private _engine;
  20264. private _options;
  20265. private _reusable;
  20266. private _textureType;
  20267. private _textureFormat;
  20268. /**
  20269. * Smart array of input and output textures for the post process.
  20270. * @hidden
  20271. */
  20272. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20273. /**
  20274. * The index in _textures that corresponds to the output texture.
  20275. * @hidden
  20276. */
  20277. _currentRenderTextureInd: number;
  20278. private _effect;
  20279. private _samplers;
  20280. private _fragmentUrl;
  20281. private _vertexUrl;
  20282. private _parameters;
  20283. private _scaleRatio;
  20284. protected _indexParameters: any;
  20285. private _shareOutputWithPostProcess;
  20286. private _texelSize;
  20287. private _forcedOutputTexture;
  20288. /**
  20289. * Returns the fragment url or shader name used in the post process.
  20290. * @returns the fragment url or name in the shader store.
  20291. */
  20292. getEffectName(): string;
  20293. /**
  20294. * An event triggered when the postprocess is activated.
  20295. */
  20296. onActivateObservable: Observable<Camera>;
  20297. private _onActivateObserver;
  20298. /**
  20299. * A function that is added to the onActivateObservable
  20300. */
  20301. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20302. /**
  20303. * An event triggered when the postprocess changes its size.
  20304. */
  20305. onSizeChangedObservable: Observable<PostProcess>;
  20306. private _onSizeChangedObserver;
  20307. /**
  20308. * A function that is added to the onSizeChangedObservable
  20309. */
  20310. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20311. /**
  20312. * An event triggered when the postprocess applies its effect.
  20313. */
  20314. onApplyObservable: Observable<Effect>;
  20315. private _onApplyObserver;
  20316. /**
  20317. * A function that is added to the onApplyObservable
  20318. */
  20319. set onApply(callback: (effect: Effect) => void);
  20320. /**
  20321. * An event triggered before rendering the postprocess
  20322. */
  20323. onBeforeRenderObservable: Observable<Effect>;
  20324. private _onBeforeRenderObserver;
  20325. /**
  20326. * A function that is added to the onBeforeRenderObservable
  20327. */
  20328. set onBeforeRender(callback: (effect: Effect) => void);
  20329. /**
  20330. * An event triggered after rendering the postprocess
  20331. */
  20332. onAfterRenderObservable: Observable<Effect>;
  20333. private _onAfterRenderObserver;
  20334. /**
  20335. * A function that is added to the onAfterRenderObservable
  20336. */
  20337. set onAfterRender(callback: (efect: Effect) => void);
  20338. /**
  20339. * 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
  20340. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20341. */
  20342. get inputTexture(): InternalTexture;
  20343. set inputTexture(value: InternalTexture);
  20344. /**
  20345. * Gets the camera which post process is applied to.
  20346. * @returns The camera the post process is applied to.
  20347. */
  20348. getCamera(): Camera;
  20349. /**
  20350. * Gets the texel size of the postprocess.
  20351. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20352. */
  20353. get texelSize(): Vector2;
  20354. /**
  20355. * Creates a new instance PostProcess
  20356. * @param name The name of the PostProcess.
  20357. * @param fragmentUrl The url of the fragment shader to be used.
  20358. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20359. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20360. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20361. * @param camera The camera to apply the render pass to.
  20362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20363. * @param engine The engine which the post process will be applied. (default: current engine)
  20364. * @param reusable If the post process can be reused on the same frame. (default: false)
  20365. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20366. * @param textureType Type of textures used when performing the post process. (default: 0)
  20367. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20368. * @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
  20369. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20370. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20371. */
  20372. constructor(
  20373. /** Name of the PostProcess. */
  20374. 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, textureFormat?: number);
  20375. /**
  20376. * Gets a string idenfifying the name of the class
  20377. * @returns "PostProcess" string
  20378. */
  20379. getClassName(): string;
  20380. /**
  20381. * Gets the engine which this post process belongs to.
  20382. * @returns The engine the post process was enabled with.
  20383. */
  20384. getEngine(): Engine;
  20385. /**
  20386. * The effect that is created when initializing the post process.
  20387. * @returns The created effect corresponding the the postprocess.
  20388. */
  20389. getEffect(): Effect;
  20390. /**
  20391. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20392. * @param postProcess The post process to share the output with.
  20393. * @returns This post process.
  20394. */
  20395. shareOutputWith(postProcess: PostProcess): PostProcess;
  20396. /**
  20397. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20398. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20399. */
  20400. useOwnOutput(): void;
  20401. /**
  20402. * Updates the effect with the current post process compile time values and recompiles the shader.
  20403. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20404. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20405. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20406. * @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
  20407. * @param onCompiled Called when the shader has been compiled.
  20408. * @param onError Called if there is an error when compiling a shader.
  20409. */
  20410. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20411. /**
  20412. * The post process is reusable if it can be used multiple times within one frame.
  20413. * @returns If the post process is reusable
  20414. */
  20415. isReusable(): boolean;
  20416. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20417. markTextureDirty(): void;
  20418. /**
  20419. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20420. * 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.
  20421. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20422. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20423. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20424. * @returns The target texture that was bound to be written to.
  20425. */
  20426. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20427. /**
  20428. * If the post process is supported.
  20429. */
  20430. get isSupported(): boolean;
  20431. /**
  20432. * The aspect ratio of the output texture.
  20433. */
  20434. get aspectRatio(): number;
  20435. /**
  20436. * Get a value indicating if the post-process is ready to be used
  20437. * @returns true if the post-process is ready (shader is compiled)
  20438. */
  20439. isReady(): boolean;
  20440. /**
  20441. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20442. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20443. */
  20444. apply(): Nullable<Effect>;
  20445. private _disposeTextures;
  20446. /**
  20447. * Disposes the post process.
  20448. * @param camera The camera to dispose the post process on.
  20449. */
  20450. dispose(camera?: Camera): void;
  20451. }
  20452. }
  20453. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20454. /** @hidden */
  20455. export var kernelBlurVaryingDeclaration: {
  20456. name: string;
  20457. shader: string;
  20458. };
  20459. }
  20460. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20461. /** @hidden */
  20462. export var kernelBlurFragment: {
  20463. name: string;
  20464. shader: string;
  20465. };
  20466. }
  20467. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20468. /** @hidden */
  20469. export var kernelBlurFragment2: {
  20470. name: string;
  20471. shader: string;
  20472. };
  20473. }
  20474. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20475. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20476. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20477. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20478. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20479. /** @hidden */
  20480. export var kernelBlurPixelShader: {
  20481. name: string;
  20482. shader: string;
  20483. };
  20484. }
  20485. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20486. /** @hidden */
  20487. export var kernelBlurVertex: {
  20488. name: string;
  20489. shader: string;
  20490. };
  20491. }
  20492. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20493. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20494. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20495. /** @hidden */
  20496. export var kernelBlurVertexShader: {
  20497. name: string;
  20498. shader: string;
  20499. };
  20500. }
  20501. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20502. import { Vector2 } from "babylonjs/Maths/math.vector";
  20503. import { Nullable } from "babylonjs/types";
  20504. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20505. import { Camera } from "babylonjs/Cameras/camera";
  20506. import { Effect } from "babylonjs/Materials/effect";
  20507. import { Engine } from "babylonjs/Engines/engine";
  20508. import "babylonjs/Shaders/kernelBlur.fragment";
  20509. import "babylonjs/Shaders/kernelBlur.vertex";
  20510. /**
  20511. * The Blur Post Process which blurs an image based on a kernel and direction.
  20512. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20513. */
  20514. export class BlurPostProcess extends PostProcess {
  20515. /** The direction in which to blur the image. */
  20516. direction: Vector2;
  20517. private blockCompilation;
  20518. protected _kernel: number;
  20519. protected _idealKernel: number;
  20520. protected _packedFloat: boolean;
  20521. private _staticDefines;
  20522. /**
  20523. * Sets the length in pixels of the blur sample region
  20524. */
  20525. set kernel(v: number);
  20526. /**
  20527. * Gets the length in pixels of the blur sample region
  20528. */
  20529. get kernel(): number;
  20530. /**
  20531. * Sets wether or not the blur needs to unpack/repack floats
  20532. */
  20533. set packedFloat(v: boolean);
  20534. /**
  20535. * Gets wether or not the blur is unpacking/repacking floats
  20536. */
  20537. get packedFloat(): boolean;
  20538. /**
  20539. * Creates a new instance BlurPostProcess
  20540. * @param name The name of the effect.
  20541. * @param direction The direction in which to blur the image.
  20542. * @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.
  20543. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20544. * @param camera The camera to apply the render pass to.
  20545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20546. * @param engine The engine which the post process will be applied. (default: current engine)
  20547. * @param reusable If the post process can be reused on the same frame. (default: false)
  20548. * @param textureType Type of textures used when performing the post process. (default: 0)
  20549. * @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)
  20550. */
  20551. constructor(name: string,
  20552. /** The direction in which to blur the image. */
  20553. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20554. /**
  20555. * Updates the effect with the current post process compile time values and recompiles the shader.
  20556. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20557. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20558. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20559. * @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
  20560. * @param onCompiled Called when the shader has been compiled.
  20561. * @param onError Called if there is an error when compiling a shader.
  20562. */
  20563. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20564. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20565. /**
  20566. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20567. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20568. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20569. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20570. * The gaps between physical kernels are compensated for in the weighting of the samples
  20571. * @param idealKernel Ideal blur kernel.
  20572. * @return Nearest best kernel.
  20573. */
  20574. protected _nearestBestKernel(idealKernel: number): number;
  20575. /**
  20576. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20577. * @param x The point on the Gaussian distribution to sample.
  20578. * @return the value of the Gaussian function at x.
  20579. */
  20580. protected _gaussianWeight(x: number): number;
  20581. /**
  20582. * Generates a string that can be used as a floating point number in GLSL.
  20583. * @param x Value to print.
  20584. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20585. * @return GLSL float string.
  20586. */
  20587. protected _glslFloat(x: number, decimalFigures?: number): string;
  20588. }
  20589. }
  20590. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20591. import { Scene } from "babylonjs/scene";
  20592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20593. import { Plane } from "babylonjs/Maths/math.plane";
  20594. /**
  20595. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20596. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20597. * You can then easily use it as a reflectionTexture on a flat surface.
  20598. * In case the surface is not a plane, please consider relying on reflection probes.
  20599. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20600. */
  20601. export class MirrorTexture extends RenderTargetTexture {
  20602. private scene;
  20603. /**
  20604. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20605. * 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.
  20606. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20607. */
  20608. mirrorPlane: Plane;
  20609. /**
  20610. * Define the blur ratio used to blur the reflection if needed.
  20611. */
  20612. set blurRatio(value: number);
  20613. get blurRatio(): number;
  20614. /**
  20615. * Define the adaptive blur kernel used to blur the reflection if needed.
  20616. * This will autocompute the closest best match for the `blurKernel`
  20617. */
  20618. set adaptiveBlurKernel(value: number);
  20619. /**
  20620. * Define the blur kernel used to blur the reflection if needed.
  20621. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20622. */
  20623. set blurKernel(value: number);
  20624. /**
  20625. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20626. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20627. */
  20628. set blurKernelX(value: number);
  20629. get blurKernelX(): number;
  20630. /**
  20631. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20632. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20633. */
  20634. set blurKernelY(value: number);
  20635. get blurKernelY(): number;
  20636. private _autoComputeBlurKernel;
  20637. protected _onRatioRescale(): void;
  20638. private _updateGammaSpace;
  20639. private _imageProcessingConfigChangeObserver;
  20640. private _transformMatrix;
  20641. private _mirrorMatrix;
  20642. private _savedViewMatrix;
  20643. private _blurX;
  20644. private _blurY;
  20645. private _adaptiveBlurKernel;
  20646. private _blurKernelX;
  20647. private _blurKernelY;
  20648. private _blurRatio;
  20649. /**
  20650. * Instantiates a Mirror Texture.
  20651. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20652. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20653. * You can then easily use it as a reflectionTexture on a flat surface.
  20654. * In case the surface is not a plane, please consider relying on reflection probes.
  20655. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20656. * @param name
  20657. * @param size
  20658. * @param scene
  20659. * @param generateMipMaps
  20660. * @param type
  20661. * @param samplingMode
  20662. * @param generateDepthBuffer
  20663. */
  20664. constructor(name: string, size: number | {
  20665. width: number;
  20666. height: number;
  20667. } | {
  20668. ratio: number;
  20669. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20670. private _preparePostProcesses;
  20671. /**
  20672. * Clone the mirror texture.
  20673. * @returns the cloned texture
  20674. */
  20675. clone(): MirrorTexture;
  20676. /**
  20677. * Serialize the texture to a JSON representation you could use in Parse later on
  20678. * @returns the serialized JSON representation
  20679. */
  20680. serialize(): any;
  20681. /**
  20682. * Dispose the texture and release its associated resources.
  20683. */
  20684. dispose(): void;
  20685. }
  20686. }
  20687. declare module "babylonjs/Materials/Textures/texture" {
  20688. import { Observable } from "babylonjs/Misc/observable";
  20689. import { Nullable } from "babylonjs/types";
  20690. import { Matrix } from "babylonjs/Maths/math.vector";
  20691. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20692. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20693. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20694. import { Scene } from "babylonjs/scene";
  20695. /**
  20696. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20697. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20698. */
  20699. export class Texture extends BaseTexture {
  20700. /**
  20701. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20702. */
  20703. static SerializeBuffers: boolean;
  20704. /** @hidden */
  20705. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20706. /** @hidden */
  20707. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20708. /** @hidden */
  20709. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20710. /** nearest is mag = nearest and min = nearest and mip = linear */
  20711. static readonly NEAREST_SAMPLINGMODE: number;
  20712. /** nearest is mag = nearest and min = nearest and mip = linear */
  20713. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20714. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20715. static readonly BILINEAR_SAMPLINGMODE: number;
  20716. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20717. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20718. /** Trilinear is mag = linear and min = linear and mip = linear */
  20719. static readonly TRILINEAR_SAMPLINGMODE: number;
  20720. /** Trilinear is mag = linear and min = linear and mip = linear */
  20721. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20722. /** mag = nearest and min = nearest and mip = nearest */
  20723. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20724. /** mag = nearest and min = linear and mip = nearest */
  20725. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20726. /** mag = nearest and min = linear and mip = linear */
  20727. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20728. /** mag = nearest and min = linear and mip = none */
  20729. static readonly NEAREST_LINEAR: number;
  20730. /** mag = nearest and min = nearest and mip = none */
  20731. static readonly NEAREST_NEAREST: number;
  20732. /** mag = linear and min = nearest and mip = nearest */
  20733. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20734. /** mag = linear and min = nearest and mip = linear */
  20735. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20736. /** mag = linear and min = linear and mip = none */
  20737. static readonly LINEAR_LINEAR: number;
  20738. /** mag = linear and min = nearest and mip = none */
  20739. static readonly LINEAR_NEAREST: number;
  20740. /** Explicit coordinates mode */
  20741. static readonly EXPLICIT_MODE: number;
  20742. /** Spherical coordinates mode */
  20743. static readonly SPHERICAL_MODE: number;
  20744. /** Planar coordinates mode */
  20745. static readonly PLANAR_MODE: number;
  20746. /** Cubic coordinates mode */
  20747. static readonly CUBIC_MODE: number;
  20748. /** Projection coordinates mode */
  20749. static readonly PROJECTION_MODE: number;
  20750. /** Inverse Cubic coordinates mode */
  20751. static readonly SKYBOX_MODE: number;
  20752. /** Inverse Cubic coordinates mode */
  20753. static readonly INVCUBIC_MODE: number;
  20754. /** Equirectangular coordinates mode */
  20755. static readonly EQUIRECTANGULAR_MODE: number;
  20756. /** Equirectangular Fixed coordinates mode */
  20757. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20758. /** Equirectangular Fixed Mirrored coordinates mode */
  20759. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20760. /** Texture is not repeating outside of 0..1 UVs */
  20761. static readonly CLAMP_ADDRESSMODE: number;
  20762. /** Texture is repeating outside of 0..1 UVs */
  20763. static readonly WRAP_ADDRESSMODE: number;
  20764. /** Texture is repeating and mirrored */
  20765. static readonly MIRROR_ADDRESSMODE: number;
  20766. /**
  20767. * 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
  20768. */
  20769. static UseSerializedUrlIfAny: boolean;
  20770. /**
  20771. * Define the url of the texture.
  20772. */
  20773. url: Nullable<string>;
  20774. /**
  20775. * Define an offset on the texture to offset the u coordinates of the UVs
  20776. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20777. */
  20778. uOffset: number;
  20779. /**
  20780. * Define an offset on the texture to offset the v coordinates of the UVs
  20781. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20782. */
  20783. vOffset: number;
  20784. /**
  20785. * Define an offset on the texture to scale the u coordinates of the UVs
  20786. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20787. */
  20788. uScale: number;
  20789. /**
  20790. * Define an offset on the texture to scale the v coordinates of the UVs
  20791. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20792. */
  20793. vScale: number;
  20794. /**
  20795. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20796. * @see http://doc.babylonjs.com/how_to/more_materials
  20797. */
  20798. uAng: number;
  20799. /**
  20800. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20801. * @see http://doc.babylonjs.com/how_to/more_materials
  20802. */
  20803. vAng: number;
  20804. /**
  20805. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20806. * @see http://doc.babylonjs.com/how_to/more_materials
  20807. */
  20808. wAng: number;
  20809. /**
  20810. * Defines the center of rotation (U)
  20811. */
  20812. uRotationCenter: number;
  20813. /**
  20814. * Defines the center of rotation (V)
  20815. */
  20816. vRotationCenter: number;
  20817. /**
  20818. * Defines the center of rotation (W)
  20819. */
  20820. wRotationCenter: number;
  20821. /**
  20822. * Are mip maps generated for this texture or not.
  20823. */
  20824. get noMipmap(): boolean;
  20825. /**
  20826. * List of inspectable custom properties (used by the Inspector)
  20827. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20828. */
  20829. inspectableCustomProperties: Nullable<IInspectable[]>;
  20830. private _noMipmap;
  20831. /** @hidden */
  20832. _invertY: boolean;
  20833. private _rowGenerationMatrix;
  20834. private _cachedTextureMatrix;
  20835. private _projectionModeMatrix;
  20836. private _t0;
  20837. private _t1;
  20838. private _t2;
  20839. private _cachedUOffset;
  20840. private _cachedVOffset;
  20841. private _cachedUScale;
  20842. private _cachedVScale;
  20843. private _cachedUAng;
  20844. private _cachedVAng;
  20845. private _cachedWAng;
  20846. private _cachedProjectionMatrixId;
  20847. private _cachedCoordinatesMode;
  20848. /** @hidden */
  20849. protected _initialSamplingMode: number;
  20850. /** @hidden */
  20851. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20852. private _deleteBuffer;
  20853. protected _format: Nullable<number>;
  20854. private _delayedOnLoad;
  20855. private _delayedOnError;
  20856. private _mimeType?;
  20857. /**
  20858. * Observable triggered once the texture has been loaded.
  20859. */
  20860. onLoadObservable: Observable<Texture>;
  20861. protected _isBlocking: boolean;
  20862. /**
  20863. * Is the texture preventing material to render while loading.
  20864. * If false, a default texture will be used instead of the loading one during the preparation step.
  20865. */
  20866. set isBlocking(value: boolean);
  20867. get isBlocking(): boolean;
  20868. /**
  20869. * Get the current sampling mode associated with the texture.
  20870. */
  20871. get samplingMode(): number;
  20872. /**
  20873. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20874. */
  20875. get invertY(): boolean;
  20876. /**
  20877. * Instantiates a new texture.
  20878. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20879. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20880. * @param url defines the url of the picture to load as a texture
  20881. * @param scene defines the scene or engine the texture will belong to
  20882. * @param noMipmap defines if the texture will require mip maps or not
  20883. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20884. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20885. * @param onLoad defines a callback triggered when the texture has been loaded
  20886. * @param onError defines a callback triggered when an error occurred during the loading session
  20887. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20888. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20889. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20890. * @param mimeType defines an optional mime type information
  20891. */
  20892. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20893. /**
  20894. * Update the url (and optional buffer) of this texture if url was null during construction.
  20895. * @param url the url of the texture
  20896. * @param buffer the buffer of the texture (defaults to null)
  20897. * @param onLoad callback called when the texture is loaded (defaults to null)
  20898. */
  20899. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20900. /**
  20901. * Finish the loading sequence of a texture flagged as delayed load.
  20902. * @hidden
  20903. */
  20904. delayLoad(): void;
  20905. private _prepareRowForTextureGeneration;
  20906. /**
  20907. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20908. * @returns the transform matrix of the texture.
  20909. */
  20910. getTextureMatrix(uBase?: number): Matrix;
  20911. /**
  20912. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20913. * @returns The reflection texture transform
  20914. */
  20915. getReflectionTextureMatrix(): Matrix;
  20916. /**
  20917. * Clones the texture.
  20918. * @returns the cloned texture
  20919. */
  20920. clone(): Texture;
  20921. /**
  20922. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20923. * @returns The JSON representation of the texture
  20924. */
  20925. serialize(): any;
  20926. /**
  20927. * Get the current class name of the texture useful for serialization or dynamic coding.
  20928. * @returns "Texture"
  20929. */
  20930. getClassName(): string;
  20931. /**
  20932. * Dispose the texture and release its associated resources.
  20933. */
  20934. dispose(): void;
  20935. /**
  20936. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20937. * @param parsedTexture Define the JSON representation of the texture
  20938. * @param scene Define the scene the parsed texture should be instantiated in
  20939. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20940. * @returns The parsed texture if successful
  20941. */
  20942. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20943. /**
  20944. * Creates a texture from its base 64 representation.
  20945. * @param data Define the base64 payload without the data: prefix
  20946. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20947. * @param scene Define the scene the texture should belong to
  20948. * @param noMipmap Forces the texture to not create mip map information if true
  20949. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20950. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20951. * @param onLoad define a callback triggered when the texture has been loaded
  20952. * @param onError define a callback triggered when an error occurred during the loading session
  20953. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20954. * @returns the created texture
  20955. */
  20956. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20957. /**
  20958. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20959. * @param data Define the base64 payload without the data: prefix
  20960. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20961. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20962. * @param scene Define the scene the texture should belong to
  20963. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20964. * @param noMipmap Forces the texture to not create mip map information if true
  20965. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20966. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20967. * @param onLoad define a callback triggered when the texture has been loaded
  20968. * @param onError define a callback triggered when an error occurred during the loading session
  20969. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20970. * @returns the created texture
  20971. */
  20972. 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;
  20973. }
  20974. }
  20975. declare module "babylonjs/PostProcesses/postProcessManager" {
  20976. import { Nullable } from "babylonjs/types";
  20977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20978. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20979. import { Scene } from "babylonjs/scene";
  20980. /**
  20981. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20982. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20983. */
  20984. export class PostProcessManager {
  20985. private _scene;
  20986. private _indexBuffer;
  20987. private _vertexBuffers;
  20988. /**
  20989. * Creates a new instance PostProcess
  20990. * @param scene The scene that the post process is associated with.
  20991. */
  20992. constructor(scene: Scene);
  20993. private _prepareBuffers;
  20994. private _buildIndexBuffer;
  20995. /**
  20996. * Rebuilds the vertex buffers of the manager.
  20997. * @hidden
  20998. */
  20999. _rebuild(): void;
  21000. /**
  21001. * Prepares a frame to be run through a post process.
  21002. * @param sourceTexture The input texture to the post procesess. (default: null)
  21003. * @param postProcesses An array of post processes to be run. (default: null)
  21004. * @returns True if the post processes were able to be run.
  21005. * @hidden
  21006. */
  21007. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21008. /**
  21009. * Manually render a set of post processes to a texture.
  21010. * @param postProcesses An array of post processes to be run.
  21011. * @param targetTexture The target texture to render to.
  21012. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21013. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21014. * @param lodLevel defines which lod of the texture to render to
  21015. */
  21016. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21017. /**
  21018. * Finalize the result of the output of the postprocesses.
  21019. * @param doNotPresent If true the result will not be displayed to the screen.
  21020. * @param targetTexture The target texture to render to.
  21021. * @param faceIndex The index of the face to bind the target texture to.
  21022. * @param postProcesses The array of post processes to render.
  21023. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21024. * @hidden
  21025. */
  21026. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21027. /**
  21028. * Disposes of the post process manager.
  21029. */
  21030. dispose(): void;
  21031. }
  21032. }
  21033. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21034. import { Observable } from "babylonjs/Misc/observable";
  21035. import { SmartArray } from "babylonjs/Misc/smartArray";
  21036. import { Nullable, Immutable } from "babylonjs/types";
  21037. import { Camera } from "babylonjs/Cameras/camera";
  21038. import { Scene } from "babylonjs/scene";
  21039. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21040. import { Color4 } from "babylonjs/Maths/math.color";
  21041. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21044. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21045. import { Texture } from "babylonjs/Materials/Textures/texture";
  21046. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21047. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21048. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21049. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21050. import { Engine } from "babylonjs/Engines/engine";
  21051. /**
  21052. * This Helps creating a texture that will be created from a camera in your scene.
  21053. * It is basically a dynamic texture that could be used to create special effects for instance.
  21054. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21055. */
  21056. export class RenderTargetTexture extends Texture {
  21057. isCube: boolean;
  21058. /**
  21059. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21060. */
  21061. static readonly REFRESHRATE_RENDER_ONCE: number;
  21062. /**
  21063. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21064. */
  21065. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21066. /**
  21067. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21068. * the central point of your effect and can save a lot of performances.
  21069. */
  21070. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21071. /**
  21072. * Use this predicate to dynamically define the list of mesh you want to render.
  21073. * If set, the renderList property will be overwritten.
  21074. */
  21075. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21076. private _renderList;
  21077. /**
  21078. * Use this list to define the list of mesh you want to render.
  21079. */
  21080. get renderList(): Nullable<Array<AbstractMesh>>;
  21081. set renderList(value: Nullable<Array<AbstractMesh>>);
  21082. /**
  21083. * Use this function to overload the renderList array at rendering time.
  21084. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21085. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21086. * the cube (if the RTT is a cube, else layerOrFace=0).
  21087. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21088. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21089. * hold dummy elements!
  21090. */
  21091. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21092. private _hookArray;
  21093. /**
  21094. * Define if particles should be rendered in your texture.
  21095. */
  21096. renderParticles: boolean;
  21097. /**
  21098. * Define if sprites should be rendered in your texture.
  21099. */
  21100. renderSprites: boolean;
  21101. /**
  21102. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21103. */
  21104. coordinatesMode: number;
  21105. /**
  21106. * Define the camera used to render the texture.
  21107. */
  21108. activeCamera: Nullable<Camera>;
  21109. /**
  21110. * Override the render function of the texture with your own one.
  21111. */
  21112. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21113. /**
  21114. * Define if camera post processes should be use while rendering the texture.
  21115. */
  21116. useCameraPostProcesses: boolean;
  21117. /**
  21118. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21119. */
  21120. ignoreCameraViewport: boolean;
  21121. private _postProcessManager;
  21122. private _postProcesses;
  21123. private _resizeObserver;
  21124. /**
  21125. * An event triggered when the texture is unbind.
  21126. */
  21127. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21128. /**
  21129. * An event triggered when the texture is unbind.
  21130. */
  21131. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21132. private _onAfterUnbindObserver;
  21133. /**
  21134. * Set a after unbind callback in the texture.
  21135. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21136. */
  21137. set onAfterUnbind(callback: () => void);
  21138. /**
  21139. * An event triggered before rendering the texture
  21140. */
  21141. onBeforeRenderObservable: Observable<number>;
  21142. private _onBeforeRenderObserver;
  21143. /**
  21144. * Set a before render callback in the texture.
  21145. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21146. */
  21147. set onBeforeRender(callback: (faceIndex: number) => void);
  21148. /**
  21149. * An event triggered after rendering the texture
  21150. */
  21151. onAfterRenderObservable: Observable<number>;
  21152. private _onAfterRenderObserver;
  21153. /**
  21154. * Set a after render callback in the texture.
  21155. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21156. */
  21157. set onAfterRender(callback: (faceIndex: number) => void);
  21158. /**
  21159. * An event triggered after the texture clear
  21160. */
  21161. onClearObservable: Observable<Engine>;
  21162. private _onClearObserver;
  21163. /**
  21164. * Set a clear callback in the texture.
  21165. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21166. */
  21167. set onClear(callback: (Engine: Engine) => void);
  21168. /**
  21169. * An event triggered when the texture is resized.
  21170. */
  21171. onResizeObservable: Observable<RenderTargetTexture>;
  21172. /**
  21173. * Define the clear color of the Render Target if it should be different from the scene.
  21174. */
  21175. clearColor: Color4;
  21176. protected _size: number | {
  21177. width: number;
  21178. height: number;
  21179. layers?: number;
  21180. };
  21181. protected _initialSizeParameter: number | {
  21182. width: number;
  21183. height: number;
  21184. } | {
  21185. ratio: number;
  21186. };
  21187. protected _sizeRatio: Nullable<number>;
  21188. /** @hidden */
  21189. _generateMipMaps: boolean;
  21190. protected _renderingManager: RenderingManager;
  21191. /** @hidden */
  21192. _waitingRenderList: string[];
  21193. protected _doNotChangeAspectRatio: boolean;
  21194. protected _currentRefreshId: number;
  21195. protected _refreshRate: number;
  21196. protected _textureMatrix: Matrix;
  21197. protected _samples: number;
  21198. protected _renderTargetOptions: RenderTargetCreationOptions;
  21199. /**
  21200. * Gets render target creation options that were used.
  21201. */
  21202. get renderTargetOptions(): RenderTargetCreationOptions;
  21203. protected _engine: Engine;
  21204. protected _onRatioRescale(): void;
  21205. /**
  21206. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21207. * It must define where the camera used to render the texture is set
  21208. */
  21209. boundingBoxPosition: Vector3;
  21210. private _boundingBoxSize;
  21211. /**
  21212. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21213. * When defined, the cubemap will switch to local mode
  21214. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21215. * @example https://www.babylonjs-playground.com/#RNASML
  21216. */
  21217. set boundingBoxSize(value: Vector3);
  21218. get boundingBoxSize(): Vector3;
  21219. /**
  21220. * In case the RTT has been created with a depth texture, get the associated
  21221. * depth texture.
  21222. * Otherwise, return null.
  21223. */
  21224. get depthStencilTexture(): Nullable<InternalTexture>;
  21225. /**
  21226. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21227. * or used a shadow, depth texture...
  21228. * @param name The friendly name of the texture
  21229. * @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)
  21230. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21231. * @param generateMipMaps True if mip maps need to be generated after render.
  21232. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21233. * @param type The type of the buffer in the RTT (int, half float, float...)
  21234. * @param isCube True if a cube texture needs to be created
  21235. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21236. * @param generateDepthBuffer True to generate a depth buffer
  21237. * @param generateStencilBuffer True to generate a stencil buffer
  21238. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21239. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21240. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21241. */
  21242. constructor(name: string, size: number | {
  21243. width: number;
  21244. height: number;
  21245. layers?: number;
  21246. } | {
  21247. ratio: number;
  21248. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21249. /**
  21250. * Creates a depth stencil texture.
  21251. * This is only available in WebGL 2 or with the depth texture extension available.
  21252. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21253. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21254. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21255. */
  21256. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21257. private _processSizeParameter;
  21258. /**
  21259. * Define the number of samples to use in case of MSAA.
  21260. * It defaults to one meaning no MSAA has been enabled.
  21261. */
  21262. get samples(): number;
  21263. set samples(value: number);
  21264. /**
  21265. * Resets the refresh counter of the texture and start bak from scratch.
  21266. * Could be useful to regenerate the texture if it is setup to render only once.
  21267. */
  21268. resetRefreshCounter(): void;
  21269. /**
  21270. * Define the refresh rate of the texture or the rendering frequency.
  21271. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21272. */
  21273. get refreshRate(): number;
  21274. set refreshRate(value: number);
  21275. /**
  21276. * Adds a post process to the render target rendering passes.
  21277. * @param postProcess define the post process to add
  21278. */
  21279. addPostProcess(postProcess: PostProcess): void;
  21280. /**
  21281. * Clear all the post processes attached to the render target
  21282. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21283. */
  21284. clearPostProcesses(dispose?: boolean): void;
  21285. /**
  21286. * Remove one of the post process from the list of attached post processes to the texture
  21287. * @param postProcess define the post process to remove from the list
  21288. */
  21289. removePostProcess(postProcess: PostProcess): void;
  21290. /** @hidden */
  21291. _shouldRender(): boolean;
  21292. /**
  21293. * Gets the actual render size of the texture.
  21294. * @returns the width of the render size
  21295. */
  21296. getRenderSize(): number;
  21297. /**
  21298. * Gets the actual render width of the texture.
  21299. * @returns the width of the render size
  21300. */
  21301. getRenderWidth(): number;
  21302. /**
  21303. * Gets the actual render height of the texture.
  21304. * @returns the height of the render size
  21305. */
  21306. getRenderHeight(): number;
  21307. /**
  21308. * Gets the actual number of layers of the texture.
  21309. * @returns the number of layers
  21310. */
  21311. getRenderLayers(): number;
  21312. /**
  21313. * Get if the texture can be rescaled or not.
  21314. */
  21315. get canRescale(): boolean;
  21316. /**
  21317. * Resize the texture using a ratio.
  21318. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21319. */
  21320. scale(ratio: number): void;
  21321. /**
  21322. * Get the texture reflection matrix used to rotate/transform the reflection.
  21323. * @returns the reflection matrix
  21324. */
  21325. getReflectionTextureMatrix(): Matrix;
  21326. /**
  21327. * Resize the texture to a new desired size.
  21328. * Be carrefull as it will recreate all the data in the new texture.
  21329. * @param size Define the new size. It can be:
  21330. * - a number for squared texture,
  21331. * - an object containing { width: number, height: number }
  21332. * - or an object containing a ratio { ratio: number }
  21333. */
  21334. resize(size: number | {
  21335. width: number;
  21336. height: number;
  21337. } | {
  21338. ratio: number;
  21339. }): void;
  21340. private _defaultRenderListPrepared;
  21341. /**
  21342. * Renders all the objects from the render list into the texture.
  21343. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21344. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21345. */
  21346. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21347. private _bestReflectionRenderTargetDimension;
  21348. private _prepareRenderingManager;
  21349. /**
  21350. * @hidden
  21351. * @param faceIndex face index to bind to if this is a cubetexture
  21352. * @param layer defines the index of the texture to bind in the array
  21353. */
  21354. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21355. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21356. private renderToTarget;
  21357. /**
  21358. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21359. * This allowed control for front to back rendering or reversly depending of the special needs.
  21360. *
  21361. * @param renderingGroupId The rendering group id corresponding to its index
  21362. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21363. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21364. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21365. */
  21366. 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;
  21367. /**
  21368. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21369. *
  21370. * @param renderingGroupId The rendering group id corresponding to its index
  21371. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21372. */
  21373. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21374. /**
  21375. * Clones the texture.
  21376. * @returns the cloned texture
  21377. */
  21378. clone(): RenderTargetTexture;
  21379. /**
  21380. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21381. * @returns The JSON representation of the texture
  21382. */
  21383. serialize(): any;
  21384. /**
  21385. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21386. */
  21387. disposeFramebufferObjects(): void;
  21388. /**
  21389. * Dispose the texture and release its associated resources.
  21390. */
  21391. dispose(): void;
  21392. /** @hidden */
  21393. _rebuild(): void;
  21394. /**
  21395. * Clear the info related to rendering groups preventing retention point in material dispose.
  21396. */
  21397. freeRenderingGroups(): void;
  21398. /**
  21399. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21400. * @returns the view count
  21401. */
  21402. getViewCount(): number;
  21403. }
  21404. }
  21405. declare module "babylonjs/Materials/material" {
  21406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21407. import { SmartArray } from "babylonjs/Misc/smartArray";
  21408. import { Observable } from "babylonjs/Misc/observable";
  21409. import { Nullable } from "babylonjs/types";
  21410. import { Scene } from "babylonjs/scene";
  21411. import { Matrix } from "babylonjs/Maths/math.vector";
  21412. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21414. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21415. import { Effect } from "babylonjs/Materials/effect";
  21416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21418. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21419. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21420. import { Mesh } from "babylonjs/Meshes/mesh";
  21421. import { Animation } from "babylonjs/Animations/animation";
  21422. /**
  21423. * Options for compiling materials.
  21424. */
  21425. export interface IMaterialCompilationOptions {
  21426. /**
  21427. * Defines whether clip planes are enabled.
  21428. */
  21429. clipPlane: boolean;
  21430. /**
  21431. * Defines whether instances are enabled.
  21432. */
  21433. useInstances: boolean;
  21434. }
  21435. /**
  21436. * Base class for the main features of a material in Babylon.js
  21437. */
  21438. export class Material implements IAnimatable {
  21439. /**
  21440. * Returns the triangle fill mode
  21441. */
  21442. static readonly TriangleFillMode: number;
  21443. /**
  21444. * Returns the wireframe mode
  21445. */
  21446. static readonly WireFrameFillMode: number;
  21447. /**
  21448. * Returns the point fill mode
  21449. */
  21450. static readonly PointFillMode: number;
  21451. /**
  21452. * Returns the point list draw mode
  21453. */
  21454. static readonly PointListDrawMode: number;
  21455. /**
  21456. * Returns the line list draw mode
  21457. */
  21458. static readonly LineListDrawMode: number;
  21459. /**
  21460. * Returns the line loop draw mode
  21461. */
  21462. static readonly LineLoopDrawMode: number;
  21463. /**
  21464. * Returns the line strip draw mode
  21465. */
  21466. static readonly LineStripDrawMode: number;
  21467. /**
  21468. * Returns the triangle strip draw mode
  21469. */
  21470. static readonly TriangleStripDrawMode: number;
  21471. /**
  21472. * Returns the triangle fan draw mode
  21473. */
  21474. static readonly TriangleFanDrawMode: number;
  21475. /**
  21476. * Stores the clock-wise side orientation
  21477. */
  21478. static readonly ClockWiseSideOrientation: number;
  21479. /**
  21480. * Stores the counter clock-wise side orientation
  21481. */
  21482. static readonly CounterClockWiseSideOrientation: number;
  21483. /**
  21484. * The dirty texture flag value
  21485. */
  21486. static readonly TextureDirtyFlag: number;
  21487. /**
  21488. * The dirty light flag value
  21489. */
  21490. static readonly LightDirtyFlag: number;
  21491. /**
  21492. * The dirty fresnel flag value
  21493. */
  21494. static readonly FresnelDirtyFlag: number;
  21495. /**
  21496. * The dirty attribute flag value
  21497. */
  21498. static readonly AttributesDirtyFlag: number;
  21499. /**
  21500. * The dirty misc flag value
  21501. */
  21502. static readonly MiscDirtyFlag: number;
  21503. /**
  21504. * The all dirty flag value
  21505. */
  21506. static readonly AllDirtyFlag: number;
  21507. /**
  21508. * The ID of the material
  21509. */
  21510. id: string;
  21511. /**
  21512. * Gets or sets the unique id of the material
  21513. */
  21514. uniqueId: number;
  21515. /**
  21516. * The name of the material
  21517. */
  21518. name: string;
  21519. /**
  21520. * Gets or sets user defined metadata
  21521. */
  21522. metadata: any;
  21523. /**
  21524. * For internal use only. Please do not use.
  21525. */
  21526. reservedDataStore: any;
  21527. /**
  21528. * Specifies if the ready state should be checked on each call
  21529. */
  21530. checkReadyOnEveryCall: boolean;
  21531. /**
  21532. * Specifies if the ready state should be checked once
  21533. */
  21534. checkReadyOnlyOnce: boolean;
  21535. /**
  21536. * The state of the material
  21537. */
  21538. state: string;
  21539. /**
  21540. * The alpha value of the material
  21541. */
  21542. protected _alpha: number;
  21543. /**
  21544. * List of inspectable custom properties (used by the Inspector)
  21545. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21546. */
  21547. inspectableCustomProperties: IInspectable[];
  21548. /**
  21549. * Sets the alpha value of the material
  21550. */
  21551. set alpha(value: number);
  21552. /**
  21553. * Gets the alpha value of the material
  21554. */
  21555. get alpha(): number;
  21556. /**
  21557. * Specifies if back face culling is enabled
  21558. */
  21559. protected _backFaceCulling: boolean;
  21560. /**
  21561. * Sets the back-face culling state
  21562. */
  21563. set backFaceCulling(value: boolean);
  21564. /**
  21565. * Gets the back-face culling state
  21566. */
  21567. get backFaceCulling(): boolean;
  21568. /**
  21569. * Stores the value for side orientation
  21570. */
  21571. sideOrientation: number;
  21572. /**
  21573. * Callback triggered when the material is compiled
  21574. */
  21575. onCompiled: Nullable<(effect: Effect) => void>;
  21576. /**
  21577. * Callback triggered when an error occurs
  21578. */
  21579. onError: Nullable<(effect: Effect, errors: string) => void>;
  21580. /**
  21581. * Callback triggered to get the render target textures
  21582. */
  21583. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21584. /**
  21585. * Gets a boolean indicating that current material needs to register RTT
  21586. */
  21587. get hasRenderTargetTextures(): boolean;
  21588. /**
  21589. * Specifies if the material should be serialized
  21590. */
  21591. doNotSerialize: boolean;
  21592. /**
  21593. * @hidden
  21594. */
  21595. _storeEffectOnSubMeshes: boolean;
  21596. /**
  21597. * Stores the animations for the material
  21598. */
  21599. animations: Nullable<Array<Animation>>;
  21600. /**
  21601. * An event triggered when the material is disposed
  21602. */
  21603. onDisposeObservable: Observable<Material>;
  21604. /**
  21605. * An observer which watches for dispose events
  21606. */
  21607. private _onDisposeObserver;
  21608. private _onUnBindObservable;
  21609. /**
  21610. * Called during a dispose event
  21611. */
  21612. set onDispose(callback: () => void);
  21613. private _onBindObservable;
  21614. /**
  21615. * An event triggered when the material is bound
  21616. */
  21617. get onBindObservable(): Observable<AbstractMesh>;
  21618. /**
  21619. * An observer which watches for bind events
  21620. */
  21621. private _onBindObserver;
  21622. /**
  21623. * Called during a bind event
  21624. */
  21625. set onBind(callback: (Mesh: AbstractMesh) => void);
  21626. /**
  21627. * An event triggered when the material is unbound
  21628. */
  21629. get onUnBindObservable(): Observable<Material>;
  21630. /**
  21631. * Stores the value of the alpha mode
  21632. */
  21633. private _alphaMode;
  21634. /**
  21635. * Sets the value of the alpha mode.
  21636. *
  21637. * | Value | Type | Description |
  21638. * | --- | --- | --- |
  21639. * | 0 | ALPHA_DISABLE | |
  21640. * | 1 | ALPHA_ADD | |
  21641. * | 2 | ALPHA_COMBINE | |
  21642. * | 3 | ALPHA_SUBTRACT | |
  21643. * | 4 | ALPHA_MULTIPLY | |
  21644. * | 5 | ALPHA_MAXIMIZED | |
  21645. * | 6 | ALPHA_ONEONE | |
  21646. * | 7 | ALPHA_PREMULTIPLIED | |
  21647. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21648. * | 9 | ALPHA_INTERPOLATE | |
  21649. * | 10 | ALPHA_SCREENMODE | |
  21650. *
  21651. */
  21652. set alphaMode(value: number);
  21653. /**
  21654. * Gets the value of the alpha mode
  21655. */
  21656. get alphaMode(): number;
  21657. /**
  21658. * Stores the state of the need depth pre-pass value
  21659. */
  21660. private _needDepthPrePass;
  21661. /**
  21662. * Sets the need depth pre-pass value
  21663. */
  21664. set needDepthPrePass(value: boolean);
  21665. /**
  21666. * Gets the depth pre-pass value
  21667. */
  21668. get needDepthPrePass(): boolean;
  21669. /**
  21670. * Specifies if depth writing should be disabled
  21671. */
  21672. disableDepthWrite: boolean;
  21673. /**
  21674. * Specifies if depth writing should be forced
  21675. */
  21676. forceDepthWrite: boolean;
  21677. /**
  21678. * Specifies the depth function that should be used. 0 means the default engine function
  21679. */
  21680. depthFunction: number;
  21681. /**
  21682. * Specifies if there should be a separate pass for culling
  21683. */
  21684. separateCullingPass: boolean;
  21685. /**
  21686. * Stores the state specifing if fog should be enabled
  21687. */
  21688. private _fogEnabled;
  21689. /**
  21690. * Sets the state for enabling fog
  21691. */
  21692. set fogEnabled(value: boolean);
  21693. /**
  21694. * Gets the value of the fog enabled state
  21695. */
  21696. get fogEnabled(): boolean;
  21697. /**
  21698. * Stores the size of points
  21699. */
  21700. pointSize: number;
  21701. /**
  21702. * Stores the z offset value
  21703. */
  21704. zOffset: number;
  21705. /**
  21706. * Gets a value specifying if wireframe mode is enabled
  21707. */
  21708. get wireframe(): boolean;
  21709. /**
  21710. * Sets the state of wireframe mode
  21711. */
  21712. set wireframe(value: boolean);
  21713. /**
  21714. * Gets the value specifying if point clouds are enabled
  21715. */
  21716. get pointsCloud(): boolean;
  21717. /**
  21718. * Sets the state of point cloud mode
  21719. */
  21720. set pointsCloud(value: boolean);
  21721. /**
  21722. * Gets the material fill mode
  21723. */
  21724. get fillMode(): number;
  21725. /**
  21726. * Sets the material fill mode
  21727. */
  21728. set fillMode(value: number);
  21729. /**
  21730. * @hidden
  21731. * Stores the effects for the material
  21732. */
  21733. _effect: Nullable<Effect>;
  21734. /**
  21735. * Specifies if uniform buffers should be used
  21736. */
  21737. private _useUBO;
  21738. /**
  21739. * Stores a reference to the scene
  21740. */
  21741. private _scene;
  21742. /**
  21743. * Stores the fill mode state
  21744. */
  21745. private _fillMode;
  21746. /**
  21747. * Specifies if the depth write state should be cached
  21748. */
  21749. private _cachedDepthWriteState;
  21750. /**
  21751. * Specifies if the depth function state should be cached
  21752. */
  21753. private _cachedDepthFunctionState;
  21754. /**
  21755. * Stores the uniform buffer
  21756. */
  21757. protected _uniformBuffer: UniformBuffer;
  21758. /** @hidden */
  21759. _indexInSceneMaterialArray: number;
  21760. /** @hidden */
  21761. meshMap: Nullable<{
  21762. [id: string]: AbstractMesh | undefined;
  21763. }>;
  21764. /**
  21765. * Creates a material instance
  21766. * @param name defines the name of the material
  21767. * @param scene defines the scene to reference
  21768. * @param doNotAdd specifies if the material should be added to the scene
  21769. */
  21770. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21771. /**
  21772. * Returns a string representation of the current material
  21773. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21774. * @returns a string with material information
  21775. */
  21776. toString(fullDetails?: boolean): string;
  21777. /**
  21778. * Gets the class name of the material
  21779. * @returns a string with the class name of the material
  21780. */
  21781. getClassName(): string;
  21782. /**
  21783. * Specifies if updates for the material been locked
  21784. */
  21785. get isFrozen(): boolean;
  21786. /**
  21787. * Locks updates for the material
  21788. */
  21789. freeze(): void;
  21790. /**
  21791. * Unlocks updates for the material
  21792. */
  21793. unfreeze(): void;
  21794. /**
  21795. * Specifies if the material is ready to be used
  21796. * @param mesh defines the mesh to check
  21797. * @param useInstances specifies if instances should be used
  21798. * @returns a boolean indicating if the material is ready to be used
  21799. */
  21800. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21801. /**
  21802. * Specifies that the submesh is ready to be used
  21803. * @param mesh defines the mesh to check
  21804. * @param subMesh defines which submesh to check
  21805. * @param useInstances specifies that instances should be used
  21806. * @returns a boolean indicating that the submesh is ready or not
  21807. */
  21808. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21809. /**
  21810. * Returns the material effect
  21811. * @returns the effect associated with the material
  21812. */
  21813. getEffect(): Nullable<Effect>;
  21814. /**
  21815. * Returns the current scene
  21816. * @returns a Scene
  21817. */
  21818. getScene(): Scene;
  21819. /**
  21820. * Specifies if the material will require alpha blending
  21821. * @returns a boolean specifying if alpha blending is needed
  21822. */
  21823. needAlphaBlending(): boolean;
  21824. /**
  21825. * Specifies if the mesh will require alpha blending
  21826. * @param mesh defines the mesh to check
  21827. * @returns a boolean specifying if alpha blending is needed for the mesh
  21828. */
  21829. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21830. /**
  21831. * Specifies if this material should be rendered in alpha test mode
  21832. * @returns a boolean specifying if an alpha test is needed.
  21833. */
  21834. needAlphaTesting(): boolean;
  21835. /**
  21836. * Gets the texture used for the alpha test
  21837. * @returns the texture to use for alpha testing
  21838. */
  21839. getAlphaTestTexture(): Nullable<BaseTexture>;
  21840. /**
  21841. * Marks the material to indicate that it needs to be re-calculated
  21842. */
  21843. markDirty(): void;
  21844. /** @hidden */
  21845. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21846. /**
  21847. * Binds the material to the mesh
  21848. * @param world defines the world transformation matrix
  21849. * @param mesh defines the mesh to bind the material to
  21850. */
  21851. bind(world: Matrix, mesh?: Mesh): void;
  21852. /**
  21853. * Binds the submesh to the material
  21854. * @param world defines the world transformation matrix
  21855. * @param mesh defines the mesh containing the submesh
  21856. * @param subMesh defines the submesh to bind the material to
  21857. */
  21858. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21859. /**
  21860. * Binds the world matrix to the material
  21861. * @param world defines the world transformation matrix
  21862. */
  21863. bindOnlyWorldMatrix(world: Matrix): void;
  21864. /**
  21865. * Binds the scene's uniform buffer to the effect.
  21866. * @param effect defines the effect to bind to the scene uniform buffer
  21867. * @param sceneUbo defines the uniform buffer storing scene data
  21868. */
  21869. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21870. /**
  21871. * Binds the view matrix to the effect
  21872. * @param effect defines the effect to bind the view matrix to
  21873. */
  21874. bindView(effect: Effect): void;
  21875. /**
  21876. * Binds the view projection matrix to the effect
  21877. * @param effect defines the effect to bind the view projection matrix to
  21878. */
  21879. bindViewProjection(effect: Effect): void;
  21880. /**
  21881. * Specifies if material alpha testing should be turned on for the mesh
  21882. * @param mesh defines the mesh to check
  21883. */
  21884. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21885. /**
  21886. * Processes to execute after binding the material to a mesh
  21887. * @param mesh defines the rendered mesh
  21888. */
  21889. protected _afterBind(mesh?: Mesh): void;
  21890. /**
  21891. * Unbinds the material from the mesh
  21892. */
  21893. unbind(): void;
  21894. /**
  21895. * Gets the active textures from the material
  21896. * @returns an array of textures
  21897. */
  21898. getActiveTextures(): BaseTexture[];
  21899. /**
  21900. * Specifies if the material uses a texture
  21901. * @param texture defines the texture to check against the material
  21902. * @returns a boolean specifying if the material uses the texture
  21903. */
  21904. hasTexture(texture: BaseTexture): boolean;
  21905. /**
  21906. * Makes a duplicate of the material, and gives it a new name
  21907. * @param name defines the new name for the duplicated material
  21908. * @returns the cloned material
  21909. */
  21910. clone(name: string): Nullable<Material>;
  21911. /**
  21912. * Gets the meshes bound to the material
  21913. * @returns an array of meshes bound to the material
  21914. */
  21915. getBindedMeshes(): AbstractMesh[];
  21916. /**
  21917. * Force shader compilation
  21918. * @param mesh defines the mesh associated with this material
  21919. * @param onCompiled defines a function to execute once the material is compiled
  21920. * @param options defines the options to configure the compilation
  21921. * @param onError defines a function to execute if the material fails compiling
  21922. */
  21923. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21924. /**
  21925. * Force shader compilation
  21926. * @param mesh defines the mesh that will use this material
  21927. * @param options defines additional options for compiling the shaders
  21928. * @returns a promise that resolves when the compilation completes
  21929. */
  21930. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21931. private static readonly _AllDirtyCallBack;
  21932. private static readonly _ImageProcessingDirtyCallBack;
  21933. private static readonly _TextureDirtyCallBack;
  21934. private static readonly _FresnelDirtyCallBack;
  21935. private static readonly _MiscDirtyCallBack;
  21936. private static readonly _LightsDirtyCallBack;
  21937. private static readonly _AttributeDirtyCallBack;
  21938. private static _FresnelAndMiscDirtyCallBack;
  21939. private static _TextureAndMiscDirtyCallBack;
  21940. private static readonly _DirtyCallbackArray;
  21941. private static readonly _RunDirtyCallBacks;
  21942. /**
  21943. * Marks a define in the material to indicate that it needs to be re-computed
  21944. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21945. */
  21946. markAsDirty(flag: number): void;
  21947. /**
  21948. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21949. * @param func defines a function which checks material defines against the submeshes
  21950. */
  21951. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21952. /**
  21953. * Indicates that we need to re-calculated for all submeshes
  21954. */
  21955. protected _markAllSubMeshesAsAllDirty(): void;
  21956. /**
  21957. * Indicates that image processing needs to be re-calculated for all submeshes
  21958. */
  21959. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21960. /**
  21961. * Indicates that textures need to be re-calculated for all submeshes
  21962. */
  21963. protected _markAllSubMeshesAsTexturesDirty(): void;
  21964. /**
  21965. * Indicates that fresnel needs to be re-calculated for all submeshes
  21966. */
  21967. protected _markAllSubMeshesAsFresnelDirty(): void;
  21968. /**
  21969. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21970. */
  21971. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21972. /**
  21973. * Indicates that lights need to be re-calculated for all submeshes
  21974. */
  21975. protected _markAllSubMeshesAsLightsDirty(): void;
  21976. /**
  21977. * Indicates that attributes need to be re-calculated for all submeshes
  21978. */
  21979. protected _markAllSubMeshesAsAttributesDirty(): void;
  21980. /**
  21981. * Indicates that misc needs to be re-calculated for all submeshes
  21982. */
  21983. protected _markAllSubMeshesAsMiscDirty(): void;
  21984. /**
  21985. * Indicates that textures and misc need to be re-calculated for all submeshes
  21986. */
  21987. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21988. /**
  21989. * Disposes the material
  21990. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21991. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21992. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21993. */
  21994. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21995. /** @hidden */
  21996. private releaseVertexArrayObject;
  21997. /**
  21998. * Serializes this material
  21999. * @returns the serialized material object
  22000. */
  22001. serialize(): any;
  22002. /**
  22003. * Creates a material from parsed material data
  22004. * @param parsedMaterial defines parsed material data
  22005. * @param scene defines the hosting scene
  22006. * @param rootUrl defines the root URL to use to load textures
  22007. * @returns a new material
  22008. */
  22009. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22010. }
  22011. }
  22012. declare module "babylonjs/Materials/multiMaterial" {
  22013. import { Nullable } from "babylonjs/types";
  22014. import { Scene } from "babylonjs/scene";
  22015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22016. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22018. import { Material } from "babylonjs/Materials/material";
  22019. /**
  22020. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22021. * separate meshes. This can be use to improve performances.
  22022. * @see http://doc.babylonjs.com/how_to/multi_materials
  22023. */
  22024. export class MultiMaterial extends Material {
  22025. private _subMaterials;
  22026. /**
  22027. * Gets or Sets the list of Materials used within the multi material.
  22028. * They need to be ordered according to the submeshes order in the associated mesh
  22029. */
  22030. get subMaterials(): Nullable<Material>[];
  22031. set subMaterials(value: Nullable<Material>[]);
  22032. /**
  22033. * Function used to align with Node.getChildren()
  22034. * @returns the list of Materials used within the multi material
  22035. */
  22036. getChildren(): Nullable<Material>[];
  22037. /**
  22038. * Instantiates a new Multi Material
  22039. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22040. * separate meshes. This can be use to improve performances.
  22041. * @see http://doc.babylonjs.com/how_to/multi_materials
  22042. * @param name Define the name in the scene
  22043. * @param scene Define the scene the material belongs to
  22044. */
  22045. constructor(name: string, scene: Scene);
  22046. private _hookArray;
  22047. /**
  22048. * Get one of the submaterial by its index in the submaterials array
  22049. * @param index The index to look the sub material at
  22050. * @returns The Material if the index has been defined
  22051. */
  22052. getSubMaterial(index: number): Nullable<Material>;
  22053. /**
  22054. * Get the list of active textures for the whole sub materials list.
  22055. * @returns All the textures that will be used during the rendering
  22056. */
  22057. getActiveTextures(): BaseTexture[];
  22058. /**
  22059. * Gets the current class name of the material e.g. "MultiMaterial"
  22060. * Mainly use in serialization.
  22061. * @returns the class name
  22062. */
  22063. getClassName(): string;
  22064. /**
  22065. * Checks if the material is ready to render the requested sub mesh
  22066. * @param mesh Define the mesh the submesh belongs to
  22067. * @param subMesh Define the sub mesh to look readyness for
  22068. * @param useInstances Define whether or not the material is used with instances
  22069. * @returns true if ready, otherwise false
  22070. */
  22071. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22072. /**
  22073. * Clones the current material and its related sub materials
  22074. * @param name Define the name of the newly cloned material
  22075. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22076. * @returns the cloned material
  22077. */
  22078. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22079. /**
  22080. * Serializes the materials into a JSON representation.
  22081. * @returns the JSON representation
  22082. */
  22083. serialize(): any;
  22084. /**
  22085. * Dispose the material and release its associated resources
  22086. * @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)
  22087. * @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)
  22088. * @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)
  22089. */
  22090. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22091. /**
  22092. * Creates a MultiMaterial from parsed MultiMaterial data.
  22093. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22094. * @param scene defines the hosting scene
  22095. * @returns a new MultiMaterial
  22096. */
  22097. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22098. }
  22099. }
  22100. declare module "babylonjs/Meshes/subMesh" {
  22101. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22102. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22103. import { Engine } from "babylonjs/Engines/engine";
  22104. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22105. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22106. import { Effect } from "babylonjs/Materials/effect";
  22107. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22108. import { Plane } from "babylonjs/Maths/math.plane";
  22109. import { Collider } from "babylonjs/Collisions/collider";
  22110. import { Material } from "babylonjs/Materials/material";
  22111. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22113. import { Mesh } from "babylonjs/Meshes/mesh";
  22114. import { Ray } from "babylonjs/Culling/ray";
  22115. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22116. /**
  22117. * Base class for submeshes
  22118. */
  22119. export class BaseSubMesh {
  22120. /** @hidden */
  22121. _materialDefines: Nullable<MaterialDefines>;
  22122. /** @hidden */
  22123. _materialEffect: Nullable<Effect>;
  22124. /**
  22125. * Gets material defines used by the effect associated to the sub mesh
  22126. */
  22127. get materialDefines(): Nullable<MaterialDefines>;
  22128. /**
  22129. * Sets material defines used by the effect associated to the sub mesh
  22130. */
  22131. set materialDefines(defines: Nullable<MaterialDefines>);
  22132. /**
  22133. * Gets associated effect
  22134. */
  22135. get effect(): Nullable<Effect>;
  22136. /**
  22137. * Sets associated effect (effect used to render this submesh)
  22138. * @param effect defines the effect to associate with
  22139. * @param defines defines the set of defines used to compile this effect
  22140. */
  22141. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22142. }
  22143. /**
  22144. * Defines a subdivision inside a mesh
  22145. */
  22146. export class SubMesh extends BaseSubMesh implements ICullable {
  22147. /** the material index to use */
  22148. materialIndex: number;
  22149. /** vertex index start */
  22150. verticesStart: number;
  22151. /** vertices count */
  22152. verticesCount: number;
  22153. /** index start */
  22154. indexStart: number;
  22155. /** indices count */
  22156. indexCount: number;
  22157. /** @hidden */
  22158. _linesIndexCount: number;
  22159. private _mesh;
  22160. private _renderingMesh;
  22161. private _boundingInfo;
  22162. private _linesIndexBuffer;
  22163. /** @hidden */
  22164. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22165. /** @hidden */
  22166. _trianglePlanes: Plane[];
  22167. /** @hidden */
  22168. _lastColliderTransformMatrix: Nullable<Matrix>;
  22169. /** @hidden */
  22170. _renderId: number;
  22171. /** @hidden */
  22172. _alphaIndex: number;
  22173. /** @hidden */
  22174. _distanceToCamera: number;
  22175. /** @hidden */
  22176. _id: number;
  22177. private _currentMaterial;
  22178. /**
  22179. * Add a new submesh to a mesh
  22180. * @param materialIndex defines the material index to use
  22181. * @param verticesStart defines vertex index start
  22182. * @param verticesCount defines vertices count
  22183. * @param indexStart defines index start
  22184. * @param indexCount defines indices count
  22185. * @param mesh defines the parent mesh
  22186. * @param renderingMesh defines an optional rendering mesh
  22187. * @param createBoundingBox defines if bounding box should be created for this submesh
  22188. * @returns the new submesh
  22189. */
  22190. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22191. /**
  22192. * Creates a new submesh
  22193. * @param materialIndex defines the material index to use
  22194. * @param verticesStart defines vertex index start
  22195. * @param verticesCount defines vertices count
  22196. * @param indexStart defines index start
  22197. * @param indexCount defines indices count
  22198. * @param mesh defines the parent mesh
  22199. * @param renderingMesh defines an optional rendering mesh
  22200. * @param createBoundingBox defines if bounding box should be created for this submesh
  22201. */
  22202. constructor(
  22203. /** the material index to use */
  22204. materialIndex: number,
  22205. /** vertex index start */
  22206. verticesStart: number,
  22207. /** vertices count */
  22208. verticesCount: number,
  22209. /** index start */
  22210. indexStart: number,
  22211. /** indices count */
  22212. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22213. /**
  22214. * Returns true if this submesh covers the entire parent mesh
  22215. * @ignorenaming
  22216. */
  22217. get IsGlobal(): boolean;
  22218. /**
  22219. * Returns the submesh BoudingInfo object
  22220. * @returns current bounding info (or mesh's one if the submesh is global)
  22221. */
  22222. getBoundingInfo(): BoundingInfo;
  22223. /**
  22224. * Sets the submesh BoundingInfo
  22225. * @param boundingInfo defines the new bounding info to use
  22226. * @returns the SubMesh
  22227. */
  22228. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22229. /**
  22230. * Returns the mesh of the current submesh
  22231. * @return the parent mesh
  22232. */
  22233. getMesh(): AbstractMesh;
  22234. /**
  22235. * Returns the rendering mesh of the submesh
  22236. * @returns the rendering mesh (could be different from parent mesh)
  22237. */
  22238. getRenderingMesh(): Mesh;
  22239. /**
  22240. * Returns the submesh material
  22241. * @returns null or the current material
  22242. */
  22243. getMaterial(): Nullable<Material>;
  22244. /**
  22245. * Sets a new updated BoundingInfo object to the submesh
  22246. * @param data defines an optional position array to use to determine the bounding info
  22247. * @returns the SubMesh
  22248. */
  22249. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22250. /** @hidden */
  22251. _checkCollision(collider: Collider): boolean;
  22252. /**
  22253. * Updates the submesh BoundingInfo
  22254. * @param world defines the world matrix to use to update the bounding info
  22255. * @returns the submesh
  22256. */
  22257. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22258. /**
  22259. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22260. * @param frustumPlanes defines the frustum planes
  22261. * @returns true if the submesh is intersecting with the frustum
  22262. */
  22263. isInFrustum(frustumPlanes: Plane[]): boolean;
  22264. /**
  22265. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22266. * @param frustumPlanes defines the frustum planes
  22267. * @returns true if the submesh is inside the frustum
  22268. */
  22269. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22270. /**
  22271. * Renders the submesh
  22272. * @param enableAlphaMode defines if alpha needs to be used
  22273. * @returns the submesh
  22274. */
  22275. render(enableAlphaMode: boolean): SubMesh;
  22276. /**
  22277. * @hidden
  22278. */
  22279. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22280. /**
  22281. * Checks if the submesh intersects with a ray
  22282. * @param ray defines the ray to test
  22283. * @returns true is the passed ray intersects the submesh bounding box
  22284. */
  22285. canIntersects(ray: Ray): boolean;
  22286. /**
  22287. * Intersects current submesh with a ray
  22288. * @param ray defines the ray to test
  22289. * @param positions defines mesh's positions array
  22290. * @param indices defines mesh's indices array
  22291. * @param fastCheck defines if only bounding info should be used
  22292. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22293. * @returns intersection info or null if no intersection
  22294. */
  22295. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22296. /** @hidden */
  22297. private _intersectLines;
  22298. /** @hidden */
  22299. private _intersectUnIndexedLines;
  22300. /** @hidden */
  22301. private _intersectTriangles;
  22302. /** @hidden */
  22303. private _intersectUnIndexedTriangles;
  22304. /** @hidden */
  22305. _rebuild(): void;
  22306. /**
  22307. * Creates a new submesh from the passed mesh
  22308. * @param newMesh defines the new hosting mesh
  22309. * @param newRenderingMesh defines an optional rendering mesh
  22310. * @returns the new submesh
  22311. */
  22312. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22313. /**
  22314. * Release associated resources
  22315. */
  22316. dispose(): void;
  22317. /**
  22318. * Gets the class name
  22319. * @returns the string "SubMesh".
  22320. */
  22321. getClassName(): string;
  22322. /**
  22323. * Creates a new submesh from indices data
  22324. * @param materialIndex the index of the main mesh material
  22325. * @param startIndex the index where to start the copy in the mesh indices array
  22326. * @param indexCount the number of indices to copy then from the startIndex
  22327. * @param mesh the main mesh to create the submesh from
  22328. * @param renderingMesh the optional rendering mesh
  22329. * @returns a new submesh
  22330. */
  22331. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22332. }
  22333. }
  22334. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22335. /**
  22336. * Class used to represent data loading progression
  22337. */
  22338. export class SceneLoaderFlags {
  22339. private static _ForceFullSceneLoadingForIncremental;
  22340. private static _ShowLoadingScreen;
  22341. private static _CleanBoneMatrixWeights;
  22342. private static _loggingLevel;
  22343. /**
  22344. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22345. */
  22346. static get ForceFullSceneLoadingForIncremental(): boolean;
  22347. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22348. /**
  22349. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22350. */
  22351. static get ShowLoadingScreen(): boolean;
  22352. static set ShowLoadingScreen(value: boolean);
  22353. /**
  22354. * Defines the current logging level (while loading the scene)
  22355. * @ignorenaming
  22356. */
  22357. static get loggingLevel(): number;
  22358. static set loggingLevel(value: number);
  22359. /**
  22360. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22361. */
  22362. static get CleanBoneMatrixWeights(): boolean;
  22363. static set CleanBoneMatrixWeights(value: boolean);
  22364. }
  22365. }
  22366. declare module "babylonjs/Meshes/geometry" {
  22367. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22368. import { Scene } from "babylonjs/scene";
  22369. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22370. import { Engine } from "babylonjs/Engines/engine";
  22371. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22372. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22373. import { Effect } from "babylonjs/Materials/effect";
  22374. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22375. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22376. import { Mesh } from "babylonjs/Meshes/mesh";
  22377. /**
  22378. * Class used to store geometry data (vertex buffers + index buffer)
  22379. */
  22380. export class Geometry implements IGetSetVerticesData {
  22381. /**
  22382. * Gets or sets the ID of the geometry
  22383. */
  22384. id: string;
  22385. /**
  22386. * Gets or sets the unique ID of the geometry
  22387. */
  22388. uniqueId: number;
  22389. /**
  22390. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22391. */
  22392. delayLoadState: number;
  22393. /**
  22394. * Gets the file containing the data to load when running in delay load state
  22395. */
  22396. delayLoadingFile: Nullable<string>;
  22397. /**
  22398. * Callback called when the geometry is updated
  22399. */
  22400. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22401. private _scene;
  22402. private _engine;
  22403. private _meshes;
  22404. private _totalVertices;
  22405. /** @hidden */
  22406. _indices: IndicesArray;
  22407. /** @hidden */
  22408. _vertexBuffers: {
  22409. [key: string]: VertexBuffer;
  22410. };
  22411. private _isDisposed;
  22412. private _extend;
  22413. private _boundingBias;
  22414. /** @hidden */
  22415. _delayInfo: Array<string>;
  22416. private _indexBuffer;
  22417. private _indexBufferIsUpdatable;
  22418. /** @hidden */
  22419. _boundingInfo: Nullable<BoundingInfo>;
  22420. /** @hidden */
  22421. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22422. /** @hidden */
  22423. _softwareSkinningFrameId: number;
  22424. private _vertexArrayObjects;
  22425. private _updatable;
  22426. /** @hidden */
  22427. _positions: Nullable<Vector3[]>;
  22428. /**
  22429. * 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
  22430. */
  22431. get boundingBias(): Vector2;
  22432. /**
  22433. * 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
  22434. */
  22435. set boundingBias(value: Vector2);
  22436. /**
  22437. * Static function used to attach a new empty geometry to a mesh
  22438. * @param mesh defines the mesh to attach the geometry to
  22439. * @returns the new Geometry
  22440. */
  22441. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22442. /**
  22443. * Creates a new geometry
  22444. * @param id defines the unique ID
  22445. * @param scene defines the hosting scene
  22446. * @param vertexData defines the VertexData used to get geometry data
  22447. * @param updatable defines if geometry must be updatable (false by default)
  22448. * @param mesh defines the mesh that will be associated with the geometry
  22449. */
  22450. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22451. /**
  22452. * Gets the current extend of the geometry
  22453. */
  22454. get extend(): {
  22455. minimum: Vector3;
  22456. maximum: Vector3;
  22457. };
  22458. /**
  22459. * Gets the hosting scene
  22460. * @returns the hosting Scene
  22461. */
  22462. getScene(): Scene;
  22463. /**
  22464. * Gets the hosting engine
  22465. * @returns the hosting Engine
  22466. */
  22467. getEngine(): Engine;
  22468. /**
  22469. * Defines if the geometry is ready to use
  22470. * @returns true if the geometry is ready to be used
  22471. */
  22472. isReady(): boolean;
  22473. /**
  22474. * Gets a value indicating that the geometry should not be serialized
  22475. */
  22476. get doNotSerialize(): boolean;
  22477. /** @hidden */
  22478. _rebuild(): void;
  22479. /**
  22480. * Affects all geometry data in one call
  22481. * @param vertexData defines the geometry data
  22482. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22483. */
  22484. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22485. /**
  22486. * Set specific vertex data
  22487. * @param kind defines the data kind (Position, normal, etc...)
  22488. * @param data defines the vertex data to use
  22489. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22490. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22491. */
  22492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22493. /**
  22494. * Removes a specific vertex data
  22495. * @param kind defines the data kind (Position, normal, etc...)
  22496. */
  22497. removeVerticesData(kind: string): void;
  22498. /**
  22499. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22500. * @param buffer defines the vertex buffer to use
  22501. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22502. */
  22503. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22504. /**
  22505. * Update a specific vertex buffer
  22506. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22507. * It will do nothing if the buffer is not updatable
  22508. * @param kind defines the data kind (Position, normal, etc...)
  22509. * @param data defines the data to use
  22510. * @param offset defines the offset in the target buffer where to store the data
  22511. * @param useBytes set to true if the offset is in bytes
  22512. */
  22513. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22514. /**
  22515. * Update a specific vertex buffer
  22516. * This function will create a new buffer if the current one is not updatable
  22517. * @param kind defines the data kind (Position, normal, etc...)
  22518. * @param data defines the data to use
  22519. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22520. */
  22521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22522. private _updateBoundingInfo;
  22523. /** @hidden */
  22524. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22525. /**
  22526. * Gets total number of vertices
  22527. * @returns the total number of vertices
  22528. */
  22529. getTotalVertices(): number;
  22530. /**
  22531. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22532. * @param kind defines the data kind (Position, normal, etc...)
  22533. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22534. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22535. * @returns a float array containing vertex data
  22536. */
  22537. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22538. /**
  22539. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22540. * @param kind defines the data kind (Position, normal, etc...)
  22541. * @returns true if the vertex buffer with the specified kind is updatable
  22542. */
  22543. isVertexBufferUpdatable(kind: string): boolean;
  22544. /**
  22545. * Gets a specific vertex buffer
  22546. * @param kind defines the data kind (Position, normal, etc...)
  22547. * @returns a VertexBuffer
  22548. */
  22549. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22550. /**
  22551. * Returns all vertex buffers
  22552. * @return an object holding all vertex buffers indexed by kind
  22553. */
  22554. getVertexBuffers(): Nullable<{
  22555. [key: string]: VertexBuffer;
  22556. }>;
  22557. /**
  22558. * Gets a boolean indicating if specific vertex buffer is present
  22559. * @param kind defines the data kind (Position, normal, etc...)
  22560. * @returns true if data is present
  22561. */
  22562. isVerticesDataPresent(kind: string): boolean;
  22563. /**
  22564. * Gets a list of all attached data kinds (Position, normal, etc...)
  22565. * @returns a list of string containing all kinds
  22566. */
  22567. getVerticesDataKinds(): string[];
  22568. /**
  22569. * Update index buffer
  22570. * @param indices defines the indices to store in the index buffer
  22571. * @param offset defines the offset in the target buffer where to store the data
  22572. * @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)
  22573. */
  22574. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22575. /**
  22576. * Creates a new index buffer
  22577. * @param indices defines the indices to store in the index buffer
  22578. * @param totalVertices defines the total number of vertices (could be null)
  22579. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22580. */
  22581. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22582. /**
  22583. * Return the total number of indices
  22584. * @returns the total number of indices
  22585. */
  22586. getTotalIndices(): number;
  22587. /**
  22588. * Gets the index buffer array
  22589. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22590. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22591. * @returns the index buffer array
  22592. */
  22593. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22594. /**
  22595. * Gets the index buffer
  22596. * @return the index buffer
  22597. */
  22598. getIndexBuffer(): Nullable<DataBuffer>;
  22599. /** @hidden */
  22600. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22601. /**
  22602. * Release the associated resources for a specific mesh
  22603. * @param mesh defines the source mesh
  22604. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22605. */
  22606. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22607. /**
  22608. * Apply current geometry to a given mesh
  22609. * @param mesh defines the mesh to apply geometry to
  22610. */
  22611. applyToMesh(mesh: Mesh): void;
  22612. private _updateExtend;
  22613. private _applyToMesh;
  22614. private notifyUpdate;
  22615. /**
  22616. * Load the geometry if it was flagged as delay loaded
  22617. * @param scene defines the hosting scene
  22618. * @param onLoaded defines a callback called when the geometry is loaded
  22619. */
  22620. load(scene: Scene, onLoaded?: () => void): void;
  22621. private _queueLoad;
  22622. /**
  22623. * Invert the geometry to move from a right handed system to a left handed one.
  22624. */
  22625. toLeftHanded(): void;
  22626. /** @hidden */
  22627. _resetPointsArrayCache(): void;
  22628. /** @hidden */
  22629. _generatePointsArray(): boolean;
  22630. /**
  22631. * Gets a value indicating if the geometry is disposed
  22632. * @returns true if the geometry was disposed
  22633. */
  22634. isDisposed(): boolean;
  22635. private _disposeVertexArrayObjects;
  22636. /**
  22637. * Free all associated resources
  22638. */
  22639. dispose(): void;
  22640. /**
  22641. * Clone the current geometry into a new geometry
  22642. * @param id defines the unique ID of the new geometry
  22643. * @returns a new geometry object
  22644. */
  22645. copy(id: string): Geometry;
  22646. /**
  22647. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22648. * @return a JSON representation of the current geometry data (without the vertices data)
  22649. */
  22650. serialize(): any;
  22651. private toNumberArray;
  22652. /**
  22653. * Serialize all vertices data into a JSON oject
  22654. * @returns a JSON representation of the current geometry data
  22655. */
  22656. serializeVerticeData(): any;
  22657. /**
  22658. * Extracts a clone of a mesh geometry
  22659. * @param mesh defines the source mesh
  22660. * @param id defines the unique ID of the new geometry object
  22661. * @returns the new geometry object
  22662. */
  22663. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22664. /**
  22665. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22666. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22667. * Be aware Math.random() could cause collisions, but:
  22668. * "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"
  22669. * @returns a string containing a new GUID
  22670. */
  22671. static RandomId(): string;
  22672. /** @hidden */
  22673. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22674. private static _CleanMatricesWeights;
  22675. /**
  22676. * Create a new geometry from persisted data (Using .babylon file format)
  22677. * @param parsedVertexData defines the persisted data
  22678. * @param scene defines the hosting scene
  22679. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22680. * @returns the new geometry object
  22681. */
  22682. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22683. }
  22684. }
  22685. declare module "babylonjs/Meshes/mesh.vertexData" {
  22686. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22687. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22688. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22689. import { Geometry } from "babylonjs/Meshes/geometry";
  22690. import { Mesh } from "babylonjs/Meshes/mesh";
  22691. /**
  22692. * Define an interface for all classes that will get and set the data on vertices
  22693. */
  22694. export interface IGetSetVerticesData {
  22695. /**
  22696. * Gets a boolean indicating if specific vertex data is present
  22697. * @param kind defines the vertex data kind to use
  22698. * @returns true is data kind is present
  22699. */
  22700. isVerticesDataPresent(kind: string): boolean;
  22701. /**
  22702. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22703. * @param kind defines the data kind (Position, normal, etc...)
  22704. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22706. * @returns a float array containing vertex data
  22707. */
  22708. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22709. /**
  22710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22711. * @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.
  22712. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22713. * @returns the indices array or an empty array if the mesh has no geometry
  22714. */
  22715. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22716. /**
  22717. * Set specific vertex data
  22718. * @param kind defines the data kind (Position, normal, etc...)
  22719. * @param data defines the vertex data to use
  22720. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22721. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22722. */
  22723. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22724. /**
  22725. * Update a specific associated vertex buffer
  22726. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22727. * - VertexBuffer.PositionKind
  22728. * - VertexBuffer.UVKind
  22729. * - VertexBuffer.UV2Kind
  22730. * - VertexBuffer.UV3Kind
  22731. * - VertexBuffer.UV4Kind
  22732. * - VertexBuffer.UV5Kind
  22733. * - VertexBuffer.UV6Kind
  22734. * - VertexBuffer.ColorKind
  22735. * - VertexBuffer.MatricesIndicesKind
  22736. * - VertexBuffer.MatricesIndicesExtraKind
  22737. * - VertexBuffer.MatricesWeightsKind
  22738. * - VertexBuffer.MatricesWeightsExtraKind
  22739. * @param data defines the data source
  22740. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22741. * @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)
  22742. */
  22743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22744. /**
  22745. * Creates a new index buffer
  22746. * @param indices defines the indices to store in the index buffer
  22747. * @param totalVertices defines the total number of vertices (could be null)
  22748. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22749. */
  22750. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22751. }
  22752. /**
  22753. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22754. */
  22755. export class VertexData {
  22756. /**
  22757. * Mesh side orientation : usually the external or front surface
  22758. */
  22759. static readonly FRONTSIDE: number;
  22760. /**
  22761. * Mesh side orientation : usually the internal or back surface
  22762. */
  22763. static readonly BACKSIDE: number;
  22764. /**
  22765. * Mesh side orientation : both internal and external or front and back surfaces
  22766. */
  22767. static readonly DOUBLESIDE: number;
  22768. /**
  22769. * Mesh side orientation : by default, `FRONTSIDE`
  22770. */
  22771. static readonly DEFAULTSIDE: number;
  22772. /**
  22773. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22774. */
  22775. positions: Nullable<FloatArray>;
  22776. /**
  22777. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22778. */
  22779. normals: Nullable<FloatArray>;
  22780. /**
  22781. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22782. */
  22783. tangents: Nullable<FloatArray>;
  22784. /**
  22785. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22786. */
  22787. uvs: Nullable<FloatArray>;
  22788. /**
  22789. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22790. */
  22791. uvs2: Nullable<FloatArray>;
  22792. /**
  22793. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22794. */
  22795. uvs3: Nullable<FloatArray>;
  22796. /**
  22797. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22798. */
  22799. uvs4: Nullable<FloatArray>;
  22800. /**
  22801. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22802. */
  22803. uvs5: Nullable<FloatArray>;
  22804. /**
  22805. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22806. */
  22807. uvs6: Nullable<FloatArray>;
  22808. /**
  22809. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22810. */
  22811. colors: Nullable<FloatArray>;
  22812. /**
  22813. * 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).
  22814. */
  22815. matricesIndices: Nullable<FloatArray>;
  22816. /**
  22817. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22818. */
  22819. matricesWeights: Nullable<FloatArray>;
  22820. /**
  22821. * An array extending the number of possible indices
  22822. */
  22823. matricesIndicesExtra: Nullable<FloatArray>;
  22824. /**
  22825. * An array extending the number of possible weights when the number of indices is extended
  22826. */
  22827. matricesWeightsExtra: Nullable<FloatArray>;
  22828. /**
  22829. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22830. */
  22831. indices: Nullable<IndicesArray>;
  22832. /**
  22833. * Uses the passed data array to set the set the values for the specified kind of data
  22834. * @param data a linear array of floating numbers
  22835. * @param kind the type of data that is being set, eg positions, colors etc
  22836. */
  22837. set(data: FloatArray, kind: string): void;
  22838. /**
  22839. * Associates the vertexData to the passed Mesh.
  22840. * Sets it as updatable or not (default `false`)
  22841. * @param mesh the mesh the vertexData is applied to
  22842. * @param updatable when used and having the value true allows new data to update the vertexData
  22843. * @returns the VertexData
  22844. */
  22845. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22846. /**
  22847. * Associates the vertexData to the passed Geometry.
  22848. * Sets it as updatable or not (default `false`)
  22849. * @param geometry the geometry the vertexData is applied to
  22850. * @param updatable when used and having the value true allows new data to update the vertexData
  22851. * @returns VertexData
  22852. */
  22853. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22854. /**
  22855. * Updates the associated mesh
  22856. * @param mesh the mesh to be updated
  22857. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22858. * @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
  22859. * @returns VertexData
  22860. */
  22861. updateMesh(mesh: Mesh): VertexData;
  22862. /**
  22863. * Updates the associated geometry
  22864. * @param geometry the geometry to be updated
  22865. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22866. * @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
  22867. * @returns VertexData.
  22868. */
  22869. updateGeometry(geometry: Geometry): VertexData;
  22870. private _applyTo;
  22871. private _update;
  22872. /**
  22873. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22874. * @param matrix the transforming matrix
  22875. * @returns the VertexData
  22876. */
  22877. transform(matrix: Matrix): VertexData;
  22878. /**
  22879. * Merges the passed VertexData into the current one
  22880. * @param other the VertexData to be merged into the current one
  22881. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22882. * @returns the modified VertexData
  22883. */
  22884. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22885. private _mergeElement;
  22886. private _validate;
  22887. /**
  22888. * Serializes the VertexData
  22889. * @returns a serialized object
  22890. */
  22891. serialize(): any;
  22892. /**
  22893. * Extracts the vertexData from a mesh
  22894. * @param mesh the mesh from which to extract the VertexData
  22895. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22896. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22897. * @returns the object VertexData associated to the passed mesh
  22898. */
  22899. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22900. /**
  22901. * Extracts the vertexData from the geometry
  22902. * @param geometry the geometry from which to extract the VertexData
  22903. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22904. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22905. * @returns the object VertexData associated to the passed mesh
  22906. */
  22907. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22908. private static _ExtractFrom;
  22909. /**
  22910. * Creates the VertexData for a Ribbon
  22911. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22912. * * pathArray array of paths, each of which an array of successive Vector3
  22913. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22914. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22915. * * 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
  22916. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22917. * * 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)
  22918. * * 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)
  22919. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22920. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22921. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22922. * @returns the VertexData of the ribbon
  22923. */
  22924. static CreateRibbon(options: {
  22925. pathArray: Vector3[][];
  22926. closeArray?: boolean;
  22927. closePath?: boolean;
  22928. offset?: number;
  22929. sideOrientation?: number;
  22930. frontUVs?: Vector4;
  22931. backUVs?: Vector4;
  22932. invertUV?: boolean;
  22933. uvs?: Vector2[];
  22934. colors?: Color4[];
  22935. }): VertexData;
  22936. /**
  22937. * Creates the VertexData for a box
  22938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22939. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22940. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22941. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22942. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22943. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22944. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22946. * * 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)
  22947. * * 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)
  22948. * @returns the VertexData of the box
  22949. */
  22950. static CreateBox(options: {
  22951. size?: number;
  22952. width?: number;
  22953. height?: number;
  22954. depth?: number;
  22955. faceUV?: Vector4[];
  22956. faceColors?: Color4[];
  22957. sideOrientation?: number;
  22958. frontUVs?: Vector4;
  22959. backUVs?: Vector4;
  22960. }): VertexData;
  22961. /**
  22962. * Creates the VertexData for a tiled box
  22963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22964. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22965. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22966. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22968. * @returns the VertexData of the box
  22969. */
  22970. static CreateTiledBox(options: {
  22971. pattern?: number;
  22972. width?: number;
  22973. height?: number;
  22974. depth?: number;
  22975. tileSize?: number;
  22976. tileWidth?: number;
  22977. tileHeight?: number;
  22978. alignHorizontal?: number;
  22979. alignVertical?: number;
  22980. faceUV?: Vector4[];
  22981. faceColors?: Color4[];
  22982. sideOrientation?: number;
  22983. }): VertexData;
  22984. /**
  22985. * Creates the VertexData for a tiled plane
  22986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22987. * * pattern a limited pattern arrangement depending on the number
  22988. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22989. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22990. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22992. * * 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)
  22993. * * 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)
  22994. * @returns the VertexData of the tiled plane
  22995. */
  22996. static CreateTiledPlane(options: {
  22997. pattern?: number;
  22998. tileSize?: number;
  22999. tileWidth?: number;
  23000. tileHeight?: number;
  23001. size?: number;
  23002. width?: number;
  23003. height?: number;
  23004. alignHorizontal?: number;
  23005. alignVertical?: number;
  23006. sideOrientation?: number;
  23007. frontUVs?: Vector4;
  23008. backUVs?: Vector4;
  23009. }): VertexData;
  23010. /**
  23011. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23013. * * segments sets the number of horizontal strips optional, default 32
  23014. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23015. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23016. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23017. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23018. * * 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
  23019. * * 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
  23020. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23021. * * 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)
  23022. * * 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)
  23023. * @returns the VertexData of the ellipsoid
  23024. */
  23025. static CreateSphere(options: {
  23026. segments?: number;
  23027. diameter?: number;
  23028. diameterX?: number;
  23029. diameterY?: number;
  23030. diameterZ?: number;
  23031. arc?: number;
  23032. slice?: number;
  23033. sideOrientation?: number;
  23034. frontUVs?: Vector4;
  23035. backUVs?: Vector4;
  23036. }): VertexData;
  23037. /**
  23038. * Creates the VertexData for a cylinder, cone or prism
  23039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23040. * * height sets the height (y direction) of the cylinder, optional, default 2
  23041. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23042. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23043. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23044. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23045. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23046. * * 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
  23047. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23048. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23049. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23050. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23052. * * 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)
  23053. * * 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)
  23054. * @returns the VertexData of the cylinder, cone or prism
  23055. */
  23056. static CreateCylinder(options: {
  23057. height?: number;
  23058. diameterTop?: number;
  23059. diameterBottom?: number;
  23060. diameter?: number;
  23061. tessellation?: number;
  23062. subdivisions?: number;
  23063. arc?: number;
  23064. faceColors?: Color4[];
  23065. faceUV?: Vector4[];
  23066. hasRings?: boolean;
  23067. enclose?: boolean;
  23068. sideOrientation?: number;
  23069. frontUVs?: Vector4;
  23070. backUVs?: Vector4;
  23071. }): VertexData;
  23072. /**
  23073. * Creates the VertexData for a torus
  23074. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23075. * * diameter the diameter of the torus, optional default 1
  23076. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23077. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23079. * * 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)
  23080. * * 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)
  23081. * @returns the VertexData of the torus
  23082. */
  23083. static CreateTorus(options: {
  23084. diameter?: number;
  23085. thickness?: number;
  23086. tessellation?: number;
  23087. sideOrientation?: number;
  23088. frontUVs?: Vector4;
  23089. backUVs?: Vector4;
  23090. }): VertexData;
  23091. /**
  23092. * Creates the VertexData of the LineSystem
  23093. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23094. * - lines an array of lines, each line being an array of successive Vector3
  23095. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23096. * @returns the VertexData of the LineSystem
  23097. */
  23098. static CreateLineSystem(options: {
  23099. lines: Vector3[][];
  23100. colors?: Nullable<Color4[][]>;
  23101. }): VertexData;
  23102. /**
  23103. * Create the VertexData for a DashedLines
  23104. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23105. * - points an array successive Vector3
  23106. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23107. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23108. * - dashNb the intended total number of dashes, optional, default 200
  23109. * @returns the VertexData for the DashedLines
  23110. */
  23111. static CreateDashedLines(options: {
  23112. points: Vector3[];
  23113. dashSize?: number;
  23114. gapSize?: number;
  23115. dashNb?: number;
  23116. }): VertexData;
  23117. /**
  23118. * Creates the VertexData for a Ground
  23119. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23120. * - width the width (x direction) of the ground, optional, default 1
  23121. * - height the height (z direction) of the ground, optional, default 1
  23122. * - subdivisions the number of subdivisions per side, optional, default 1
  23123. * @returns the VertexData of the Ground
  23124. */
  23125. static CreateGround(options: {
  23126. width?: number;
  23127. height?: number;
  23128. subdivisions?: number;
  23129. subdivisionsX?: number;
  23130. subdivisionsY?: number;
  23131. }): VertexData;
  23132. /**
  23133. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23134. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23135. * * xmin the ground minimum X coordinate, optional, default -1
  23136. * * zmin the ground minimum Z coordinate, optional, default -1
  23137. * * xmax the ground maximum X coordinate, optional, default 1
  23138. * * zmax the ground maximum Z coordinate, optional, default 1
  23139. * * 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}
  23140. * * 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}
  23141. * @returns the VertexData of the TiledGround
  23142. */
  23143. static CreateTiledGround(options: {
  23144. xmin: number;
  23145. zmin: number;
  23146. xmax: number;
  23147. zmax: number;
  23148. subdivisions?: {
  23149. w: number;
  23150. h: number;
  23151. };
  23152. precision?: {
  23153. w: number;
  23154. h: number;
  23155. };
  23156. }): VertexData;
  23157. /**
  23158. * Creates the VertexData of the Ground designed from a heightmap
  23159. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23160. * * width the width (x direction) of the ground
  23161. * * height the height (z direction) of the ground
  23162. * * subdivisions the number of subdivisions per side
  23163. * * minHeight the minimum altitude on the ground, optional, default 0
  23164. * * maxHeight the maximum altitude on the ground, optional default 1
  23165. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23166. * * buffer the array holding the image color data
  23167. * * bufferWidth the width of image
  23168. * * bufferHeight the height of image
  23169. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23170. * @returns the VertexData of the Ground designed from a heightmap
  23171. */
  23172. static CreateGroundFromHeightMap(options: {
  23173. width: number;
  23174. height: number;
  23175. subdivisions: number;
  23176. minHeight: number;
  23177. maxHeight: number;
  23178. colorFilter: Color3;
  23179. buffer: Uint8Array;
  23180. bufferWidth: number;
  23181. bufferHeight: number;
  23182. alphaFilter: number;
  23183. }): VertexData;
  23184. /**
  23185. * Creates the VertexData for a Plane
  23186. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23187. * * size sets the width and height of the plane to the value of size, optional default 1
  23188. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23189. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23191. * * 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)
  23192. * * 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)
  23193. * @returns the VertexData of the box
  23194. */
  23195. static CreatePlane(options: {
  23196. size?: number;
  23197. width?: number;
  23198. height?: number;
  23199. sideOrientation?: number;
  23200. frontUVs?: Vector4;
  23201. backUVs?: Vector4;
  23202. }): VertexData;
  23203. /**
  23204. * Creates the VertexData of the Disc or regular Polygon
  23205. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23206. * * radius the radius of the disc, optional default 0.5
  23207. * * tessellation the number of polygon sides, optional, default 64
  23208. * * 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
  23209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23210. * * 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)
  23211. * * 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)
  23212. * @returns the VertexData of the box
  23213. */
  23214. static CreateDisc(options: {
  23215. radius?: number;
  23216. tessellation?: number;
  23217. arc?: number;
  23218. sideOrientation?: number;
  23219. frontUVs?: Vector4;
  23220. backUVs?: Vector4;
  23221. }): VertexData;
  23222. /**
  23223. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23224. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23225. * @param polygon a mesh built from polygonTriangulation.build()
  23226. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23227. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23228. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23229. * @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)
  23230. * @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)
  23231. * @returns the VertexData of the Polygon
  23232. */
  23233. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23234. /**
  23235. * Creates the VertexData of the IcoSphere
  23236. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23237. * * radius the radius of the IcoSphere, optional default 1
  23238. * * radiusX allows stretching in the x direction, optional, default radius
  23239. * * radiusY allows stretching in the y direction, optional, default radius
  23240. * * radiusZ allows stretching in the z direction, optional, default radius
  23241. * * flat when true creates a flat shaded mesh, optional, default true
  23242. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23244. * * 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)
  23245. * * 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)
  23246. * @returns the VertexData of the IcoSphere
  23247. */
  23248. static CreateIcoSphere(options: {
  23249. radius?: number;
  23250. radiusX?: number;
  23251. radiusY?: number;
  23252. radiusZ?: number;
  23253. flat?: boolean;
  23254. subdivisions?: number;
  23255. sideOrientation?: number;
  23256. frontUVs?: Vector4;
  23257. backUVs?: Vector4;
  23258. }): VertexData;
  23259. /**
  23260. * Creates the VertexData for a Polyhedron
  23261. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23262. * * type provided types are:
  23263. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23264. * * 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)
  23265. * * size the size of the IcoSphere, optional default 1
  23266. * * sizeX allows stretching in the x direction, optional, default size
  23267. * * sizeY allows stretching in the y direction, optional, default size
  23268. * * sizeZ allows stretching in the z direction, optional, default size
  23269. * * 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
  23270. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23271. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23272. * * flat when true creates a flat shaded mesh, optional, default true
  23273. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23275. * * 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)
  23276. * * 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)
  23277. * @returns the VertexData of the Polyhedron
  23278. */
  23279. static CreatePolyhedron(options: {
  23280. type?: number;
  23281. size?: number;
  23282. sizeX?: number;
  23283. sizeY?: number;
  23284. sizeZ?: number;
  23285. custom?: any;
  23286. faceUV?: Vector4[];
  23287. faceColors?: Color4[];
  23288. flat?: boolean;
  23289. sideOrientation?: number;
  23290. frontUVs?: Vector4;
  23291. backUVs?: Vector4;
  23292. }): VertexData;
  23293. /**
  23294. * Creates the VertexData for a TorusKnot
  23295. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23296. * * radius the radius of the torus knot, optional, default 2
  23297. * * tube the thickness of the tube, optional, default 0.5
  23298. * * radialSegments the number of sides on each tube segments, optional, default 32
  23299. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23300. * * p the number of windings around the z axis, optional, default 2
  23301. * * q the number of windings around the x axis, optional, default 3
  23302. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23303. * * 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)
  23304. * * 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)
  23305. * @returns the VertexData of the Torus Knot
  23306. */
  23307. static CreateTorusKnot(options: {
  23308. radius?: number;
  23309. tube?: number;
  23310. radialSegments?: number;
  23311. tubularSegments?: number;
  23312. p?: number;
  23313. q?: number;
  23314. sideOrientation?: number;
  23315. frontUVs?: Vector4;
  23316. backUVs?: Vector4;
  23317. }): VertexData;
  23318. /**
  23319. * Compute normals for given positions and indices
  23320. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23321. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23322. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23323. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23324. * * facetNormals : optional array of facet normals (vector3)
  23325. * * facetPositions : optional array of facet positions (vector3)
  23326. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23327. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23328. * * bInfo : optional bounding info, required for facetPartitioning computation
  23329. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23330. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23331. * * useRightHandedSystem: optional boolean to for right handed system computation
  23332. * * depthSort : optional boolean to enable the facet depth sort computation
  23333. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23334. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23335. */
  23336. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23337. facetNormals?: any;
  23338. facetPositions?: any;
  23339. facetPartitioning?: any;
  23340. ratio?: number;
  23341. bInfo?: any;
  23342. bbSize?: Vector3;
  23343. subDiv?: any;
  23344. useRightHandedSystem?: boolean;
  23345. depthSort?: boolean;
  23346. distanceTo?: Vector3;
  23347. depthSortedFacets?: any;
  23348. }): void;
  23349. /** @hidden */
  23350. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23351. /**
  23352. * Applies VertexData created from the imported parameters to the geometry
  23353. * @param parsedVertexData the parsed data from an imported file
  23354. * @param geometry the geometry to apply the VertexData to
  23355. */
  23356. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23357. }
  23358. }
  23359. declare module "babylonjs/Morph/morphTarget" {
  23360. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23361. import { Observable } from "babylonjs/Misc/observable";
  23362. import { Nullable, FloatArray } from "babylonjs/types";
  23363. import { Scene } from "babylonjs/scene";
  23364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23365. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23366. /**
  23367. * Defines a target to use with MorphTargetManager
  23368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23369. */
  23370. export class MorphTarget implements IAnimatable {
  23371. /** defines the name of the target */
  23372. name: string;
  23373. /**
  23374. * Gets or sets the list of animations
  23375. */
  23376. animations: import("babylonjs/Animations/animation").Animation[];
  23377. private _scene;
  23378. private _positions;
  23379. private _normals;
  23380. private _tangents;
  23381. private _uvs;
  23382. private _influence;
  23383. private _uniqueId;
  23384. /**
  23385. * Observable raised when the influence changes
  23386. */
  23387. onInfluenceChanged: Observable<boolean>;
  23388. /** @hidden */
  23389. _onDataLayoutChanged: Observable<void>;
  23390. /**
  23391. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23392. */
  23393. get influence(): number;
  23394. set influence(influence: number);
  23395. /**
  23396. * Gets or sets the id of the morph Target
  23397. */
  23398. id: string;
  23399. private _animationPropertiesOverride;
  23400. /**
  23401. * Gets or sets the animation properties override
  23402. */
  23403. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23404. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23405. /**
  23406. * Creates a new MorphTarget
  23407. * @param name defines the name of the target
  23408. * @param influence defines the influence to use
  23409. * @param scene defines the scene the morphtarget belongs to
  23410. */
  23411. constructor(
  23412. /** defines the name of the target */
  23413. name: string, influence?: number, scene?: Nullable<Scene>);
  23414. /**
  23415. * Gets the unique ID of this manager
  23416. */
  23417. get uniqueId(): number;
  23418. /**
  23419. * Gets a boolean defining if the target contains position data
  23420. */
  23421. get hasPositions(): boolean;
  23422. /**
  23423. * Gets a boolean defining if the target contains normal data
  23424. */
  23425. get hasNormals(): boolean;
  23426. /**
  23427. * Gets a boolean defining if the target contains tangent data
  23428. */
  23429. get hasTangents(): boolean;
  23430. /**
  23431. * Gets a boolean defining if the target contains texture coordinates data
  23432. */
  23433. get hasUVs(): boolean;
  23434. /**
  23435. * Affects position data to this target
  23436. * @param data defines the position data to use
  23437. */
  23438. setPositions(data: Nullable<FloatArray>): void;
  23439. /**
  23440. * Gets the position data stored in this target
  23441. * @returns a FloatArray containing the position data (or null if not present)
  23442. */
  23443. getPositions(): Nullable<FloatArray>;
  23444. /**
  23445. * Affects normal data to this target
  23446. * @param data defines the normal data to use
  23447. */
  23448. setNormals(data: Nullable<FloatArray>): void;
  23449. /**
  23450. * Gets the normal data stored in this target
  23451. * @returns a FloatArray containing the normal data (or null if not present)
  23452. */
  23453. getNormals(): Nullable<FloatArray>;
  23454. /**
  23455. * Affects tangent data to this target
  23456. * @param data defines the tangent data to use
  23457. */
  23458. setTangents(data: Nullable<FloatArray>): void;
  23459. /**
  23460. * Gets the tangent data stored in this target
  23461. * @returns a FloatArray containing the tangent data (or null if not present)
  23462. */
  23463. getTangents(): Nullable<FloatArray>;
  23464. /**
  23465. * Affects texture coordinates data to this target
  23466. * @param data defines the texture coordinates data to use
  23467. */
  23468. setUVs(data: Nullable<FloatArray>): void;
  23469. /**
  23470. * Gets the texture coordinates data stored in this target
  23471. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23472. */
  23473. getUVs(): Nullable<FloatArray>;
  23474. /**
  23475. * Clone the current target
  23476. * @returns a new MorphTarget
  23477. */
  23478. clone(): MorphTarget;
  23479. /**
  23480. * Serializes the current target into a Serialization object
  23481. * @returns the serialized object
  23482. */
  23483. serialize(): any;
  23484. /**
  23485. * Returns the string "MorphTarget"
  23486. * @returns "MorphTarget"
  23487. */
  23488. getClassName(): string;
  23489. /**
  23490. * Creates a new target from serialized data
  23491. * @param serializationObject defines the serialized data to use
  23492. * @returns a new MorphTarget
  23493. */
  23494. static Parse(serializationObject: any): MorphTarget;
  23495. /**
  23496. * Creates a MorphTarget from mesh data
  23497. * @param mesh defines the source mesh
  23498. * @param name defines the name to use for the new target
  23499. * @param influence defines the influence to attach to the target
  23500. * @returns a new MorphTarget
  23501. */
  23502. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23503. }
  23504. }
  23505. declare module "babylonjs/Morph/morphTargetManager" {
  23506. import { Nullable } from "babylonjs/types";
  23507. import { Scene } from "babylonjs/scene";
  23508. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23509. /**
  23510. * This class is used to deform meshes using morphing between different targets
  23511. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23512. */
  23513. export class MorphTargetManager {
  23514. private _targets;
  23515. private _targetInfluenceChangedObservers;
  23516. private _targetDataLayoutChangedObservers;
  23517. private _activeTargets;
  23518. private _scene;
  23519. private _influences;
  23520. private _supportsNormals;
  23521. private _supportsTangents;
  23522. private _supportsUVs;
  23523. private _vertexCount;
  23524. private _uniqueId;
  23525. private _tempInfluences;
  23526. /**
  23527. * Gets or sets a boolean indicating if normals must be morphed
  23528. */
  23529. enableNormalMorphing: boolean;
  23530. /**
  23531. * Gets or sets a boolean indicating if tangents must be morphed
  23532. */
  23533. enableTangentMorphing: boolean;
  23534. /**
  23535. * Gets or sets a boolean indicating if UV must be morphed
  23536. */
  23537. enableUVMorphing: boolean;
  23538. /**
  23539. * Creates a new MorphTargetManager
  23540. * @param scene defines the current scene
  23541. */
  23542. constructor(scene?: Nullable<Scene>);
  23543. /**
  23544. * Gets the unique ID of this manager
  23545. */
  23546. get uniqueId(): number;
  23547. /**
  23548. * Gets the number of vertices handled by this manager
  23549. */
  23550. get vertexCount(): number;
  23551. /**
  23552. * Gets a boolean indicating if this manager supports morphing of normals
  23553. */
  23554. get supportsNormals(): boolean;
  23555. /**
  23556. * Gets a boolean indicating if this manager supports morphing of tangents
  23557. */
  23558. get supportsTangents(): boolean;
  23559. /**
  23560. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23561. */
  23562. get supportsUVs(): boolean;
  23563. /**
  23564. * Gets the number of targets stored in this manager
  23565. */
  23566. get numTargets(): number;
  23567. /**
  23568. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23569. */
  23570. get numInfluencers(): number;
  23571. /**
  23572. * Gets the list of influences (one per target)
  23573. */
  23574. get influences(): Float32Array;
  23575. /**
  23576. * Gets the active target at specified index. An active target is a target with an influence > 0
  23577. * @param index defines the index to check
  23578. * @returns the requested target
  23579. */
  23580. getActiveTarget(index: number): MorphTarget;
  23581. /**
  23582. * Gets the target at specified index
  23583. * @param index defines the index to check
  23584. * @returns the requested target
  23585. */
  23586. getTarget(index: number): MorphTarget;
  23587. /**
  23588. * Add a new target to this manager
  23589. * @param target defines the target to add
  23590. */
  23591. addTarget(target: MorphTarget): void;
  23592. /**
  23593. * Removes a target from the manager
  23594. * @param target defines the target to remove
  23595. */
  23596. removeTarget(target: MorphTarget): void;
  23597. /**
  23598. * Clone the current manager
  23599. * @returns a new MorphTargetManager
  23600. */
  23601. clone(): MorphTargetManager;
  23602. /**
  23603. * Serializes the current manager into a Serialization object
  23604. * @returns the serialized object
  23605. */
  23606. serialize(): any;
  23607. private _syncActiveTargets;
  23608. /**
  23609. * Syncrhonize the targets with all the meshes using this morph target manager
  23610. */
  23611. synchronize(): void;
  23612. /**
  23613. * Creates a new MorphTargetManager from serialized data
  23614. * @param serializationObject defines the serialized data
  23615. * @param scene defines the hosting scene
  23616. * @returns the new MorphTargetManager
  23617. */
  23618. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23619. }
  23620. }
  23621. declare module "babylonjs/Meshes/meshLODLevel" {
  23622. import { Mesh } from "babylonjs/Meshes/mesh";
  23623. import { Nullable } from "babylonjs/types";
  23624. /**
  23625. * Class used to represent a specific level of detail of a mesh
  23626. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23627. */
  23628. export class MeshLODLevel {
  23629. /** Defines the distance where this level should start being displayed */
  23630. distance: number;
  23631. /** Defines the mesh to use to render this level */
  23632. mesh: Nullable<Mesh>;
  23633. /**
  23634. * Creates a new LOD level
  23635. * @param distance defines the distance where this level should star being displayed
  23636. * @param mesh defines the mesh to use to render this level
  23637. */
  23638. constructor(
  23639. /** Defines the distance where this level should start being displayed */
  23640. distance: number,
  23641. /** Defines the mesh to use to render this level */
  23642. mesh: Nullable<Mesh>);
  23643. }
  23644. }
  23645. declare module "babylonjs/Meshes/groundMesh" {
  23646. import { Scene } from "babylonjs/scene";
  23647. import { Vector3 } from "babylonjs/Maths/math.vector";
  23648. import { Mesh } from "babylonjs/Meshes/mesh";
  23649. /**
  23650. * Mesh representing the gorund
  23651. */
  23652. export class GroundMesh extends Mesh {
  23653. /** If octree should be generated */
  23654. generateOctree: boolean;
  23655. private _heightQuads;
  23656. /** @hidden */
  23657. _subdivisionsX: number;
  23658. /** @hidden */
  23659. _subdivisionsY: number;
  23660. /** @hidden */
  23661. _width: number;
  23662. /** @hidden */
  23663. _height: number;
  23664. /** @hidden */
  23665. _minX: number;
  23666. /** @hidden */
  23667. _maxX: number;
  23668. /** @hidden */
  23669. _minZ: number;
  23670. /** @hidden */
  23671. _maxZ: number;
  23672. constructor(name: string, scene: Scene);
  23673. /**
  23674. * "GroundMesh"
  23675. * @returns "GroundMesh"
  23676. */
  23677. getClassName(): string;
  23678. /**
  23679. * The minimum of x and y subdivisions
  23680. */
  23681. get subdivisions(): number;
  23682. /**
  23683. * X subdivisions
  23684. */
  23685. get subdivisionsX(): number;
  23686. /**
  23687. * Y subdivisions
  23688. */
  23689. get subdivisionsY(): number;
  23690. /**
  23691. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23692. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23693. * @param chunksCount the number of subdivisions for x and y
  23694. * @param octreeBlocksSize (Default: 32)
  23695. */
  23696. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23697. /**
  23698. * Returns a height (y) value in the Worl system :
  23699. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23700. * @param x x coordinate
  23701. * @param z z coordinate
  23702. * @returns the ground y position if (x, z) are outside the ground surface.
  23703. */
  23704. getHeightAtCoordinates(x: number, z: number): number;
  23705. /**
  23706. * Returns a normalized vector (Vector3) orthogonal to the ground
  23707. * at the ground coordinates (x, z) expressed in the World system.
  23708. * @param x x coordinate
  23709. * @param z z coordinate
  23710. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23711. */
  23712. getNormalAtCoordinates(x: number, z: number): Vector3;
  23713. /**
  23714. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23715. * at the ground coordinates (x, z) expressed in the World system.
  23716. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23717. * @param x x coordinate
  23718. * @param z z coordinate
  23719. * @param ref vector to store the result
  23720. * @returns the GroundMesh.
  23721. */
  23722. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23723. /**
  23724. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23725. * if the ground has been updated.
  23726. * This can be used in the render loop.
  23727. * @returns the GroundMesh.
  23728. */
  23729. updateCoordinateHeights(): GroundMesh;
  23730. private _getFacetAt;
  23731. private _initHeightQuads;
  23732. private _computeHeightQuads;
  23733. /**
  23734. * Serializes this ground mesh
  23735. * @param serializationObject object to write serialization to
  23736. */
  23737. serialize(serializationObject: any): void;
  23738. /**
  23739. * Parses a serialized ground mesh
  23740. * @param parsedMesh the serialized mesh
  23741. * @param scene the scene to create the ground mesh in
  23742. * @returns the created ground mesh
  23743. */
  23744. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23745. }
  23746. }
  23747. declare module "babylonjs/Physics/physicsJoint" {
  23748. import { Vector3 } from "babylonjs/Maths/math.vector";
  23749. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23750. /**
  23751. * Interface for Physics-Joint data
  23752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23753. */
  23754. export interface PhysicsJointData {
  23755. /**
  23756. * The main pivot of the joint
  23757. */
  23758. mainPivot?: Vector3;
  23759. /**
  23760. * The connected pivot of the joint
  23761. */
  23762. connectedPivot?: Vector3;
  23763. /**
  23764. * The main axis of the joint
  23765. */
  23766. mainAxis?: Vector3;
  23767. /**
  23768. * The connected axis of the joint
  23769. */
  23770. connectedAxis?: Vector3;
  23771. /**
  23772. * The collision of the joint
  23773. */
  23774. collision?: boolean;
  23775. /**
  23776. * Native Oimo/Cannon/Energy data
  23777. */
  23778. nativeParams?: any;
  23779. }
  23780. /**
  23781. * This is a holder class for the physics joint created by the physics plugin
  23782. * It holds a set of functions to control the underlying joint
  23783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23784. */
  23785. export class PhysicsJoint {
  23786. /**
  23787. * The type of the physics joint
  23788. */
  23789. type: number;
  23790. /**
  23791. * The data for the physics joint
  23792. */
  23793. jointData: PhysicsJointData;
  23794. private _physicsJoint;
  23795. protected _physicsPlugin: IPhysicsEnginePlugin;
  23796. /**
  23797. * Initializes the physics joint
  23798. * @param type The type of the physics joint
  23799. * @param jointData The data for the physics joint
  23800. */
  23801. constructor(
  23802. /**
  23803. * The type of the physics joint
  23804. */
  23805. type: number,
  23806. /**
  23807. * The data for the physics joint
  23808. */
  23809. jointData: PhysicsJointData);
  23810. /**
  23811. * Gets the physics joint
  23812. */
  23813. get physicsJoint(): any;
  23814. /**
  23815. * Sets the physics joint
  23816. */
  23817. set physicsJoint(newJoint: any);
  23818. /**
  23819. * Sets the physics plugin
  23820. */
  23821. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23822. /**
  23823. * Execute a function that is physics-plugin specific.
  23824. * @param {Function} func the function that will be executed.
  23825. * It accepts two parameters: the physics world and the physics joint
  23826. */
  23827. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23828. /**
  23829. * Distance-Joint type
  23830. */
  23831. static DistanceJoint: number;
  23832. /**
  23833. * Hinge-Joint type
  23834. */
  23835. static HingeJoint: number;
  23836. /**
  23837. * Ball-and-Socket joint type
  23838. */
  23839. static BallAndSocketJoint: number;
  23840. /**
  23841. * Wheel-Joint type
  23842. */
  23843. static WheelJoint: number;
  23844. /**
  23845. * Slider-Joint type
  23846. */
  23847. static SliderJoint: number;
  23848. /**
  23849. * Prismatic-Joint type
  23850. */
  23851. static PrismaticJoint: number;
  23852. /**
  23853. * Universal-Joint type
  23854. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23855. */
  23856. static UniversalJoint: number;
  23857. /**
  23858. * Hinge-Joint 2 type
  23859. */
  23860. static Hinge2Joint: number;
  23861. /**
  23862. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23863. */
  23864. static PointToPointJoint: number;
  23865. /**
  23866. * Spring-Joint type
  23867. */
  23868. static SpringJoint: number;
  23869. /**
  23870. * Lock-Joint type
  23871. */
  23872. static LockJoint: number;
  23873. }
  23874. /**
  23875. * A class representing a physics distance joint
  23876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23877. */
  23878. export class DistanceJoint extends PhysicsJoint {
  23879. /**
  23880. *
  23881. * @param jointData The data for the Distance-Joint
  23882. */
  23883. constructor(jointData: DistanceJointData);
  23884. /**
  23885. * Update the predefined distance.
  23886. * @param maxDistance The maximum preferred distance
  23887. * @param minDistance The minimum preferred distance
  23888. */
  23889. updateDistance(maxDistance: number, minDistance?: number): void;
  23890. }
  23891. /**
  23892. * Represents a Motor-Enabled Joint
  23893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23894. */
  23895. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23896. /**
  23897. * Initializes the Motor-Enabled Joint
  23898. * @param type The type of the joint
  23899. * @param jointData The physica joint data for the joint
  23900. */
  23901. constructor(type: number, jointData: PhysicsJointData);
  23902. /**
  23903. * Set the motor values.
  23904. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23905. * @param force the force to apply
  23906. * @param maxForce max force for this motor.
  23907. */
  23908. setMotor(force?: number, maxForce?: number): void;
  23909. /**
  23910. * Set the motor's limits.
  23911. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23912. * @param upperLimit The upper limit of the motor
  23913. * @param lowerLimit The lower limit of the motor
  23914. */
  23915. setLimit(upperLimit: number, lowerLimit?: number): void;
  23916. }
  23917. /**
  23918. * This class represents a single physics Hinge-Joint
  23919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23920. */
  23921. export class HingeJoint extends MotorEnabledJoint {
  23922. /**
  23923. * Initializes the Hinge-Joint
  23924. * @param jointData The joint data for the Hinge-Joint
  23925. */
  23926. constructor(jointData: PhysicsJointData);
  23927. /**
  23928. * Set the motor values.
  23929. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23930. * @param {number} force the force to apply
  23931. * @param {number} maxForce max force for this motor.
  23932. */
  23933. setMotor(force?: number, maxForce?: number): void;
  23934. /**
  23935. * Set the motor's limits.
  23936. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23937. * @param upperLimit The upper limit of the motor
  23938. * @param lowerLimit The lower limit of the motor
  23939. */
  23940. setLimit(upperLimit: number, lowerLimit?: number): void;
  23941. }
  23942. /**
  23943. * This class represents a dual hinge physics joint (same as wheel joint)
  23944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23945. */
  23946. export class Hinge2Joint extends MotorEnabledJoint {
  23947. /**
  23948. * Initializes the Hinge2-Joint
  23949. * @param jointData The joint data for the Hinge2-Joint
  23950. */
  23951. constructor(jointData: PhysicsJointData);
  23952. /**
  23953. * Set the motor values.
  23954. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23955. * @param {number} targetSpeed the speed the motor is to reach
  23956. * @param {number} maxForce max force for this motor.
  23957. * @param {motorIndex} the motor's index, 0 or 1.
  23958. */
  23959. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23960. /**
  23961. * Set the motor limits.
  23962. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23963. * @param {number} upperLimit the upper limit
  23964. * @param {number} lowerLimit lower limit
  23965. * @param {motorIndex} the motor's index, 0 or 1.
  23966. */
  23967. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23968. }
  23969. /**
  23970. * Interface for a motor enabled joint
  23971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23972. */
  23973. export interface IMotorEnabledJoint {
  23974. /**
  23975. * Physics joint
  23976. */
  23977. physicsJoint: any;
  23978. /**
  23979. * Sets the motor of the motor-enabled joint
  23980. * @param force The force of the motor
  23981. * @param maxForce The maximum force of the motor
  23982. * @param motorIndex The index of the motor
  23983. */
  23984. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23985. /**
  23986. * Sets the limit of the motor
  23987. * @param upperLimit The upper limit of the motor
  23988. * @param lowerLimit The lower limit of the motor
  23989. * @param motorIndex The index of the motor
  23990. */
  23991. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23992. }
  23993. /**
  23994. * Joint data for a Distance-Joint
  23995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23996. */
  23997. export interface DistanceJointData extends PhysicsJointData {
  23998. /**
  23999. * Max distance the 2 joint objects can be apart
  24000. */
  24001. maxDistance: number;
  24002. }
  24003. /**
  24004. * Joint data from a spring joint
  24005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24006. */
  24007. export interface SpringJointData extends PhysicsJointData {
  24008. /**
  24009. * Length of the spring
  24010. */
  24011. length: number;
  24012. /**
  24013. * Stiffness of the spring
  24014. */
  24015. stiffness: number;
  24016. /**
  24017. * Damping of the spring
  24018. */
  24019. damping: number;
  24020. /** this callback will be called when applying the force to the impostors. */
  24021. forceApplicationCallback: () => void;
  24022. }
  24023. }
  24024. declare module "babylonjs/Physics/physicsRaycastResult" {
  24025. import { Vector3 } from "babylonjs/Maths/math.vector";
  24026. /**
  24027. * Holds the data for the raycast result
  24028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24029. */
  24030. export class PhysicsRaycastResult {
  24031. private _hasHit;
  24032. private _hitDistance;
  24033. private _hitNormalWorld;
  24034. private _hitPointWorld;
  24035. private _rayFromWorld;
  24036. private _rayToWorld;
  24037. /**
  24038. * Gets if there was a hit
  24039. */
  24040. get hasHit(): boolean;
  24041. /**
  24042. * Gets the distance from the hit
  24043. */
  24044. get hitDistance(): number;
  24045. /**
  24046. * Gets the hit normal/direction in the world
  24047. */
  24048. get hitNormalWorld(): Vector3;
  24049. /**
  24050. * Gets the hit point in the world
  24051. */
  24052. get hitPointWorld(): Vector3;
  24053. /**
  24054. * Gets the ray "start point" of the ray in the world
  24055. */
  24056. get rayFromWorld(): Vector3;
  24057. /**
  24058. * Gets the ray "end point" of the ray in the world
  24059. */
  24060. get rayToWorld(): Vector3;
  24061. /**
  24062. * Sets the hit data (normal & point in world space)
  24063. * @param hitNormalWorld defines the normal in world space
  24064. * @param hitPointWorld defines the point in world space
  24065. */
  24066. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24067. /**
  24068. * Sets the distance from the start point to the hit point
  24069. * @param distance
  24070. */
  24071. setHitDistance(distance: number): void;
  24072. /**
  24073. * Calculates the distance manually
  24074. */
  24075. calculateHitDistance(): void;
  24076. /**
  24077. * Resets all the values to default
  24078. * @param from The from point on world space
  24079. * @param to The to point on world space
  24080. */
  24081. reset(from?: Vector3, to?: Vector3): void;
  24082. }
  24083. /**
  24084. * Interface for the size containing width and height
  24085. */
  24086. interface IXYZ {
  24087. /**
  24088. * X
  24089. */
  24090. x: number;
  24091. /**
  24092. * Y
  24093. */
  24094. y: number;
  24095. /**
  24096. * Z
  24097. */
  24098. z: number;
  24099. }
  24100. }
  24101. declare module "babylonjs/Physics/IPhysicsEngine" {
  24102. import { Nullable } from "babylonjs/types";
  24103. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24105. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24106. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24107. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24108. /**
  24109. * Interface used to describe a physics joint
  24110. */
  24111. export interface PhysicsImpostorJoint {
  24112. /** Defines the main impostor to which the joint is linked */
  24113. mainImpostor: PhysicsImpostor;
  24114. /** Defines the impostor that is connected to the main impostor using this joint */
  24115. connectedImpostor: PhysicsImpostor;
  24116. /** Defines the joint itself */
  24117. joint: PhysicsJoint;
  24118. }
  24119. /** @hidden */
  24120. export interface IPhysicsEnginePlugin {
  24121. world: any;
  24122. name: string;
  24123. setGravity(gravity: Vector3): void;
  24124. setTimeStep(timeStep: number): void;
  24125. getTimeStep(): number;
  24126. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24127. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24128. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24129. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24130. removePhysicsBody(impostor: PhysicsImpostor): void;
  24131. generateJoint(joint: PhysicsImpostorJoint): void;
  24132. removeJoint(joint: PhysicsImpostorJoint): void;
  24133. isSupported(): boolean;
  24134. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24135. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24136. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24137. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24138. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24139. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24140. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24141. getBodyMass(impostor: PhysicsImpostor): number;
  24142. getBodyFriction(impostor: PhysicsImpostor): number;
  24143. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24144. getBodyRestitution(impostor: PhysicsImpostor): number;
  24145. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24146. getBodyPressure?(impostor: PhysicsImpostor): number;
  24147. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24148. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24149. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24150. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24151. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24152. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24153. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24154. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24155. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24156. sleepBody(impostor: PhysicsImpostor): void;
  24157. wakeUpBody(impostor: PhysicsImpostor): void;
  24158. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24159. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24160. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24161. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24162. getRadius(impostor: PhysicsImpostor): number;
  24163. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24164. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24165. dispose(): void;
  24166. }
  24167. /**
  24168. * Interface used to define a physics engine
  24169. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24170. */
  24171. export interface IPhysicsEngine {
  24172. /**
  24173. * Gets the gravity vector used by the simulation
  24174. */
  24175. gravity: Vector3;
  24176. /**
  24177. * Sets the gravity vector used by the simulation
  24178. * @param gravity defines the gravity vector to use
  24179. */
  24180. setGravity(gravity: Vector3): void;
  24181. /**
  24182. * Set the time step of the physics engine.
  24183. * Default is 1/60.
  24184. * To slow it down, enter 1/600 for example.
  24185. * To speed it up, 1/30
  24186. * @param newTimeStep the new timestep to apply to this world.
  24187. */
  24188. setTimeStep(newTimeStep: number): void;
  24189. /**
  24190. * Get the time step of the physics engine.
  24191. * @returns the current time step
  24192. */
  24193. getTimeStep(): number;
  24194. /**
  24195. * Set the sub time step of the physics engine.
  24196. * Default is 0 meaning there is no sub steps
  24197. * To increase physics resolution precision, set a small value (like 1 ms)
  24198. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24199. */
  24200. setSubTimeStep(subTimeStep: number): void;
  24201. /**
  24202. * Get the sub time step of the physics engine.
  24203. * @returns the current sub time step
  24204. */
  24205. getSubTimeStep(): number;
  24206. /**
  24207. * Release all resources
  24208. */
  24209. dispose(): void;
  24210. /**
  24211. * Gets the name of the current physics plugin
  24212. * @returns the name of the plugin
  24213. */
  24214. getPhysicsPluginName(): string;
  24215. /**
  24216. * Adding a new impostor for the impostor tracking.
  24217. * This will be done by the impostor itself.
  24218. * @param impostor the impostor to add
  24219. */
  24220. addImpostor(impostor: PhysicsImpostor): void;
  24221. /**
  24222. * Remove an impostor from the engine.
  24223. * This impostor and its mesh will not longer be updated by the physics engine.
  24224. * @param impostor the impostor to remove
  24225. */
  24226. removeImpostor(impostor: PhysicsImpostor): void;
  24227. /**
  24228. * Add a joint to the physics engine
  24229. * @param mainImpostor defines the main impostor to which the joint is added.
  24230. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24231. * @param joint defines the joint that will connect both impostors.
  24232. */
  24233. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24234. /**
  24235. * Removes a joint from the simulation
  24236. * @param mainImpostor defines the impostor used with the joint
  24237. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24238. * @param joint defines the joint to remove
  24239. */
  24240. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24241. /**
  24242. * Gets the current plugin used to run the simulation
  24243. * @returns current plugin
  24244. */
  24245. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24246. /**
  24247. * Gets the list of physic impostors
  24248. * @returns an array of PhysicsImpostor
  24249. */
  24250. getImpostors(): Array<PhysicsImpostor>;
  24251. /**
  24252. * Gets the impostor for a physics enabled object
  24253. * @param object defines the object impersonated by the impostor
  24254. * @returns the PhysicsImpostor or null if not found
  24255. */
  24256. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24257. /**
  24258. * Gets the impostor for a physics body object
  24259. * @param body defines physics body used by the impostor
  24260. * @returns the PhysicsImpostor or null if not found
  24261. */
  24262. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24263. /**
  24264. * Does a raycast in the physics world
  24265. * @param from when should the ray start?
  24266. * @param to when should the ray end?
  24267. * @returns PhysicsRaycastResult
  24268. */
  24269. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24270. /**
  24271. * Called by the scene. No need to call it.
  24272. * @param delta defines the timespam between frames
  24273. */
  24274. _step(delta: number): void;
  24275. }
  24276. }
  24277. declare module "babylonjs/Physics/physicsImpostor" {
  24278. import { Nullable, IndicesArray } from "babylonjs/types";
  24279. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24282. import { Scene } from "babylonjs/scene";
  24283. import { Bone } from "babylonjs/Bones/bone";
  24284. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24285. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24286. import { Space } from "babylonjs/Maths/math.axis";
  24287. /**
  24288. * The interface for the physics imposter parameters
  24289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24290. */
  24291. export interface PhysicsImpostorParameters {
  24292. /**
  24293. * The mass of the physics imposter
  24294. */
  24295. mass: number;
  24296. /**
  24297. * The friction of the physics imposter
  24298. */
  24299. friction?: number;
  24300. /**
  24301. * The coefficient of restitution of the physics imposter
  24302. */
  24303. restitution?: number;
  24304. /**
  24305. * The native options of the physics imposter
  24306. */
  24307. nativeOptions?: any;
  24308. /**
  24309. * Specifies if the parent should be ignored
  24310. */
  24311. ignoreParent?: boolean;
  24312. /**
  24313. * Specifies if bi-directional transformations should be disabled
  24314. */
  24315. disableBidirectionalTransformation?: boolean;
  24316. /**
  24317. * The pressure inside the physics imposter, soft object only
  24318. */
  24319. pressure?: number;
  24320. /**
  24321. * The stiffness the physics imposter, soft object only
  24322. */
  24323. stiffness?: number;
  24324. /**
  24325. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24326. */
  24327. velocityIterations?: number;
  24328. /**
  24329. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24330. */
  24331. positionIterations?: number;
  24332. /**
  24333. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24334. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24335. * Add to fix multiple points
  24336. */
  24337. fixedPoints?: number;
  24338. /**
  24339. * The collision margin around a soft object
  24340. */
  24341. margin?: number;
  24342. /**
  24343. * The collision margin around a soft object
  24344. */
  24345. damping?: number;
  24346. /**
  24347. * The path for a rope based on an extrusion
  24348. */
  24349. path?: any;
  24350. /**
  24351. * The shape of an extrusion used for a rope based on an extrusion
  24352. */
  24353. shape?: any;
  24354. }
  24355. /**
  24356. * Interface for a physics-enabled object
  24357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24358. */
  24359. export interface IPhysicsEnabledObject {
  24360. /**
  24361. * The position of the physics-enabled object
  24362. */
  24363. position: Vector3;
  24364. /**
  24365. * The rotation of the physics-enabled object
  24366. */
  24367. rotationQuaternion: Nullable<Quaternion>;
  24368. /**
  24369. * The scale of the physics-enabled object
  24370. */
  24371. scaling: Vector3;
  24372. /**
  24373. * The rotation of the physics-enabled object
  24374. */
  24375. rotation?: Vector3;
  24376. /**
  24377. * The parent of the physics-enabled object
  24378. */
  24379. parent?: any;
  24380. /**
  24381. * The bounding info of the physics-enabled object
  24382. * @returns The bounding info of the physics-enabled object
  24383. */
  24384. getBoundingInfo(): BoundingInfo;
  24385. /**
  24386. * Computes the world matrix
  24387. * @param force Specifies if the world matrix should be computed by force
  24388. * @returns A world matrix
  24389. */
  24390. computeWorldMatrix(force: boolean): Matrix;
  24391. /**
  24392. * Gets the world matrix
  24393. * @returns A world matrix
  24394. */
  24395. getWorldMatrix?(): Matrix;
  24396. /**
  24397. * Gets the child meshes
  24398. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24399. * @returns An array of abstract meshes
  24400. */
  24401. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24402. /**
  24403. * Gets the vertex data
  24404. * @param kind The type of vertex data
  24405. * @returns A nullable array of numbers, or a float32 array
  24406. */
  24407. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24408. /**
  24409. * Gets the indices from the mesh
  24410. * @returns A nullable array of index arrays
  24411. */
  24412. getIndices?(): Nullable<IndicesArray>;
  24413. /**
  24414. * Gets the scene from the mesh
  24415. * @returns the indices array or null
  24416. */
  24417. getScene?(): Scene;
  24418. /**
  24419. * Gets the absolute position from the mesh
  24420. * @returns the absolute position
  24421. */
  24422. getAbsolutePosition(): Vector3;
  24423. /**
  24424. * Gets the absolute pivot point from the mesh
  24425. * @returns the absolute pivot point
  24426. */
  24427. getAbsolutePivotPoint(): Vector3;
  24428. /**
  24429. * Rotates the mesh
  24430. * @param axis The axis of rotation
  24431. * @param amount The amount of rotation
  24432. * @param space The space of the rotation
  24433. * @returns The rotation transform node
  24434. */
  24435. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24436. /**
  24437. * Translates the mesh
  24438. * @param axis The axis of translation
  24439. * @param distance The distance of translation
  24440. * @param space The space of the translation
  24441. * @returns The transform node
  24442. */
  24443. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24444. /**
  24445. * Sets the absolute position of the mesh
  24446. * @param absolutePosition The absolute position of the mesh
  24447. * @returns The transform node
  24448. */
  24449. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24450. /**
  24451. * Gets the class name of the mesh
  24452. * @returns The class name
  24453. */
  24454. getClassName(): string;
  24455. }
  24456. /**
  24457. * Represents a physics imposter
  24458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24459. */
  24460. export class PhysicsImpostor {
  24461. /**
  24462. * The physics-enabled object used as the physics imposter
  24463. */
  24464. object: IPhysicsEnabledObject;
  24465. /**
  24466. * The type of the physics imposter
  24467. */
  24468. type: number;
  24469. private _options;
  24470. private _scene?;
  24471. /**
  24472. * The default object size of the imposter
  24473. */
  24474. static DEFAULT_OBJECT_SIZE: Vector3;
  24475. /**
  24476. * The identity quaternion of the imposter
  24477. */
  24478. static IDENTITY_QUATERNION: Quaternion;
  24479. /** @hidden */
  24480. _pluginData: any;
  24481. private _physicsEngine;
  24482. private _physicsBody;
  24483. private _bodyUpdateRequired;
  24484. private _onBeforePhysicsStepCallbacks;
  24485. private _onAfterPhysicsStepCallbacks;
  24486. /** @hidden */
  24487. _onPhysicsCollideCallbacks: Array<{
  24488. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24489. otherImpostors: Array<PhysicsImpostor>;
  24490. }>;
  24491. private _deltaPosition;
  24492. private _deltaRotation;
  24493. private _deltaRotationConjugated;
  24494. /** @hidden */
  24495. _isFromLine: boolean;
  24496. private _parent;
  24497. private _isDisposed;
  24498. private static _tmpVecs;
  24499. private static _tmpQuat;
  24500. /**
  24501. * Specifies if the physics imposter is disposed
  24502. */
  24503. get isDisposed(): boolean;
  24504. /**
  24505. * Gets the mass of the physics imposter
  24506. */
  24507. get mass(): number;
  24508. set mass(value: number);
  24509. /**
  24510. * Gets the coefficient of friction
  24511. */
  24512. get friction(): number;
  24513. /**
  24514. * Sets the coefficient of friction
  24515. */
  24516. set friction(value: number);
  24517. /**
  24518. * Gets the coefficient of restitution
  24519. */
  24520. get restitution(): number;
  24521. /**
  24522. * Sets the coefficient of restitution
  24523. */
  24524. set restitution(value: number);
  24525. /**
  24526. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24527. */
  24528. get pressure(): number;
  24529. /**
  24530. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24531. */
  24532. set pressure(value: number);
  24533. /**
  24534. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24535. */
  24536. get stiffness(): number;
  24537. /**
  24538. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24539. */
  24540. set stiffness(value: number);
  24541. /**
  24542. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24543. */
  24544. get velocityIterations(): number;
  24545. /**
  24546. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24547. */
  24548. set velocityIterations(value: number);
  24549. /**
  24550. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24551. */
  24552. get positionIterations(): number;
  24553. /**
  24554. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24555. */
  24556. set positionIterations(value: number);
  24557. /**
  24558. * The unique id of the physics imposter
  24559. * set by the physics engine when adding this impostor to the array
  24560. */
  24561. uniqueId: number;
  24562. /**
  24563. * @hidden
  24564. */
  24565. soft: boolean;
  24566. /**
  24567. * @hidden
  24568. */
  24569. segments: number;
  24570. private _joints;
  24571. /**
  24572. * Initializes the physics imposter
  24573. * @param object The physics-enabled object used as the physics imposter
  24574. * @param type The type of the physics imposter
  24575. * @param _options The options for the physics imposter
  24576. * @param _scene The Babylon scene
  24577. */
  24578. constructor(
  24579. /**
  24580. * The physics-enabled object used as the physics imposter
  24581. */
  24582. object: IPhysicsEnabledObject,
  24583. /**
  24584. * The type of the physics imposter
  24585. */
  24586. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24587. /**
  24588. * This function will completly initialize this impostor.
  24589. * It will create a new body - but only if this mesh has no parent.
  24590. * If it has, this impostor will not be used other than to define the impostor
  24591. * of the child mesh.
  24592. * @hidden
  24593. */
  24594. _init(): void;
  24595. private _getPhysicsParent;
  24596. /**
  24597. * Should a new body be generated.
  24598. * @returns boolean specifying if body initialization is required
  24599. */
  24600. isBodyInitRequired(): boolean;
  24601. /**
  24602. * Sets the updated scaling
  24603. * @param updated Specifies if the scaling is updated
  24604. */
  24605. setScalingUpdated(): void;
  24606. /**
  24607. * Force a regeneration of this or the parent's impostor's body.
  24608. * Use under cautious - This will remove all joints already implemented.
  24609. */
  24610. forceUpdate(): void;
  24611. /**
  24612. * Gets the body that holds this impostor. Either its own, or its parent.
  24613. */
  24614. get physicsBody(): any;
  24615. /**
  24616. * Get the parent of the physics imposter
  24617. * @returns Physics imposter or null
  24618. */
  24619. get parent(): Nullable<PhysicsImpostor>;
  24620. /**
  24621. * Sets the parent of the physics imposter
  24622. */
  24623. set parent(value: Nullable<PhysicsImpostor>);
  24624. /**
  24625. * Set the physics body. Used mainly by the physics engine/plugin
  24626. */
  24627. set physicsBody(physicsBody: any);
  24628. /**
  24629. * Resets the update flags
  24630. */
  24631. resetUpdateFlags(): void;
  24632. /**
  24633. * Gets the object extend size
  24634. * @returns the object extend size
  24635. */
  24636. getObjectExtendSize(): Vector3;
  24637. /**
  24638. * Gets the object center
  24639. * @returns The object center
  24640. */
  24641. getObjectCenter(): Vector3;
  24642. /**
  24643. * Get a specific parameter from the options parameters
  24644. * @param paramName The object parameter name
  24645. * @returns The object parameter
  24646. */
  24647. getParam(paramName: string): any;
  24648. /**
  24649. * Sets a specific parameter in the options given to the physics plugin
  24650. * @param paramName The parameter name
  24651. * @param value The value of the parameter
  24652. */
  24653. setParam(paramName: string, value: number): void;
  24654. /**
  24655. * Specifically change the body's mass option. Won't recreate the physics body object
  24656. * @param mass The mass of the physics imposter
  24657. */
  24658. setMass(mass: number): void;
  24659. /**
  24660. * Gets the linear velocity
  24661. * @returns linear velocity or null
  24662. */
  24663. getLinearVelocity(): Nullable<Vector3>;
  24664. /**
  24665. * Sets the linear velocity
  24666. * @param velocity linear velocity or null
  24667. */
  24668. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24669. /**
  24670. * Gets the angular velocity
  24671. * @returns angular velocity or null
  24672. */
  24673. getAngularVelocity(): Nullable<Vector3>;
  24674. /**
  24675. * Sets the angular velocity
  24676. * @param velocity The velocity or null
  24677. */
  24678. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24679. /**
  24680. * Execute a function with the physics plugin native code
  24681. * Provide a function the will have two variables - the world object and the physics body object
  24682. * @param func The function to execute with the physics plugin native code
  24683. */
  24684. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24685. /**
  24686. * Register a function that will be executed before the physics world is stepping forward
  24687. * @param func The function to execute before the physics world is stepped forward
  24688. */
  24689. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24690. /**
  24691. * Unregister a function that will be executed before the physics world is stepping forward
  24692. * @param func The function to execute before the physics world is stepped forward
  24693. */
  24694. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24695. /**
  24696. * Register a function that will be executed after the physics step
  24697. * @param func The function to execute after physics step
  24698. */
  24699. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24700. /**
  24701. * Unregisters a function that will be executed after the physics step
  24702. * @param func The function to execute after physics step
  24703. */
  24704. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24705. /**
  24706. * register a function that will be executed when this impostor collides against a different body
  24707. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24708. * @param func Callback that is executed on collision
  24709. */
  24710. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24711. /**
  24712. * Unregisters the physics imposter on contact
  24713. * @param collideAgainst The physics object to collide against
  24714. * @param func Callback to execute on collision
  24715. */
  24716. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24717. private _tmpQuat;
  24718. private _tmpQuat2;
  24719. /**
  24720. * Get the parent rotation
  24721. * @returns The parent rotation
  24722. */
  24723. getParentsRotation(): Quaternion;
  24724. /**
  24725. * this function is executed by the physics engine.
  24726. */
  24727. beforeStep: () => void;
  24728. /**
  24729. * this function is executed by the physics engine
  24730. */
  24731. afterStep: () => void;
  24732. /**
  24733. * Legacy collision detection event support
  24734. */
  24735. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24736. /**
  24737. * event and body object due to cannon's event-based architecture.
  24738. */
  24739. onCollide: (e: {
  24740. body: any;
  24741. }) => void;
  24742. /**
  24743. * Apply a force
  24744. * @param force The force to apply
  24745. * @param contactPoint The contact point for the force
  24746. * @returns The physics imposter
  24747. */
  24748. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24749. /**
  24750. * Apply an impulse
  24751. * @param force The impulse force
  24752. * @param contactPoint The contact point for the impulse force
  24753. * @returns The physics imposter
  24754. */
  24755. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24756. /**
  24757. * A help function to create a joint
  24758. * @param otherImpostor A physics imposter used to create a joint
  24759. * @param jointType The type of joint
  24760. * @param jointData The data for the joint
  24761. * @returns The physics imposter
  24762. */
  24763. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24764. /**
  24765. * Add a joint to this impostor with a different impostor
  24766. * @param otherImpostor A physics imposter used to add a joint
  24767. * @param joint The joint to add
  24768. * @returns The physics imposter
  24769. */
  24770. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24771. /**
  24772. * Add an anchor to a cloth impostor
  24773. * @param otherImpostor rigid impostor to anchor to
  24774. * @param width ratio across width from 0 to 1
  24775. * @param height ratio up height from 0 to 1
  24776. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24777. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24778. * @returns impostor the soft imposter
  24779. */
  24780. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24781. /**
  24782. * Add a hook to a rope impostor
  24783. * @param otherImpostor rigid impostor to anchor to
  24784. * @param length ratio across rope from 0 to 1
  24785. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24786. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24787. * @returns impostor the rope imposter
  24788. */
  24789. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24790. /**
  24791. * Will keep this body still, in a sleep mode.
  24792. * @returns the physics imposter
  24793. */
  24794. sleep(): PhysicsImpostor;
  24795. /**
  24796. * Wake the body up.
  24797. * @returns The physics imposter
  24798. */
  24799. wakeUp(): PhysicsImpostor;
  24800. /**
  24801. * Clones the physics imposter
  24802. * @param newObject The physics imposter clones to this physics-enabled object
  24803. * @returns A nullable physics imposter
  24804. */
  24805. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24806. /**
  24807. * Disposes the physics imposter
  24808. */
  24809. dispose(): void;
  24810. /**
  24811. * Sets the delta position
  24812. * @param position The delta position amount
  24813. */
  24814. setDeltaPosition(position: Vector3): void;
  24815. /**
  24816. * Sets the delta rotation
  24817. * @param rotation The delta rotation amount
  24818. */
  24819. setDeltaRotation(rotation: Quaternion): void;
  24820. /**
  24821. * Gets the box size of the physics imposter and stores the result in the input parameter
  24822. * @param result Stores the box size
  24823. * @returns The physics imposter
  24824. */
  24825. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24826. /**
  24827. * Gets the radius of the physics imposter
  24828. * @returns Radius of the physics imposter
  24829. */
  24830. getRadius(): number;
  24831. /**
  24832. * Sync a bone with this impostor
  24833. * @param bone The bone to sync to the impostor.
  24834. * @param boneMesh The mesh that the bone is influencing.
  24835. * @param jointPivot The pivot of the joint / bone in local space.
  24836. * @param distToJoint Optional distance from the impostor to the joint.
  24837. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24838. */
  24839. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24840. /**
  24841. * Sync impostor to a bone
  24842. * @param bone The bone that the impostor will be synced to.
  24843. * @param boneMesh The mesh that the bone is influencing.
  24844. * @param jointPivot The pivot of the joint / bone in local space.
  24845. * @param distToJoint Optional distance from the impostor to the joint.
  24846. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24847. * @param boneAxis Optional vector3 axis the bone is aligned with
  24848. */
  24849. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24850. /**
  24851. * No-Imposter type
  24852. */
  24853. static NoImpostor: number;
  24854. /**
  24855. * Sphere-Imposter type
  24856. */
  24857. static SphereImpostor: number;
  24858. /**
  24859. * Box-Imposter type
  24860. */
  24861. static BoxImpostor: number;
  24862. /**
  24863. * Plane-Imposter type
  24864. */
  24865. static PlaneImpostor: number;
  24866. /**
  24867. * Mesh-imposter type
  24868. */
  24869. static MeshImpostor: number;
  24870. /**
  24871. * Capsule-Impostor type (Ammo.js plugin only)
  24872. */
  24873. static CapsuleImpostor: number;
  24874. /**
  24875. * Cylinder-Imposter type
  24876. */
  24877. static CylinderImpostor: number;
  24878. /**
  24879. * Particle-Imposter type
  24880. */
  24881. static ParticleImpostor: number;
  24882. /**
  24883. * Heightmap-Imposter type
  24884. */
  24885. static HeightmapImpostor: number;
  24886. /**
  24887. * ConvexHull-Impostor type (Ammo.js plugin only)
  24888. */
  24889. static ConvexHullImpostor: number;
  24890. /**
  24891. * Custom-Imposter type (Ammo.js plugin only)
  24892. */
  24893. static CustomImpostor: number;
  24894. /**
  24895. * Rope-Imposter type
  24896. */
  24897. static RopeImpostor: number;
  24898. /**
  24899. * Cloth-Imposter type
  24900. */
  24901. static ClothImpostor: number;
  24902. /**
  24903. * Softbody-Imposter type
  24904. */
  24905. static SoftbodyImpostor: number;
  24906. }
  24907. }
  24908. declare module "babylonjs/Meshes/mesh" {
  24909. import { Observable } from "babylonjs/Misc/observable";
  24910. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24911. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24912. import { Camera } from "babylonjs/Cameras/camera";
  24913. import { Scene } from "babylonjs/scene";
  24914. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24915. import { Color4 } from "babylonjs/Maths/math.color";
  24916. import { Engine } from "babylonjs/Engines/engine";
  24917. import { Node } from "babylonjs/node";
  24918. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24919. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24920. import { Buffer } from "babylonjs/Meshes/buffer";
  24921. import { Geometry } from "babylonjs/Meshes/geometry";
  24922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24923. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24924. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24925. import { Effect } from "babylonjs/Materials/effect";
  24926. import { Material } from "babylonjs/Materials/material";
  24927. import { Skeleton } from "babylonjs/Bones/skeleton";
  24928. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24929. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24930. import { Path3D } from "babylonjs/Maths/math.path";
  24931. import { Plane } from "babylonjs/Maths/math.plane";
  24932. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24933. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24934. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24935. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24936. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24937. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24938. /**
  24939. * @hidden
  24940. **/
  24941. export class _CreationDataStorage {
  24942. closePath?: boolean;
  24943. closeArray?: boolean;
  24944. idx: number[];
  24945. dashSize: number;
  24946. gapSize: number;
  24947. path3D: Path3D;
  24948. pathArray: Vector3[][];
  24949. arc: number;
  24950. radius: number;
  24951. cap: number;
  24952. tessellation: number;
  24953. }
  24954. /**
  24955. * @hidden
  24956. **/
  24957. class _InstanceDataStorage {
  24958. visibleInstances: any;
  24959. batchCache: _InstancesBatch;
  24960. instancesBufferSize: number;
  24961. instancesBuffer: Nullable<Buffer>;
  24962. instancesData: Float32Array;
  24963. overridenInstanceCount: number;
  24964. isFrozen: boolean;
  24965. previousBatch: Nullable<_InstancesBatch>;
  24966. hardwareInstancedRendering: boolean;
  24967. sideOrientation: number;
  24968. manualUpdate: boolean;
  24969. }
  24970. /**
  24971. * @hidden
  24972. **/
  24973. export class _InstancesBatch {
  24974. mustReturn: boolean;
  24975. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24976. renderSelf: boolean[];
  24977. hardwareInstancedRendering: boolean[];
  24978. }
  24979. /**
  24980. * Class used to represent renderable models
  24981. */
  24982. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24983. /**
  24984. * Mesh side orientation : usually the external or front surface
  24985. */
  24986. static readonly FRONTSIDE: number;
  24987. /**
  24988. * Mesh side orientation : usually the internal or back surface
  24989. */
  24990. static readonly BACKSIDE: number;
  24991. /**
  24992. * Mesh side orientation : both internal and external or front and back surfaces
  24993. */
  24994. static readonly DOUBLESIDE: number;
  24995. /**
  24996. * Mesh side orientation : by default, `FRONTSIDE`
  24997. */
  24998. static readonly DEFAULTSIDE: number;
  24999. /**
  25000. * Mesh cap setting : no cap
  25001. */
  25002. static readonly NO_CAP: number;
  25003. /**
  25004. * Mesh cap setting : one cap at the beginning of the mesh
  25005. */
  25006. static readonly CAP_START: number;
  25007. /**
  25008. * Mesh cap setting : one cap at the end of the mesh
  25009. */
  25010. static readonly CAP_END: number;
  25011. /**
  25012. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25013. */
  25014. static readonly CAP_ALL: number;
  25015. /**
  25016. * Mesh pattern setting : no flip or rotate
  25017. */
  25018. static readonly NO_FLIP: number;
  25019. /**
  25020. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25021. */
  25022. static readonly FLIP_TILE: number;
  25023. /**
  25024. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25025. */
  25026. static readonly ROTATE_TILE: number;
  25027. /**
  25028. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25029. */
  25030. static readonly FLIP_ROW: number;
  25031. /**
  25032. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25033. */
  25034. static readonly ROTATE_ROW: number;
  25035. /**
  25036. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25037. */
  25038. static readonly FLIP_N_ROTATE_TILE: number;
  25039. /**
  25040. * Mesh pattern setting : rotate pattern and rotate
  25041. */
  25042. static readonly FLIP_N_ROTATE_ROW: number;
  25043. /**
  25044. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25045. */
  25046. static readonly CENTER: number;
  25047. /**
  25048. * Mesh tile positioning : part tiles on left
  25049. */
  25050. static readonly LEFT: number;
  25051. /**
  25052. * Mesh tile positioning : part tiles on right
  25053. */
  25054. static readonly RIGHT: number;
  25055. /**
  25056. * Mesh tile positioning : part tiles on top
  25057. */
  25058. static readonly TOP: number;
  25059. /**
  25060. * Mesh tile positioning : part tiles on bottom
  25061. */
  25062. static readonly BOTTOM: number;
  25063. /**
  25064. * Gets the default side orientation.
  25065. * @param orientation the orientation to value to attempt to get
  25066. * @returns the default orientation
  25067. * @hidden
  25068. */
  25069. static _GetDefaultSideOrientation(orientation?: number): number;
  25070. private _internalMeshDataInfo;
  25071. /**
  25072. * An event triggered before rendering the mesh
  25073. */
  25074. get onBeforeRenderObservable(): Observable<Mesh>;
  25075. /**
  25076. * An event triggered before binding the mesh
  25077. */
  25078. get onBeforeBindObservable(): Observable<Mesh>;
  25079. /**
  25080. * An event triggered after rendering the mesh
  25081. */
  25082. get onAfterRenderObservable(): Observable<Mesh>;
  25083. /**
  25084. * An event triggered before drawing the mesh
  25085. */
  25086. get onBeforeDrawObservable(): Observable<Mesh>;
  25087. private _onBeforeDrawObserver;
  25088. /**
  25089. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25090. */
  25091. set onBeforeDraw(callback: () => void);
  25092. get hasInstances(): boolean;
  25093. /**
  25094. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25095. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25096. */
  25097. delayLoadState: number;
  25098. /**
  25099. * Gets the list of instances created from this mesh
  25100. * it is not supposed to be modified manually.
  25101. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25102. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25103. */
  25104. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25105. /**
  25106. * Gets the file containing delay loading data for this mesh
  25107. */
  25108. delayLoadingFile: string;
  25109. /** @hidden */
  25110. _binaryInfo: any;
  25111. /**
  25112. * User defined function used to change how LOD level selection is done
  25113. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25114. */
  25115. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25116. /**
  25117. * Gets or sets the morph target manager
  25118. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25119. */
  25120. get morphTargetManager(): Nullable<MorphTargetManager>;
  25121. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25122. /** @hidden */
  25123. _creationDataStorage: Nullable<_CreationDataStorage>;
  25124. /** @hidden */
  25125. _geometry: Nullable<Geometry>;
  25126. /** @hidden */
  25127. _delayInfo: Array<string>;
  25128. /** @hidden */
  25129. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25130. /** @hidden */
  25131. _instanceDataStorage: _InstanceDataStorage;
  25132. private _effectiveMaterial;
  25133. /** @hidden */
  25134. _shouldGenerateFlatShading: boolean;
  25135. /** @hidden */
  25136. _originalBuilderSideOrientation: number;
  25137. /**
  25138. * Use this property to change the original side orientation defined at construction time
  25139. */
  25140. overrideMaterialSideOrientation: Nullable<number>;
  25141. /**
  25142. * Gets the source mesh (the one used to clone this one from)
  25143. */
  25144. get source(): Nullable<Mesh>;
  25145. /**
  25146. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25147. */
  25148. get isUnIndexed(): boolean;
  25149. set isUnIndexed(value: boolean);
  25150. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25151. get worldMatrixInstancedBuffer(): Float32Array;
  25152. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25153. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25154. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25155. /**
  25156. * @constructor
  25157. * @param name The value used by scene.getMeshByName() to do a lookup.
  25158. * @param scene The scene to add this mesh to.
  25159. * @param parent The parent of this mesh, if it has one
  25160. * @param source An optional Mesh from which geometry is shared, cloned.
  25161. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25162. * When false, achieved by calling a clone(), also passing False.
  25163. * This will make creation of children, recursive.
  25164. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25165. */
  25166. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25167. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25168. doNotInstantiate: boolean;
  25169. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25170. /**
  25171. * Gets the class name
  25172. * @returns the string "Mesh".
  25173. */
  25174. getClassName(): string;
  25175. /** @hidden */
  25176. get _isMesh(): boolean;
  25177. /**
  25178. * Returns a description of this mesh
  25179. * @param fullDetails define if full details about this mesh must be used
  25180. * @returns a descriptive string representing this mesh
  25181. */
  25182. toString(fullDetails?: boolean): string;
  25183. /** @hidden */
  25184. _unBindEffect(): void;
  25185. /**
  25186. * Gets a boolean indicating if this mesh has LOD
  25187. */
  25188. get hasLODLevels(): boolean;
  25189. /**
  25190. * Gets the list of MeshLODLevel associated with the current mesh
  25191. * @returns an array of MeshLODLevel
  25192. */
  25193. getLODLevels(): MeshLODLevel[];
  25194. private _sortLODLevels;
  25195. /**
  25196. * Add a mesh as LOD level triggered at the given distance.
  25197. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25198. * @param distance The distance from the center of the object to show this level
  25199. * @param mesh The mesh to be added as LOD level (can be null)
  25200. * @return This mesh (for chaining)
  25201. */
  25202. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25203. /**
  25204. * Returns the LOD level mesh at the passed distance or null if not found.
  25205. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25206. * @param distance The distance from the center of the object to show this level
  25207. * @returns a Mesh or `null`
  25208. */
  25209. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25210. /**
  25211. * Remove a mesh from the LOD array
  25212. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25213. * @param mesh defines the mesh to be removed
  25214. * @return This mesh (for chaining)
  25215. */
  25216. removeLODLevel(mesh: Mesh): Mesh;
  25217. /**
  25218. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25219. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25220. * @param camera defines the camera to use to compute distance
  25221. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25222. * @return This mesh (for chaining)
  25223. */
  25224. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25225. /**
  25226. * Gets the mesh internal Geometry object
  25227. */
  25228. get geometry(): Nullable<Geometry>;
  25229. /**
  25230. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25231. * @returns the total number of vertices
  25232. */
  25233. getTotalVertices(): number;
  25234. /**
  25235. * Returns the content of an associated vertex buffer
  25236. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25237. * - VertexBuffer.PositionKind
  25238. * - VertexBuffer.UVKind
  25239. * - VertexBuffer.UV2Kind
  25240. * - VertexBuffer.UV3Kind
  25241. * - VertexBuffer.UV4Kind
  25242. * - VertexBuffer.UV5Kind
  25243. * - VertexBuffer.UV6Kind
  25244. * - VertexBuffer.ColorKind
  25245. * - VertexBuffer.MatricesIndicesKind
  25246. * - VertexBuffer.MatricesIndicesExtraKind
  25247. * - VertexBuffer.MatricesWeightsKind
  25248. * - VertexBuffer.MatricesWeightsExtraKind
  25249. * @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
  25250. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25251. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25252. */
  25253. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25254. /**
  25255. * Returns the mesh VertexBuffer object from the requested `kind`
  25256. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25257. * - VertexBuffer.PositionKind
  25258. * - VertexBuffer.NormalKind
  25259. * - VertexBuffer.UVKind
  25260. * - VertexBuffer.UV2Kind
  25261. * - VertexBuffer.UV3Kind
  25262. * - VertexBuffer.UV4Kind
  25263. * - VertexBuffer.UV5Kind
  25264. * - VertexBuffer.UV6Kind
  25265. * - VertexBuffer.ColorKind
  25266. * - VertexBuffer.MatricesIndicesKind
  25267. * - VertexBuffer.MatricesIndicesExtraKind
  25268. * - VertexBuffer.MatricesWeightsKind
  25269. * - VertexBuffer.MatricesWeightsExtraKind
  25270. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25271. */
  25272. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25273. /**
  25274. * Tests if a specific vertex buffer is associated with this mesh
  25275. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25276. * - VertexBuffer.PositionKind
  25277. * - VertexBuffer.NormalKind
  25278. * - VertexBuffer.UVKind
  25279. * - VertexBuffer.UV2Kind
  25280. * - VertexBuffer.UV3Kind
  25281. * - VertexBuffer.UV4Kind
  25282. * - VertexBuffer.UV5Kind
  25283. * - VertexBuffer.UV6Kind
  25284. * - VertexBuffer.ColorKind
  25285. * - VertexBuffer.MatricesIndicesKind
  25286. * - VertexBuffer.MatricesIndicesExtraKind
  25287. * - VertexBuffer.MatricesWeightsKind
  25288. * - VertexBuffer.MatricesWeightsExtraKind
  25289. * @returns a boolean
  25290. */
  25291. isVerticesDataPresent(kind: string): boolean;
  25292. /**
  25293. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25294. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25295. * - VertexBuffer.PositionKind
  25296. * - VertexBuffer.UVKind
  25297. * - VertexBuffer.UV2Kind
  25298. * - VertexBuffer.UV3Kind
  25299. * - VertexBuffer.UV4Kind
  25300. * - VertexBuffer.UV5Kind
  25301. * - VertexBuffer.UV6Kind
  25302. * - VertexBuffer.ColorKind
  25303. * - VertexBuffer.MatricesIndicesKind
  25304. * - VertexBuffer.MatricesIndicesExtraKind
  25305. * - VertexBuffer.MatricesWeightsKind
  25306. * - VertexBuffer.MatricesWeightsExtraKind
  25307. * @returns a boolean
  25308. */
  25309. isVertexBufferUpdatable(kind: string): boolean;
  25310. /**
  25311. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25312. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25313. * - VertexBuffer.PositionKind
  25314. * - VertexBuffer.NormalKind
  25315. * - VertexBuffer.UVKind
  25316. * - VertexBuffer.UV2Kind
  25317. * - VertexBuffer.UV3Kind
  25318. * - VertexBuffer.UV4Kind
  25319. * - VertexBuffer.UV5Kind
  25320. * - VertexBuffer.UV6Kind
  25321. * - VertexBuffer.ColorKind
  25322. * - VertexBuffer.MatricesIndicesKind
  25323. * - VertexBuffer.MatricesIndicesExtraKind
  25324. * - VertexBuffer.MatricesWeightsKind
  25325. * - VertexBuffer.MatricesWeightsExtraKind
  25326. * @returns an array of strings
  25327. */
  25328. getVerticesDataKinds(): string[];
  25329. /**
  25330. * Returns a positive integer : the total number of indices in this mesh geometry.
  25331. * @returns the numner of indices or zero if the mesh has no geometry.
  25332. */
  25333. getTotalIndices(): number;
  25334. /**
  25335. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25336. * @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.
  25337. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25338. * @returns the indices array or an empty array if the mesh has no geometry
  25339. */
  25340. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25341. get isBlocked(): boolean;
  25342. /**
  25343. * Determine if the current mesh is ready to be rendered
  25344. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25345. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25346. * @returns true if all associated assets are ready (material, textures, shaders)
  25347. */
  25348. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25349. /**
  25350. * 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.
  25351. */
  25352. get areNormalsFrozen(): boolean;
  25353. /**
  25354. * 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.
  25355. * @returns the current mesh
  25356. */
  25357. freezeNormals(): Mesh;
  25358. /**
  25359. * 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
  25360. * @returns the current mesh
  25361. */
  25362. unfreezeNormals(): Mesh;
  25363. /**
  25364. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25365. */
  25366. set overridenInstanceCount(count: number);
  25367. /** @hidden */
  25368. _preActivate(): Mesh;
  25369. /** @hidden */
  25370. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25371. /** @hidden */
  25372. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25373. /**
  25374. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25375. * This means the mesh underlying bounding box and sphere are recomputed.
  25376. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25377. * @returns the current mesh
  25378. */
  25379. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25380. /** @hidden */
  25381. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25382. /**
  25383. * This function will subdivide the mesh into multiple submeshes
  25384. * @param count defines the expected number of submeshes
  25385. */
  25386. subdivide(count: number): void;
  25387. /**
  25388. * Copy a FloatArray into a specific associated vertex buffer
  25389. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25390. * - VertexBuffer.PositionKind
  25391. * - VertexBuffer.UVKind
  25392. * - VertexBuffer.UV2Kind
  25393. * - VertexBuffer.UV3Kind
  25394. * - VertexBuffer.UV4Kind
  25395. * - VertexBuffer.UV5Kind
  25396. * - VertexBuffer.UV6Kind
  25397. * - VertexBuffer.ColorKind
  25398. * - VertexBuffer.MatricesIndicesKind
  25399. * - VertexBuffer.MatricesIndicesExtraKind
  25400. * - VertexBuffer.MatricesWeightsKind
  25401. * - VertexBuffer.MatricesWeightsExtraKind
  25402. * @param data defines the data source
  25403. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25404. * @param stride defines the data stride size (can be null)
  25405. * @returns the current mesh
  25406. */
  25407. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25408. /**
  25409. * Delete a vertex buffer associated with this mesh
  25410. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25411. * - VertexBuffer.PositionKind
  25412. * - VertexBuffer.UVKind
  25413. * - VertexBuffer.UV2Kind
  25414. * - VertexBuffer.UV3Kind
  25415. * - VertexBuffer.UV4Kind
  25416. * - VertexBuffer.UV5Kind
  25417. * - VertexBuffer.UV6Kind
  25418. * - VertexBuffer.ColorKind
  25419. * - VertexBuffer.MatricesIndicesKind
  25420. * - VertexBuffer.MatricesIndicesExtraKind
  25421. * - VertexBuffer.MatricesWeightsKind
  25422. * - VertexBuffer.MatricesWeightsExtraKind
  25423. */
  25424. removeVerticesData(kind: string): void;
  25425. /**
  25426. * Flags an associated vertex buffer as updatable
  25427. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25428. * - VertexBuffer.PositionKind
  25429. * - VertexBuffer.UVKind
  25430. * - VertexBuffer.UV2Kind
  25431. * - VertexBuffer.UV3Kind
  25432. * - VertexBuffer.UV4Kind
  25433. * - VertexBuffer.UV5Kind
  25434. * - VertexBuffer.UV6Kind
  25435. * - VertexBuffer.ColorKind
  25436. * - VertexBuffer.MatricesIndicesKind
  25437. * - VertexBuffer.MatricesIndicesExtraKind
  25438. * - VertexBuffer.MatricesWeightsKind
  25439. * - VertexBuffer.MatricesWeightsExtraKind
  25440. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25441. */
  25442. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25443. /**
  25444. * Sets the mesh global Vertex Buffer
  25445. * @param buffer defines the buffer to use
  25446. * @returns the current mesh
  25447. */
  25448. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25449. /**
  25450. * Update a specific associated vertex buffer
  25451. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25452. * - VertexBuffer.PositionKind
  25453. * - VertexBuffer.UVKind
  25454. * - VertexBuffer.UV2Kind
  25455. * - VertexBuffer.UV3Kind
  25456. * - VertexBuffer.UV4Kind
  25457. * - VertexBuffer.UV5Kind
  25458. * - VertexBuffer.UV6Kind
  25459. * - VertexBuffer.ColorKind
  25460. * - VertexBuffer.MatricesIndicesKind
  25461. * - VertexBuffer.MatricesIndicesExtraKind
  25462. * - VertexBuffer.MatricesWeightsKind
  25463. * - VertexBuffer.MatricesWeightsExtraKind
  25464. * @param data defines the data source
  25465. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25466. * @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)
  25467. * @returns the current mesh
  25468. */
  25469. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25470. /**
  25471. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25472. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25473. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25474. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25475. * @returns the current mesh
  25476. */
  25477. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25478. /**
  25479. * Creates a un-shared specific occurence of the geometry for the mesh.
  25480. * @returns the current mesh
  25481. */
  25482. makeGeometryUnique(): Mesh;
  25483. /**
  25484. * Set the index buffer of this mesh
  25485. * @param indices defines the source data
  25486. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25487. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25488. * @returns the current mesh
  25489. */
  25490. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25491. /**
  25492. * Update the current index buffer
  25493. * @param indices defines the source data
  25494. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25495. * @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)
  25496. * @returns the current mesh
  25497. */
  25498. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25499. /**
  25500. * Invert the geometry to move from a right handed system to a left handed one.
  25501. * @returns the current mesh
  25502. */
  25503. toLeftHanded(): Mesh;
  25504. /** @hidden */
  25505. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25506. /** @hidden */
  25507. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25508. /**
  25509. * Registers for this mesh a javascript function called just before the rendering process
  25510. * @param func defines the function to call before rendering this mesh
  25511. * @returns the current mesh
  25512. */
  25513. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25514. /**
  25515. * Disposes a previously registered javascript function called before the rendering
  25516. * @param func defines the function to remove
  25517. * @returns the current mesh
  25518. */
  25519. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25520. /**
  25521. * Registers for this mesh a javascript function called just after the rendering is complete
  25522. * @param func defines the function to call after rendering this mesh
  25523. * @returns the current mesh
  25524. */
  25525. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25526. /**
  25527. * Disposes a previously registered javascript function called after the rendering.
  25528. * @param func defines the function to remove
  25529. * @returns the current mesh
  25530. */
  25531. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25532. /** @hidden */
  25533. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25534. /** @hidden */
  25535. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25536. /** @hidden */
  25537. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25538. /** @hidden */
  25539. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25540. /** @hidden */
  25541. _rebuild(): void;
  25542. /** @hidden */
  25543. _freeze(): void;
  25544. /** @hidden */
  25545. _unFreeze(): void;
  25546. /**
  25547. * 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
  25548. * @param subMesh defines the subMesh to render
  25549. * @param enableAlphaMode defines if alpha mode can be changed
  25550. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25551. * @returns the current mesh
  25552. */
  25553. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25554. private _onBeforeDraw;
  25555. /**
  25556. * Renormalize the mesh and patch it up if there are no weights
  25557. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25558. * However in the case of zero weights then we set just a single influence to 1.
  25559. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25560. */
  25561. cleanMatrixWeights(): void;
  25562. private normalizeSkinFourWeights;
  25563. private normalizeSkinWeightsAndExtra;
  25564. /**
  25565. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25566. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25567. * the user know there was an issue with importing the mesh
  25568. * @returns a validation object with skinned, valid and report string
  25569. */
  25570. validateSkinning(): {
  25571. skinned: boolean;
  25572. valid: boolean;
  25573. report: string;
  25574. };
  25575. /** @hidden */
  25576. _checkDelayState(): Mesh;
  25577. private _queueLoad;
  25578. /**
  25579. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25580. * A mesh is in the frustum if its bounding box intersects the frustum
  25581. * @param frustumPlanes defines the frustum to test
  25582. * @returns true if the mesh is in the frustum planes
  25583. */
  25584. isInFrustum(frustumPlanes: Plane[]): boolean;
  25585. /**
  25586. * Sets the mesh material by the material or multiMaterial `id` property
  25587. * @param id is a string identifying the material or the multiMaterial
  25588. * @returns the current mesh
  25589. */
  25590. setMaterialByID(id: string): Mesh;
  25591. /**
  25592. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25593. * @returns an array of IAnimatable
  25594. */
  25595. getAnimatables(): IAnimatable[];
  25596. /**
  25597. * Modifies the mesh geometry according to the passed transformation matrix.
  25598. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25599. * The mesh normals are modified using the same transformation.
  25600. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25601. * @param transform defines the transform matrix to use
  25602. * @see http://doc.babylonjs.com/resources/baking_transformations
  25603. * @returns the current mesh
  25604. */
  25605. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25606. /**
  25607. * Modifies the mesh geometry according to its own current World Matrix.
  25608. * The mesh World Matrix is then reset.
  25609. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25610. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25611. * @see http://doc.babylonjs.com/resources/baking_transformations
  25612. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25613. * @returns the current mesh
  25614. */
  25615. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25616. /** @hidden */
  25617. get _positions(): Nullable<Vector3[]>;
  25618. /** @hidden */
  25619. _resetPointsArrayCache(): Mesh;
  25620. /** @hidden */
  25621. _generatePointsArray(): boolean;
  25622. /**
  25623. * Returns a new Mesh object generated from the current mesh properties.
  25624. * This method must not get confused with createInstance()
  25625. * @param name is a string, the name given to the new mesh
  25626. * @param newParent can be any Node object (default `null`)
  25627. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25628. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25629. * @returns a new mesh
  25630. */
  25631. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25632. /**
  25633. * Releases resources associated with this mesh.
  25634. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25635. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25636. */
  25637. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25638. /** @hidden */
  25639. _disposeInstanceSpecificData(): void;
  25640. /**
  25641. * Modifies the mesh geometry according to a displacement map.
  25642. * 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.
  25643. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25644. * @param url is a string, the URL from the image file is to be downloaded.
  25645. * @param minHeight is the lower limit of the displacement.
  25646. * @param maxHeight is the upper limit of the displacement.
  25647. * @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.
  25648. * @param uvOffset is an optional vector2 used to offset UV.
  25649. * @param uvScale is an optional vector2 used to scale UV.
  25650. * @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.
  25651. * @returns the Mesh.
  25652. */
  25653. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25654. /**
  25655. * Modifies the mesh geometry according to a displacementMap buffer.
  25656. * 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.
  25657. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25658. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25659. * @param heightMapWidth is the width of the buffer image.
  25660. * @param heightMapHeight is the height of the buffer image.
  25661. * @param minHeight is the lower limit of the displacement.
  25662. * @param maxHeight is the upper limit of the displacement.
  25663. * @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.
  25664. * @param uvOffset is an optional vector2 used to offset UV.
  25665. * @param uvScale is an optional vector2 used to scale UV.
  25666. * @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.
  25667. * @returns the Mesh.
  25668. */
  25669. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25670. /**
  25671. * Modify the mesh to get a flat shading rendering.
  25672. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25673. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25674. * @returns current mesh
  25675. */
  25676. convertToFlatShadedMesh(): Mesh;
  25677. /**
  25678. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25679. * In other words, more vertices, no more indices and a single bigger VBO.
  25680. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25681. * @returns current mesh
  25682. */
  25683. convertToUnIndexedMesh(): Mesh;
  25684. /**
  25685. * Inverses facet orientations.
  25686. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25687. * @param flipNormals will also inverts the normals
  25688. * @returns current mesh
  25689. */
  25690. flipFaces(flipNormals?: boolean): Mesh;
  25691. /**
  25692. * Increase the number of facets and hence vertices in a mesh
  25693. * Vertex normals are interpolated from existing vertex normals
  25694. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25695. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25696. */
  25697. increaseVertices(numberPerEdge: number): void;
  25698. /**
  25699. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25700. * This will undo any application of covertToFlatShadedMesh
  25701. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25702. */
  25703. forceSharedVertices(): void;
  25704. /** @hidden */
  25705. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25706. /** @hidden */
  25707. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25708. /**
  25709. * Creates a new InstancedMesh object from the mesh model.
  25710. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25711. * @param name defines the name of the new instance
  25712. * @returns a new InstancedMesh
  25713. */
  25714. createInstance(name: string): InstancedMesh;
  25715. /**
  25716. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25717. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25718. * @returns the current mesh
  25719. */
  25720. synchronizeInstances(): Mesh;
  25721. /**
  25722. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25723. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25724. * This should be used together with the simplification to avoid disappearing triangles.
  25725. * @param successCallback an optional success callback to be called after the optimization finished.
  25726. * @returns the current mesh
  25727. */
  25728. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25729. /**
  25730. * Serialize current mesh
  25731. * @param serializationObject defines the object which will receive the serialization data
  25732. */
  25733. serialize(serializationObject: any): void;
  25734. /** @hidden */
  25735. _syncGeometryWithMorphTargetManager(): void;
  25736. /** @hidden */
  25737. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25738. /**
  25739. * Returns a new Mesh object parsed from the source provided.
  25740. * @param parsedMesh is the source
  25741. * @param scene defines the hosting scene
  25742. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25743. * @returns a new Mesh
  25744. */
  25745. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25746. /**
  25747. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25748. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25749. * @param name defines the name of the mesh to create
  25750. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25751. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25752. * @param closePath creates a seam between the first and the last points of each path of the path array
  25753. * @param offset is taken in account only if the `pathArray` is containing a single path
  25754. * @param scene defines the hosting scene
  25755. * @param updatable defines if the mesh must be flagged as updatable
  25756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25757. * @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)
  25758. * @returns a new Mesh
  25759. */
  25760. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25761. /**
  25762. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25763. * @param name defines the name of the mesh to create
  25764. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25765. * @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
  25766. * @param scene defines the hosting scene
  25767. * @param updatable defines if the mesh must be flagged as updatable
  25768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25769. * @returns a new Mesh
  25770. */
  25771. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25772. /**
  25773. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25774. * @param name defines the name of the mesh to create
  25775. * @param size sets the size (float) of each box side (default 1)
  25776. * @param scene defines the hosting scene
  25777. * @param updatable defines if the mesh must be flagged as updatable
  25778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25779. * @returns a new Mesh
  25780. */
  25781. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25782. /**
  25783. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25784. * @param name defines the name of the mesh to create
  25785. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25786. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25787. * @param scene defines the hosting scene
  25788. * @param updatable defines if the mesh must be flagged as updatable
  25789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25790. * @returns a new Mesh
  25791. */
  25792. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25793. /**
  25794. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25795. * @param name defines the name of the mesh to create
  25796. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25797. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25798. * @param scene defines the hosting scene
  25799. * @returns a new Mesh
  25800. */
  25801. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25802. /**
  25803. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25804. * @param name defines the name of the mesh to create
  25805. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25806. * @param diameterTop set the top cap diameter (floats, default 1)
  25807. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25808. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25809. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25810. * @param scene defines the hosting scene
  25811. * @param updatable defines if the mesh must be flagged as updatable
  25812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25813. * @returns a new Mesh
  25814. */
  25815. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25816. /**
  25817. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25818. * @param name defines the name of the mesh to create
  25819. * @param diameter sets the diameter size (float) of the torus (default 1)
  25820. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25821. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25822. * @param scene defines the hosting scene
  25823. * @param updatable defines if the mesh must be flagged as updatable
  25824. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25825. * @returns a new Mesh
  25826. */
  25827. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25828. /**
  25829. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25830. * @param name defines the name of the mesh to create
  25831. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25832. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25833. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25834. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25835. * @param p the number of windings on X axis (positive integers, default 2)
  25836. * @param q the number of windings on Y axis (positive integers, default 3)
  25837. * @param scene defines the hosting scene
  25838. * @param updatable defines if the mesh must be flagged as updatable
  25839. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25840. * @returns a new Mesh
  25841. */
  25842. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25843. /**
  25844. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25845. * @param name defines the name of the mesh to create
  25846. * @param points is an array successive Vector3
  25847. * @param scene defines the hosting scene
  25848. * @param updatable defines if the mesh must be flagged as updatable
  25849. * @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).
  25850. * @returns a new Mesh
  25851. */
  25852. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25853. /**
  25854. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25855. * @param name defines the name of the mesh to create
  25856. * @param points is an array successive Vector3
  25857. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25858. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25859. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25860. * @param scene defines the hosting scene
  25861. * @param updatable defines if the mesh must be flagged as updatable
  25862. * @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)
  25863. * @returns a new Mesh
  25864. */
  25865. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25866. /**
  25867. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25868. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25869. * 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.
  25870. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25871. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25872. * Remember you can only change the shape positions, not their number when updating a polygon.
  25873. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25874. * @param name defines the name of the mesh to create
  25875. * @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
  25876. * @param scene defines the hosting scene
  25877. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25878. * @param updatable defines if the mesh must be flagged as updatable
  25879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25880. * @param earcutInjection can be used to inject your own earcut reference
  25881. * @returns a new Mesh
  25882. */
  25883. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25884. /**
  25885. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25886. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25887. * @param name defines the name of the mesh to create
  25888. * @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
  25889. * @param depth defines the height of extrusion
  25890. * @param scene defines the hosting scene
  25891. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25892. * @param updatable defines if the mesh must be flagged as updatable
  25893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25894. * @param earcutInjection can be used to inject your own earcut reference
  25895. * @returns a new Mesh
  25896. */
  25897. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25898. /**
  25899. * Creates an extruded shape mesh.
  25900. * 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
  25901. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25902. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25903. * @param name defines the name of the mesh to create
  25904. * @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
  25905. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25906. * @param scale is the value to scale the shape
  25907. * @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
  25908. * @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
  25909. * @param scene defines the hosting scene
  25910. * @param updatable defines if the mesh must be flagged as updatable
  25911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25912. * @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)
  25913. * @returns a new Mesh
  25914. */
  25915. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25916. /**
  25917. * Creates an custom extruded shape mesh.
  25918. * The custom extrusion is a parametric shape.
  25919. * It has no predefined shape. Its final shape will depend on the input parameters.
  25920. * Please consider using the same method from the MeshBuilder class instead
  25921. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25922. * @param name defines the name of the mesh to create
  25923. * @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
  25924. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25925. * @param scaleFunction is a custom Javascript function called on each path point
  25926. * @param rotationFunction is a custom Javascript function called on each path point
  25927. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25928. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25929. * @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
  25930. * @param scene defines the hosting scene
  25931. * @param updatable defines if the mesh must be flagged as updatable
  25932. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25933. * @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)
  25934. * @returns a new Mesh
  25935. */
  25936. 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;
  25937. /**
  25938. * Creates lathe mesh.
  25939. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25940. * Please consider using the same method from the MeshBuilder class instead
  25941. * @param name defines the name of the mesh to create
  25942. * @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
  25943. * @param radius is the radius value of the lathe
  25944. * @param tessellation is the side number of the lathe.
  25945. * @param scene defines the hosting scene
  25946. * @param updatable defines if the mesh must be flagged as updatable
  25947. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25948. * @returns a new Mesh
  25949. */
  25950. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25951. /**
  25952. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25953. * @param name defines the name of the mesh to create
  25954. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25955. * @param scene defines the hosting scene
  25956. * @param updatable defines if the mesh must be flagged as updatable
  25957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25958. * @returns a new Mesh
  25959. */
  25960. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25961. /**
  25962. * Creates a ground mesh.
  25963. * Please consider using the same method from the MeshBuilder class instead
  25964. * @param name defines the name of the mesh to create
  25965. * @param width set the width of the ground
  25966. * @param height set the height of the ground
  25967. * @param subdivisions sets the number of subdivisions per side
  25968. * @param scene defines the hosting scene
  25969. * @param updatable defines if the mesh must be flagged as updatable
  25970. * @returns a new Mesh
  25971. */
  25972. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25973. /**
  25974. * Creates a tiled ground mesh.
  25975. * Please consider using the same method from the MeshBuilder class instead
  25976. * @param name defines the name of the mesh to create
  25977. * @param xmin set the ground minimum X coordinate
  25978. * @param zmin set the ground minimum Y coordinate
  25979. * @param xmax set the ground maximum X coordinate
  25980. * @param zmax set the ground maximum Z coordinate
  25981. * @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
  25982. * @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
  25983. * @param scene defines the hosting scene
  25984. * @param updatable defines if the mesh must be flagged as updatable
  25985. * @returns a new Mesh
  25986. */
  25987. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25988. w: number;
  25989. h: number;
  25990. }, precision: {
  25991. w: number;
  25992. h: number;
  25993. }, scene: Scene, updatable?: boolean): Mesh;
  25994. /**
  25995. * Creates a ground mesh from a height map.
  25996. * Please consider using the same method from the MeshBuilder class instead
  25997. * @see http://doc.babylonjs.com/babylon101/height_map
  25998. * @param name defines the name of the mesh to create
  25999. * @param url sets the URL of the height map image resource
  26000. * @param width set the ground width size
  26001. * @param height set the ground height size
  26002. * @param subdivisions sets the number of subdivision per side
  26003. * @param minHeight is the minimum altitude on the ground
  26004. * @param maxHeight is the maximum altitude on the ground
  26005. * @param scene defines the hosting scene
  26006. * @param updatable defines if the mesh must be flagged as updatable
  26007. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26008. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26009. * @returns a new Mesh
  26010. */
  26011. 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;
  26012. /**
  26013. * Creates a tube mesh.
  26014. * The tube is a parametric shape.
  26015. * It has no predefined shape. Its final shape will depend on the input parameters.
  26016. * Please consider using the same method from the MeshBuilder class instead
  26017. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26018. * @param name defines the name of the mesh to create
  26019. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26020. * @param radius sets the tube radius size
  26021. * @param tessellation is the number of sides on the tubular surface
  26022. * @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
  26023. * @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
  26024. * @param scene defines the hosting scene
  26025. * @param updatable defines if the mesh must be flagged as updatable
  26026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26027. * @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)
  26028. * @returns a new Mesh
  26029. */
  26030. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26031. (i: number, distance: number): number;
  26032. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26033. /**
  26034. * Creates a polyhedron mesh.
  26035. * Please consider using the same method from the MeshBuilder class instead.
  26036. * * 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
  26037. * * The parameter `size` (positive float, default 1) sets the polygon size
  26038. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26039. * * 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`
  26040. * * 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
  26041. * * 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)`)
  26042. * * 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
  26043. * * 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
  26044. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26045. * * If you create a double-sided mesh, you can choose what parts of 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
  26046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26047. * @param name defines the name of the mesh to create
  26048. * @param options defines the options used to create the mesh
  26049. * @param scene defines the hosting scene
  26050. * @returns a new Mesh
  26051. */
  26052. static CreatePolyhedron(name: string, options: {
  26053. type?: number;
  26054. size?: number;
  26055. sizeX?: number;
  26056. sizeY?: number;
  26057. sizeZ?: number;
  26058. custom?: any;
  26059. faceUV?: Vector4[];
  26060. faceColors?: Color4[];
  26061. updatable?: boolean;
  26062. sideOrientation?: number;
  26063. }, scene: Scene): Mesh;
  26064. /**
  26065. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26066. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26067. * * 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`)
  26068. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26069. * * 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
  26070. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26071. * * If you create a double-sided mesh, you can choose what parts of 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
  26072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26073. * @param name defines the name of the mesh
  26074. * @param options defines the options used to create the mesh
  26075. * @param scene defines the hosting scene
  26076. * @returns a new Mesh
  26077. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26078. */
  26079. static CreateIcoSphere(name: string, options: {
  26080. radius?: number;
  26081. flat?: boolean;
  26082. subdivisions?: number;
  26083. sideOrientation?: number;
  26084. updatable?: boolean;
  26085. }, scene: Scene): Mesh;
  26086. /**
  26087. * Creates a decal mesh.
  26088. * Please consider using the same method from the MeshBuilder class instead.
  26089. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26090. * @param name defines the name of the mesh
  26091. * @param sourceMesh defines the mesh receiving the decal
  26092. * @param position sets the position of the decal in world coordinates
  26093. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26094. * @param size sets the decal scaling
  26095. * @param angle sets the angle to rotate the decal
  26096. * @returns a new Mesh
  26097. */
  26098. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26099. /**
  26100. * Prepare internal position array for software CPU skinning
  26101. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26102. */
  26103. setPositionsForCPUSkinning(): Float32Array;
  26104. /**
  26105. * Prepare internal normal array for software CPU skinning
  26106. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26107. */
  26108. setNormalsForCPUSkinning(): Float32Array;
  26109. /**
  26110. * Updates the vertex buffer by applying transformation from the bones
  26111. * @param skeleton defines the skeleton to apply to current mesh
  26112. * @returns the current mesh
  26113. */
  26114. applySkeleton(skeleton: Skeleton): Mesh;
  26115. /**
  26116. * 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
  26117. * @param meshes defines the list of meshes to scan
  26118. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26119. */
  26120. static MinMax(meshes: AbstractMesh[]): {
  26121. min: Vector3;
  26122. max: Vector3;
  26123. };
  26124. /**
  26125. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26126. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26127. * @returns a vector3
  26128. */
  26129. static Center(meshesOrMinMaxVector: {
  26130. min: Vector3;
  26131. max: Vector3;
  26132. } | AbstractMesh[]): Vector3;
  26133. /**
  26134. * Merge the array of meshes into a single mesh for performance reasons.
  26135. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26136. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26137. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26138. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26139. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26140. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26141. * @returns a new mesh
  26142. */
  26143. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26144. /** @hidden */
  26145. addInstance(instance: InstancedMesh): void;
  26146. /** @hidden */
  26147. removeInstance(instance: InstancedMesh): void;
  26148. }
  26149. }
  26150. declare module "babylonjs/Cameras/camera" {
  26151. import { SmartArray } from "babylonjs/Misc/smartArray";
  26152. import { Observable } from "babylonjs/Misc/observable";
  26153. import { Nullable } from "babylonjs/types";
  26154. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26155. import { Scene } from "babylonjs/scene";
  26156. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26157. import { Node } from "babylonjs/node";
  26158. import { Mesh } from "babylonjs/Meshes/mesh";
  26159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26160. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26161. import { Viewport } from "babylonjs/Maths/math.viewport";
  26162. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26163. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26165. import { Ray } from "babylonjs/Culling/ray";
  26166. /**
  26167. * This is the base class of all the camera used in the application.
  26168. * @see http://doc.babylonjs.com/features/cameras
  26169. */
  26170. export class Camera extends Node {
  26171. /** @hidden */
  26172. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26173. /**
  26174. * This is the default projection mode used by the cameras.
  26175. * It helps recreating a feeling of perspective and better appreciate depth.
  26176. * This is the best way to simulate real life cameras.
  26177. */
  26178. static readonly PERSPECTIVE_CAMERA: number;
  26179. /**
  26180. * This helps creating camera with an orthographic mode.
  26181. * 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.
  26182. */
  26183. static readonly ORTHOGRAPHIC_CAMERA: number;
  26184. /**
  26185. * This is the default FOV mode for perspective cameras.
  26186. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26187. */
  26188. static readonly FOVMODE_VERTICAL_FIXED: number;
  26189. /**
  26190. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26191. */
  26192. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26193. /**
  26194. * This specifies ther is no need for a camera rig.
  26195. * Basically only one eye is rendered corresponding to the camera.
  26196. */
  26197. static readonly RIG_MODE_NONE: number;
  26198. /**
  26199. * Simulates a camera Rig with one blue eye and one red eye.
  26200. * This can be use with 3d blue and red glasses.
  26201. */
  26202. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26203. /**
  26204. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26205. */
  26206. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26207. /**
  26208. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26209. */
  26210. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26211. /**
  26212. * Defines that both eyes of the camera will be rendered over under each other.
  26213. */
  26214. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26215. /**
  26216. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26217. */
  26218. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26219. /**
  26220. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26221. */
  26222. static readonly RIG_MODE_VR: number;
  26223. /**
  26224. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26225. */
  26226. static readonly RIG_MODE_WEBVR: number;
  26227. /**
  26228. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26229. */
  26230. static readonly RIG_MODE_CUSTOM: number;
  26231. /**
  26232. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26233. */
  26234. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26235. /**
  26236. * Define the input manager associated with the camera.
  26237. */
  26238. inputs: CameraInputsManager<Camera>;
  26239. /** @hidden */
  26240. _position: Vector3;
  26241. /**
  26242. * Define the current local position of the camera in the scene
  26243. */
  26244. get position(): Vector3;
  26245. set position(newPosition: Vector3);
  26246. /**
  26247. * The vector the camera should consider as up.
  26248. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26249. */
  26250. upVector: Vector3;
  26251. /**
  26252. * Define the current limit on the left side for an orthographic camera
  26253. * In scene unit
  26254. */
  26255. orthoLeft: Nullable<number>;
  26256. /**
  26257. * Define the current limit on the right side for an orthographic camera
  26258. * In scene unit
  26259. */
  26260. orthoRight: Nullable<number>;
  26261. /**
  26262. * Define the current limit on the bottom side for an orthographic camera
  26263. * In scene unit
  26264. */
  26265. orthoBottom: Nullable<number>;
  26266. /**
  26267. * Define the current limit on the top side for an orthographic camera
  26268. * In scene unit
  26269. */
  26270. orthoTop: Nullable<number>;
  26271. /**
  26272. * Field Of View is set in Radians. (default is 0.8)
  26273. */
  26274. fov: number;
  26275. /**
  26276. * Define the minimum distance the camera can see from.
  26277. * This is important to note that the depth buffer are not infinite and the closer it starts
  26278. * the more your scene might encounter depth fighting issue.
  26279. */
  26280. minZ: number;
  26281. /**
  26282. * Define the maximum distance the camera can see to.
  26283. * This is important to note that the depth buffer are not infinite and the further it end
  26284. * the more your scene might encounter depth fighting issue.
  26285. */
  26286. maxZ: number;
  26287. /**
  26288. * Define the default inertia of the camera.
  26289. * This helps giving a smooth feeling to the camera movement.
  26290. */
  26291. inertia: number;
  26292. /**
  26293. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26294. */
  26295. mode: number;
  26296. /**
  26297. * Define whether the camera is intermediate.
  26298. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26299. */
  26300. isIntermediate: boolean;
  26301. /**
  26302. * Define the viewport of the camera.
  26303. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26304. */
  26305. viewport: Viewport;
  26306. /**
  26307. * Restricts the camera to viewing objects with the same layerMask.
  26308. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26309. */
  26310. layerMask: number;
  26311. /**
  26312. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26313. */
  26314. fovMode: number;
  26315. /**
  26316. * Rig mode of the camera.
  26317. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26318. * This is normally controlled byt the camera themselves as internal use.
  26319. */
  26320. cameraRigMode: number;
  26321. /**
  26322. * Defines the distance between both "eyes" in case of a RIG
  26323. */
  26324. interaxialDistance: number;
  26325. /**
  26326. * Defines if stereoscopic rendering is done side by side or over under.
  26327. */
  26328. isStereoscopicSideBySide: boolean;
  26329. /**
  26330. * 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
  26331. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26332. * else in the scene. (Eg. security camera)
  26333. *
  26334. * 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)
  26335. */
  26336. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26337. /**
  26338. * When set, the camera will render to this render target instead of the default canvas
  26339. *
  26340. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26341. */
  26342. outputRenderTarget: Nullable<RenderTargetTexture>;
  26343. /**
  26344. * Observable triggered when the camera view matrix has changed.
  26345. */
  26346. onViewMatrixChangedObservable: Observable<Camera>;
  26347. /**
  26348. * Observable triggered when the camera Projection matrix has changed.
  26349. */
  26350. onProjectionMatrixChangedObservable: Observable<Camera>;
  26351. /**
  26352. * Observable triggered when the inputs have been processed.
  26353. */
  26354. onAfterCheckInputsObservable: Observable<Camera>;
  26355. /**
  26356. * Observable triggered when reset has been called and applied to the camera.
  26357. */
  26358. onRestoreStateObservable: Observable<Camera>;
  26359. /**
  26360. * Is this camera a part of a rig system?
  26361. */
  26362. isRigCamera: boolean;
  26363. /**
  26364. * If isRigCamera set to true this will be set with the parent camera.
  26365. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26366. */
  26367. rigParent?: Camera;
  26368. /** @hidden */
  26369. _cameraRigParams: any;
  26370. /** @hidden */
  26371. _rigCameras: Camera[];
  26372. /** @hidden */
  26373. _rigPostProcess: Nullable<PostProcess>;
  26374. protected _webvrViewMatrix: Matrix;
  26375. /** @hidden */
  26376. _skipRendering: boolean;
  26377. /** @hidden */
  26378. _projectionMatrix: Matrix;
  26379. /** @hidden */
  26380. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26381. /** @hidden */
  26382. _activeMeshes: SmartArray<AbstractMesh>;
  26383. protected _globalPosition: Vector3;
  26384. /** @hidden */
  26385. _computedViewMatrix: Matrix;
  26386. private _doNotComputeProjectionMatrix;
  26387. private _transformMatrix;
  26388. private _frustumPlanes;
  26389. private _refreshFrustumPlanes;
  26390. private _storedFov;
  26391. private _stateStored;
  26392. /**
  26393. * Instantiates a new camera object.
  26394. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26395. * @see http://doc.babylonjs.com/features/cameras
  26396. * @param name Defines the name of the camera in the scene
  26397. * @param position Defines the position of the camera
  26398. * @param scene Defines the scene the camera belongs too
  26399. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26400. */
  26401. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26402. /**
  26403. * Store current camera state (fov, position, etc..)
  26404. * @returns the camera
  26405. */
  26406. storeState(): Camera;
  26407. /**
  26408. * Restores the camera state values if it has been stored. You must call storeState() first
  26409. */
  26410. protected _restoreStateValues(): boolean;
  26411. /**
  26412. * Restored camera state. You must call storeState() first.
  26413. * @returns true if restored and false otherwise
  26414. */
  26415. restoreState(): boolean;
  26416. /**
  26417. * Gets the class name of the camera.
  26418. * @returns the class name
  26419. */
  26420. getClassName(): string;
  26421. /** @hidden */
  26422. readonly _isCamera: boolean;
  26423. /**
  26424. * Gets a string representation of the camera useful for debug purpose.
  26425. * @param fullDetails Defines that a more verboe level of logging is required
  26426. * @returns the string representation
  26427. */
  26428. toString(fullDetails?: boolean): string;
  26429. /**
  26430. * Gets the current world space position of the camera.
  26431. */
  26432. get globalPosition(): Vector3;
  26433. /**
  26434. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26435. * @returns the active meshe list
  26436. */
  26437. getActiveMeshes(): SmartArray<AbstractMesh>;
  26438. /**
  26439. * Check whether a mesh is part of the current active mesh list of the camera
  26440. * @param mesh Defines the mesh to check
  26441. * @returns true if active, false otherwise
  26442. */
  26443. isActiveMesh(mesh: Mesh): boolean;
  26444. /**
  26445. * Is this camera ready to be used/rendered
  26446. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26447. * @return true if the camera is ready
  26448. */
  26449. isReady(completeCheck?: boolean): boolean;
  26450. /** @hidden */
  26451. _initCache(): void;
  26452. /** @hidden */
  26453. _updateCache(ignoreParentClass?: boolean): void;
  26454. /** @hidden */
  26455. _isSynchronized(): boolean;
  26456. /** @hidden */
  26457. _isSynchronizedViewMatrix(): boolean;
  26458. /** @hidden */
  26459. _isSynchronizedProjectionMatrix(): boolean;
  26460. /**
  26461. * Attach the input controls to a specific dom element to get the input from.
  26462. * @param element Defines the element the controls should be listened from
  26463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26464. */
  26465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26466. /**
  26467. * Detach the current controls from the specified dom element.
  26468. * @param element Defines the element to stop listening the inputs from
  26469. */
  26470. detachControl(element: HTMLElement): void;
  26471. /**
  26472. * Update the camera state according to the different inputs gathered during the frame.
  26473. */
  26474. update(): void;
  26475. /** @hidden */
  26476. _checkInputs(): void;
  26477. /** @hidden */
  26478. get rigCameras(): Camera[];
  26479. /**
  26480. * Gets the post process used by the rig cameras
  26481. */
  26482. get rigPostProcess(): Nullable<PostProcess>;
  26483. /**
  26484. * Internal, gets the first post proces.
  26485. * @returns the first post process to be run on this camera.
  26486. */
  26487. _getFirstPostProcess(): Nullable<PostProcess>;
  26488. private _cascadePostProcessesToRigCams;
  26489. /**
  26490. * Attach a post process to the camera.
  26491. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26492. * @param postProcess The post process to attach to the camera
  26493. * @param insertAt The position of the post process in case several of them are in use in the scene
  26494. * @returns the position the post process has been inserted at
  26495. */
  26496. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26497. /**
  26498. * Detach a post process to the camera.
  26499. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26500. * @param postProcess The post process to detach from the camera
  26501. */
  26502. detachPostProcess(postProcess: PostProcess): void;
  26503. /**
  26504. * Gets the current world matrix of the camera
  26505. */
  26506. getWorldMatrix(): Matrix;
  26507. /** @hidden */
  26508. _getViewMatrix(): Matrix;
  26509. /**
  26510. * Gets the current view matrix of the camera.
  26511. * @param force forces the camera to recompute the matrix without looking at the cached state
  26512. * @returns the view matrix
  26513. */
  26514. getViewMatrix(force?: boolean): Matrix;
  26515. /**
  26516. * Freeze the projection matrix.
  26517. * It will prevent the cache check of the camera projection compute and can speed up perf
  26518. * if no parameter of the camera are meant to change
  26519. * @param projection Defines manually a projection if necessary
  26520. */
  26521. freezeProjectionMatrix(projection?: Matrix): void;
  26522. /**
  26523. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26524. */
  26525. unfreezeProjectionMatrix(): void;
  26526. /**
  26527. * Gets the current projection matrix of the camera.
  26528. * @param force forces the camera to recompute the matrix without looking at the cached state
  26529. * @returns the projection matrix
  26530. */
  26531. getProjectionMatrix(force?: boolean): Matrix;
  26532. /**
  26533. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26534. * @returns a Matrix
  26535. */
  26536. getTransformationMatrix(): Matrix;
  26537. private _updateFrustumPlanes;
  26538. /**
  26539. * Checks if a cullable object (mesh...) is in the camera frustum
  26540. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26541. * @param target The object to check
  26542. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26543. * @returns true if the object is in frustum otherwise false
  26544. */
  26545. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26546. /**
  26547. * Checks if a cullable object (mesh...) is in the camera frustum
  26548. * Unlike isInFrustum this cheks the full bounding box
  26549. * @param target The object to check
  26550. * @returns true if the object is in frustum otherwise false
  26551. */
  26552. isCompletelyInFrustum(target: ICullable): boolean;
  26553. /**
  26554. * Gets a ray in the forward direction from the camera.
  26555. * @param length Defines the length of the ray to create
  26556. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26557. * @param origin Defines the start point of the ray which defaults to the camera position
  26558. * @returns the forward ray
  26559. */
  26560. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26561. /**
  26562. * Releases resources associated with this node.
  26563. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26564. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26565. */
  26566. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26567. /** @hidden */
  26568. _isLeftCamera: boolean;
  26569. /**
  26570. * Gets the left camera of a rig setup in case of Rigged Camera
  26571. */
  26572. get isLeftCamera(): boolean;
  26573. /** @hidden */
  26574. _isRightCamera: boolean;
  26575. /**
  26576. * Gets the right camera of a rig setup in case of Rigged Camera
  26577. */
  26578. get isRightCamera(): boolean;
  26579. /**
  26580. * Gets the left camera of a rig setup in case of Rigged Camera
  26581. */
  26582. get leftCamera(): Nullable<FreeCamera>;
  26583. /**
  26584. * Gets the right camera of a rig setup in case of Rigged Camera
  26585. */
  26586. get rightCamera(): Nullable<FreeCamera>;
  26587. /**
  26588. * Gets the left camera target of a rig setup in case of Rigged Camera
  26589. * @returns the target position
  26590. */
  26591. getLeftTarget(): Nullable<Vector3>;
  26592. /**
  26593. * Gets the right camera target of a rig setup in case of Rigged Camera
  26594. * @returns the target position
  26595. */
  26596. getRightTarget(): Nullable<Vector3>;
  26597. /**
  26598. * @hidden
  26599. */
  26600. setCameraRigMode(mode: number, rigParams: any): void;
  26601. /** @hidden */
  26602. static _setStereoscopicRigMode(camera: Camera): void;
  26603. /** @hidden */
  26604. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26605. /** @hidden */
  26606. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26607. /** @hidden */
  26608. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26609. /** @hidden */
  26610. _getVRProjectionMatrix(): Matrix;
  26611. protected _updateCameraRotationMatrix(): void;
  26612. protected _updateWebVRCameraRotationMatrix(): void;
  26613. /**
  26614. * This function MUST be overwritten by the different WebVR cameras available.
  26615. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26616. * @hidden
  26617. */
  26618. _getWebVRProjectionMatrix(): Matrix;
  26619. /**
  26620. * This function MUST be overwritten by the different WebVR cameras available.
  26621. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26622. * @hidden
  26623. */
  26624. _getWebVRViewMatrix(): Matrix;
  26625. /** @hidden */
  26626. setCameraRigParameter(name: string, value: any): void;
  26627. /**
  26628. * needs to be overridden by children so sub has required properties to be copied
  26629. * @hidden
  26630. */
  26631. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26632. /**
  26633. * May need to be overridden by children
  26634. * @hidden
  26635. */
  26636. _updateRigCameras(): void;
  26637. /** @hidden */
  26638. _setupInputs(): void;
  26639. /**
  26640. * Serialiaze the camera setup to a json represention
  26641. * @returns the JSON representation
  26642. */
  26643. serialize(): any;
  26644. /**
  26645. * Clones the current camera.
  26646. * @param name The cloned camera name
  26647. * @returns the cloned camera
  26648. */
  26649. clone(name: string): Camera;
  26650. /**
  26651. * Gets the direction of the camera relative to a given local axis.
  26652. * @param localAxis Defines the reference axis to provide a relative direction.
  26653. * @return the direction
  26654. */
  26655. getDirection(localAxis: Vector3): Vector3;
  26656. /**
  26657. * Returns the current camera absolute rotation
  26658. */
  26659. get absoluteRotation(): Quaternion;
  26660. /**
  26661. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26662. * @param localAxis Defines the reference axis to provide a relative direction.
  26663. * @param result Defines the vector to store the result in
  26664. */
  26665. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26666. /**
  26667. * Gets a camera constructor for a given camera type
  26668. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26669. * @param name The name of the camera the result will be able to instantiate
  26670. * @param scene The scene the result will construct the camera in
  26671. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26672. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26673. * @returns a factory method to construc the camera
  26674. */
  26675. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26676. /**
  26677. * Compute the world matrix of the camera.
  26678. * @returns the camera world matrix
  26679. */
  26680. computeWorldMatrix(): Matrix;
  26681. /**
  26682. * Parse a JSON and creates the camera from the parsed information
  26683. * @param parsedCamera The JSON to parse
  26684. * @param scene The scene to instantiate the camera in
  26685. * @returns the newly constructed camera
  26686. */
  26687. static Parse(parsedCamera: any, scene: Scene): Camera;
  26688. }
  26689. }
  26690. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26691. import { Nullable } from "babylonjs/types";
  26692. import { Scene } from "babylonjs/scene";
  26693. import { Vector4 } from "babylonjs/Maths/math.vector";
  26694. import { Mesh } from "babylonjs/Meshes/mesh";
  26695. /**
  26696. * Class containing static functions to help procedurally build meshes
  26697. */
  26698. export class DiscBuilder {
  26699. /**
  26700. * Creates a plane polygonal mesh. By default, this is a disc
  26701. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26702. * * 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
  26703. * * 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
  26704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26707. * @param name defines the name of the mesh
  26708. * @param options defines the options used to create the mesh
  26709. * @param scene defines the hosting scene
  26710. * @returns the plane polygonal mesh
  26711. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26712. */
  26713. static CreateDisc(name: string, options: {
  26714. radius?: number;
  26715. tessellation?: number;
  26716. arc?: number;
  26717. updatable?: boolean;
  26718. sideOrientation?: number;
  26719. frontUVs?: Vector4;
  26720. backUVs?: Vector4;
  26721. }, scene?: Nullable<Scene>): Mesh;
  26722. }
  26723. }
  26724. declare module "babylonjs/Materials/fresnelParameters" {
  26725. import { Color3 } from "babylonjs/Maths/math.color";
  26726. /**
  26727. * This represents all the required information to add a fresnel effect on a material:
  26728. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26729. */
  26730. export class FresnelParameters {
  26731. private _isEnabled;
  26732. /**
  26733. * Define if the fresnel effect is enable or not.
  26734. */
  26735. get isEnabled(): boolean;
  26736. set isEnabled(value: boolean);
  26737. /**
  26738. * Define the color used on edges (grazing angle)
  26739. */
  26740. leftColor: Color3;
  26741. /**
  26742. * Define the color used on center
  26743. */
  26744. rightColor: Color3;
  26745. /**
  26746. * Define bias applied to computed fresnel term
  26747. */
  26748. bias: number;
  26749. /**
  26750. * Defined the power exponent applied to fresnel term
  26751. */
  26752. power: number;
  26753. /**
  26754. * Clones the current fresnel and its valuues
  26755. * @returns a clone fresnel configuration
  26756. */
  26757. clone(): FresnelParameters;
  26758. /**
  26759. * Serializes the current fresnel parameters to a JSON representation.
  26760. * @return the JSON serialization
  26761. */
  26762. serialize(): any;
  26763. /**
  26764. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26765. * @param parsedFresnelParameters Define the JSON representation
  26766. * @returns the parsed parameters
  26767. */
  26768. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26769. }
  26770. }
  26771. declare module "babylonjs/Materials/pushMaterial" {
  26772. import { Nullable } from "babylonjs/types";
  26773. import { Scene } from "babylonjs/scene";
  26774. import { Matrix } from "babylonjs/Maths/math.vector";
  26775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26776. import { Mesh } from "babylonjs/Meshes/mesh";
  26777. import { Material } from "babylonjs/Materials/material";
  26778. import { Effect } from "babylonjs/Materials/effect";
  26779. /**
  26780. * Base class of materials working in push mode in babylon JS
  26781. * @hidden
  26782. */
  26783. export class PushMaterial extends Material {
  26784. protected _activeEffect: Effect;
  26785. protected _normalMatrix: Matrix;
  26786. /**
  26787. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26788. * This means that the material can keep using a previous shader while a new one is being compiled.
  26789. * This is mostly used when shader parallel compilation is supported (true by default)
  26790. */
  26791. allowShaderHotSwapping: boolean;
  26792. constructor(name: string, scene: Scene);
  26793. getEffect(): Effect;
  26794. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26795. /**
  26796. * Binds the given world matrix to the active effect
  26797. *
  26798. * @param world the matrix to bind
  26799. */
  26800. bindOnlyWorldMatrix(world: Matrix): void;
  26801. /**
  26802. * Binds the given normal matrix to the active effect
  26803. *
  26804. * @param normalMatrix the matrix to bind
  26805. */
  26806. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26807. bind(world: Matrix, mesh?: Mesh): void;
  26808. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26809. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26810. }
  26811. }
  26812. declare module "babylonjs/Materials/materialFlags" {
  26813. /**
  26814. * This groups all the flags used to control the materials channel.
  26815. */
  26816. export class MaterialFlags {
  26817. private static _DiffuseTextureEnabled;
  26818. /**
  26819. * Are diffuse textures enabled in the application.
  26820. */
  26821. static get DiffuseTextureEnabled(): boolean;
  26822. static set DiffuseTextureEnabled(value: boolean);
  26823. private static _AmbientTextureEnabled;
  26824. /**
  26825. * Are ambient textures enabled in the application.
  26826. */
  26827. static get AmbientTextureEnabled(): boolean;
  26828. static set AmbientTextureEnabled(value: boolean);
  26829. private static _OpacityTextureEnabled;
  26830. /**
  26831. * Are opacity textures enabled in the application.
  26832. */
  26833. static get OpacityTextureEnabled(): boolean;
  26834. static set OpacityTextureEnabled(value: boolean);
  26835. private static _ReflectionTextureEnabled;
  26836. /**
  26837. * Are reflection textures enabled in the application.
  26838. */
  26839. static get ReflectionTextureEnabled(): boolean;
  26840. static set ReflectionTextureEnabled(value: boolean);
  26841. private static _EmissiveTextureEnabled;
  26842. /**
  26843. * Are emissive textures enabled in the application.
  26844. */
  26845. static get EmissiveTextureEnabled(): boolean;
  26846. static set EmissiveTextureEnabled(value: boolean);
  26847. private static _SpecularTextureEnabled;
  26848. /**
  26849. * Are specular textures enabled in the application.
  26850. */
  26851. static get SpecularTextureEnabled(): boolean;
  26852. static set SpecularTextureEnabled(value: boolean);
  26853. private static _BumpTextureEnabled;
  26854. /**
  26855. * Are bump textures enabled in the application.
  26856. */
  26857. static get BumpTextureEnabled(): boolean;
  26858. static set BumpTextureEnabled(value: boolean);
  26859. private static _LightmapTextureEnabled;
  26860. /**
  26861. * Are lightmap textures enabled in the application.
  26862. */
  26863. static get LightmapTextureEnabled(): boolean;
  26864. static set LightmapTextureEnabled(value: boolean);
  26865. private static _RefractionTextureEnabled;
  26866. /**
  26867. * Are refraction textures enabled in the application.
  26868. */
  26869. static get RefractionTextureEnabled(): boolean;
  26870. static set RefractionTextureEnabled(value: boolean);
  26871. private static _ColorGradingTextureEnabled;
  26872. /**
  26873. * Are color grading textures enabled in the application.
  26874. */
  26875. static get ColorGradingTextureEnabled(): boolean;
  26876. static set ColorGradingTextureEnabled(value: boolean);
  26877. private static _FresnelEnabled;
  26878. /**
  26879. * Are fresnels enabled in the application.
  26880. */
  26881. static get FresnelEnabled(): boolean;
  26882. static set FresnelEnabled(value: boolean);
  26883. private static _ClearCoatTextureEnabled;
  26884. /**
  26885. * Are clear coat textures enabled in the application.
  26886. */
  26887. static get ClearCoatTextureEnabled(): boolean;
  26888. static set ClearCoatTextureEnabled(value: boolean);
  26889. private static _ClearCoatBumpTextureEnabled;
  26890. /**
  26891. * Are clear coat bump textures enabled in the application.
  26892. */
  26893. static get ClearCoatBumpTextureEnabled(): boolean;
  26894. static set ClearCoatBumpTextureEnabled(value: boolean);
  26895. private static _ClearCoatTintTextureEnabled;
  26896. /**
  26897. * Are clear coat tint textures enabled in the application.
  26898. */
  26899. static get ClearCoatTintTextureEnabled(): boolean;
  26900. static set ClearCoatTintTextureEnabled(value: boolean);
  26901. private static _SheenTextureEnabled;
  26902. /**
  26903. * Are sheen textures enabled in the application.
  26904. */
  26905. static get SheenTextureEnabled(): boolean;
  26906. static set SheenTextureEnabled(value: boolean);
  26907. private static _AnisotropicTextureEnabled;
  26908. /**
  26909. * Are anisotropic textures enabled in the application.
  26910. */
  26911. static get AnisotropicTextureEnabled(): boolean;
  26912. static set AnisotropicTextureEnabled(value: boolean);
  26913. private static _ThicknessTextureEnabled;
  26914. /**
  26915. * Are thickness textures enabled in the application.
  26916. */
  26917. static get ThicknessTextureEnabled(): boolean;
  26918. static set ThicknessTextureEnabled(value: boolean);
  26919. }
  26920. }
  26921. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26922. /** @hidden */
  26923. export var defaultFragmentDeclaration: {
  26924. name: string;
  26925. shader: string;
  26926. };
  26927. }
  26928. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26929. /** @hidden */
  26930. export var defaultUboDeclaration: {
  26931. name: string;
  26932. shader: string;
  26933. };
  26934. }
  26935. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26936. /** @hidden */
  26937. export var lightFragmentDeclaration: {
  26938. name: string;
  26939. shader: string;
  26940. };
  26941. }
  26942. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26943. /** @hidden */
  26944. export var lightUboDeclaration: {
  26945. name: string;
  26946. shader: string;
  26947. };
  26948. }
  26949. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26950. /** @hidden */
  26951. export var lightsFragmentFunctions: {
  26952. name: string;
  26953. shader: string;
  26954. };
  26955. }
  26956. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26957. /** @hidden */
  26958. export var shadowsFragmentFunctions: {
  26959. name: string;
  26960. shader: string;
  26961. };
  26962. }
  26963. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26964. /** @hidden */
  26965. export var fresnelFunction: {
  26966. name: string;
  26967. shader: string;
  26968. };
  26969. }
  26970. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26971. /** @hidden */
  26972. export var reflectionFunction: {
  26973. name: string;
  26974. shader: string;
  26975. };
  26976. }
  26977. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26978. /** @hidden */
  26979. export var bumpFragmentFunctions: {
  26980. name: string;
  26981. shader: string;
  26982. };
  26983. }
  26984. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26985. /** @hidden */
  26986. export var logDepthDeclaration: {
  26987. name: string;
  26988. shader: string;
  26989. };
  26990. }
  26991. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26992. /** @hidden */
  26993. export var bumpFragment: {
  26994. name: string;
  26995. shader: string;
  26996. };
  26997. }
  26998. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26999. /** @hidden */
  27000. export var depthPrePass: {
  27001. name: string;
  27002. shader: string;
  27003. };
  27004. }
  27005. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27006. /** @hidden */
  27007. export var lightFragment: {
  27008. name: string;
  27009. shader: string;
  27010. };
  27011. }
  27012. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27013. /** @hidden */
  27014. export var logDepthFragment: {
  27015. name: string;
  27016. shader: string;
  27017. };
  27018. }
  27019. declare module "babylonjs/Shaders/default.fragment" {
  27020. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27021. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27023. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27024. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27025. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27026. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27027. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27028. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27029. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27030. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27031. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27032. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27033. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27034. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27035. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27036. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27037. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27038. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27039. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27040. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27041. /** @hidden */
  27042. export var defaultPixelShader: {
  27043. name: string;
  27044. shader: string;
  27045. };
  27046. }
  27047. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27048. /** @hidden */
  27049. export var defaultVertexDeclaration: {
  27050. name: string;
  27051. shader: string;
  27052. };
  27053. }
  27054. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27055. /** @hidden */
  27056. export var bumpVertexDeclaration: {
  27057. name: string;
  27058. shader: string;
  27059. };
  27060. }
  27061. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27062. /** @hidden */
  27063. export var bumpVertex: {
  27064. name: string;
  27065. shader: string;
  27066. };
  27067. }
  27068. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27069. /** @hidden */
  27070. export var fogVertex: {
  27071. name: string;
  27072. shader: string;
  27073. };
  27074. }
  27075. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27076. /** @hidden */
  27077. export var shadowsVertex: {
  27078. name: string;
  27079. shader: string;
  27080. };
  27081. }
  27082. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27083. /** @hidden */
  27084. export var pointCloudVertex: {
  27085. name: string;
  27086. shader: string;
  27087. };
  27088. }
  27089. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27090. /** @hidden */
  27091. export var logDepthVertex: {
  27092. name: string;
  27093. shader: string;
  27094. };
  27095. }
  27096. declare module "babylonjs/Shaders/default.vertex" {
  27097. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27098. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27099. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27100. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27101. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27102. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27103. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27104. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27105. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27106. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27107. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27108. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27109. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27110. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27111. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27112. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27113. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27114. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27115. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27116. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27117. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27118. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27119. /** @hidden */
  27120. export var defaultVertexShader: {
  27121. name: string;
  27122. shader: string;
  27123. };
  27124. }
  27125. declare module "babylonjs/Materials/standardMaterial" {
  27126. import { SmartArray } from "babylonjs/Misc/smartArray";
  27127. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27128. import { Nullable } from "babylonjs/types";
  27129. import { Scene } from "babylonjs/scene";
  27130. import { Matrix } from "babylonjs/Maths/math.vector";
  27131. import { Color3 } from "babylonjs/Maths/math.color";
  27132. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27134. import { Mesh } from "babylonjs/Meshes/mesh";
  27135. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27136. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27137. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27138. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27139. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27141. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27142. import "babylonjs/Shaders/default.fragment";
  27143. import "babylonjs/Shaders/default.vertex";
  27144. /** @hidden */
  27145. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27146. MAINUV1: boolean;
  27147. MAINUV2: boolean;
  27148. DIFFUSE: boolean;
  27149. DIFFUSEDIRECTUV: number;
  27150. AMBIENT: boolean;
  27151. AMBIENTDIRECTUV: number;
  27152. OPACITY: boolean;
  27153. OPACITYDIRECTUV: number;
  27154. OPACITYRGB: boolean;
  27155. REFLECTION: boolean;
  27156. EMISSIVE: boolean;
  27157. EMISSIVEDIRECTUV: number;
  27158. SPECULAR: boolean;
  27159. SPECULARDIRECTUV: number;
  27160. BUMP: boolean;
  27161. BUMPDIRECTUV: number;
  27162. PARALLAX: boolean;
  27163. PARALLAXOCCLUSION: boolean;
  27164. SPECULAROVERALPHA: boolean;
  27165. CLIPPLANE: boolean;
  27166. CLIPPLANE2: boolean;
  27167. CLIPPLANE3: boolean;
  27168. CLIPPLANE4: boolean;
  27169. CLIPPLANE5: boolean;
  27170. CLIPPLANE6: boolean;
  27171. ALPHATEST: boolean;
  27172. DEPTHPREPASS: boolean;
  27173. ALPHAFROMDIFFUSE: boolean;
  27174. POINTSIZE: boolean;
  27175. FOG: boolean;
  27176. SPECULARTERM: boolean;
  27177. DIFFUSEFRESNEL: boolean;
  27178. OPACITYFRESNEL: boolean;
  27179. REFLECTIONFRESNEL: boolean;
  27180. REFRACTIONFRESNEL: boolean;
  27181. EMISSIVEFRESNEL: boolean;
  27182. FRESNEL: boolean;
  27183. NORMAL: boolean;
  27184. UV1: boolean;
  27185. UV2: boolean;
  27186. VERTEXCOLOR: boolean;
  27187. VERTEXALPHA: boolean;
  27188. NUM_BONE_INFLUENCERS: number;
  27189. BonesPerMesh: number;
  27190. BONETEXTURE: boolean;
  27191. INSTANCES: boolean;
  27192. GLOSSINESS: boolean;
  27193. ROUGHNESS: boolean;
  27194. EMISSIVEASILLUMINATION: boolean;
  27195. LINKEMISSIVEWITHDIFFUSE: boolean;
  27196. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27197. LIGHTMAP: boolean;
  27198. LIGHTMAPDIRECTUV: number;
  27199. OBJECTSPACE_NORMALMAP: boolean;
  27200. USELIGHTMAPASSHADOWMAP: boolean;
  27201. REFLECTIONMAP_3D: boolean;
  27202. REFLECTIONMAP_SPHERICAL: boolean;
  27203. REFLECTIONMAP_PLANAR: boolean;
  27204. REFLECTIONMAP_CUBIC: boolean;
  27205. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27206. REFLECTIONMAP_PROJECTION: boolean;
  27207. REFLECTIONMAP_SKYBOX: boolean;
  27208. REFLECTIONMAP_EXPLICIT: boolean;
  27209. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27210. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27211. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27212. INVERTCUBICMAP: boolean;
  27213. LOGARITHMICDEPTH: boolean;
  27214. REFRACTION: boolean;
  27215. REFRACTIONMAP_3D: boolean;
  27216. REFLECTIONOVERALPHA: boolean;
  27217. TWOSIDEDLIGHTING: boolean;
  27218. SHADOWFLOAT: boolean;
  27219. MORPHTARGETS: boolean;
  27220. MORPHTARGETS_NORMAL: boolean;
  27221. MORPHTARGETS_TANGENT: boolean;
  27222. MORPHTARGETS_UV: boolean;
  27223. NUM_MORPH_INFLUENCERS: number;
  27224. NONUNIFORMSCALING: boolean;
  27225. PREMULTIPLYALPHA: boolean;
  27226. IMAGEPROCESSING: boolean;
  27227. VIGNETTE: boolean;
  27228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27229. VIGNETTEBLENDMODEOPAQUE: boolean;
  27230. TONEMAPPING: boolean;
  27231. TONEMAPPING_ACES: boolean;
  27232. CONTRAST: boolean;
  27233. COLORCURVES: boolean;
  27234. COLORGRADING: boolean;
  27235. COLORGRADING3D: boolean;
  27236. SAMPLER3DGREENDEPTH: boolean;
  27237. SAMPLER3DBGRMAP: boolean;
  27238. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27239. MULTIVIEW: boolean;
  27240. /**
  27241. * If the reflection texture on this material is in linear color space
  27242. * @hidden
  27243. */
  27244. IS_REFLECTION_LINEAR: boolean;
  27245. /**
  27246. * If the refraction texture on this material is in linear color space
  27247. * @hidden
  27248. */
  27249. IS_REFRACTION_LINEAR: boolean;
  27250. EXPOSURE: boolean;
  27251. constructor();
  27252. setReflectionMode(modeToEnable: string): void;
  27253. }
  27254. /**
  27255. * This is the default material used in Babylon. It is the best trade off between quality
  27256. * and performances.
  27257. * @see http://doc.babylonjs.com/babylon101/materials
  27258. */
  27259. export class StandardMaterial extends PushMaterial {
  27260. private _diffuseTexture;
  27261. /**
  27262. * The basic texture of the material as viewed under a light.
  27263. */
  27264. diffuseTexture: Nullable<BaseTexture>;
  27265. private _ambientTexture;
  27266. /**
  27267. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27268. */
  27269. ambientTexture: Nullable<BaseTexture>;
  27270. private _opacityTexture;
  27271. /**
  27272. * Define the transparency of the material from a texture.
  27273. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27274. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27275. */
  27276. opacityTexture: Nullable<BaseTexture>;
  27277. private _reflectionTexture;
  27278. /**
  27279. * Define the texture used to display the reflection.
  27280. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27281. */
  27282. reflectionTexture: Nullable<BaseTexture>;
  27283. private _emissiveTexture;
  27284. /**
  27285. * Define texture of the material as if self lit.
  27286. * This will be mixed in the final result even in the absence of light.
  27287. */
  27288. emissiveTexture: Nullable<BaseTexture>;
  27289. private _specularTexture;
  27290. /**
  27291. * Define how the color and intensity of the highlight given by the light in the material.
  27292. */
  27293. specularTexture: Nullable<BaseTexture>;
  27294. private _bumpTexture;
  27295. /**
  27296. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27297. * 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.
  27298. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27299. */
  27300. bumpTexture: Nullable<BaseTexture>;
  27301. private _lightmapTexture;
  27302. /**
  27303. * Complex lighting can be computationally expensive to compute at runtime.
  27304. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27305. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27306. */
  27307. lightmapTexture: Nullable<BaseTexture>;
  27308. private _refractionTexture;
  27309. /**
  27310. * Define the texture used to display the refraction.
  27311. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27312. */
  27313. refractionTexture: Nullable<BaseTexture>;
  27314. /**
  27315. * The color of the material lit by the environmental background lighting.
  27316. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27317. */
  27318. ambientColor: Color3;
  27319. /**
  27320. * The basic color of the material as viewed under a light.
  27321. */
  27322. diffuseColor: Color3;
  27323. /**
  27324. * Define how the color and intensity of the highlight given by the light in the material.
  27325. */
  27326. specularColor: Color3;
  27327. /**
  27328. * Define the color of the material as if self lit.
  27329. * This will be mixed in the final result even in the absence of light.
  27330. */
  27331. emissiveColor: Color3;
  27332. /**
  27333. * Defines how sharp are the highlights in the material.
  27334. * The bigger the value the sharper giving a more glossy feeling to the result.
  27335. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27336. */
  27337. specularPower: number;
  27338. private _useAlphaFromDiffuseTexture;
  27339. /**
  27340. * Does the transparency come from the diffuse texture alpha channel.
  27341. */
  27342. useAlphaFromDiffuseTexture: boolean;
  27343. private _useEmissiveAsIllumination;
  27344. /**
  27345. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27346. */
  27347. useEmissiveAsIllumination: boolean;
  27348. private _linkEmissiveWithDiffuse;
  27349. /**
  27350. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27351. * the emissive level when the final color is close to one.
  27352. */
  27353. linkEmissiveWithDiffuse: boolean;
  27354. private _useSpecularOverAlpha;
  27355. /**
  27356. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27357. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27358. */
  27359. useSpecularOverAlpha: boolean;
  27360. private _useReflectionOverAlpha;
  27361. /**
  27362. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27363. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27364. */
  27365. useReflectionOverAlpha: boolean;
  27366. private _disableLighting;
  27367. /**
  27368. * Does lights from the scene impacts this material.
  27369. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27370. */
  27371. disableLighting: boolean;
  27372. private _useObjectSpaceNormalMap;
  27373. /**
  27374. * Allows using an object space normal map (instead of tangent space).
  27375. */
  27376. useObjectSpaceNormalMap: boolean;
  27377. private _useParallax;
  27378. /**
  27379. * Is parallax enabled or not.
  27380. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27381. */
  27382. useParallax: boolean;
  27383. private _useParallaxOcclusion;
  27384. /**
  27385. * Is parallax occlusion enabled or not.
  27386. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27387. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27388. */
  27389. useParallaxOcclusion: boolean;
  27390. /**
  27391. * 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.
  27392. */
  27393. parallaxScaleBias: number;
  27394. private _roughness;
  27395. /**
  27396. * Helps to define how blurry the reflections should appears in the material.
  27397. */
  27398. roughness: number;
  27399. /**
  27400. * In case of refraction, define the value of the index of refraction.
  27401. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27402. */
  27403. indexOfRefraction: number;
  27404. /**
  27405. * Invert the refraction texture alongside the y axis.
  27406. * It can be useful with procedural textures or probe for instance.
  27407. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27408. */
  27409. invertRefractionY: boolean;
  27410. /**
  27411. * Defines the alpha limits in alpha test mode.
  27412. */
  27413. alphaCutOff: number;
  27414. private _useLightmapAsShadowmap;
  27415. /**
  27416. * In case of light mapping, define whether the map contains light or shadow informations.
  27417. */
  27418. useLightmapAsShadowmap: boolean;
  27419. private _diffuseFresnelParameters;
  27420. /**
  27421. * Define the diffuse fresnel parameters of the material.
  27422. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27423. */
  27424. diffuseFresnelParameters: FresnelParameters;
  27425. private _opacityFresnelParameters;
  27426. /**
  27427. * Define the opacity fresnel parameters of the material.
  27428. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27429. */
  27430. opacityFresnelParameters: FresnelParameters;
  27431. private _reflectionFresnelParameters;
  27432. /**
  27433. * Define the reflection fresnel parameters of the material.
  27434. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27435. */
  27436. reflectionFresnelParameters: FresnelParameters;
  27437. private _refractionFresnelParameters;
  27438. /**
  27439. * Define the refraction fresnel parameters of the material.
  27440. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27441. */
  27442. refractionFresnelParameters: FresnelParameters;
  27443. private _emissiveFresnelParameters;
  27444. /**
  27445. * Define the emissive fresnel parameters of the material.
  27446. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27447. */
  27448. emissiveFresnelParameters: FresnelParameters;
  27449. private _useReflectionFresnelFromSpecular;
  27450. /**
  27451. * If true automatically deducts the fresnels values from the material specularity.
  27452. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27453. */
  27454. useReflectionFresnelFromSpecular: boolean;
  27455. private _useGlossinessFromSpecularMapAlpha;
  27456. /**
  27457. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27458. */
  27459. useGlossinessFromSpecularMapAlpha: boolean;
  27460. private _maxSimultaneousLights;
  27461. /**
  27462. * Defines the maximum number of lights that can be used in the material
  27463. */
  27464. maxSimultaneousLights: number;
  27465. private _invertNormalMapX;
  27466. /**
  27467. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27468. */
  27469. invertNormalMapX: boolean;
  27470. private _invertNormalMapY;
  27471. /**
  27472. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27473. */
  27474. invertNormalMapY: boolean;
  27475. private _twoSidedLighting;
  27476. /**
  27477. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27478. */
  27479. twoSidedLighting: boolean;
  27480. /**
  27481. * Default configuration related to image processing available in the standard Material.
  27482. */
  27483. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27484. /**
  27485. * Gets the image processing configuration used either in this material.
  27486. */
  27487. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27488. /**
  27489. * Sets the Default image processing configuration used either in the this material.
  27490. *
  27491. * If sets to null, the scene one is in use.
  27492. */
  27493. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27494. /**
  27495. * Keep track of the image processing observer to allow dispose and replace.
  27496. */
  27497. private _imageProcessingObserver;
  27498. /**
  27499. * Attaches a new image processing configuration to the Standard Material.
  27500. * @param configuration
  27501. */
  27502. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27503. /**
  27504. * Gets wether the color curves effect is enabled.
  27505. */
  27506. get cameraColorCurvesEnabled(): boolean;
  27507. /**
  27508. * Sets wether the color curves effect is enabled.
  27509. */
  27510. set cameraColorCurvesEnabled(value: boolean);
  27511. /**
  27512. * Gets wether the color grading effect is enabled.
  27513. */
  27514. get cameraColorGradingEnabled(): boolean;
  27515. /**
  27516. * Gets wether the color grading effect is enabled.
  27517. */
  27518. set cameraColorGradingEnabled(value: boolean);
  27519. /**
  27520. * Gets wether tonemapping is enabled or not.
  27521. */
  27522. get cameraToneMappingEnabled(): boolean;
  27523. /**
  27524. * Sets wether tonemapping is enabled or not
  27525. */
  27526. set cameraToneMappingEnabled(value: boolean);
  27527. /**
  27528. * The camera exposure used on this material.
  27529. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27530. * This corresponds to a photographic exposure.
  27531. */
  27532. get cameraExposure(): number;
  27533. /**
  27534. * The camera exposure used on this material.
  27535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27536. * This corresponds to a photographic exposure.
  27537. */
  27538. set cameraExposure(value: number);
  27539. /**
  27540. * Gets The camera contrast used on this material.
  27541. */
  27542. get cameraContrast(): number;
  27543. /**
  27544. * Sets The camera contrast used on this material.
  27545. */
  27546. set cameraContrast(value: number);
  27547. /**
  27548. * Gets the Color Grading 2D Lookup Texture.
  27549. */
  27550. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27551. /**
  27552. * Sets the Color Grading 2D Lookup Texture.
  27553. */
  27554. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27555. /**
  27556. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27557. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27558. * 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;
  27559. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27560. */
  27561. get cameraColorCurves(): Nullable<ColorCurves>;
  27562. /**
  27563. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27564. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27565. * 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;
  27566. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27567. */
  27568. set cameraColorCurves(value: Nullable<ColorCurves>);
  27569. /**
  27570. * Custom callback helping to override the default shader used in the material.
  27571. */
  27572. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27573. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27574. protected _worldViewProjectionMatrix: Matrix;
  27575. protected _globalAmbientColor: Color3;
  27576. protected _useLogarithmicDepth: boolean;
  27577. protected _rebuildInParallel: boolean;
  27578. /**
  27579. * Instantiates a new standard material.
  27580. * This is the default material used in Babylon. It is the best trade off between quality
  27581. * and performances.
  27582. * @see http://doc.babylonjs.com/babylon101/materials
  27583. * @param name Define the name of the material in the scene
  27584. * @param scene Define the scene the material belong to
  27585. */
  27586. constructor(name: string, scene: Scene);
  27587. /**
  27588. * Gets a boolean indicating that current material needs to register RTT
  27589. */
  27590. get hasRenderTargetTextures(): boolean;
  27591. /**
  27592. * Gets the current class name of the material e.g. "StandardMaterial"
  27593. * Mainly use in serialization.
  27594. * @returns the class name
  27595. */
  27596. getClassName(): string;
  27597. /**
  27598. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27599. * You can try switching to logarithmic depth.
  27600. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27601. */
  27602. get useLogarithmicDepth(): boolean;
  27603. set useLogarithmicDepth(value: boolean);
  27604. /**
  27605. * Specifies if the material will require alpha blending
  27606. * @returns a boolean specifying if alpha blending is needed
  27607. */
  27608. needAlphaBlending(): boolean;
  27609. /**
  27610. * Specifies if this material should be rendered in alpha test mode
  27611. * @returns a boolean specifying if an alpha test is needed.
  27612. */
  27613. needAlphaTesting(): boolean;
  27614. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27615. /**
  27616. * Get the texture used for alpha test purpose.
  27617. * @returns the diffuse texture in case of the standard material.
  27618. */
  27619. getAlphaTestTexture(): Nullable<BaseTexture>;
  27620. /**
  27621. * Get if the submesh is ready to be used and all its information available.
  27622. * Child classes can use it to update shaders
  27623. * @param mesh defines the mesh to check
  27624. * @param subMesh defines which submesh to check
  27625. * @param useInstances specifies that instances should be used
  27626. * @returns a boolean indicating that the submesh is ready or not
  27627. */
  27628. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27629. /**
  27630. * Builds the material UBO layouts.
  27631. * Used internally during the effect preparation.
  27632. */
  27633. buildUniformLayout(): void;
  27634. /**
  27635. * Unbinds the material from the mesh
  27636. */
  27637. unbind(): void;
  27638. /**
  27639. * Binds the submesh to this material by preparing the effect and shader to draw
  27640. * @param world defines the world transformation matrix
  27641. * @param mesh defines the mesh containing the submesh
  27642. * @param subMesh defines the submesh to bind the material to
  27643. */
  27644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27645. /**
  27646. * Get the list of animatables in the material.
  27647. * @returns the list of animatables object used in the material
  27648. */
  27649. getAnimatables(): IAnimatable[];
  27650. /**
  27651. * Gets the active textures from the material
  27652. * @returns an array of textures
  27653. */
  27654. getActiveTextures(): BaseTexture[];
  27655. /**
  27656. * Specifies if the material uses a texture
  27657. * @param texture defines the texture to check against the material
  27658. * @returns a boolean specifying if the material uses the texture
  27659. */
  27660. hasTexture(texture: BaseTexture): boolean;
  27661. /**
  27662. * Disposes the material
  27663. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27664. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27665. */
  27666. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27667. /**
  27668. * Makes a duplicate of the material, and gives it a new name
  27669. * @param name defines the new name for the duplicated material
  27670. * @returns the cloned material
  27671. */
  27672. clone(name: string): StandardMaterial;
  27673. /**
  27674. * Serializes this material in a JSON representation
  27675. * @returns the serialized material object
  27676. */
  27677. serialize(): any;
  27678. /**
  27679. * Creates a standard material from parsed material data
  27680. * @param source defines the JSON representation of the material
  27681. * @param scene defines the hosting scene
  27682. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27683. * @returns a new standard material
  27684. */
  27685. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27686. /**
  27687. * Are diffuse textures enabled in the application.
  27688. */
  27689. static get DiffuseTextureEnabled(): boolean;
  27690. static set DiffuseTextureEnabled(value: boolean);
  27691. /**
  27692. * Are ambient textures enabled in the application.
  27693. */
  27694. static get AmbientTextureEnabled(): boolean;
  27695. static set AmbientTextureEnabled(value: boolean);
  27696. /**
  27697. * Are opacity textures enabled in the application.
  27698. */
  27699. static get OpacityTextureEnabled(): boolean;
  27700. static set OpacityTextureEnabled(value: boolean);
  27701. /**
  27702. * Are reflection textures enabled in the application.
  27703. */
  27704. static get ReflectionTextureEnabled(): boolean;
  27705. static set ReflectionTextureEnabled(value: boolean);
  27706. /**
  27707. * Are emissive textures enabled in the application.
  27708. */
  27709. static get EmissiveTextureEnabled(): boolean;
  27710. static set EmissiveTextureEnabled(value: boolean);
  27711. /**
  27712. * Are specular textures enabled in the application.
  27713. */
  27714. static get SpecularTextureEnabled(): boolean;
  27715. static set SpecularTextureEnabled(value: boolean);
  27716. /**
  27717. * Are bump textures enabled in the application.
  27718. */
  27719. static get BumpTextureEnabled(): boolean;
  27720. static set BumpTextureEnabled(value: boolean);
  27721. /**
  27722. * Are lightmap textures enabled in the application.
  27723. */
  27724. static get LightmapTextureEnabled(): boolean;
  27725. static set LightmapTextureEnabled(value: boolean);
  27726. /**
  27727. * Are refraction textures enabled in the application.
  27728. */
  27729. static get RefractionTextureEnabled(): boolean;
  27730. static set RefractionTextureEnabled(value: boolean);
  27731. /**
  27732. * Are color grading textures enabled in the application.
  27733. */
  27734. static get ColorGradingTextureEnabled(): boolean;
  27735. static set ColorGradingTextureEnabled(value: boolean);
  27736. /**
  27737. * Are fresnels enabled in the application.
  27738. */
  27739. static get FresnelEnabled(): boolean;
  27740. static set FresnelEnabled(value: boolean);
  27741. }
  27742. }
  27743. declare module "babylonjs/Particles/solidParticleSystem" {
  27744. import { Nullable } from "babylonjs/types";
  27745. import { Vector3 } from "babylonjs/Maths/math.vector";
  27746. import { Mesh } from "babylonjs/Meshes/mesh";
  27747. import { Scene, IDisposable } from "babylonjs/scene";
  27748. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27749. import { Material } from "babylonjs/Materials/material";
  27750. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27751. /**
  27752. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27753. *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.
  27754. * The SPS is also a particle system. It provides some methods to manage the particles.
  27755. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27756. *
  27757. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27758. */
  27759. export class SolidParticleSystem implements IDisposable {
  27760. /**
  27761. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27762. * Example : var p = SPS.particles[i];
  27763. */
  27764. particles: SolidParticle[];
  27765. /**
  27766. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27767. */
  27768. nbParticles: number;
  27769. /**
  27770. * If the particles must ever face the camera (default false). Useful for planar particles.
  27771. */
  27772. billboard: boolean;
  27773. /**
  27774. * Recompute normals when adding a shape
  27775. */
  27776. recomputeNormals: boolean;
  27777. /**
  27778. * This a counter ofr your own usage. It's not set by any SPS functions.
  27779. */
  27780. counter: number;
  27781. /**
  27782. * The SPS name. This name is also given to the underlying mesh.
  27783. */
  27784. name: string;
  27785. /**
  27786. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27787. */
  27788. mesh: Mesh;
  27789. /**
  27790. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27791. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27792. */
  27793. vars: any;
  27794. /**
  27795. * This array is populated when the SPS is set as 'pickable'.
  27796. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27797. * Each element of this array is an object `{idx: int, faceId: int}`.
  27798. * `idx` is the picked particle index in the `SPS.particles` array
  27799. * `faceId` is the picked face index counted within this particle.
  27800. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27801. */
  27802. pickedParticles: {
  27803. idx: number;
  27804. faceId: number;
  27805. }[];
  27806. /**
  27807. * This array is populated when `enableDepthSort` is set to true.
  27808. * Each element of this array is an instance of the class DepthSortedParticle.
  27809. */
  27810. depthSortedParticles: DepthSortedParticle[];
  27811. /**
  27812. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27813. * @hidden
  27814. */
  27815. _bSphereOnly: boolean;
  27816. /**
  27817. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27818. * @hidden
  27819. */
  27820. _bSphereRadiusFactor: number;
  27821. private _scene;
  27822. private _positions;
  27823. private _indices;
  27824. private _normals;
  27825. private _colors;
  27826. private _uvs;
  27827. private _indices32;
  27828. private _positions32;
  27829. private _normals32;
  27830. private _fixedNormal32;
  27831. private _colors32;
  27832. private _uvs32;
  27833. private _index;
  27834. private _updatable;
  27835. private _pickable;
  27836. private _isVisibilityBoxLocked;
  27837. private _alwaysVisible;
  27838. private _depthSort;
  27839. private _expandable;
  27840. private _shapeCounter;
  27841. private _copy;
  27842. private _color;
  27843. private _computeParticleColor;
  27844. private _computeParticleTexture;
  27845. private _computeParticleRotation;
  27846. private _computeParticleVertex;
  27847. private _computeBoundingBox;
  27848. private _depthSortParticles;
  27849. private _camera;
  27850. private _mustUnrotateFixedNormals;
  27851. private _particlesIntersect;
  27852. private _needs32Bits;
  27853. private _isNotBuilt;
  27854. private _lastParticleId;
  27855. private _idxOfId;
  27856. private _multimaterialEnabled;
  27857. private _useModelMaterial;
  27858. private _indicesByMaterial;
  27859. private _materialIndexes;
  27860. private _depthSortFunction;
  27861. private _materialSortFunction;
  27862. private _materials;
  27863. private _multimaterial;
  27864. private _materialIndexesById;
  27865. private _defaultMaterial;
  27866. private _autoUpdateSubMeshes;
  27867. /**
  27868. * Creates a SPS (Solid Particle System) object.
  27869. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27870. * @param scene (Scene) is the scene in which the SPS is added.
  27871. * @param options defines the options of the sps e.g.
  27872. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27873. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27874. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27875. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27876. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27877. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27878. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27879. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27880. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27881. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27882. */
  27883. constructor(name: string, scene: Scene, options?: {
  27884. updatable?: boolean;
  27885. isPickable?: boolean;
  27886. enableDepthSort?: boolean;
  27887. particleIntersection?: boolean;
  27888. boundingSphereOnly?: boolean;
  27889. bSphereRadiusFactor?: number;
  27890. expandable?: boolean;
  27891. useModelMaterial?: boolean;
  27892. enableMultiMaterial?: boolean;
  27893. });
  27894. /**
  27895. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27896. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27897. * @returns the created mesh
  27898. */
  27899. buildMesh(): Mesh;
  27900. /**
  27901. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27902. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27903. * Thus the particles generated from `digest()` have their property `position` set yet.
  27904. * @param mesh ( Mesh ) is the mesh to be digested
  27905. * @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
  27906. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27907. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27908. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27909. * @returns the current SPS
  27910. */
  27911. digest(mesh: Mesh, options?: {
  27912. facetNb?: number;
  27913. number?: number;
  27914. delta?: number;
  27915. storage?: [];
  27916. }): SolidParticleSystem;
  27917. /**
  27918. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27919. * @hidden
  27920. */
  27921. private _unrotateFixedNormals;
  27922. /**
  27923. * Resets the temporary working copy particle
  27924. * @hidden
  27925. */
  27926. private _resetCopy;
  27927. /**
  27928. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27929. * @param p the current index in the positions array to be updated
  27930. * @param ind the current index in the indices array
  27931. * @param shape a Vector3 array, the shape geometry
  27932. * @param positions the positions array to be updated
  27933. * @param meshInd the shape indices array
  27934. * @param indices the indices array to be updated
  27935. * @param meshUV the shape uv array
  27936. * @param uvs the uv array to be updated
  27937. * @param meshCol the shape color array
  27938. * @param colors the color array to be updated
  27939. * @param meshNor the shape normals array
  27940. * @param normals the normals array to be updated
  27941. * @param idx the particle index
  27942. * @param idxInShape the particle index in its shape
  27943. * @param options the addShape() method passed options
  27944. * @model the particle model
  27945. * @hidden
  27946. */
  27947. private _meshBuilder;
  27948. /**
  27949. * Returns a shape Vector3 array from positions float array
  27950. * @param positions float array
  27951. * @returns a vector3 array
  27952. * @hidden
  27953. */
  27954. private _posToShape;
  27955. /**
  27956. * Returns a shapeUV array from a float uvs (array deep copy)
  27957. * @param uvs as a float array
  27958. * @returns a shapeUV array
  27959. * @hidden
  27960. */
  27961. private _uvsToShapeUV;
  27962. /**
  27963. * Adds a new particle object in the particles array
  27964. * @param idx particle index in particles array
  27965. * @param id particle id
  27966. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27967. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27968. * @param model particle ModelShape object
  27969. * @param shapeId model shape identifier
  27970. * @param idxInShape index of the particle in the current model
  27971. * @param bInfo model bounding info object
  27972. * @param storage target storage array, if any
  27973. * @hidden
  27974. */
  27975. private _addParticle;
  27976. /**
  27977. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27978. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27979. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27980. * @param nb (positive integer) the number of particles to be created from this model
  27981. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27982. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27983. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27984. * @returns the number of shapes in the system
  27985. */
  27986. addShape(mesh: Mesh, nb: number, options?: {
  27987. positionFunction?: any;
  27988. vertexFunction?: any;
  27989. storage?: [];
  27990. }): number;
  27991. /**
  27992. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27993. * @hidden
  27994. */
  27995. private _rebuildParticle;
  27996. /**
  27997. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27998. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27999. * @returns the SPS.
  28000. */
  28001. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28002. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28003. * Returns an array with the removed particles.
  28004. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  28005. * The SPS can't be empty so at least one particle needs to remain in place.
  28006. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28007. * @param start index of the first particle to remove
  28008. * @param end index of the last particle to remove (included)
  28009. * @returns an array populated with the removed particles
  28010. */
  28011. removeParticles(start: number, end: number): SolidParticle[];
  28012. /**
  28013. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28014. * @param solidParticleArray an array populated with Solid Particles objects
  28015. * @returns the SPS
  28016. */
  28017. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28018. /**
  28019. * Creates a new particle and modifies the SPS mesh geometry :
  28020. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28021. * - calls _addParticle() to populate the particle array
  28022. * factorized code from addShape() and insertParticlesFromArray()
  28023. * @param idx particle index in the particles array
  28024. * @param i particle index in its shape
  28025. * @param modelShape particle ModelShape object
  28026. * @param shape shape vertex array
  28027. * @param meshInd shape indices array
  28028. * @param meshUV shape uv array
  28029. * @param meshCol shape color array
  28030. * @param meshNor shape normals array
  28031. * @param bbInfo shape bounding info
  28032. * @param storage target particle storage
  28033. * @options addShape() passed options
  28034. * @hidden
  28035. */
  28036. private _insertNewParticle;
  28037. /**
  28038. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28039. * This method calls `updateParticle()` for each particle of the SPS.
  28040. * For an animated SPS, it is usually called within the render loop.
  28041. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  28042. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28043. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28044. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28045. * @returns the SPS.
  28046. */
  28047. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28048. /**
  28049. * Disposes the SPS.
  28050. */
  28051. dispose(): void;
  28052. /**
  28053. * Returns a SolidParticle object from its identifier : particle.id
  28054. * @param id (integer) the particle Id
  28055. * @returns the searched particle or null if not found in the SPS.
  28056. */
  28057. getParticleById(id: number): Nullable<SolidParticle>;
  28058. /**
  28059. * Returns a new array populated with the particles having the passed shapeId.
  28060. * @param shapeId (integer) the shape identifier
  28061. * @returns a new solid particle array
  28062. */
  28063. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28064. /**
  28065. * Populates the passed array "ref" with the particles having the passed shapeId.
  28066. * @param shapeId the shape identifier
  28067. * @returns the SPS
  28068. * @param ref
  28069. */
  28070. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28071. /**
  28072. * Computes the required SubMeshes according the materials assigned to the particles.
  28073. * @returns the solid particle system.
  28074. * Does nothing if called before the SPS mesh is built.
  28075. */
  28076. computeSubMeshes(): SolidParticleSystem;
  28077. /**
  28078. * Sorts the solid particles by material when MultiMaterial is enabled.
  28079. * Updates the indices32 array.
  28080. * Updates the indicesByMaterial array.
  28081. * Updates the mesh indices array.
  28082. * @returns the SPS
  28083. * @hidden
  28084. */
  28085. private _sortParticlesByMaterial;
  28086. /**
  28087. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28088. * @hidden
  28089. */
  28090. private _setMaterialIndexesById;
  28091. /**
  28092. * Returns an array with unique values of Materials from the passed array
  28093. * @param array the material array to be checked and filtered
  28094. * @hidden
  28095. */
  28096. private _filterUniqueMaterialId;
  28097. /**
  28098. * Sets a new Standard Material as _defaultMaterial if not already set.
  28099. * @hidden
  28100. */
  28101. private _setDefaultMaterial;
  28102. /**
  28103. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28104. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28105. * @returns the SPS.
  28106. */
  28107. refreshVisibleSize(): SolidParticleSystem;
  28108. /**
  28109. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28110. * @param size the size (float) of the visibility box
  28111. * note : this doesn't lock the SPS mesh bounding box.
  28112. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28113. */
  28114. setVisibilityBox(size: number): void;
  28115. /**
  28116. * Gets whether the SPS as always visible or not
  28117. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28118. */
  28119. get isAlwaysVisible(): boolean;
  28120. /**
  28121. * Sets the SPS as always visible or not
  28122. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28123. */
  28124. set isAlwaysVisible(val: boolean);
  28125. /**
  28126. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28127. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28128. */
  28129. set isVisibilityBoxLocked(val: boolean);
  28130. /**
  28131. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28132. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28133. */
  28134. get isVisibilityBoxLocked(): boolean;
  28135. /**
  28136. * Tells to `setParticles()` to compute the particle rotations or not.
  28137. * Default value : true. The SPS is faster when it's set to false.
  28138. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28139. */
  28140. set computeParticleRotation(val: boolean);
  28141. /**
  28142. * Tells to `setParticles()` to compute the particle colors or not.
  28143. * Default value : true. The SPS is faster when it's set to false.
  28144. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28145. */
  28146. set computeParticleColor(val: boolean);
  28147. set computeParticleTexture(val: boolean);
  28148. /**
  28149. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28150. * Default value : false. The SPS is faster when it's set to false.
  28151. * Note : the particle custom vertex positions aren't stored values.
  28152. */
  28153. set computeParticleVertex(val: boolean);
  28154. /**
  28155. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28156. */
  28157. set computeBoundingBox(val: boolean);
  28158. /**
  28159. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28160. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28161. * Default : `true`
  28162. */
  28163. set depthSortParticles(val: boolean);
  28164. /**
  28165. * Gets if `setParticles()` computes the particle rotations or not.
  28166. * Default value : true. The SPS is faster when it's set to false.
  28167. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28168. */
  28169. get computeParticleRotation(): boolean;
  28170. /**
  28171. * Gets if `setParticles()` computes the particle colors or not.
  28172. * Default value : true. The SPS is faster when it's set to false.
  28173. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28174. */
  28175. get computeParticleColor(): boolean;
  28176. /**
  28177. * Gets if `setParticles()` computes the particle textures or not.
  28178. * Default value : true. The SPS is faster when it's set to false.
  28179. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28180. */
  28181. get computeParticleTexture(): boolean;
  28182. /**
  28183. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28184. * Default value : false. The SPS is faster when it's set to false.
  28185. * Note : the particle custom vertex positions aren't stored values.
  28186. */
  28187. get computeParticleVertex(): boolean;
  28188. /**
  28189. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28190. */
  28191. get computeBoundingBox(): boolean;
  28192. /**
  28193. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28194. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28195. * Default : `true`
  28196. */
  28197. get depthSortParticles(): boolean;
  28198. /**
  28199. * Gets if the SPS is created as expandable at construction time.
  28200. * Default : `false`
  28201. */
  28202. get expandable(): boolean;
  28203. /**
  28204. * Gets if the SPS supports the Multi Materials
  28205. */
  28206. get multimaterialEnabled(): boolean;
  28207. /**
  28208. * Gets if the SPS uses the model materials for its own multimaterial.
  28209. */
  28210. get useModelMaterial(): boolean;
  28211. /**
  28212. * The SPS used material array.
  28213. */
  28214. get materials(): Material[];
  28215. /**
  28216. * Sets the SPS MultiMaterial from the passed materials.
  28217. * Note : the passed array is internally copied and not used then by reference.
  28218. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28219. */
  28220. setMultiMaterial(materials: Material[]): void;
  28221. /**
  28222. * The SPS computed multimaterial object
  28223. */
  28224. get multimaterial(): MultiMaterial;
  28225. set multimaterial(mm: MultiMaterial);
  28226. /**
  28227. * If the subMeshes must be updated on the next call to setParticles()
  28228. */
  28229. get autoUpdateSubMeshes(): boolean;
  28230. set autoUpdateSubMeshes(val: boolean);
  28231. /**
  28232. * This function does nothing. It may be overwritten to set all the particle first values.
  28233. * The SPS doesn't call this function, you may have to call it by your own.
  28234. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28235. */
  28236. initParticles(): void;
  28237. /**
  28238. * This function does nothing. It may be overwritten to recycle a particle.
  28239. * The SPS doesn't call this function, you may have to call it by your own.
  28240. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28241. * @param particle The particle to recycle
  28242. * @returns the recycled particle
  28243. */
  28244. recycleParticle(particle: SolidParticle): SolidParticle;
  28245. /**
  28246. * Updates a particle : this function should be overwritten by the user.
  28247. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28248. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28249. * @example : just set a particle position or velocity and recycle conditions
  28250. * @param particle The particle to update
  28251. * @returns the updated particle
  28252. */
  28253. updateParticle(particle: SolidParticle): SolidParticle;
  28254. /**
  28255. * Updates a vertex of a particle : it can be overwritten by the user.
  28256. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28257. * @param particle the current particle
  28258. * @param vertex the current index of the current particle
  28259. * @param pt the index of the current vertex in the particle shape
  28260. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28261. * @example : just set a vertex particle position
  28262. * @returns the updated vertex
  28263. */
  28264. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28265. /**
  28266. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28267. * This does nothing and may be overwritten by the user.
  28268. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28269. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28270. * @param update the boolean update value actually passed to setParticles()
  28271. */
  28272. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28273. /**
  28274. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28275. * This will be passed three parameters.
  28276. * This does nothing and may be overwritten by the user.
  28277. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28278. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28279. * @param update the boolean update value actually passed to setParticles()
  28280. */
  28281. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28282. }
  28283. }
  28284. declare module "babylonjs/Particles/solidParticle" {
  28285. import { Nullable } from "babylonjs/types";
  28286. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28287. import { Color4 } from "babylonjs/Maths/math.color";
  28288. import { Mesh } from "babylonjs/Meshes/mesh";
  28289. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28290. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28291. import { Plane } from "babylonjs/Maths/math.plane";
  28292. import { Material } from "babylonjs/Materials/material";
  28293. /**
  28294. * Represents one particle of a solid particle system.
  28295. */
  28296. export class SolidParticle {
  28297. /**
  28298. * particle global index
  28299. */
  28300. idx: number;
  28301. /**
  28302. * particle identifier
  28303. */
  28304. id: number;
  28305. /**
  28306. * The color of the particle
  28307. */
  28308. color: Nullable<Color4>;
  28309. /**
  28310. * The world space position of the particle.
  28311. */
  28312. position: Vector3;
  28313. /**
  28314. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28315. */
  28316. rotation: Vector3;
  28317. /**
  28318. * The world space rotation quaternion of the particle.
  28319. */
  28320. rotationQuaternion: Nullable<Quaternion>;
  28321. /**
  28322. * The scaling of the particle.
  28323. */
  28324. scaling: Vector3;
  28325. /**
  28326. * The uvs of the particle.
  28327. */
  28328. uvs: Vector4;
  28329. /**
  28330. * The current speed of the particle.
  28331. */
  28332. velocity: Vector3;
  28333. /**
  28334. * The pivot point in the particle local space.
  28335. */
  28336. pivot: Vector3;
  28337. /**
  28338. * Must the particle be translated from its pivot point in its local space ?
  28339. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28340. * Default : false
  28341. */
  28342. translateFromPivot: boolean;
  28343. /**
  28344. * Is the particle active or not ?
  28345. */
  28346. alive: boolean;
  28347. /**
  28348. * Is the particle visible or not ?
  28349. */
  28350. isVisible: boolean;
  28351. /**
  28352. * Index of this particle in the global "positions" array (Internal use)
  28353. * @hidden
  28354. */
  28355. _pos: number;
  28356. /**
  28357. * @hidden Index of this particle in the global "indices" array (Internal use)
  28358. */
  28359. _ind: number;
  28360. /**
  28361. * @hidden ModelShape of this particle (Internal use)
  28362. */
  28363. _model: ModelShape;
  28364. /**
  28365. * ModelShape id of this particle
  28366. */
  28367. shapeId: number;
  28368. /**
  28369. * Index of the particle in its shape id
  28370. */
  28371. idxInShape: number;
  28372. /**
  28373. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28374. */
  28375. _modelBoundingInfo: BoundingInfo;
  28376. /**
  28377. * @hidden Particle BoundingInfo object (Internal use)
  28378. */
  28379. _boundingInfo: BoundingInfo;
  28380. /**
  28381. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28382. */
  28383. _sps: SolidParticleSystem;
  28384. /**
  28385. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28386. */
  28387. _stillInvisible: boolean;
  28388. /**
  28389. * @hidden Last computed particle rotation matrix
  28390. */
  28391. _rotationMatrix: number[];
  28392. /**
  28393. * Parent particle Id, if any.
  28394. * Default null.
  28395. */
  28396. parentId: Nullable<number>;
  28397. /**
  28398. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28399. */
  28400. materialIndex: Nullable<number>;
  28401. /**
  28402. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28403. * The possible values are :
  28404. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28405. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28406. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28407. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28408. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28409. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28410. * */
  28411. cullingStrategy: number;
  28412. /**
  28413. * @hidden Internal global position in the SPS.
  28414. */
  28415. _globalPosition: Vector3;
  28416. /**
  28417. * Creates a Solid Particle object.
  28418. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28419. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28420. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28421. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28422. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28423. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28424. * @param shapeId (integer) is the model shape identifier in the SPS.
  28425. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28426. * @param sps defines the sps it is associated to
  28427. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28428. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28429. */
  28430. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28431. /**
  28432. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28433. * @param target the particle target
  28434. * @returns the current particle
  28435. */
  28436. copyToRef(target: SolidParticle): SolidParticle;
  28437. /**
  28438. * Legacy support, changed scale to scaling
  28439. */
  28440. get scale(): Vector3;
  28441. /**
  28442. * Legacy support, changed scale to scaling
  28443. */
  28444. set scale(scale: Vector3);
  28445. /**
  28446. * Legacy support, changed quaternion to rotationQuaternion
  28447. */
  28448. get quaternion(): Nullable<Quaternion>;
  28449. /**
  28450. * Legacy support, changed quaternion to rotationQuaternion
  28451. */
  28452. set quaternion(q: Nullable<Quaternion>);
  28453. /**
  28454. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28455. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28456. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28457. * @returns true if it intersects
  28458. */
  28459. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28460. /**
  28461. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28462. * A particle is in the frustum if its bounding box intersects the frustum
  28463. * @param frustumPlanes defines the frustum to test
  28464. * @returns true if the particle is in the frustum planes
  28465. */
  28466. isInFrustum(frustumPlanes: Plane[]): boolean;
  28467. /**
  28468. * get the rotation matrix of the particle
  28469. * @hidden
  28470. */
  28471. getRotationMatrix(m: Matrix): void;
  28472. }
  28473. /**
  28474. * Represents the shape of the model used by one particle of a solid particle system.
  28475. * SPS internal tool, don't use it manually.
  28476. */
  28477. export class ModelShape {
  28478. /**
  28479. * The shape id
  28480. * @hidden
  28481. */
  28482. shapeID: number;
  28483. /**
  28484. * flat array of model positions (internal use)
  28485. * @hidden
  28486. */
  28487. _shape: Vector3[];
  28488. /**
  28489. * flat array of model UVs (internal use)
  28490. * @hidden
  28491. */
  28492. _shapeUV: number[];
  28493. /**
  28494. * color array of the model
  28495. * @hidden
  28496. */
  28497. _shapeColors: number[];
  28498. /**
  28499. * indices array of the model
  28500. * @hidden
  28501. */
  28502. _indices: number[];
  28503. /**
  28504. * normals array of the model
  28505. * @hidden
  28506. */
  28507. _normals: number[];
  28508. /**
  28509. * length of the shape in the model indices array (internal use)
  28510. * @hidden
  28511. */
  28512. _indicesLength: number;
  28513. /**
  28514. * Custom position function (internal use)
  28515. * @hidden
  28516. */
  28517. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28518. /**
  28519. * Custom vertex function (internal use)
  28520. * @hidden
  28521. */
  28522. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28523. /**
  28524. * Model material (internal use)
  28525. * @hidden
  28526. */
  28527. _material: Nullable<Material>;
  28528. /**
  28529. * 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.
  28530. * SPS internal tool, don't use it manually.
  28531. * @hidden
  28532. */
  28533. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28534. }
  28535. /**
  28536. * Represents a Depth Sorted Particle in the solid particle system.
  28537. * @hidden
  28538. */
  28539. export class DepthSortedParticle {
  28540. /**
  28541. * Index of the particle in the "indices" array
  28542. */
  28543. ind: number;
  28544. /**
  28545. * Length of the particle shape in the "indices" array
  28546. */
  28547. indicesLength: number;
  28548. /**
  28549. * Squared distance from the particle to the camera
  28550. */
  28551. sqDistance: number;
  28552. /**
  28553. * Material index when used with MultiMaterials
  28554. */
  28555. materialIndex: number;
  28556. /**
  28557. * Creates a new sorted particle
  28558. * @param materialIndex
  28559. */
  28560. constructor(ind: number, indLength: number, materialIndex: number);
  28561. }
  28562. }
  28563. declare module "babylonjs/Collisions/meshCollisionData" {
  28564. import { Collider } from "babylonjs/Collisions/collider";
  28565. import { Vector3 } from "babylonjs/Maths/math.vector";
  28566. import { Nullable } from "babylonjs/types";
  28567. import { Observer } from "babylonjs/Misc/observable";
  28568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28569. /**
  28570. * @hidden
  28571. */
  28572. export class _MeshCollisionData {
  28573. _checkCollisions: boolean;
  28574. _collisionMask: number;
  28575. _collisionGroup: number;
  28576. _collider: Nullable<Collider>;
  28577. _oldPositionForCollisions: Vector3;
  28578. _diffPositionForCollisions: Vector3;
  28579. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28580. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28581. }
  28582. }
  28583. declare module "babylonjs/Meshes/abstractMesh" {
  28584. import { Observable } from "babylonjs/Misc/observable";
  28585. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28586. import { Camera } from "babylonjs/Cameras/camera";
  28587. import { Scene, IDisposable } from "babylonjs/scene";
  28588. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28589. import { Node } from "babylonjs/node";
  28590. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28593. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28594. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28595. import { Material } from "babylonjs/Materials/material";
  28596. import { Light } from "babylonjs/Lights/light";
  28597. import { Skeleton } from "babylonjs/Bones/skeleton";
  28598. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28599. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28600. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28601. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28602. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28603. import { Plane } from "babylonjs/Maths/math.plane";
  28604. import { Ray } from "babylonjs/Culling/ray";
  28605. import { Collider } from "babylonjs/Collisions/collider";
  28606. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28607. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28608. /** @hidden */
  28609. class _FacetDataStorage {
  28610. facetPositions: Vector3[];
  28611. facetNormals: Vector3[];
  28612. facetPartitioning: number[][];
  28613. facetNb: number;
  28614. partitioningSubdivisions: number;
  28615. partitioningBBoxRatio: number;
  28616. facetDataEnabled: boolean;
  28617. facetParameters: any;
  28618. bbSize: Vector3;
  28619. subDiv: {
  28620. max: number;
  28621. X: number;
  28622. Y: number;
  28623. Z: number;
  28624. };
  28625. facetDepthSort: boolean;
  28626. facetDepthSortEnabled: boolean;
  28627. depthSortedIndices: IndicesArray;
  28628. depthSortedFacets: {
  28629. ind: number;
  28630. sqDistance: number;
  28631. }[];
  28632. facetDepthSortFunction: (f1: {
  28633. ind: number;
  28634. sqDistance: number;
  28635. }, f2: {
  28636. ind: number;
  28637. sqDistance: number;
  28638. }) => number;
  28639. facetDepthSortFrom: Vector3;
  28640. facetDepthSortOrigin: Vector3;
  28641. invertedMatrix: Matrix;
  28642. }
  28643. /**
  28644. * @hidden
  28645. **/
  28646. class _InternalAbstractMeshDataInfo {
  28647. _hasVertexAlpha: boolean;
  28648. _useVertexColors: boolean;
  28649. _numBoneInfluencers: number;
  28650. _applyFog: boolean;
  28651. _receiveShadows: boolean;
  28652. _facetData: _FacetDataStorage;
  28653. _visibility: number;
  28654. _skeleton: Nullable<Skeleton>;
  28655. _layerMask: number;
  28656. _computeBonesUsingShaders: boolean;
  28657. _isActive: boolean;
  28658. _onlyForInstances: boolean;
  28659. _isActiveIntermediate: boolean;
  28660. _onlyForInstancesIntermediate: boolean;
  28661. _actAsRegularMesh: boolean;
  28662. }
  28663. /**
  28664. * Class used to store all common mesh properties
  28665. */
  28666. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28667. /** No occlusion */
  28668. static OCCLUSION_TYPE_NONE: number;
  28669. /** Occlusion set to optimisitic */
  28670. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28671. /** Occlusion set to strict */
  28672. static OCCLUSION_TYPE_STRICT: number;
  28673. /** Use an accurante occlusion algorithm */
  28674. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28675. /** Use a conservative occlusion algorithm */
  28676. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28677. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28678. * Test order :
  28679. * Is the bounding sphere outside the frustum ?
  28680. * If not, are the bounding box vertices outside the frustum ?
  28681. * It not, then the cullable object is in the frustum.
  28682. */
  28683. static readonly CULLINGSTRATEGY_STANDARD: number;
  28684. /** Culling strategy : Bounding Sphere Only.
  28685. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28686. * It's also less accurate than the standard because some not visible objects can still be selected.
  28687. * Test : is the bounding sphere outside the frustum ?
  28688. * If not, then the cullable object is in the frustum.
  28689. */
  28690. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28691. /** Culling strategy : Optimistic Inclusion.
  28692. * This in an inclusion test first, then the standard exclusion test.
  28693. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28694. * 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.
  28695. * Anyway, it's as accurate as the standard strategy.
  28696. * Test :
  28697. * Is the cullable object bounding sphere center in the frustum ?
  28698. * If not, apply the default culling strategy.
  28699. */
  28700. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28701. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28702. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28703. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28704. * 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.
  28705. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28706. * Test :
  28707. * Is the cullable object bounding sphere center in the frustum ?
  28708. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28709. */
  28710. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28711. /**
  28712. * No billboard
  28713. */
  28714. static get BILLBOARDMODE_NONE(): number;
  28715. /** Billboard on X axis */
  28716. static get BILLBOARDMODE_X(): number;
  28717. /** Billboard on Y axis */
  28718. static get BILLBOARDMODE_Y(): number;
  28719. /** Billboard on Z axis */
  28720. static get BILLBOARDMODE_Z(): number;
  28721. /** Billboard on all axes */
  28722. static get BILLBOARDMODE_ALL(): number;
  28723. /** Billboard on using position instead of orientation */
  28724. static get BILLBOARDMODE_USE_POSITION(): number;
  28725. /** @hidden */
  28726. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28727. /**
  28728. * The culling strategy to use to check whether the mesh must be rendered or not.
  28729. * This value can be changed at any time and will be used on the next render mesh selection.
  28730. * The possible values are :
  28731. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28732. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28733. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28734. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28735. * Please read each static variable documentation to get details about the culling process.
  28736. * */
  28737. cullingStrategy: number;
  28738. /**
  28739. * Gets the number of facets in the mesh
  28740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28741. */
  28742. get facetNb(): number;
  28743. /**
  28744. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28746. */
  28747. get partitioningSubdivisions(): number;
  28748. set partitioningSubdivisions(nb: number);
  28749. /**
  28750. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28751. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28753. */
  28754. get partitioningBBoxRatio(): number;
  28755. set partitioningBBoxRatio(ratio: number);
  28756. /**
  28757. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28758. * Works only for updatable meshes.
  28759. * Doesn't work with multi-materials
  28760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28761. */
  28762. get mustDepthSortFacets(): boolean;
  28763. set mustDepthSortFacets(sort: boolean);
  28764. /**
  28765. * The location (Vector3) where the facet depth sort must be computed from.
  28766. * By default, the active camera position.
  28767. * Used only when facet depth sort is enabled
  28768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28769. */
  28770. get facetDepthSortFrom(): Vector3;
  28771. set facetDepthSortFrom(location: Vector3);
  28772. /**
  28773. * gets a boolean indicating if facetData is enabled
  28774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28775. */
  28776. get isFacetDataEnabled(): boolean;
  28777. /** @hidden */
  28778. _updateNonUniformScalingState(value: boolean): boolean;
  28779. /**
  28780. * An event triggered when this mesh collides with another one
  28781. */
  28782. onCollideObservable: Observable<AbstractMesh>;
  28783. /** Set a function to call when this mesh collides with another one */
  28784. set onCollide(callback: () => void);
  28785. /**
  28786. * An event triggered when the collision's position changes
  28787. */
  28788. onCollisionPositionChangeObservable: Observable<Vector3>;
  28789. /** Set a function to call when the collision's position changes */
  28790. set onCollisionPositionChange(callback: () => void);
  28791. /**
  28792. * An event triggered when material is changed
  28793. */
  28794. onMaterialChangedObservable: Observable<AbstractMesh>;
  28795. /**
  28796. * Gets or sets the orientation for POV movement & rotation
  28797. */
  28798. definedFacingForward: boolean;
  28799. /** @hidden */
  28800. _occlusionQuery: Nullable<WebGLQuery>;
  28801. /** @hidden */
  28802. _renderingGroup: Nullable<RenderingGroup>;
  28803. /**
  28804. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28805. */
  28806. get visibility(): number;
  28807. /**
  28808. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28809. */
  28810. set visibility(value: number);
  28811. /** Gets or sets the alpha index used to sort transparent meshes
  28812. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28813. */
  28814. alphaIndex: number;
  28815. /**
  28816. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28817. */
  28818. isVisible: boolean;
  28819. /**
  28820. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28821. */
  28822. isPickable: boolean;
  28823. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28824. showSubMeshesBoundingBox: boolean;
  28825. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28826. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28827. */
  28828. isBlocker: boolean;
  28829. /**
  28830. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28831. */
  28832. enablePointerMoveEvents: boolean;
  28833. /**
  28834. * Specifies the rendering group id for this mesh (0 by default)
  28835. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28836. */
  28837. renderingGroupId: number;
  28838. private _material;
  28839. /** Gets or sets current material */
  28840. get material(): Nullable<Material>;
  28841. set material(value: Nullable<Material>);
  28842. /**
  28843. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28844. * @see http://doc.babylonjs.com/babylon101/shadows
  28845. */
  28846. get receiveShadows(): boolean;
  28847. set receiveShadows(value: boolean);
  28848. /** Defines color to use when rendering outline */
  28849. outlineColor: Color3;
  28850. /** Define width to use when rendering outline */
  28851. outlineWidth: number;
  28852. /** Defines color to use when rendering overlay */
  28853. overlayColor: Color3;
  28854. /** Defines alpha to use when rendering overlay */
  28855. overlayAlpha: number;
  28856. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28857. get hasVertexAlpha(): boolean;
  28858. set hasVertexAlpha(value: boolean);
  28859. /** 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) */
  28860. get useVertexColors(): boolean;
  28861. set useVertexColors(value: boolean);
  28862. /**
  28863. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28864. */
  28865. get computeBonesUsingShaders(): boolean;
  28866. set computeBonesUsingShaders(value: boolean);
  28867. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28868. get numBoneInfluencers(): number;
  28869. set numBoneInfluencers(value: number);
  28870. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28871. get applyFog(): boolean;
  28872. set applyFog(value: boolean);
  28873. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28874. useOctreeForRenderingSelection: boolean;
  28875. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28876. useOctreeForPicking: boolean;
  28877. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28878. useOctreeForCollisions: boolean;
  28879. /**
  28880. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28881. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28882. */
  28883. get layerMask(): number;
  28884. set layerMask(value: number);
  28885. /**
  28886. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28887. */
  28888. alwaysSelectAsActiveMesh: boolean;
  28889. /**
  28890. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28891. */
  28892. doNotSyncBoundingInfo: boolean;
  28893. /**
  28894. * Gets or sets the current action manager
  28895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28896. */
  28897. actionManager: Nullable<AbstractActionManager>;
  28898. private _meshCollisionData;
  28899. /**
  28900. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28901. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28902. */
  28903. ellipsoid: Vector3;
  28904. /**
  28905. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28906. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28907. */
  28908. ellipsoidOffset: Vector3;
  28909. /**
  28910. * Gets or sets a collision mask used to mask collisions (default is -1).
  28911. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28912. */
  28913. get collisionMask(): number;
  28914. set collisionMask(mask: number);
  28915. /**
  28916. * Gets or sets the current collision group mask (-1 by default).
  28917. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28918. */
  28919. get collisionGroup(): number;
  28920. set collisionGroup(mask: number);
  28921. /**
  28922. * Defines edge width used when edgesRenderer is enabled
  28923. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28924. */
  28925. edgesWidth: number;
  28926. /**
  28927. * Defines edge color used when edgesRenderer is enabled
  28928. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28929. */
  28930. edgesColor: Color4;
  28931. /** @hidden */
  28932. _edgesRenderer: Nullable<IEdgesRenderer>;
  28933. /** @hidden */
  28934. _masterMesh: Nullable<AbstractMesh>;
  28935. /** @hidden */
  28936. _boundingInfo: Nullable<BoundingInfo>;
  28937. /** @hidden */
  28938. _renderId: number;
  28939. /**
  28940. * Gets or sets the list of subMeshes
  28941. * @see http://doc.babylonjs.com/how_to/multi_materials
  28942. */
  28943. subMeshes: SubMesh[];
  28944. /** @hidden */
  28945. _intersectionsInProgress: AbstractMesh[];
  28946. /** @hidden */
  28947. _unIndexed: boolean;
  28948. /** @hidden */
  28949. _lightSources: Light[];
  28950. /** Gets the list of lights affecting that mesh */
  28951. get lightSources(): Light[];
  28952. /** @hidden */
  28953. get _positions(): Nullable<Vector3[]>;
  28954. /** @hidden */
  28955. _waitingData: {
  28956. lods: Nullable<any>;
  28957. actions: Nullable<any>;
  28958. freezeWorldMatrix: Nullable<boolean>;
  28959. };
  28960. /** @hidden */
  28961. _bonesTransformMatrices: Nullable<Float32Array>;
  28962. /** @hidden */
  28963. _transformMatrixTexture: Nullable<RawTexture>;
  28964. /**
  28965. * Gets or sets a skeleton to apply skining transformations
  28966. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28967. */
  28968. set skeleton(value: Nullable<Skeleton>);
  28969. get skeleton(): Nullable<Skeleton>;
  28970. /**
  28971. * An event triggered when the mesh is rebuilt.
  28972. */
  28973. onRebuildObservable: Observable<AbstractMesh>;
  28974. /**
  28975. * Creates a new AbstractMesh
  28976. * @param name defines the name of the mesh
  28977. * @param scene defines the hosting scene
  28978. */
  28979. constructor(name: string, scene?: Nullable<Scene>);
  28980. /**
  28981. * Returns the string "AbstractMesh"
  28982. * @returns "AbstractMesh"
  28983. */
  28984. getClassName(): string;
  28985. /**
  28986. * Gets a string representation of the current mesh
  28987. * @param fullDetails defines a boolean indicating if full details must be included
  28988. * @returns a string representation of the current mesh
  28989. */
  28990. toString(fullDetails?: boolean): string;
  28991. /**
  28992. * @hidden
  28993. */
  28994. protected _getEffectiveParent(): Nullable<Node>;
  28995. /** @hidden */
  28996. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28997. /** @hidden */
  28998. _rebuild(): void;
  28999. /** @hidden */
  29000. _resyncLightSources(): void;
  29001. /** @hidden */
  29002. _resyncLightSource(light: Light): void;
  29003. /** @hidden */
  29004. _unBindEffect(): void;
  29005. /** @hidden */
  29006. _removeLightSource(light: Light, dispose: boolean): void;
  29007. private _markSubMeshesAsDirty;
  29008. /** @hidden */
  29009. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29010. /** @hidden */
  29011. _markSubMeshesAsAttributesDirty(): void;
  29012. /** @hidden */
  29013. _markSubMeshesAsMiscDirty(): void;
  29014. /**
  29015. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29016. */
  29017. get scaling(): Vector3;
  29018. set scaling(newScaling: Vector3);
  29019. /**
  29020. * Returns true if the mesh is blocked. Implemented by child classes
  29021. */
  29022. get isBlocked(): boolean;
  29023. /**
  29024. * Returns the mesh itself by default. Implemented by child classes
  29025. * @param camera defines the camera to use to pick the right LOD level
  29026. * @returns the currentAbstractMesh
  29027. */
  29028. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29029. /**
  29030. * Returns 0 by default. Implemented by child classes
  29031. * @returns an integer
  29032. */
  29033. getTotalVertices(): number;
  29034. /**
  29035. * Returns a positive integer : the total number of indices in this mesh geometry.
  29036. * @returns the numner of indices or zero if the mesh has no geometry.
  29037. */
  29038. getTotalIndices(): number;
  29039. /**
  29040. * Returns null by default. Implemented by child classes
  29041. * @returns null
  29042. */
  29043. getIndices(): Nullable<IndicesArray>;
  29044. /**
  29045. * Returns the array of the requested vertex data kind. Implemented by child classes
  29046. * @param kind defines the vertex data kind to use
  29047. * @returns null
  29048. */
  29049. getVerticesData(kind: string): Nullable<FloatArray>;
  29050. /**
  29051. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29052. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29053. * Note that a new underlying VertexBuffer object is created each call.
  29054. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29055. * @param kind defines vertex data kind:
  29056. * * VertexBuffer.PositionKind
  29057. * * VertexBuffer.UVKind
  29058. * * VertexBuffer.UV2Kind
  29059. * * VertexBuffer.UV3Kind
  29060. * * VertexBuffer.UV4Kind
  29061. * * VertexBuffer.UV5Kind
  29062. * * VertexBuffer.UV6Kind
  29063. * * VertexBuffer.ColorKind
  29064. * * VertexBuffer.MatricesIndicesKind
  29065. * * VertexBuffer.MatricesIndicesExtraKind
  29066. * * VertexBuffer.MatricesWeightsKind
  29067. * * VertexBuffer.MatricesWeightsExtraKind
  29068. * @param data defines the data source
  29069. * @param updatable defines if the data must be flagged as updatable (or static)
  29070. * @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
  29071. * @returns the current mesh
  29072. */
  29073. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29074. /**
  29075. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29076. * If the mesh has no geometry, it is simply returned as it is.
  29077. * @param kind defines vertex data kind:
  29078. * * VertexBuffer.PositionKind
  29079. * * VertexBuffer.UVKind
  29080. * * VertexBuffer.UV2Kind
  29081. * * VertexBuffer.UV3Kind
  29082. * * VertexBuffer.UV4Kind
  29083. * * VertexBuffer.UV5Kind
  29084. * * VertexBuffer.UV6Kind
  29085. * * VertexBuffer.ColorKind
  29086. * * VertexBuffer.MatricesIndicesKind
  29087. * * VertexBuffer.MatricesIndicesExtraKind
  29088. * * VertexBuffer.MatricesWeightsKind
  29089. * * VertexBuffer.MatricesWeightsExtraKind
  29090. * @param data defines the data source
  29091. * @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
  29092. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29093. * @returns the current mesh
  29094. */
  29095. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29096. /**
  29097. * Sets the mesh indices,
  29098. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29099. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29100. * @param totalVertices Defines the total number of vertices
  29101. * @returns the current mesh
  29102. */
  29103. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29104. /**
  29105. * Gets a boolean indicating if specific vertex data is present
  29106. * @param kind defines the vertex data kind to use
  29107. * @returns true is data kind is present
  29108. */
  29109. isVerticesDataPresent(kind: string): boolean;
  29110. /**
  29111. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29112. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29113. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29114. * @returns a BoundingInfo
  29115. */
  29116. getBoundingInfo(): BoundingInfo;
  29117. /**
  29118. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29119. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29120. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29121. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29122. * @returns the current mesh
  29123. */
  29124. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29125. /**
  29126. * Overwrite the current bounding info
  29127. * @param boundingInfo defines the new bounding info
  29128. * @returns the current mesh
  29129. */
  29130. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29131. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29132. get useBones(): boolean;
  29133. /** @hidden */
  29134. _preActivate(): void;
  29135. /** @hidden */
  29136. _preActivateForIntermediateRendering(renderId: number): void;
  29137. /** @hidden */
  29138. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29139. /** @hidden */
  29140. _postActivate(): void;
  29141. /** @hidden */
  29142. _freeze(): void;
  29143. /** @hidden */
  29144. _unFreeze(): void;
  29145. /**
  29146. * Gets the current world matrix
  29147. * @returns a Matrix
  29148. */
  29149. getWorldMatrix(): Matrix;
  29150. /** @hidden */
  29151. _getWorldMatrixDeterminant(): number;
  29152. /**
  29153. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29154. */
  29155. get isAnInstance(): boolean;
  29156. /**
  29157. * Gets a boolean indicating if this mesh has instances
  29158. */
  29159. get hasInstances(): boolean;
  29160. /**
  29161. * Perform relative position change from the point of view of behind the front of the mesh.
  29162. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29163. * Supports definition of mesh facing forward or backward
  29164. * @param amountRight defines the distance on the right axis
  29165. * @param amountUp defines the distance on the up axis
  29166. * @param amountForward defines the distance on the forward axis
  29167. * @returns the current mesh
  29168. */
  29169. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29170. /**
  29171. * Calculate relative position change from the point of view of behind the front of the mesh.
  29172. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29173. * Supports definition of mesh facing forward or backward
  29174. * @param amountRight defines the distance on the right axis
  29175. * @param amountUp defines the distance on the up axis
  29176. * @param amountForward defines the distance on the forward axis
  29177. * @returns the new displacement vector
  29178. */
  29179. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29180. /**
  29181. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29182. * Supports definition of mesh facing forward or backward
  29183. * @param flipBack defines the flip
  29184. * @param twirlClockwise defines the twirl
  29185. * @param tiltRight defines the tilt
  29186. * @returns the current mesh
  29187. */
  29188. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29189. /**
  29190. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29191. * Supports definition of mesh facing forward or backward.
  29192. * @param flipBack defines the flip
  29193. * @param twirlClockwise defines the twirl
  29194. * @param tiltRight defines the tilt
  29195. * @returns the new rotation vector
  29196. */
  29197. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29198. /**
  29199. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29200. * This means the mesh underlying bounding box and sphere are recomputed.
  29201. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29202. * @returns the current mesh
  29203. */
  29204. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29205. /** @hidden */
  29206. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29207. /** @hidden */
  29208. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29209. /** @hidden */
  29210. _updateBoundingInfo(): AbstractMesh;
  29211. /** @hidden */
  29212. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29213. /** @hidden */
  29214. protected _afterComputeWorldMatrix(): void;
  29215. /** @hidden */
  29216. get _effectiveMesh(): AbstractMesh;
  29217. /**
  29218. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29219. * A mesh is in the frustum if its bounding box intersects the frustum
  29220. * @param frustumPlanes defines the frustum to test
  29221. * @returns true if the mesh is in the frustum planes
  29222. */
  29223. isInFrustum(frustumPlanes: Plane[]): boolean;
  29224. /**
  29225. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29226. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29227. * @param frustumPlanes defines the frustum to test
  29228. * @returns true if the mesh is completely in the frustum planes
  29229. */
  29230. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29231. /**
  29232. * True if the mesh intersects another mesh or a SolidParticle object
  29233. * @param mesh defines a target mesh or SolidParticle to test
  29234. * @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)
  29235. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29236. * @returns true if there is an intersection
  29237. */
  29238. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29239. /**
  29240. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29241. * @param point defines the point to test
  29242. * @returns true if there is an intersection
  29243. */
  29244. intersectsPoint(point: Vector3): boolean;
  29245. /**
  29246. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29248. */
  29249. get checkCollisions(): boolean;
  29250. set checkCollisions(collisionEnabled: boolean);
  29251. /**
  29252. * Gets Collider object used to compute collisions (not physics)
  29253. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29254. */
  29255. get collider(): Nullable<Collider>;
  29256. /**
  29257. * Move the mesh using collision engine
  29258. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29259. * @param displacement defines the requested displacement vector
  29260. * @returns the current mesh
  29261. */
  29262. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29263. private _onCollisionPositionChange;
  29264. /** @hidden */
  29265. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29266. /** @hidden */
  29267. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29268. /** @hidden */
  29269. _checkCollision(collider: Collider): AbstractMesh;
  29270. /** @hidden */
  29271. _generatePointsArray(): boolean;
  29272. /**
  29273. * Checks if the passed Ray intersects with the mesh
  29274. * @param ray defines the ray to use
  29275. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29276. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29277. * @returns the picking info
  29278. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29279. */
  29280. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29281. /**
  29282. * Clones the current mesh
  29283. * @param name defines the mesh name
  29284. * @param newParent defines the new mesh parent
  29285. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29286. * @returns the new mesh
  29287. */
  29288. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29289. /**
  29290. * Disposes all the submeshes of the current meshnp
  29291. * @returns the current mesh
  29292. */
  29293. releaseSubMeshes(): AbstractMesh;
  29294. /**
  29295. * Releases resources associated with this abstract mesh.
  29296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29298. */
  29299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29300. /**
  29301. * Adds the passed mesh as a child to the current mesh
  29302. * @param mesh defines the child mesh
  29303. * @returns the current mesh
  29304. */
  29305. addChild(mesh: AbstractMesh): AbstractMesh;
  29306. /**
  29307. * Removes the passed mesh from the current mesh children list
  29308. * @param mesh defines the child mesh
  29309. * @returns the current mesh
  29310. */
  29311. removeChild(mesh: AbstractMesh): AbstractMesh;
  29312. /** @hidden */
  29313. private _initFacetData;
  29314. /**
  29315. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29316. * This method can be called within the render loop.
  29317. * 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
  29318. * @returns the current mesh
  29319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29320. */
  29321. updateFacetData(): AbstractMesh;
  29322. /**
  29323. * Returns the facetLocalNormals array.
  29324. * The normals are expressed in the mesh local spac
  29325. * @returns an array of Vector3
  29326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29327. */
  29328. getFacetLocalNormals(): Vector3[];
  29329. /**
  29330. * Returns the facetLocalPositions array.
  29331. * The facet positions are expressed in the mesh local space
  29332. * @returns an array of Vector3
  29333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29334. */
  29335. getFacetLocalPositions(): Vector3[];
  29336. /**
  29337. * Returns the facetLocalPartioning array
  29338. * @returns an array of array of numbers
  29339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29340. */
  29341. getFacetLocalPartitioning(): number[][];
  29342. /**
  29343. * Returns the i-th facet position in the world system.
  29344. * This method allocates a new Vector3 per call
  29345. * @param i defines the facet index
  29346. * @returns a new Vector3
  29347. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29348. */
  29349. getFacetPosition(i: number): Vector3;
  29350. /**
  29351. * Sets the reference Vector3 with the i-th facet position in the world system
  29352. * @param i defines the facet index
  29353. * @param ref defines the target vector
  29354. * @returns the current mesh
  29355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29356. */
  29357. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29358. /**
  29359. * Returns the i-th facet normal in the world system.
  29360. * This method allocates a new Vector3 per call
  29361. * @param i defines the facet index
  29362. * @returns a new Vector3
  29363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29364. */
  29365. getFacetNormal(i: number): Vector3;
  29366. /**
  29367. * Sets the reference Vector3 with the i-th facet normal in the world system
  29368. * @param i defines the facet index
  29369. * @param ref defines the target vector
  29370. * @returns the current mesh
  29371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29372. */
  29373. getFacetNormalToRef(i: number, ref: Vector3): this;
  29374. /**
  29375. * 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)
  29376. * @param x defines x coordinate
  29377. * @param y defines y coordinate
  29378. * @param z defines z coordinate
  29379. * @returns the array of facet indexes
  29380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29381. */
  29382. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29383. /**
  29384. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29385. * @param projected sets as the (x,y,z) world projection on the facet
  29386. * @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
  29387. * @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
  29388. * @param x defines x coordinate
  29389. * @param y defines y coordinate
  29390. * @param z defines z coordinate
  29391. * @returns the face index if found (or null instead)
  29392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29393. */
  29394. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29395. /**
  29396. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29397. * @param projected sets as the (x,y,z) local projection on the facet
  29398. * @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
  29399. * @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
  29400. * @param x defines x coordinate
  29401. * @param y defines y coordinate
  29402. * @param z defines z coordinate
  29403. * @returns the face index if found (or null instead)
  29404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29405. */
  29406. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29407. /**
  29408. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29409. * @returns the parameters
  29410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29411. */
  29412. getFacetDataParameters(): any;
  29413. /**
  29414. * Disables the feature FacetData and frees the related memory
  29415. * @returns the current mesh
  29416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29417. */
  29418. disableFacetData(): AbstractMesh;
  29419. /**
  29420. * Updates the AbstractMesh indices array
  29421. * @param indices defines the data source
  29422. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29423. * @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)
  29424. * @returns the current mesh
  29425. */
  29426. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29427. /**
  29428. * Creates new normals data for the mesh
  29429. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29430. * @returns the current mesh
  29431. */
  29432. createNormals(updatable: boolean): AbstractMesh;
  29433. /**
  29434. * Align the mesh with a normal
  29435. * @param normal defines the normal to use
  29436. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29437. * @returns the current mesh
  29438. */
  29439. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29440. /** @hidden */
  29441. _checkOcclusionQuery(): boolean;
  29442. /**
  29443. * Disables the mesh edge rendering mode
  29444. * @returns the currentAbstractMesh
  29445. */
  29446. disableEdgesRendering(): AbstractMesh;
  29447. /**
  29448. * Enables the edge rendering mode on the mesh.
  29449. * This mode makes the mesh edges visible
  29450. * @param epsilon defines the maximal distance between two angles to detect a face
  29451. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29452. * @returns the currentAbstractMesh
  29453. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29454. */
  29455. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29456. }
  29457. }
  29458. declare module "babylonjs/Actions/actionEvent" {
  29459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29460. import { Nullable } from "babylonjs/types";
  29461. import { Sprite } from "babylonjs/Sprites/sprite";
  29462. import { Scene } from "babylonjs/scene";
  29463. import { Vector2 } from "babylonjs/Maths/math.vector";
  29464. /**
  29465. * Interface used to define ActionEvent
  29466. */
  29467. export interface IActionEvent {
  29468. /** The mesh or sprite that triggered the action */
  29469. source: any;
  29470. /** The X mouse cursor position at the time of the event */
  29471. pointerX: number;
  29472. /** The Y mouse cursor position at the time of the event */
  29473. pointerY: number;
  29474. /** The mesh that is currently pointed at (can be null) */
  29475. meshUnderPointer: Nullable<AbstractMesh>;
  29476. /** the original (browser) event that triggered the ActionEvent */
  29477. sourceEvent?: any;
  29478. /** additional data for the event */
  29479. additionalData?: any;
  29480. }
  29481. /**
  29482. * ActionEvent is the event being sent when an action is triggered.
  29483. */
  29484. export class ActionEvent implements IActionEvent {
  29485. /** The mesh or sprite that triggered the action */
  29486. source: any;
  29487. /** The X mouse cursor position at the time of the event */
  29488. pointerX: number;
  29489. /** The Y mouse cursor position at the time of the event */
  29490. pointerY: number;
  29491. /** The mesh that is currently pointed at (can be null) */
  29492. meshUnderPointer: Nullable<AbstractMesh>;
  29493. /** the original (browser) event that triggered the ActionEvent */
  29494. sourceEvent?: any;
  29495. /** additional data for the event */
  29496. additionalData?: any;
  29497. /**
  29498. * Creates a new ActionEvent
  29499. * @param source The mesh or sprite that triggered the action
  29500. * @param pointerX The X mouse cursor position at the time of the event
  29501. * @param pointerY The Y mouse cursor position at the time of the event
  29502. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29503. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29504. * @param additionalData additional data for the event
  29505. */
  29506. constructor(
  29507. /** The mesh or sprite that triggered the action */
  29508. source: any,
  29509. /** The X mouse cursor position at the time of the event */
  29510. pointerX: number,
  29511. /** The Y mouse cursor position at the time of the event */
  29512. pointerY: number,
  29513. /** The mesh that is currently pointed at (can be null) */
  29514. meshUnderPointer: Nullable<AbstractMesh>,
  29515. /** the original (browser) event that triggered the ActionEvent */
  29516. sourceEvent?: any,
  29517. /** additional data for the event */
  29518. additionalData?: any);
  29519. /**
  29520. * Helper function to auto-create an ActionEvent from a source mesh.
  29521. * @param source The source mesh that triggered the event
  29522. * @param evt The original (browser) event
  29523. * @param additionalData additional data for the event
  29524. * @returns the new ActionEvent
  29525. */
  29526. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29527. /**
  29528. * Helper function to auto-create an ActionEvent from a source sprite
  29529. * @param source The source sprite that triggered the event
  29530. * @param scene Scene associated with the sprite
  29531. * @param evt The original (browser) event
  29532. * @param additionalData additional data for the event
  29533. * @returns the new ActionEvent
  29534. */
  29535. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29536. /**
  29537. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29538. * @param scene the scene where the event occurred
  29539. * @param evt The original (browser) event
  29540. * @returns the new ActionEvent
  29541. */
  29542. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29543. /**
  29544. * Helper function to auto-create an ActionEvent from a primitive
  29545. * @param prim defines the target primitive
  29546. * @param pointerPos defines the pointer position
  29547. * @param evt The original (browser) event
  29548. * @param additionalData additional data for the event
  29549. * @returns the new ActionEvent
  29550. */
  29551. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29552. }
  29553. }
  29554. declare module "babylonjs/Actions/abstractActionManager" {
  29555. import { IDisposable } from "babylonjs/scene";
  29556. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29557. import { IAction } from "babylonjs/Actions/action";
  29558. import { Nullable } from "babylonjs/types";
  29559. /**
  29560. * Abstract class used to decouple action Manager from scene and meshes.
  29561. * Do not instantiate.
  29562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29563. */
  29564. export abstract class AbstractActionManager implements IDisposable {
  29565. /** Gets the list of active triggers */
  29566. static Triggers: {
  29567. [key: string]: number;
  29568. };
  29569. /** Gets the cursor to use when hovering items */
  29570. hoverCursor: string;
  29571. /** Gets the list of actions */
  29572. actions: IAction[];
  29573. /**
  29574. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29575. */
  29576. isRecursive: boolean;
  29577. /**
  29578. * Releases all associated resources
  29579. */
  29580. abstract dispose(): void;
  29581. /**
  29582. * Does this action manager has pointer triggers
  29583. */
  29584. abstract get hasPointerTriggers(): boolean;
  29585. /**
  29586. * Does this action manager has pick triggers
  29587. */
  29588. abstract get hasPickTriggers(): boolean;
  29589. /**
  29590. * Process a specific trigger
  29591. * @param trigger defines the trigger to process
  29592. * @param evt defines the event details to be processed
  29593. */
  29594. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29595. /**
  29596. * Does this action manager handles actions of any of the given triggers
  29597. * @param triggers defines the triggers to be tested
  29598. * @return a boolean indicating whether one (or more) of the triggers is handled
  29599. */
  29600. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29601. /**
  29602. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29603. * speed.
  29604. * @param triggerA defines the trigger to be tested
  29605. * @param triggerB defines the trigger to be tested
  29606. * @return a boolean indicating whether one (or more) of the triggers is handled
  29607. */
  29608. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29609. /**
  29610. * Does this action manager handles actions of a given trigger
  29611. * @param trigger defines the trigger to be tested
  29612. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29613. * @return whether the trigger is handled
  29614. */
  29615. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29616. /**
  29617. * Serialize this manager to a JSON object
  29618. * @param name defines the property name to store this manager
  29619. * @returns a JSON representation of this manager
  29620. */
  29621. abstract serialize(name: string): any;
  29622. /**
  29623. * Registers an action to this action manager
  29624. * @param action defines the action to be registered
  29625. * @return the action amended (prepared) after registration
  29626. */
  29627. abstract registerAction(action: IAction): Nullable<IAction>;
  29628. /**
  29629. * Unregisters an action to this action manager
  29630. * @param action defines the action to be unregistered
  29631. * @return a boolean indicating whether the action has been unregistered
  29632. */
  29633. abstract unregisterAction(action: IAction): Boolean;
  29634. /**
  29635. * Does exist one action manager with at least one trigger
  29636. **/
  29637. static get HasTriggers(): boolean;
  29638. /**
  29639. * Does exist one action manager with at least one pick trigger
  29640. **/
  29641. static get HasPickTriggers(): boolean;
  29642. /**
  29643. * Does exist one action manager that handles actions of a given trigger
  29644. * @param trigger defines the trigger to be tested
  29645. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29646. **/
  29647. static HasSpecificTrigger(trigger: number): boolean;
  29648. }
  29649. }
  29650. declare module "babylonjs/node" {
  29651. import { Scene } from "babylonjs/scene";
  29652. import { Nullable } from "babylonjs/types";
  29653. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29654. import { Engine } from "babylonjs/Engines/engine";
  29655. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29656. import { Observable } from "babylonjs/Misc/observable";
  29657. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29658. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29659. import { Animatable } from "babylonjs/Animations/animatable";
  29660. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29661. import { Animation } from "babylonjs/Animations/animation";
  29662. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29664. /**
  29665. * Defines how a node can be built from a string name.
  29666. */
  29667. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29668. /**
  29669. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29670. */
  29671. export class Node implements IBehaviorAware<Node> {
  29672. /** @hidden */
  29673. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29674. private static _NodeConstructors;
  29675. /**
  29676. * Add a new node constructor
  29677. * @param type defines the type name of the node to construct
  29678. * @param constructorFunc defines the constructor function
  29679. */
  29680. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29681. /**
  29682. * Returns a node constructor based on type name
  29683. * @param type defines the type name
  29684. * @param name defines the new node name
  29685. * @param scene defines the hosting scene
  29686. * @param options defines optional options to transmit to constructors
  29687. * @returns the new constructor or null
  29688. */
  29689. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29690. /**
  29691. * Gets or sets the name of the node
  29692. */
  29693. name: string;
  29694. /**
  29695. * Gets or sets the id of the node
  29696. */
  29697. id: string;
  29698. /**
  29699. * Gets or sets the unique id of the node
  29700. */
  29701. uniqueId: number;
  29702. /**
  29703. * Gets or sets a string used to store user defined state for the node
  29704. */
  29705. state: string;
  29706. /**
  29707. * Gets or sets an object used to store user defined information for the node
  29708. */
  29709. metadata: any;
  29710. /**
  29711. * For internal use only. Please do not use.
  29712. */
  29713. reservedDataStore: any;
  29714. /**
  29715. * List of inspectable custom properties (used by the Inspector)
  29716. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29717. */
  29718. inspectableCustomProperties: IInspectable[];
  29719. private _doNotSerialize;
  29720. /**
  29721. * Gets or sets a boolean used to define if the node must be serialized
  29722. */
  29723. get doNotSerialize(): boolean;
  29724. set doNotSerialize(value: boolean);
  29725. /** @hidden */
  29726. _isDisposed: boolean;
  29727. /**
  29728. * Gets a list of Animations associated with the node
  29729. */
  29730. animations: import("babylonjs/Animations/animation").Animation[];
  29731. protected _ranges: {
  29732. [name: string]: Nullable<AnimationRange>;
  29733. };
  29734. /**
  29735. * Callback raised when the node is ready to be used
  29736. */
  29737. onReady: Nullable<(node: Node) => void>;
  29738. private _isEnabled;
  29739. private _isParentEnabled;
  29740. private _isReady;
  29741. /** @hidden */
  29742. _currentRenderId: number;
  29743. private _parentUpdateId;
  29744. /** @hidden */
  29745. _childUpdateId: number;
  29746. /** @hidden */
  29747. _waitingParentId: Nullable<string>;
  29748. /** @hidden */
  29749. _scene: Scene;
  29750. /** @hidden */
  29751. _cache: any;
  29752. private _parentNode;
  29753. private _children;
  29754. /** @hidden */
  29755. _worldMatrix: Matrix;
  29756. /** @hidden */
  29757. _worldMatrixDeterminant: number;
  29758. /** @hidden */
  29759. _worldMatrixDeterminantIsDirty: boolean;
  29760. /** @hidden */
  29761. private _sceneRootNodesIndex;
  29762. /**
  29763. * Gets a boolean indicating if the node has been disposed
  29764. * @returns true if the node was disposed
  29765. */
  29766. isDisposed(): boolean;
  29767. /**
  29768. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29769. * @see https://doc.babylonjs.com/how_to/parenting
  29770. */
  29771. set parent(parent: Nullable<Node>);
  29772. get parent(): Nullable<Node>;
  29773. /** @hidden */
  29774. _addToSceneRootNodes(): void;
  29775. /** @hidden */
  29776. _removeFromSceneRootNodes(): void;
  29777. private _animationPropertiesOverride;
  29778. /**
  29779. * Gets or sets the animation properties override
  29780. */
  29781. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29782. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29783. /**
  29784. * Gets a string idenfifying the name of the class
  29785. * @returns "Node" string
  29786. */
  29787. getClassName(): string;
  29788. /** @hidden */
  29789. readonly _isNode: boolean;
  29790. /**
  29791. * An event triggered when the mesh is disposed
  29792. */
  29793. onDisposeObservable: Observable<Node>;
  29794. private _onDisposeObserver;
  29795. /**
  29796. * Sets a callback that will be raised when the node will be disposed
  29797. */
  29798. set onDispose(callback: () => void);
  29799. /**
  29800. * Creates a new Node
  29801. * @param name the name and id to be given to this node
  29802. * @param scene the scene this node will be added to
  29803. */
  29804. constructor(name: string, scene?: Nullable<Scene>);
  29805. /**
  29806. * Gets the scene of the node
  29807. * @returns a scene
  29808. */
  29809. getScene(): Scene;
  29810. /**
  29811. * Gets the engine of the node
  29812. * @returns a Engine
  29813. */
  29814. getEngine(): Engine;
  29815. private _behaviors;
  29816. /**
  29817. * Attach a behavior to the node
  29818. * @see http://doc.babylonjs.com/features/behaviour
  29819. * @param behavior defines the behavior to attach
  29820. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29821. * @returns the current Node
  29822. */
  29823. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29824. /**
  29825. * Remove an attached behavior
  29826. * @see http://doc.babylonjs.com/features/behaviour
  29827. * @param behavior defines the behavior to attach
  29828. * @returns the current Node
  29829. */
  29830. removeBehavior(behavior: Behavior<Node>): Node;
  29831. /**
  29832. * Gets the list of attached behaviors
  29833. * @see http://doc.babylonjs.com/features/behaviour
  29834. */
  29835. get behaviors(): Behavior<Node>[];
  29836. /**
  29837. * Gets an attached behavior by name
  29838. * @param name defines the name of the behavior to look for
  29839. * @see http://doc.babylonjs.com/features/behaviour
  29840. * @returns null if behavior was not found else the requested behavior
  29841. */
  29842. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29843. /**
  29844. * Returns the latest update of the World matrix
  29845. * @returns a Matrix
  29846. */
  29847. getWorldMatrix(): Matrix;
  29848. /** @hidden */
  29849. _getWorldMatrixDeterminant(): number;
  29850. /**
  29851. * Returns directly the latest state of the mesh World matrix.
  29852. * A Matrix is returned.
  29853. */
  29854. get worldMatrixFromCache(): Matrix;
  29855. /** @hidden */
  29856. _initCache(): void;
  29857. /** @hidden */
  29858. updateCache(force?: boolean): void;
  29859. /** @hidden */
  29860. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29861. /** @hidden */
  29862. _updateCache(ignoreParentClass?: boolean): void;
  29863. /** @hidden */
  29864. _isSynchronized(): boolean;
  29865. /** @hidden */
  29866. _markSyncedWithParent(): void;
  29867. /** @hidden */
  29868. isSynchronizedWithParent(): boolean;
  29869. /** @hidden */
  29870. isSynchronized(): boolean;
  29871. /**
  29872. * Is this node ready to be used/rendered
  29873. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29874. * @return true if the node is ready
  29875. */
  29876. isReady(completeCheck?: boolean): boolean;
  29877. /**
  29878. * Is this node enabled?
  29879. * 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
  29880. * @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
  29881. * @return whether this node (and its parent) is enabled
  29882. */
  29883. isEnabled(checkAncestors?: boolean): boolean;
  29884. /** @hidden */
  29885. protected _syncParentEnabledState(): void;
  29886. /**
  29887. * Set the enabled state of this node
  29888. * @param value defines the new enabled state
  29889. */
  29890. setEnabled(value: boolean): void;
  29891. /**
  29892. * Is this node a descendant of the given node?
  29893. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29894. * @param ancestor defines the parent node to inspect
  29895. * @returns a boolean indicating if this node is a descendant of the given node
  29896. */
  29897. isDescendantOf(ancestor: Node): boolean;
  29898. /** @hidden */
  29899. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29900. /**
  29901. * Will return all nodes that have this node as ascendant
  29902. * @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
  29903. * @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
  29904. * @return all children nodes of all types
  29905. */
  29906. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29907. /**
  29908. * Get all child-meshes of this node
  29909. * @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)
  29910. * @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
  29911. * @returns an array of AbstractMesh
  29912. */
  29913. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29914. /**
  29915. * Get all direct children of this node
  29916. * @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
  29917. * @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)
  29918. * @returns an array of Node
  29919. */
  29920. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29921. /** @hidden */
  29922. _setReady(state: boolean): void;
  29923. /**
  29924. * Get an animation by name
  29925. * @param name defines the name of the animation to look for
  29926. * @returns null if not found else the requested animation
  29927. */
  29928. getAnimationByName(name: string): Nullable<Animation>;
  29929. /**
  29930. * Creates an animation range for this node
  29931. * @param name defines the name of the range
  29932. * @param from defines the starting key
  29933. * @param to defines the end key
  29934. */
  29935. createAnimationRange(name: string, from: number, to: number): void;
  29936. /**
  29937. * Delete a specific animation range
  29938. * @param name defines the name of the range to delete
  29939. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29940. */
  29941. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29942. /**
  29943. * Get an animation range by name
  29944. * @param name defines the name of the animation range to look for
  29945. * @returns null if not found else the requested animation range
  29946. */
  29947. getAnimationRange(name: string): Nullable<AnimationRange>;
  29948. /**
  29949. * Gets the list of all animation ranges defined on this node
  29950. * @returns an array
  29951. */
  29952. getAnimationRanges(): Nullable<AnimationRange>[];
  29953. /**
  29954. * Will start the animation sequence
  29955. * @param name defines the range frames for animation sequence
  29956. * @param loop defines if the animation should loop (false by default)
  29957. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29958. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29959. * @returns the object created for this animation. If range does not exist, it will return null
  29960. */
  29961. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29962. /**
  29963. * Serialize animation ranges into a JSON compatible object
  29964. * @returns serialization object
  29965. */
  29966. serializeAnimationRanges(): any;
  29967. /**
  29968. * Computes the world matrix of the node
  29969. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29970. * @returns the world matrix
  29971. */
  29972. computeWorldMatrix(force?: boolean): Matrix;
  29973. /**
  29974. * Releases resources associated with this node.
  29975. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29976. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29977. */
  29978. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29979. /**
  29980. * Parse animation range data from a serialization object and store them into a given node
  29981. * @param node defines where to store the animation ranges
  29982. * @param parsedNode defines the serialization object to read data from
  29983. * @param scene defines the hosting scene
  29984. */
  29985. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29986. /**
  29987. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29988. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29989. * @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
  29990. * @returns the new bounding vectors
  29991. */
  29992. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29993. min: Vector3;
  29994. max: Vector3;
  29995. };
  29996. }
  29997. }
  29998. declare module "babylonjs/Animations/animation" {
  29999. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30000. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30001. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30002. import { Nullable } from "babylonjs/types";
  30003. import { Scene } from "babylonjs/scene";
  30004. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30005. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30006. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30007. import { Node } from "babylonjs/node";
  30008. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30009. import { Size } from "babylonjs/Maths/math.size";
  30010. import { Animatable } from "babylonjs/Animations/animatable";
  30011. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30012. /**
  30013. * @hidden
  30014. */
  30015. export class _IAnimationState {
  30016. key: number;
  30017. repeatCount: number;
  30018. workValue?: any;
  30019. loopMode?: number;
  30020. offsetValue?: any;
  30021. highLimitValue?: any;
  30022. }
  30023. /**
  30024. * Class used to store any kind of animation
  30025. */
  30026. export class Animation {
  30027. /**Name of the animation */
  30028. name: string;
  30029. /**Property to animate */
  30030. targetProperty: string;
  30031. /**The frames per second of the animation */
  30032. framePerSecond: number;
  30033. /**The data type of the animation */
  30034. dataType: number;
  30035. /**The loop mode of the animation */
  30036. loopMode?: number | undefined;
  30037. /**Specifies if blending should be enabled */
  30038. enableBlending?: boolean | undefined;
  30039. /**
  30040. * Use matrix interpolation instead of using direct key value when animating matrices
  30041. */
  30042. static AllowMatricesInterpolation: boolean;
  30043. /**
  30044. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30045. */
  30046. static AllowMatrixDecomposeForInterpolation: boolean;
  30047. /**
  30048. * Stores the key frames of the animation
  30049. */
  30050. private _keys;
  30051. /**
  30052. * Stores the easing function of the animation
  30053. */
  30054. private _easingFunction;
  30055. /**
  30056. * @hidden Internal use only
  30057. */
  30058. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30059. /**
  30060. * The set of event that will be linked to this animation
  30061. */
  30062. private _events;
  30063. /**
  30064. * Stores an array of target property paths
  30065. */
  30066. targetPropertyPath: string[];
  30067. /**
  30068. * Stores the blending speed of the animation
  30069. */
  30070. blendingSpeed: number;
  30071. /**
  30072. * Stores the animation ranges for the animation
  30073. */
  30074. private _ranges;
  30075. /**
  30076. * @hidden Internal use
  30077. */
  30078. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30079. /**
  30080. * Sets up an animation
  30081. * @param property The property to animate
  30082. * @param animationType The animation type to apply
  30083. * @param framePerSecond The frames per second of the animation
  30084. * @param easingFunction The easing function used in the animation
  30085. * @returns The created animation
  30086. */
  30087. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30088. /**
  30089. * Create and start an animation on a node
  30090. * @param name defines the name of the global animation that will be run on all nodes
  30091. * @param node defines the root node where the animation will take place
  30092. * @param targetProperty defines property to animate
  30093. * @param framePerSecond defines the number of frame per second yo use
  30094. * @param totalFrame defines the number of frames in total
  30095. * @param from defines the initial value
  30096. * @param to defines the final value
  30097. * @param loopMode defines which loop mode you want to use (off by default)
  30098. * @param easingFunction defines the easing function to use (linear by default)
  30099. * @param onAnimationEnd defines the callback to call when animation end
  30100. * @returns the animatable created for this animation
  30101. */
  30102. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30103. /**
  30104. * Create and start an animation on a node and its descendants
  30105. * @param name defines the name of the global animation that will be run on all nodes
  30106. * @param node defines the root node where the animation will take place
  30107. * @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
  30108. * @param targetProperty defines property to animate
  30109. * @param framePerSecond defines the number of frame per second to use
  30110. * @param totalFrame defines the number of frames in total
  30111. * @param from defines the initial value
  30112. * @param to defines the final value
  30113. * @param loopMode defines which loop mode you want to use (off by default)
  30114. * @param easingFunction defines the easing function to use (linear by default)
  30115. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30116. * @returns the list of animatables created for all nodes
  30117. * @example https://www.babylonjs-playground.com/#MH0VLI
  30118. */
  30119. 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[]>;
  30120. /**
  30121. * Creates a new animation, merges it with the existing animations and starts it
  30122. * @param name Name of the animation
  30123. * @param node Node which contains the scene that begins the animations
  30124. * @param targetProperty Specifies which property to animate
  30125. * @param framePerSecond The frames per second of the animation
  30126. * @param totalFrame The total number of frames
  30127. * @param from The frame at the beginning of the animation
  30128. * @param to The frame at the end of the animation
  30129. * @param loopMode Specifies the loop mode of the animation
  30130. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30131. * @param onAnimationEnd Callback to run once the animation is complete
  30132. * @returns Nullable animation
  30133. */
  30134. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30135. /**
  30136. * Transition property of an host to the target Value
  30137. * @param property The property to transition
  30138. * @param targetValue The target Value of the property
  30139. * @param host The object where the property to animate belongs
  30140. * @param scene Scene used to run the animation
  30141. * @param frameRate Framerate (in frame/s) to use
  30142. * @param transition The transition type we want to use
  30143. * @param duration The duration of the animation, in milliseconds
  30144. * @param onAnimationEnd Callback trigger at the end of the animation
  30145. * @returns Nullable animation
  30146. */
  30147. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30148. /**
  30149. * Return the array of runtime animations currently using this animation
  30150. */
  30151. get runtimeAnimations(): RuntimeAnimation[];
  30152. /**
  30153. * Specifies if any of the runtime animations are currently running
  30154. */
  30155. get hasRunningRuntimeAnimations(): boolean;
  30156. /**
  30157. * Initializes the animation
  30158. * @param name Name of the animation
  30159. * @param targetProperty Property to animate
  30160. * @param framePerSecond The frames per second of the animation
  30161. * @param dataType The data type of the animation
  30162. * @param loopMode The loop mode of the animation
  30163. * @param enableBlending Specifies if blending should be enabled
  30164. */
  30165. constructor(
  30166. /**Name of the animation */
  30167. name: string,
  30168. /**Property to animate */
  30169. targetProperty: string,
  30170. /**The frames per second of the animation */
  30171. framePerSecond: number,
  30172. /**The data type of the animation */
  30173. dataType: number,
  30174. /**The loop mode of the animation */
  30175. loopMode?: number | undefined,
  30176. /**Specifies if blending should be enabled */
  30177. enableBlending?: boolean | undefined);
  30178. /**
  30179. * Converts the animation to a string
  30180. * @param fullDetails support for multiple levels of logging within scene loading
  30181. * @returns String form of the animation
  30182. */
  30183. toString(fullDetails?: boolean): string;
  30184. /**
  30185. * Add an event to this animation
  30186. * @param event Event to add
  30187. */
  30188. addEvent(event: AnimationEvent): void;
  30189. /**
  30190. * Remove all events found at the given frame
  30191. * @param frame The frame to remove events from
  30192. */
  30193. removeEvents(frame: number): void;
  30194. /**
  30195. * Retrieves all the events from the animation
  30196. * @returns Events from the animation
  30197. */
  30198. getEvents(): AnimationEvent[];
  30199. /**
  30200. * Creates an animation range
  30201. * @param name Name of the animation range
  30202. * @param from Starting frame of the animation range
  30203. * @param to Ending frame of the animation
  30204. */
  30205. createRange(name: string, from: number, to: number): void;
  30206. /**
  30207. * Deletes an animation range by name
  30208. * @param name Name of the animation range to delete
  30209. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30210. */
  30211. deleteRange(name: string, deleteFrames?: boolean): void;
  30212. /**
  30213. * Gets the animation range by name, or null if not defined
  30214. * @param name Name of the animation range
  30215. * @returns Nullable animation range
  30216. */
  30217. getRange(name: string): Nullable<AnimationRange>;
  30218. /**
  30219. * Gets the key frames from the animation
  30220. * @returns The key frames of the animation
  30221. */
  30222. getKeys(): Array<IAnimationKey>;
  30223. /**
  30224. * Gets the highest frame rate of the animation
  30225. * @returns Highest frame rate of the animation
  30226. */
  30227. getHighestFrame(): number;
  30228. /**
  30229. * Gets the easing function of the animation
  30230. * @returns Easing function of the animation
  30231. */
  30232. getEasingFunction(): IEasingFunction;
  30233. /**
  30234. * Sets the easing function of the animation
  30235. * @param easingFunction A custom mathematical formula for animation
  30236. */
  30237. setEasingFunction(easingFunction: EasingFunction): void;
  30238. /**
  30239. * Interpolates a scalar linearly
  30240. * @param startValue Start value of the animation curve
  30241. * @param endValue End value of the animation curve
  30242. * @param gradient Scalar amount to interpolate
  30243. * @returns Interpolated scalar value
  30244. */
  30245. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30246. /**
  30247. * Interpolates a scalar cubically
  30248. * @param startValue Start value of the animation curve
  30249. * @param outTangent End tangent of the animation
  30250. * @param endValue End value of the animation curve
  30251. * @param inTangent Start tangent of the animation curve
  30252. * @param gradient Scalar amount to interpolate
  30253. * @returns Interpolated scalar value
  30254. */
  30255. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30256. /**
  30257. * Interpolates a quaternion using a spherical linear interpolation
  30258. * @param startValue Start value of the animation curve
  30259. * @param endValue End value of the animation curve
  30260. * @param gradient Scalar amount to interpolate
  30261. * @returns Interpolated quaternion value
  30262. */
  30263. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30264. /**
  30265. * Interpolates a quaternion cubically
  30266. * @param startValue Start value of the animation curve
  30267. * @param outTangent End tangent of the animation curve
  30268. * @param endValue End value of the animation curve
  30269. * @param inTangent Start tangent of the animation curve
  30270. * @param gradient Scalar amount to interpolate
  30271. * @returns Interpolated quaternion value
  30272. */
  30273. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30274. /**
  30275. * Interpolates a Vector3 linearl
  30276. * @param startValue Start value of the animation curve
  30277. * @param endValue End value of the animation curve
  30278. * @param gradient Scalar amount to interpolate
  30279. * @returns Interpolated scalar value
  30280. */
  30281. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30282. /**
  30283. * Interpolates a Vector3 cubically
  30284. * @param startValue Start value of the animation curve
  30285. * @param outTangent End tangent of the animation
  30286. * @param endValue End value of the animation curve
  30287. * @param inTangent Start tangent of the animation curve
  30288. * @param gradient Scalar amount to interpolate
  30289. * @returns InterpolatedVector3 value
  30290. */
  30291. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30292. /**
  30293. * Interpolates a Vector2 linearly
  30294. * @param startValue Start value of the animation curve
  30295. * @param endValue End value of the animation curve
  30296. * @param gradient Scalar amount to interpolate
  30297. * @returns Interpolated Vector2 value
  30298. */
  30299. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30300. /**
  30301. * Interpolates a Vector2 cubically
  30302. * @param startValue Start value of the animation curve
  30303. * @param outTangent End tangent of the animation
  30304. * @param endValue End value of the animation curve
  30305. * @param inTangent Start tangent of the animation curve
  30306. * @param gradient Scalar amount to interpolate
  30307. * @returns Interpolated Vector2 value
  30308. */
  30309. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30310. /**
  30311. * Interpolates a size linearly
  30312. * @param startValue Start value of the animation curve
  30313. * @param endValue End value of the animation curve
  30314. * @param gradient Scalar amount to interpolate
  30315. * @returns Interpolated Size value
  30316. */
  30317. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30318. /**
  30319. * Interpolates a Color3 linearly
  30320. * @param startValue Start value of the animation curve
  30321. * @param endValue End value of the animation curve
  30322. * @param gradient Scalar amount to interpolate
  30323. * @returns Interpolated Color3 value
  30324. */
  30325. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30326. /**
  30327. * Interpolates a Color4 linearly
  30328. * @param startValue Start value of the animation curve
  30329. * @param endValue End value of the animation curve
  30330. * @param gradient Scalar amount to interpolate
  30331. * @returns Interpolated Color3 value
  30332. */
  30333. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30334. /**
  30335. * @hidden Internal use only
  30336. */
  30337. _getKeyValue(value: any): any;
  30338. /**
  30339. * @hidden Internal use only
  30340. */
  30341. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30342. /**
  30343. * Defines the function to use to interpolate matrices
  30344. * @param startValue defines the start matrix
  30345. * @param endValue defines the end matrix
  30346. * @param gradient defines the gradient between both matrices
  30347. * @param result defines an optional target matrix where to store the interpolation
  30348. * @returns the interpolated matrix
  30349. */
  30350. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30351. /**
  30352. * Makes a copy of the animation
  30353. * @returns Cloned animation
  30354. */
  30355. clone(): Animation;
  30356. /**
  30357. * Sets the key frames of the animation
  30358. * @param values The animation key frames to set
  30359. */
  30360. setKeys(values: Array<IAnimationKey>): void;
  30361. /**
  30362. * Serializes the animation to an object
  30363. * @returns Serialized object
  30364. */
  30365. serialize(): any;
  30366. /**
  30367. * Float animation type
  30368. */
  30369. static readonly ANIMATIONTYPE_FLOAT: number;
  30370. /**
  30371. * Vector3 animation type
  30372. */
  30373. static readonly ANIMATIONTYPE_VECTOR3: number;
  30374. /**
  30375. * Quaternion animation type
  30376. */
  30377. static readonly ANIMATIONTYPE_QUATERNION: number;
  30378. /**
  30379. * Matrix animation type
  30380. */
  30381. static readonly ANIMATIONTYPE_MATRIX: number;
  30382. /**
  30383. * Color3 animation type
  30384. */
  30385. static readonly ANIMATIONTYPE_COLOR3: number;
  30386. /**
  30387. * Color3 animation type
  30388. */
  30389. static readonly ANIMATIONTYPE_COLOR4: number;
  30390. /**
  30391. * Vector2 animation type
  30392. */
  30393. static readonly ANIMATIONTYPE_VECTOR2: number;
  30394. /**
  30395. * Size animation type
  30396. */
  30397. static readonly ANIMATIONTYPE_SIZE: number;
  30398. /**
  30399. * Relative Loop Mode
  30400. */
  30401. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30402. /**
  30403. * Cycle Loop Mode
  30404. */
  30405. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30406. /**
  30407. * Constant Loop Mode
  30408. */
  30409. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30410. /** @hidden */
  30411. static _UniversalLerp(left: any, right: any, amount: number): any;
  30412. /**
  30413. * Parses an animation object and creates an animation
  30414. * @param parsedAnimation Parsed animation object
  30415. * @returns Animation object
  30416. */
  30417. static Parse(parsedAnimation: any): Animation;
  30418. /**
  30419. * Appends the serialized animations from the source animations
  30420. * @param source Source containing the animations
  30421. * @param destination Target to store the animations
  30422. */
  30423. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30424. }
  30425. }
  30426. declare module "babylonjs/Animations/animatable.interface" {
  30427. import { Nullable } from "babylonjs/types";
  30428. import { Animation } from "babylonjs/Animations/animation";
  30429. /**
  30430. * Interface containing an array of animations
  30431. */
  30432. export interface IAnimatable {
  30433. /**
  30434. * Array of animations
  30435. */
  30436. animations: Nullable<Array<Animation>>;
  30437. }
  30438. }
  30439. declare module "babylonjs/Misc/decorators" {
  30440. import { Nullable } from "babylonjs/types";
  30441. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30442. import { Scene } from "babylonjs/scene";
  30443. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30444. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30445. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30446. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30447. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30448. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30449. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30450. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30451. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30452. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30453. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30454. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30455. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30456. /**
  30457. * Decorator used to define property that can be serialized as reference to a camera
  30458. * @param sourceName defines the name of the property to decorate
  30459. */
  30460. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30461. /**
  30462. * Class used to help serialization objects
  30463. */
  30464. export class SerializationHelper {
  30465. /** @hidden */
  30466. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30467. /** @hidden */
  30468. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30469. /** @hidden */
  30470. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30471. /** @hidden */
  30472. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30473. /**
  30474. * Appends the serialized animations from the source animations
  30475. * @param source Source containing the animations
  30476. * @param destination Target to store the animations
  30477. */
  30478. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30479. /**
  30480. * Static function used to serialized a specific entity
  30481. * @param entity defines the entity to serialize
  30482. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30483. * @returns a JSON compatible object representing the serialization of the entity
  30484. */
  30485. static Serialize<T>(entity: T, serializationObject?: any): any;
  30486. /**
  30487. * Creates a new entity from a serialization data object
  30488. * @param creationFunction defines a function used to instanciated the new entity
  30489. * @param source defines the source serialization data
  30490. * @param scene defines the hosting scene
  30491. * @param rootUrl defines the root url for resources
  30492. * @returns a new entity
  30493. */
  30494. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30495. /**
  30496. * Clones an object
  30497. * @param creationFunction defines the function used to instanciate the new object
  30498. * @param source defines the source object
  30499. * @returns the cloned object
  30500. */
  30501. static Clone<T>(creationFunction: () => T, source: T): T;
  30502. /**
  30503. * Instanciates a new object based on a source one (some data will be shared between both object)
  30504. * @param creationFunction defines the function used to instanciate the new object
  30505. * @param source defines the source object
  30506. * @returns the new object
  30507. */
  30508. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30509. }
  30510. }
  30511. declare module "babylonjs/Misc/guid" {
  30512. /**
  30513. * Class used to manipulate GUIDs
  30514. */
  30515. export class GUID {
  30516. /**
  30517. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30518. * Be aware Math.random() could cause collisions, but:
  30519. * "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"
  30520. * @returns a pseudo random id
  30521. */
  30522. static RandomId(): string;
  30523. }
  30524. }
  30525. declare module "babylonjs/Materials/Textures/baseTexture" {
  30526. import { Observable } from "babylonjs/Misc/observable";
  30527. import { Nullable } from "babylonjs/types";
  30528. import { Scene } from "babylonjs/scene";
  30529. import { Matrix } from "babylonjs/Maths/math.vector";
  30530. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30531. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30532. import { ISize } from "babylonjs/Maths/math.size";
  30533. import "babylonjs/Misc/fileTools";
  30534. /**
  30535. * Base class of all the textures in babylon.
  30536. * It groups all the common properties the materials, post process, lights... might need
  30537. * in order to make a correct use of the texture.
  30538. */
  30539. export class BaseTexture implements IAnimatable {
  30540. /**
  30541. * Default anisotropic filtering level for the application.
  30542. * It is set to 4 as a good tradeoff between perf and quality.
  30543. */
  30544. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30545. /**
  30546. * Gets or sets the unique id of the texture
  30547. */
  30548. uniqueId: number;
  30549. /**
  30550. * Define the name of the texture.
  30551. */
  30552. name: string;
  30553. /**
  30554. * Gets or sets an object used to store user defined information.
  30555. */
  30556. metadata: any;
  30557. /**
  30558. * For internal use only. Please do not use.
  30559. */
  30560. reservedDataStore: any;
  30561. private _hasAlpha;
  30562. /**
  30563. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30564. */
  30565. set hasAlpha(value: boolean);
  30566. get hasAlpha(): boolean;
  30567. /**
  30568. * Defines if the alpha value should be determined via the rgb values.
  30569. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30570. */
  30571. getAlphaFromRGB: boolean;
  30572. /**
  30573. * Intensity or strength of the texture.
  30574. * It is commonly used by materials to fine tune the intensity of the texture
  30575. */
  30576. level: number;
  30577. /**
  30578. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30579. * This is part of the texture as textures usually maps to one uv set.
  30580. */
  30581. coordinatesIndex: number;
  30582. private _coordinatesMode;
  30583. /**
  30584. * How a texture is mapped.
  30585. *
  30586. * | Value | Type | Description |
  30587. * | ----- | ----------------------------------- | ----------- |
  30588. * | 0 | EXPLICIT_MODE | |
  30589. * | 1 | SPHERICAL_MODE | |
  30590. * | 2 | PLANAR_MODE | |
  30591. * | 3 | CUBIC_MODE | |
  30592. * | 4 | PROJECTION_MODE | |
  30593. * | 5 | SKYBOX_MODE | |
  30594. * | 6 | INVCUBIC_MODE | |
  30595. * | 7 | EQUIRECTANGULAR_MODE | |
  30596. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30597. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30598. */
  30599. set coordinatesMode(value: number);
  30600. get coordinatesMode(): number;
  30601. /**
  30602. * | Value | Type | Description |
  30603. * | ----- | ------------------ | ----------- |
  30604. * | 0 | CLAMP_ADDRESSMODE | |
  30605. * | 1 | WRAP_ADDRESSMODE | |
  30606. * | 2 | MIRROR_ADDRESSMODE | |
  30607. */
  30608. wrapU: number;
  30609. /**
  30610. * | Value | Type | Description |
  30611. * | ----- | ------------------ | ----------- |
  30612. * | 0 | CLAMP_ADDRESSMODE | |
  30613. * | 1 | WRAP_ADDRESSMODE | |
  30614. * | 2 | MIRROR_ADDRESSMODE | |
  30615. */
  30616. wrapV: number;
  30617. /**
  30618. * | Value | Type | Description |
  30619. * | ----- | ------------------ | ----------- |
  30620. * | 0 | CLAMP_ADDRESSMODE | |
  30621. * | 1 | WRAP_ADDRESSMODE | |
  30622. * | 2 | MIRROR_ADDRESSMODE | |
  30623. */
  30624. wrapR: number;
  30625. /**
  30626. * With compliant hardware and browser (supporting anisotropic filtering)
  30627. * this defines the level of anisotropic filtering in the texture.
  30628. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30629. */
  30630. anisotropicFilteringLevel: number;
  30631. /**
  30632. * Define if the texture is a cube texture or if false a 2d texture.
  30633. */
  30634. get isCube(): boolean;
  30635. set isCube(value: boolean);
  30636. /**
  30637. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30638. */
  30639. get is3D(): boolean;
  30640. set is3D(value: boolean);
  30641. /**
  30642. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30643. */
  30644. get is2DArray(): boolean;
  30645. set is2DArray(value: boolean);
  30646. /**
  30647. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30648. * HDR texture are usually stored in linear space.
  30649. * This only impacts the PBR and Background materials
  30650. */
  30651. gammaSpace: boolean;
  30652. /**
  30653. * Gets or sets whether or not the texture contains RGBD data.
  30654. */
  30655. get isRGBD(): boolean;
  30656. set isRGBD(value: boolean);
  30657. /**
  30658. * Is Z inverted in the texture (useful in a cube texture).
  30659. */
  30660. invertZ: boolean;
  30661. /**
  30662. * Are mip maps generated for this texture or not.
  30663. */
  30664. get noMipmap(): boolean;
  30665. /**
  30666. * @hidden
  30667. */
  30668. lodLevelInAlpha: boolean;
  30669. /**
  30670. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30671. */
  30672. get lodGenerationOffset(): number;
  30673. set lodGenerationOffset(value: number);
  30674. /**
  30675. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30676. */
  30677. get lodGenerationScale(): number;
  30678. set lodGenerationScale(value: number);
  30679. /**
  30680. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30681. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30682. * average roughness values.
  30683. */
  30684. get linearSpecularLOD(): boolean;
  30685. set linearSpecularLOD(value: boolean);
  30686. /**
  30687. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30688. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30689. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30690. */
  30691. get irradianceTexture(): Nullable<BaseTexture>;
  30692. set irradianceTexture(value: Nullable<BaseTexture>);
  30693. /**
  30694. * Define if the texture is a render target.
  30695. */
  30696. isRenderTarget: boolean;
  30697. /**
  30698. * Define the unique id of the texture in the scene.
  30699. */
  30700. get uid(): string;
  30701. /**
  30702. * Return a string representation of the texture.
  30703. * @returns the texture as a string
  30704. */
  30705. toString(): string;
  30706. /**
  30707. * Get the class name of the texture.
  30708. * @returns "BaseTexture"
  30709. */
  30710. getClassName(): string;
  30711. /**
  30712. * Define the list of animation attached to the texture.
  30713. */
  30714. animations: import("babylonjs/Animations/animation").Animation[];
  30715. /**
  30716. * An event triggered when the texture is disposed.
  30717. */
  30718. onDisposeObservable: Observable<BaseTexture>;
  30719. private _onDisposeObserver;
  30720. /**
  30721. * Callback triggered when the texture has been disposed.
  30722. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30723. */
  30724. set onDispose(callback: () => void);
  30725. /**
  30726. * Define the current state of the loading sequence when in delayed load mode.
  30727. */
  30728. delayLoadState: number;
  30729. private _scene;
  30730. /** @hidden */
  30731. _texture: Nullable<InternalTexture>;
  30732. private _uid;
  30733. /**
  30734. * Define if the texture is preventinga material to render or not.
  30735. * If not and the texture is not ready, the engine will use a default black texture instead.
  30736. */
  30737. get isBlocking(): boolean;
  30738. /**
  30739. * Instantiates a new BaseTexture.
  30740. * Base class of all the textures in babylon.
  30741. * It groups all the common properties the materials, post process, lights... might need
  30742. * in order to make a correct use of the texture.
  30743. * @param scene Define the scene the texture blongs to
  30744. */
  30745. constructor(scene: Nullable<Scene>);
  30746. /**
  30747. * Get the scene the texture belongs to.
  30748. * @returns the scene or null if undefined
  30749. */
  30750. getScene(): Nullable<Scene>;
  30751. /**
  30752. * Get the texture transform matrix used to offset tile the texture for istance.
  30753. * @returns the transformation matrix
  30754. */
  30755. getTextureMatrix(): Matrix;
  30756. /**
  30757. * Get the texture reflection matrix used to rotate/transform the reflection.
  30758. * @returns the reflection matrix
  30759. */
  30760. getReflectionTextureMatrix(): Matrix;
  30761. /**
  30762. * Get the underlying lower level texture from Babylon.
  30763. * @returns the insternal texture
  30764. */
  30765. getInternalTexture(): Nullable<InternalTexture>;
  30766. /**
  30767. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30768. * @returns true if ready or not blocking
  30769. */
  30770. isReadyOrNotBlocking(): boolean;
  30771. /**
  30772. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30773. * @returns true if fully ready
  30774. */
  30775. isReady(): boolean;
  30776. private _cachedSize;
  30777. /**
  30778. * Get the size of the texture.
  30779. * @returns the texture size.
  30780. */
  30781. getSize(): ISize;
  30782. /**
  30783. * Get the base size of the texture.
  30784. * It can be different from the size if the texture has been resized for POT for instance
  30785. * @returns the base size
  30786. */
  30787. getBaseSize(): ISize;
  30788. /**
  30789. * Update the sampling mode of the texture.
  30790. * Default is Trilinear mode.
  30791. *
  30792. * | Value | Type | Description |
  30793. * | ----- | ------------------ | ----------- |
  30794. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30795. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30796. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30797. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30798. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30799. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30800. * | 7 | NEAREST_LINEAR | |
  30801. * | 8 | NEAREST_NEAREST | |
  30802. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30803. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30804. * | 11 | LINEAR_LINEAR | |
  30805. * | 12 | LINEAR_NEAREST | |
  30806. *
  30807. * > _mag_: magnification filter (close to the viewer)
  30808. * > _min_: minification filter (far from the viewer)
  30809. * > _mip_: filter used between mip map levels
  30810. *@param samplingMode Define the new sampling mode of the texture
  30811. */
  30812. updateSamplingMode(samplingMode: number): void;
  30813. /**
  30814. * Scales the texture if is `canRescale()`
  30815. * @param ratio the resize factor we want to use to rescale
  30816. */
  30817. scale(ratio: number): void;
  30818. /**
  30819. * Get if the texture can rescale.
  30820. */
  30821. get canRescale(): boolean;
  30822. /** @hidden */
  30823. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30824. /** @hidden */
  30825. _rebuild(): void;
  30826. /**
  30827. * Triggers the load sequence in delayed load mode.
  30828. */
  30829. delayLoad(): void;
  30830. /**
  30831. * Clones the texture.
  30832. * @returns the cloned texture
  30833. */
  30834. clone(): Nullable<BaseTexture>;
  30835. /**
  30836. * Get the texture underlying type (INT, FLOAT...)
  30837. */
  30838. get textureType(): number;
  30839. /**
  30840. * Get the texture underlying format (RGB, RGBA...)
  30841. */
  30842. get textureFormat(): number;
  30843. /**
  30844. * Indicates that textures need to be re-calculated for all materials
  30845. */
  30846. protected _markAllSubMeshesAsTexturesDirty(): void;
  30847. /**
  30848. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30849. * This will returns an RGBA array buffer containing either in values (0-255) or
  30850. * float values (0-1) depending of the underlying buffer type.
  30851. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30852. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30853. * @param buffer defines a user defined buffer to fill with data (can be null)
  30854. * @returns The Array buffer containing the pixels data.
  30855. */
  30856. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30857. /**
  30858. * Release and destroy the underlying lower level texture aka internalTexture.
  30859. */
  30860. releaseInternalTexture(): void;
  30861. /** @hidden */
  30862. get _lodTextureHigh(): Nullable<BaseTexture>;
  30863. /** @hidden */
  30864. get _lodTextureMid(): Nullable<BaseTexture>;
  30865. /** @hidden */
  30866. get _lodTextureLow(): Nullable<BaseTexture>;
  30867. /**
  30868. * Dispose the texture and release its associated resources.
  30869. */
  30870. dispose(): void;
  30871. /**
  30872. * Serialize the texture into a JSON representation that can be parsed later on.
  30873. * @returns the JSON representation of the texture
  30874. */
  30875. serialize(): any;
  30876. /**
  30877. * Helper function to be called back once a list of texture contains only ready textures.
  30878. * @param textures Define the list of textures to wait for
  30879. * @param callback Define the callback triggered once the entire list will be ready
  30880. */
  30881. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30882. }
  30883. }
  30884. declare module "babylonjs/Materials/effect" {
  30885. import { Observable } from "babylonjs/Misc/observable";
  30886. import { Nullable } from "babylonjs/types";
  30887. import { IDisposable } from "babylonjs/scene";
  30888. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30889. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30890. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30891. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30892. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30893. import { Engine } from "babylonjs/Engines/engine";
  30894. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30897. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30898. /**
  30899. * Options to be used when creating an effect.
  30900. */
  30901. export interface IEffectCreationOptions {
  30902. /**
  30903. * Atrributes that will be used in the shader.
  30904. */
  30905. attributes: string[];
  30906. /**
  30907. * Uniform varible names that will be set in the shader.
  30908. */
  30909. uniformsNames: string[];
  30910. /**
  30911. * Uniform buffer variable names that will be set in the shader.
  30912. */
  30913. uniformBuffersNames: string[];
  30914. /**
  30915. * Sampler texture variable names that will be set in the shader.
  30916. */
  30917. samplers: string[];
  30918. /**
  30919. * Define statements that will be set in the shader.
  30920. */
  30921. defines: any;
  30922. /**
  30923. * Possible fallbacks for this effect to improve performance when needed.
  30924. */
  30925. fallbacks: Nullable<IEffectFallbacks>;
  30926. /**
  30927. * Callback that will be called when the shader is compiled.
  30928. */
  30929. onCompiled: Nullable<(effect: Effect) => void>;
  30930. /**
  30931. * Callback that will be called if an error occurs during shader compilation.
  30932. */
  30933. onError: Nullable<(effect: Effect, errors: string) => void>;
  30934. /**
  30935. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30936. */
  30937. indexParameters?: any;
  30938. /**
  30939. * Max number of lights that can be used in the shader.
  30940. */
  30941. maxSimultaneousLights?: number;
  30942. /**
  30943. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30944. */
  30945. transformFeedbackVaryings?: Nullable<string[]>;
  30946. }
  30947. /**
  30948. * Effect containing vertex and fragment shader that can be executed on an object.
  30949. */
  30950. export class Effect implements IDisposable {
  30951. /**
  30952. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30953. */
  30954. static ShadersRepository: string;
  30955. /**
  30956. * Enable logging of the shader code when a compilation error occurs
  30957. */
  30958. static LogShaderCodeOnCompilationError: boolean;
  30959. /**
  30960. * Name of the effect.
  30961. */
  30962. name: any;
  30963. /**
  30964. * String container all the define statements that should be set on the shader.
  30965. */
  30966. defines: string;
  30967. /**
  30968. * Callback that will be called when the shader is compiled.
  30969. */
  30970. onCompiled: Nullable<(effect: Effect) => void>;
  30971. /**
  30972. * Callback that will be called if an error occurs during shader compilation.
  30973. */
  30974. onError: Nullable<(effect: Effect, errors: string) => void>;
  30975. /**
  30976. * Callback that will be called when effect is bound.
  30977. */
  30978. onBind: Nullable<(effect: Effect) => void>;
  30979. /**
  30980. * Unique ID of the effect.
  30981. */
  30982. uniqueId: number;
  30983. /**
  30984. * Observable that will be called when the shader is compiled.
  30985. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30986. */
  30987. onCompileObservable: Observable<Effect>;
  30988. /**
  30989. * Observable that will be called if an error occurs during shader compilation.
  30990. */
  30991. onErrorObservable: Observable<Effect>;
  30992. /** @hidden */
  30993. _onBindObservable: Nullable<Observable<Effect>>;
  30994. /**
  30995. * @hidden
  30996. * Specifies if the effect was previously ready
  30997. */
  30998. _wasPreviouslyReady: boolean;
  30999. /**
  31000. * Observable that will be called when effect is bound.
  31001. */
  31002. get onBindObservable(): Observable<Effect>;
  31003. /** @hidden */
  31004. _bonesComputationForcedToCPU: boolean;
  31005. private static _uniqueIdSeed;
  31006. private _engine;
  31007. private _uniformBuffersNames;
  31008. private _uniformsNames;
  31009. private _samplerList;
  31010. private _samplers;
  31011. private _isReady;
  31012. private _compilationError;
  31013. private _allFallbacksProcessed;
  31014. private _attributesNames;
  31015. private _attributes;
  31016. private _attributeLocationByName;
  31017. private _uniforms;
  31018. /**
  31019. * Key for the effect.
  31020. * @hidden
  31021. */
  31022. _key: string;
  31023. private _indexParameters;
  31024. private _fallbacks;
  31025. private _vertexSourceCode;
  31026. private _fragmentSourceCode;
  31027. private _vertexSourceCodeOverride;
  31028. private _fragmentSourceCodeOverride;
  31029. private _transformFeedbackVaryings;
  31030. /**
  31031. * Compiled shader to webGL program.
  31032. * @hidden
  31033. */
  31034. _pipelineContext: Nullable<IPipelineContext>;
  31035. private _valueCache;
  31036. private static _baseCache;
  31037. /**
  31038. * Instantiates an effect.
  31039. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31040. * @param baseName Name of the effect.
  31041. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31042. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31043. * @param samplers List of sampler variables that will be passed to the shader.
  31044. * @param engine Engine to be used to render the effect
  31045. * @param defines Define statements to be added to the shader.
  31046. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31047. * @param onCompiled Callback that will be called when the shader is compiled.
  31048. * @param onError Callback that will be called if an error occurs during shader compilation.
  31049. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31050. */
  31051. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  31052. private _useFinalCode;
  31053. /**
  31054. * Unique key for this effect
  31055. */
  31056. get key(): string;
  31057. /**
  31058. * If the effect has been compiled and prepared.
  31059. * @returns if the effect is compiled and prepared.
  31060. */
  31061. isReady(): boolean;
  31062. private _isReadyInternal;
  31063. /**
  31064. * The engine the effect was initialized with.
  31065. * @returns the engine.
  31066. */
  31067. getEngine(): Engine;
  31068. /**
  31069. * The pipeline context for this effect
  31070. * @returns the associated pipeline context
  31071. */
  31072. getPipelineContext(): Nullable<IPipelineContext>;
  31073. /**
  31074. * The set of names of attribute variables for the shader.
  31075. * @returns An array of attribute names.
  31076. */
  31077. getAttributesNames(): string[];
  31078. /**
  31079. * Returns the attribute at the given index.
  31080. * @param index The index of the attribute.
  31081. * @returns The location of the attribute.
  31082. */
  31083. getAttributeLocation(index: number): number;
  31084. /**
  31085. * Returns the attribute based on the name of the variable.
  31086. * @param name of the attribute to look up.
  31087. * @returns the attribute location.
  31088. */
  31089. getAttributeLocationByName(name: string): number;
  31090. /**
  31091. * The number of attributes.
  31092. * @returns the numnber of attributes.
  31093. */
  31094. getAttributesCount(): number;
  31095. /**
  31096. * Gets the index of a uniform variable.
  31097. * @param uniformName of the uniform to look up.
  31098. * @returns the index.
  31099. */
  31100. getUniformIndex(uniformName: string): number;
  31101. /**
  31102. * Returns the attribute based on the name of the variable.
  31103. * @param uniformName of the uniform to look up.
  31104. * @returns the location of the uniform.
  31105. */
  31106. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31107. /**
  31108. * Returns an array of sampler variable names
  31109. * @returns The array of sampler variable neames.
  31110. */
  31111. getSamplers(): string[];
  31112. /**
  31113. * The error from the last compilation.
  31114. * @returns the error string.
  31115. */
  31116. getCompilationError(): string;
  31117. /**
  31118. * Gets a boolean indicating that all fallbacks were used during compilation
  31119. * @returns true if all fallbacks were used
  31120. */
  31121. allFallbacksProcessed(): boolean;
  31122. /**
  31123. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31124. * @param func The callback to be used.
  31125. */
  31126. executeWhenCompiled(func: (effect: Effect) => void): void;
  31127. private _checkIsReady;
  31128. private _loadShader;
  31129. /**
  31130. * Recompiles the webGL program
  31131. * @param vertexSourceCode The source code for the vertex shader.
  31132. * @param fragmentSourceCode The source code for the fragment shader.
  31133. * @param onCompiled Callback called when completed.
  31134. * @param onError Callback called on error.
  31135. * @hidden
  31136. */
  31137. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31138. /**
  31139. * Prepares the effect
  31140. * @hidden
  31141. */
  31142. _prepareEffect(): void;
  31143. private _getShaderCodeAndErrorLine;
  31144. private _processCompilationErrors;
  31145. /**
  31146. * Checks if the effect is supported. (Must be called after compilation)
  31147. */
  31148. get isSupported(): boolean;
  31149. /**
  31150. * Binds a texture to the engine to be used as output of the shader.
  31151. * @param channel Name of the output variable.
  31152. * @param texture Texture to bind.
  31153. * @hidden
  31154. */
  31155. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31156. /**
  31157. * Sets a texture on the engine to be used in the shader.
  31158. * @param channel Name of the sampler variable.
  31159. * @param texture Texture to set.
  31160. */
  31161. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31162. /**
  31163. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31164. * @param channel Name of the sampler variable.
  31165. * @param texture Texture to set.
  31166. */
  31167. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31168. /**
  31169. * Sets an array of textures on the engine to be used in the shader.
  31170. * @param channel Name of the variable.
  31171. * @param textures Textures to set.
  31172. */
  31173. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31174. /**
  31175. * 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)
  31176. * @param channel Name of the sampler variable.
  31177. * @param postProcess Post process to get the input texture from.
  31178. */
  31179. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31180. /**
  31181. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31182. * 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)
  31183. * @param channel Name of the sampler variable.
  31184. * @param postProcess Post process to get the output texture from.
  31185. */
  31186. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31187. /** @hidden */
  31188. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31189. /** @hidden */
  31190. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31191. /** @hidden */
  31192. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31193. /** @hidden */
  31194. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31195. /**
  31196. * Binds a buffer to a uniform.
  31197. * @param buffer Buffer to bind.
  31198. * @param name Name of the uniform variable to bind to.
  31199. */
  31200. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31201. /**
  31202. * Binds block to a uniform.
  31203. * @param blockName Name of the block to bind.
  31204. * @param index Index to bind.
  31205. */
  31206. bindUniformBlock(blockName: string, index: number): void;
  31207. /**
  31208. * Sets an interger value on a uniform variable.
  31209. * @param uniformName Name of the variable.
  31210. * @param value Value to be set.
  31211. * @returns this effect.
  31212. */
  31213. setInt(uniformName: string, value: number): Effect;
  31214. /**
  31215. * Sets an int array on a uniform variable.
  31216. * @param uniformName Name of the variable.
  31217. * @param array array to be set.
  31218. * @returns this effect.
  31219. */
  31220. setIntArray(uniformName: string, array: Int32Array): Effect;
  31221. /**
  31222. * 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)
  31223. * @param uniformName Name of the variable.
  31224. * @param array array to be set.
  31225. * @returns this effect.
  31226. */
  31227. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31228. /**
  31229. * 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)
  31230. * @param uniformName Name of the variable.
  31231. * @param array array to be set.
  31232. * @returns this effect.
  31233. */
  31234. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31235. /**
  31236. * 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)
  31237. * @param uniformName Name of the variable.
  31238. * @param array array to be set.
  31239. * @returns this effect.
  31240. */
  31241. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31242. /**
  31243. * Sets an float array on a uniform variable.
  31244. * @param uniformName Name of the variable.
  31245. * @param array array to be set.
  31246. * @returns this effect.
  31247. */
  31248. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31249. /**
  31250. * 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)
  31251. * @param uniformName Name of the variable.
  31252. * @param array array to be set.
  31253. * @returns this effect.
  31254. */
  31255. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31256. /**
  31257. * 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)
  31258. * @param uniformName Name of the variable.
  31259. * @param array array to be set.
  31260. * @returns this effect.
  31261. */
  31262. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31263. /**
  31264. * 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)
  31265. * @param uniformName Name of the variable.
  31266. * @param array array to be set.
  31267. * @returns this effect.
  31268. */
  31269. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31270. /**
  31271. * Sets an array on a uniform variable.
  31272. * @param uniformName Name of the variable.
  31273. * @param array array to be set.
  31274. * @returns this effect.
  31275. */
  31276. setArray(uniformName: string, array: number[]): Effect;
  31277. /**
  31278. * 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)
  31279. * @param uniformName Name of the variable.
  31280. * @param array array to be set.
  31281. * @returns this effect.
  31282. */
  31283. setArray2(uniformName: string, array: number[]): Effect;
  31284. /**
  31285. * 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)
  31286. * @param uniformName Name of the variable.
  31287. * @param array array to be set.
  31288. * @returns this effect.
  31289. */
  31290. setArray3(uniformName: string, array: number[]): Effect;
  31291. /**
  31292. * 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)
  31293. * @param uniformName Name of the variable.
  31294. * @param array array to be set.
  31295. * @returns this effect.
  31296. */
  31297. setArray4(uniformName: string, array: number[]): Effect;
  31298. /**
  31299. * Sets matrices on a uniform variable.
  31300. * @param uniformName Name of the variable.
  31301. * @param matrices matrices to be set.
  31302. * @returns this effect.
  31303. */
  31304. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31305. /**
  31306. * Sets matrix on a uniform variable.
  31307. * @param uniformName Name of the variable.
  31308. * @param matrix matrix to be set.
  31309. * @returns this effect.
  31310. */
  31311. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31312. /**
  31313. * 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)
  31314. * @param uniformName Name of the variable.
  31315. * @param matrix matrix to be set.
  31316. * @returns this effect.
  31317. */
  31318. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31319. /**
  31320. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31321. * @param uniformName Name of the variable.
  31322. * @param matrix matrix to be set.
  31323. * @returns this effect.
  31324. */
  31325. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31326. /**
  31327. * Sets a float on a uniform variable.
  31328. * @param uniformName Name of the variable.
  31329. * @param value value to be set.
  31330. * @returns this effect.
  31331. */
  31332. setFloat(uniformName: string, value: number): Effect;
  31333. /**
  31334. * Sets a boolean on a uniform variable.
  31335. * @param uniformName Name of the variable.
  31336. * @param bool value to be set.
  31337. * @returns this effect.
  31338. */
  31339. setBool(uniformName: string, bool: boolean): Effect;
  31340. /**
  31341. * Sets a Vector2 on a uniform variable.
  31342. * @param uniformName Name of the variable.
  31343. * @param vector2 vector2 to be set.
  31344. * @returns this effect.
  31345. */
  31346. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31347. /**
  31348. * Sets a float2 on a uniform variable.
  31349. * @param uniformName Name of the variable.
  31350. * @param x First float in float2.
  31351. * @param y Second float in float2.
  31352. * @returns this effect.
  31353. */
  31354. setFloat2(uniformName: string, x: number, y: number): Effect;
  31355. /**
  31356. * Sets a Vector3 on a uniform variable.
  31357. * @param uniformName Name of the variable.
  31358. * @param vector3 Value to be set.
  31359. * @returns this effect.
  31360. */
  31361. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31362. /**
  31363. * Sets a float3 on a uniform variable.
  31364. * @param uniformName Name of the variable.
  31365. * @param x First float in float3.
  31366. * @param y Second float in float3.
  31367. * @param z Third float in float3.
  31368. * @returns this effect.
  31369. */
  31370. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31371. /**
  31372. * Sets a Vector4 on a uniform variable.
  31373. * @param uniformName Name of the variable.
  31374. * @param vector4 Value to be set.
  31375. * @returns this effect.
  31376. */
  31377. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31378. /**
  31379. * Sets a float4 on a uniform variable.
  31380. * @param uniformName Name of the variable.
  31381. * @param x First float in float4.
  31382. * @param y Second float in float4.
  31383. * @param z Third float in float4.
  31384. * @param w Fourth float in float4.
  31385. * @returns this effect.
  31386. */
  31387. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31388. /**
  31389. * Sets a Color3 on a uniform variable.
  31390. * @param uniformName Name of the variable.
  31391. * @param color3 Value to be set.
  31392. * @returns this effect.
  31393. */
  31394. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31395. /**
  31396. * Sets a Color4 on a uniform variable.
  31397. * @param uniformName Name of the variable.
  31398. * @param color3 Value to be set.
  31399. * @param alpha Alpha value to be set.
  31400. * @returns this effect.
  31401. */
  31402. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31403. /**
  31404. * Sets a Color4 on a uniform variable
  31405. * @param uniformName defines the name of the variable
  31406. * @param color4 defines the value to be set
  31407. * @returns this effect.
  31408. */
  31409. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31410. /** Release all associated resources */
  31411. dispose(): void;
  31412. /**
  31413. * This function will add a new shader to the shader store
  31414. * @param name the name of the shader
  31415. * @param pixelShader optional pixel shader content
  31416. * @param vertexShader optional vertex shader content
  31417. */
  31418. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31419. /**
  31420. * Store of each shader (The can be looked up using effect.key)
  31421. */
  31422. static ShadersStore: {
  31423. [key: string]: string;
  31424. };
  31425. /**
  31426. * Store of each included file for a shader (The can be looked up using effect.key)
  31427. */
  31428. static IncludesShadersStore: {
  31429. [key: string]: string;
  31430. };
  31431. /**
  31432. * Resets the cache of effects.
  31433. */
  31434. static ResetCache(): void;
  31435. }
  31436. }
  31437. declare module "babylonjs/Engines/engineCapabilities" {
  31438. /**
  31439. * Interface used to describe the capabilities of the engine relatively to the current browser
  31440. */
  31441. export interface EngineCapabilities {
  31442. /** Maximum textures units per fragment shader */
  31443. maxTexturesImageUnits: number;
  31444. /** Maximum texture units per vertex shader */
  31445. maxVertexTextureImageUnits: number;
  31446. /** Maximum textures units in the entire pipeline */
  31447. maxCombinedTexturesImageUnits: number;
  31448. /** Maximum texture size */
  31449. maxTextureSize: number;
  31450. /** Maximum texture samples */
  31451. maxSamples?: number;
  31452. /** Maximum cube texture size */
  31453. maxCubemapTextureSize: number;
  31454. /** Maximum render texture size */
  31455. maxRenderTextureSize: number;
  31456. /** Maximum number of vertex attributes */
  31457. maxVertexAttribs: number;
  31458. /** Maximum number of varyings */
  31459. maxVaryingVectors: number;
  31460. /** Maximum number of uniforms per vertex shader */
  31461. maxVertexUniformVectors: number;
  31462. /** Maximum number of uniforms per fragment shader */
  31463. maxFragmentUniformVectors: number;
  31464. /** Defines if standard derivates (dx/dy) are supported */
  31465. standardDerivatives: boolean;
  31466. /** Defines if s3tc texture compression is supported */
  31467. s3tc?: WEBGL_compressed_texture_s3tc;
  31468. /** Defines if pvrtc texture compression is supported */
  31469. pvrtc: any;
  31470. /** Defines if etc1 texture compression is supported */
  31471. etc1: any;
  31472. /** Defines if etc2 texture compression is supported */
  31473. etc2: any;
  31474. /** Defines if astc texture compression is supported */
  31475. astc: any;
  31476. /** Defines if float textures are supported */
  31477. textureFloat: boolean;
  31478. /** Defines if vertex array objects are supported */
  31479. vertexArrayObject: boolean;
  31480. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31481. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31482. /** Gets the maximum level of anisotropy supported */
  31483. maxAnisotropy: number;
  31484. /** Defines if instancing is supported */
  31485. instancedArrays: boolean;
  31486. /** Defines if 32 bits indices are supported */
  31487. uintIndices: boolean;
  31488. /** Defines if high precision shaders are supported */
  31489. highPrecisionShaderSupported: boolean;
  31490. /** Defines if depth reading in the fragment shader is supported */
  31491. fragmentDepthSupported: boolean;
  31492. /** Defines if float texture linear filtering is supported*/
  31493. textureFloatLinearFiltering: boolean;
  31494. /** Defines if rendering to float textures is supported */
  31495. textureFloatRender: boolean;
  31496. /** Defines if half float textures are supported*/
  31497. textureHalfFloat: boolean;
  31498. /** Defines if half float texture linear filtering is supported*/
  31499. textureHalfFloatLinearFiltering: boolean;
  31500. /** Defines if rendering to half float textures is supported */
  31501. textureHalfFloatRender: boolean;
  31502. /** Defines if textureLOD shader command is supported */
  31503. textureLOD: boolean;
  31504. /** Defines if draw buffers extension is supported */
  31505. drawBuffersExtension: boolean;
  31506. /** Defines if depth textures are supported */
  31507. depthTextureExtension: boolean;
  31508. /** Defines if float color buffer are supported */
  31509. colorBufferFloat: boolean;
  31510. /** Gets disjoint timer query extension (null if not supported) */
  31511. timerQuery?: EXT_disjoint_timer_query;
  31512. /** Defines if timestamp can be used with timer query */
  31513. canUseTimestampForTimerQuery: boolean;
  31514. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31515. multiview?: any;
  31516. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31517. oculusMultiview?: any;
  31518. /** Function used to let the system compiles shaders in background */
  31519. parallelShaderCompile?: {
  31520. COMPLETION_STATUS_KHR: number;
  31521. };
  31522. /** Max number of texture samples for MSAA */
  31523. maxMSAASamples: number;
  31524. /** Defines if the blend min max extension is supported */
  31525. blendMinMax: boolean;
  31526. }
  31527. }
  31528. declare module "babylonjs/States/depthCullingState" {
  31529. import { Nullable } from "babylonjs/types";
  31530. /**
  31531. * @hidden
  31532. **/
  31533. export class DepthCullingState {
  31534. private _isDepthTestDirty;
  31535. private _isDepthMaskDirty;
  31536. private _isDepthFuncDirty;
  31537. private _isCullFaceDirty;
  31538. private _isCullDirty;
  31539. private _isZOffsetDirty;
  31540. private _isFrontFaceDirty;
  31541. private _depthTest;
  31542. private _depthMask;
  31543. private _depthFunc;
  31544. private _cull;
  31545. private _cullFace;
  31546. private _zOffset;
  31547. private _frontFace;
  31548. /**
  31549. * Initializes the state.
  31550. */
  31551. constructor();
  31552. get isDirty(): boolean;
  31553. get zOffset(): number;
  31554. set zOffset(value: number);
  31555. get cullFace(): Nullable<number>;
  31556. set cullFace(value: Nullable<number>);
  31557. get cull(): Nullable<boolean>;
  31558. set cull(value: Nullable<boolean>);
  31559. get depthFunc(): Nullable<number>;
  31560. set depthFunc(value: Nullable<number>);
  31561. get depthMask(): boolean;
  31562. set depthMask(value: boolean);
  31563. get depthTest(): boolean;
  31564. set depthTest(value: boolean);
  31565. get frontFace(): Nullable<number>;
  31566. set frontFace(value: Nullable<number>);
  31567. reset(): void;
  31568. apply(gl: WebGLRenderingContext): void;
  31569. }
  31570. }
  31571. declare module "babylonjs/States/stencilState" {
  31572. /**
  31573. * @hidden
  31574. **/
  31575. export class StencilState {
  31576. /** 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 */
  31577. static readonly ALWAYS: number;
  31578. /** Passed to stencilOperation to specify that stencil value must be kept */
  31579. static readonly KEEP: number;
  31580. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31581. static readonly REPLACE: number;
  31582. private _isStencilTestDirty;
  31583. private _isStencilMaskDirty;
  31584. private _isStencilFuncDirty;
  31585. private _isStencilOpDirty;
  31586. private _stencilTest;
  31587. private _stencilMask;
  31588. private _stencilFunc;
  31589. private _stencilFuncRef;
  31590. private _stencilFuncMask;
  31591. private _stencilOpStencilFail;
  31592. private _stencilOpDepthFail;
  31593. private _stencilOpStencilDepthPass;
  31594. get isDirty(): boolean;
  31595. get stencilFunc(): number;
  31596. set stencilFunc(value: number);
  31597. get stencilFuncRef(): number;
  31598. set stencilFuncRef(value: number);
  31599. get stencilFuncMask(): number;
  31600. set stencilFuncMask(value: number);
  31601. get stencilOpStencilFail(): number;
  31602. set stencilOpStencilFail(value: number);
  31603. get stencilOpDepthFail(): number;
  31604. set stencilOpDepthFail(value: number);
  31605. get stencilOpStencilDepthPass(): number;
  31606. set stencilOpStencilDepthPass(value: number);
  31607. get stencilMask(): number;
  31608. set stencilMask(value: number);
  31609. get stencilTest(): boolean;
  31610. set stencilTest(value: boolean);
  31611. constructor();
  31612. reset(): void;
  31613. apply(gl: WebGLRenderingContext): void;
  31614. }
  31615. }
  31616. declare module "babylonjs/States/alphaCullingState" {
  31617. /**
  31618. * @hidden
  31619. **/
  31620. export class AlphaState {
  31621. private _isAlphaBlendDirty;
  31622. private _isBlendFunctionParametersDirty;
  31623. private _isBlendEquationParametersDirty;
  31624. private _isBlendConstantsDirty;
  31625. private _alphaBlend;
  31626. private _blendFunctionParameters;
  31627. private _blendEquationParameters;
  31628. private _blendConstants;
  31629. /**
  31630. * Initializes the state.
  31631. */
  31632. constructor();
  31633. get isDirty(): boolean;
  31634. get alphaBlend(): boolean;
  31635. set alphaBlend(value: boolean);
  31636. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31637. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31638. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31639. reset(): void;
  31640. apply(gl: WebGLRenderingContext): void;
  31641. }
  31642. }
  31643. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31644. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31645. /** @hidden */
  31646. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31647. attributeProcessor(attribute: string): string;
  31648. varyingProcessor(varying: string, isFragment: boolean): string;
  31649. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31650. }
  31651. }
  31652. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31653. /**
  31654. * Interface for attribute information associated with buffer instanciation
  31655. */
  31656. export interface InstancingAttributeInfo {
  31657. /**
  31658. * Name of the GLSL attribute
  31659. * if attribute index is not specified, this is used to retrieve the index from the effect
  31660. */
  31661. attributeName: string;
  31662. /**
  31663. * Index/offset of the attribute in the vertex shader
  31664. * if not specified, this will be computes from the name.
  31665. */
  31666. index?: number;
  31667. /**
  31668. * size of the attribute, 1, 2, 3 or 4
  31669. */
  31670. attributeSize: number;
  31671. /**
  31672. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31673. */
  31674. offset: number;
  31675. /**
  31676. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31677. * default to 1
  31678. */
  31679. divisor?: number;
  31680. /**
  31681. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31682. * default is FLOAT
  31683. */
  31684. attributeType?: number;
  31685. /**
  31686. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31687. */
  31688. normalized?: boolean;
  31689. }
  31690. }
  31691. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31693. import { Nullable } from "babylonjs/types";
  31694. module "babylonjs/Engines/thinEngine" {
  31695. interface ThinEngine {
  31696. /**
  31697. * Update a video texture
  31698. * @param texture defines the texture to update
  31699. * @param video defines the video element to use
  31700. * @param invertY defines if data must be stored with Y axis inverted
  31701. */
  31702. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31703. }
  31704. }
  31705. }
  31706. declare module "babylonjs/Materials/Textures/videoTexture" {
  31707. import { Observable } from "babylonjs/Misc/observable";
  31708. import { Nullable } from "babylonjs/types";
  31709. import { Scene } from "babylonjs/scene";
  31710. import { Texture } from "babylonjs/Materials/Textures/texture";
  31711. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31712. /**
  31713. * Settings for finer control over video usage
  31714. */
  31715. export interface VideoTextureSettings {
  31716. /**
  31717. * Applies `autoplay` to video, if specified
  31718. */
  31719. autoPlay?: boolean;
  31720. /**
  31721. * Applies `loop` to video, if specified
  31722. */
  31723. loop?: boolean;
  31724. /**
  31725. * Automatically updates internal texture from video at every frame in the render loop
  31726. */
  31727. autoUpdateTexture: boolean;
  31728. /**
  31729. * Image src displayed during the video loading or until the user interacts with the video.
  31730. */
  31731. poster?: string;
  31732. }
  31733. /**
  31734. * If you want to display a video in your scene, this is the special texture for that.
  31735. * This special texture works similar to other textures, with the exception of a few parameters.
  31736. * @see https://doc.babylonjs.com/how_to/video_texture
  31737. */
  31738. export class VideoTexture extends Texture {
  31739. /**
  31740. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31741. */
  31742. readonly autoUpdateTexture: boolean;
  31743. /**
  31744. * The video instance used by the texture internally
  31745. */
  31746. readonly video: HTMLVideoElement;
  31747. private _onUserActionRequestedObservable;
  31748. /**
  31749. * Event triggerd when a dom action is required by the user to play the video.
  31750. * This happens due to recent changes in browser policies preventing video to auto start.
  31751. */
  31752. get onUserActionRequestedObservable(): Observable<Texture>;
  31753. private _generateMipMaps;
  31754. private _engine;
  31755. private _stillImageCaptured;
  31756. private _displayingPosterTexture;
  31757. private _settings;
  31758. private _createInternalTextureOnEvent;
  31759. private _frameId;
  31760. private _currentSrc;
  31761. /**
  31762. * Creates a video texture.
  31763. * If you want to display a video in your scene, this is the special texture for that.
  31764. * This special texture works similar to other textures, with the exception of a few parameters.
  31765. * @see https://doc.babylonjs.com/how_to/video_texture
  31766. * @param name optional name, will detect from video source, if not defined
  31767. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31768. * @param scene is obviously the current scene.
  31769. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31770. * @param invertY is false by default but can be used to invert video on Y axis
  31771. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31772. * @param settings allows finer control over video usage
  31773. */
  31774. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31775. private _getName;
  31776. private _getVideo;
  31777. private _createInternalTexture;
  31778. private reset;
  31779. /**
  31780. * @hidden Internal method to initiate `update`.
  31781. */
  31782. _rebuild(): void;
  31783. /**
  31784. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31785. */
  31786. update(): void;
  31787. /**
  31788. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31789. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31790. */
  31791. updateTexture(isVisible: boolean): void;
  31792. protected _updateInternalTexture: () => void;
  31793. /**
  31794. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31795. * @param url New url.
  31796. */
  31797. updateURL(url: string): void;
  31798. /**
  31799. * Clones the texture.
  31800. * @returns the cloned texture
  31801. */
  31802. clone(): VideoTexture;
  31803. /**
  31804. * Dispose the texture and release its associated resources.
  31805. */
  31806. dispose(): void;
  31807. /**
  31808. * Creates a video texture straight from a stream.
  31809. * @param scene Define the scene the texture should be created in
  31810. * @param stream Define the stream the texture should be created from
  31811. * @returns The created video texture as a promise
  31812. */
  31813. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31814. /**
  31815. * Creates a video texture straight from your WebCam video feed.
  31816. * @param scene Define the scene the texture should be created in
  31817. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31818. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31819. * @returns The created video texture as a promise
  31820. */
  31821. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31822. minWidth: number;
  31823. maxWidth: number;
  31824. minHeight: number;
  31825. maxHeight: number;
  31826. deviceId: string;
  31827. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31828. /**
  31829. * Creates a video texture straight from your WebCam video feed.
  31830. * @param scene Define the scene the texture should be created in
  31831. * @param onReady Define a callback to triggered once the texture will be ready
  31832. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31833. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31834. */
  31835. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31836. minWidth: number;
  31837. maxWidth: number;
  31838. minHeight: number;
  31839. maxHeight: number;
  31840. deviceId: string;
  31841. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31842. }
  31843. }
  31844. declare module "babylonjs/Engines/thinEngine" {
  31845. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31846. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31847. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31848. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31849. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31850. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31851. import { Observable } from "babylonjs/Misc/observable";
  31852. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31853. import { StencilState } from "babylonjs/States/stencilState";
  31854. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31855. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31856. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31857. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31858. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31859. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31860. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31861. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31862. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31864. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31865. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31866. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31867. import { WebRequest } from "babylonjs/Misc/webRequest";
  31868. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31869. /**
  31870. * Defines the interface used by objects working like Scene
  31871. * @hidden
  31872. */
  31873. export interface ISceneLike {
  31874. _addPendingData(data: any): void;
  31875. _removePendingData(data: any): void;
  31876. offlineProvider: IOfflineProvider;
  31877. }
  31878. /** Interface defining initialization parameters for Engine class */
  31879. export interface EngineOptions extends WebGLContextAttributes {
  31880. /**
  31881. * Defines if the engine should no exceed a specified device ratio
  31882. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31883. */
  31884. limitDeviceRatio?: number;
  31885. /**
  31886. * Defines if webvr should be enabled automatically
  31887. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31888. */
  31889. autoEnableWebVR?: boolean;
  31890. /**
  31891. * Defines if webgl2 should be turned off even if supported
  31892. * @see http://doc.babylonjs.com/features/webgl2
  31893. */
  31894. disableWebGL2Support?: boolean;
  31895. /**
  31896. * Defines if webaudio should be initialized as well
  31897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31898. */
  31899. audioEngine?: boolean;
  31900. /**
  31901. * Defines if animations should run using a deterministic lock step
  31902. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31903. */
  31904. deterministicLockstep?: boolean;
  31905. /** Defines the maximum steps to use with deterministic lock step mode */
  31906. lockstepMaxSteps?: number;
  31907. /** Defines the seconds between each deterministic lock step */
  31908. timeStep?: number;
  31909. /**
  31910. * Defines that engine should ignore context lost events
  31911. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31912. */
  31913. doNotHandleContextLost?: boolean;
  31914. /**
  31915. * Defines that engine should ignore modifying touch action attribute and style
  31916. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31917. */
  31918. doNotHandleTouchAction?: boolean;
  31919. /**
  31920. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31921. */
  31922. useHighPrecisionFloats?: boolean;
  31923. }
  31924. /**
  31925. * The base engine class (root of all engines)
  31926. */
  31927. export class ThinEngine {
  31928. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31929. static ExceptionList: ({
  31930. key: string;
  31931. capture: string;
  31932. captureConstraint: number;
  31933. targets: string[];
  31934. } | {
  31935. key: string;
  31936. capture: null;
  31937. captureConstraint: null;
  31938. targets: string[];
  31939. })[];
  31940. /** @hidden */
  31941. static _TextureLoaders: IInternalTextureLoader[];
  31942. /**
  31943. * Returns the current npm package of the sdk
  31944. */
  31945. static get NpmPackage(): string;
  31946. /**
  31947. * Returns the current version of the framework
  31948. */
  31949. static get Version(): string;
  31950. /**
  31951. * Returns a string describing the current engine
  31952. */
  31953. get description(): string;
  31954. /**
  31955. * Gets or sets the epsilon value used by collision engine
  31956. */
  31957. static CollisionsEpsilon: number;
  31958. /**
  31959. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31960. */
  31961. static get ShadersRepository(): string;
  31962. static set ShadersRepository(value: string);
  31963. /** @hidden */
  31964. _shaderProcessor: IShaderProcessor;
  31965. /**
  31966. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31967. */
  31968. forcePOTTextures: boolean;
  31969. /**
  31970. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31971. */
  31972. isFullscreen: boolean;
  31973. /**
  31974. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31975. */
  31976. cullBackFaces: boolean;
  31977. /**
  31978. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31979. */
  31980. renderEvenInBackground: boolean;
  31981. /**
  31982. * Gets or sets a boolean indicating that cache can be kept between frames
  31983. */
  31984. preventCacheWipeBetweenFrames: boolean;
  31985. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31986. validateShaderPrograms: boolean;
  31987. /**
  31988. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31989. * This can provide greater z depth for distant objects.
  31990. */
  31991. useReverseDepthBuffer: boolean;
  31992. /**
  31993. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31994. */
  31995. disableUniformBuffers: boolean;
  31996. /** @hidden */
  31997. _uniformBuffers: UniformBuffer[];
  31998. /**
  31999. * Gets a boolean indicating that the engine supports uniform buffers
  32000. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32001. */
  32002. get supportsUniformBuffers(): boolean;
  32003. /** @hidden */
  32004. _gl: WebGLRenderingContext;
  32005. /** @hidden */
  32006. _webGLVersion: number;
  32007. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32008. protected _windowIsBackground: boolean;
  32009. protected _creationOptions: EngineOptions;
  32010. protected _highPrecisionShadersAllowed: boolean;
  32011. /** @hidden */
  32012. get _shouldUseHighPrecisionShader(): boolean;
  32013. /**
  32014. * Gets a boolean indicating that only power of 2 textures are supported
  32015. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32016. */
  32017. get needPOTTextures(): boolean;
  32018. /** @hidden */
  32019. _badOS: boolean;
  32020. /** @hidden */
  32021. _badDesktopOS: boolean;
  32022. private _hardwareScalingLevel;
  32023. /** @hidden */
  32024. _caps: EngineCapabilities;
  32025. private _isStencilEnable;
  32026. private _glVersion;
  32027. private _glRenderer;
  32028. private _glVendor;
  32029. /** @hidden */
  32030. _videoTextureSupported: boolean;
  32031. protected _renderingQueueLaunched: boolean;
  32032. protected _activeRenderLoops: (() => void)[];
  32033. /**
  32034. * Observable signaled when a context lost event is raised
  32035. */
  32036. onContextLostObservable: Observable<ThinEngine>;
  32037. /**
  32038. * Observable signaled when a context restored event is raised
  32039. */
  32040. onContextRestoredObservable: Observable<ThinEngine>;
  32041. private _onContextLost;
  32042. private _onContextRestored;
  32043. protected _contextWasLost: boolean;
  32044. /** @hidden */
  32045. _doNotHandleContextLost: boolean;
  32046. /**
  32047. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32049. */
  32050. get doNotHandleContextLost(): boolean;
  32051. set doNotHandleContextLost(value: boolean);
  32052. /**
  32053. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32054. */
  32055. disableVertexArrayObjects: boolean;
  32056. /** @hidden */
  32057. protected _colorWrite: boolean;
  32058. /** @hidden */
  32059. protected _colorWriteChanged: boolean;
  32060. /** @hidden */
  32061. protected _depthCullingState: DepthCullingState;
  32062. /** @hidden */
  32063. protected _stencilState: StencilState;
  32064. /** @hidden */
  32065. _alphaState: AlphaState;
  32066. /** @hidden */
  32067. _alphaMode: number;
  32068. /** @hidden */
  32069. _alphaEquation: number;
  32070. /** @hidden */
  32071. _internalTexturesCache: InternalTexture[];
  32072. /** @hidden */
  32073. protected _activeChannel: number;
  32074. private _currentTextureChannel;
  32075. /** @hidden */
  32076. protected _boundTexturesCache: {
  32077. [key: string]: Nullable<InternalTexture>;
  32078. };
  32079. /** @hidden */
  32080. protected _currentEffect: Nullable<Effect>;
  32081. /** @hidden */
  32082. protected _currentProgram: Nullable<WebGLProgram>;
  32083. private _compiledEffects;
  32084. private _vertexAttribArraysEnabled;
  32085. /** @hidden */
  32086. protected _cachedViewport: Nullable<IViewportLike>;
  32087. private _cachedVertexArrayObject;
  32088. /** @hidden */
  32089. protected _cachedVertexBuffers: any;
  32090. /** @hidden */
  32091. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32092. /** @hidden */
  32093. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32094. /** @hidden */
  32095. _currentRenderTarget: Nullable<InternalTexture>;
  32096. private _uintIndicesCurrentlySet;
  32097. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32098. /** @hidden */
  32099. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32100. private _currentBufferPointers;
  32101. private _currentInstanceLocations;
  32102. private _currentInstanceBuffers;
  32103. private _textureUnits;
  32104. /** @hidden */
  32105. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32106. /** @hidden */
  32107. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32108. /** @hidden */
  32109. _boundRenderFunction: any;
  32110. private _vaoRecordInProgress;
  32111. private _mustWipeVertexAttributes;
  32112. private _emptyTexture;
  32113. private _emptyCubeTexture;
  32114. private _emptyTexture3D;
  32115. private _emptyTexture2DArray;
  32116. /** @hidden */
  32117. _frameHandler: number;
  32118. private _nextFreeTextureSlots;
  32119. private _maxSimultaneousTextures;
  32120. private _activeRequests;
  32121. protected _texturesSupported: string[];
  32122. /** @hidden */
  32123. _textureFormatInUse: Nullable<string>;
  32124. protected get _supportsHardwareTextureRescaling(): boolean;
  32125. private _framebufferDimensionsObject;
  32126. /**
  32127. * sets the object from which width and height will be taken from when getting render width and height
  32128. * Will fallback to the gl object
  32129. * @param dimensions the framebuffer width and height that will be used.
  32130. */
  32131. set framebufferDimensionsObject(dimensions: Nullable<{
  32132. framebufferWidth: number;
  32133. framebufferHeight: number;
  32134. }>);
  32135. /**
  32136. * Gets the list of texture formats supported
  32137. */
  32138. get texturesSupported(): Array<string>;
  32139. /**
  32140. * Gets the list of texture formats in use
  32141. */
  32142. get textureFormatInUse(): Nullable<string>;
  32143. /**
  32144. * Gets the current viewport
  32145. */
  32146. get currentViewport(): Nullable<IViewportLike>;
  32147. /**
  32148. * Gets the default empty texture
  32149. */
  32150. get emptyTexture(): InternalTexture;
  32151. /**
  32152. * Gets the default empty 3D texture
  32153. */
  32154. get emptyTexture3D(): InternalTexture;
  32155. /**
  32156. * Gets the default empty 2D array texture
  32157. */
  32158. get emptyTexture2DArray(): InternalTexture;
  32159. /**
  32160. * Gets the default empty cube texture
  32161. */
  32162. get emptyCubeTexture(): InternalTexture;
  32163. /**
  32164. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32165. */
  32166. readonly premultipliedAlpha: boolean;
  32167. /**
  32168. * Observable event triggered before each texture is initialized
  32169. */
  32170. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32171. /**
  32172. * Creates a new engine
  32173. * @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
  32174. * @param antialias defines enable antialiasing (default: false)
  32175. * @param options defines further options to be sent to the getContext() function
  32176. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32177. */
  32178. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32179. private _rebuildInternalTextures;
  32180. private _rebuildEffects;
  32181. /**
  32182. * Gets a boolean indicating if all created effects are ready
  32183. * @returns true if all effects are ready
  32184. */
  32185. areAllEffectsReady(): boolean;
  32186. protected _rebuildBuffers(): void;
  32187. private _initGLContext;
  32188. /**
  32189. * Gets version of the current webGL context
  32190. */
  32191. get webGLVersion(): number;
  32192. /**
  32193. * Gets a string idenfifying the name of the class
  32194. * @returns "Engine" string
  32195. */
  32196. getClassName(): string;
  32197. /**
  32198. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32199. */
  32200. get isStencilEnable(): boolean;
  32201. /** @hidden */
  32202. _prepareWorkingCanvas(): void;
  32203. /**
  32204. * Reset the texture cache to empty state
  32205. */
  32206. resetTextureCache(): void;
  32207. /**
  32208. * Gets an object containing information about the current webGL context
  32209. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32210. */
  32211. getGlInfo(): {
  32212. vendor: string;
  32213. renderer: string;
  32214. version: string;
  32215. };
  32216. /**
  32217. * Defines the hardware scaling level.
  32218. * By default the hardware scaling level is computed from the window device ratio.
  32219. * 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.
  32220. * @param level defines the level to use
  32221. */
  32222. setHardwareScalingLevel(level: number): void;
  32223. /**
  32224. * Gets the current hardware scaling level.
  32225. * By default the hardware scaling level is computed from the window device ratio.
  32226. * 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.
  32227. * @returns a number indicating the current hardware scaling level
  32228. */
  32229. getHardwareScalingLevel(): number;
  32230. /**
  32231. * Gets the list of loaded textures
  32232. * @returns an array containing all loaded textures
  32233. */
  32234. getLoadedTexturesCache(): InternalTexture[];
  32235. /**
  32236. * Gets the object containing all engine capabilities
  32237. * @returns the EngineCapabilities object
  32238. */
  32239. getCaps(): EngineCapabilities;
  32240. /**
  32241. * stop executing a render loop function and remove it from the execution array
  32242. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32243. */
  32244. stopRenderLoop(renderFunction?: () => void): void;
  32245. /** @hidden */
  32246. _renderLoop(): void;
  32247. /**
  32248. * Gets the HTML canvas attached with the current webGL context
  32249. * @returns a HTML canvas
  32250. */
  32251. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32252. /**
  32253. * Gets host window
  32254. * @returns the host window object
  32255. */
  32256. getHostWindow(): Nullable<Window>;
  32257. /**
  32258. * Gets the current render width
  32259. * @param useScreen defines if screen size must be used (or the current render target if any)
  32260. * @returns a number defining the current render width
  32261. */
  32262. getRenderWidth(useScreen?: boolean): number;
  32263. /**
  32264. * Gets the current render height
  32265. * @param useScreen defines if screen size must be used (or the current render target if any)
  32266. * @returns a number defining the current render height
  32267. */
  32268. getRenderHeight(useScreen?: boolean): number;
  32269. /**
  32270. * Can be used to override the current requestAnimationFrame requester.
  32271. * @hidden
  32272. */
  32273. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32274. /**
  32275. * Register and execute a render loop. The engine can have more than one render function
  32276. * @param renderFunction defines the function to continuously execute
  32277. */
  32278. runRenderLoop(renderFunction: () => void): void;
  32279. /**
  32280. * Clear the current render buffer or the current render target (if any is set up)
  32281. * @param color defines the color to use
  32282. * @param backBuffer defines if the back buffer must be cleared
  32283. * @param depth defines if the depth buffer must be cleared
  32284. * @param stencil defines if the stencil buffer must be cleared
  32285. */
  32286. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32287. private _viewportCached;
  32288. /** @hidden */
  32289. _viewport(x: number, y: number, width: number, height: number): void;
  32290. /**
  32291. * Set the WebGL's viewport
  32292. * @param viewport defines the viewport element to be used
  32293. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32294. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32295. */
  32296. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32297. /**
  32298. * Begin a new frame
  32299. */
  32300. beginFrame(): void;
  32301. /**
  32302. * Enf the current frame
  32303. */
  32304. endFrame(): void;
  32305. /**
  32306. * Resize the view according to the canvas' size
  32307. */
  32308. resize(): void;
  32309. /**
  32310. * Force a specific size of the canvas
  32311. * @param width defines the new canvas' width
  32312. * @param height defines the new canvas' height
  32313. */
  32314. setSize(width: number, height: number): void;
  32315. /**
  32316. * Binds the frame buffer to the specified texture.
  32317. * @param texture The texture to render to or null for the default canvas
  32318. * @param faceIndex The face of the texture to render to in case of cube texture
  32319. * @param requiredWidth The width of the target to render to
  32320. * @param requiredHeight The height of the target to render to
  32321. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32322. * @param lodLevel defines the lod level to bind to the frame buffer
  32323. * @param layer defines the 2d array index to bind to frame buffer to
  32324. */
  32325. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32326. /** @hidden */
  32327. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32328. /**
  32329. * Unbind the current render target texture from the webGL context
  32330. * @param texture defines the render target texture to unbind
  32331. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32332. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32333. */
  32334. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32335. /**
  32336. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32337. */
  32338. flushFramebuffer(): void;
  32339. /**
  32340. * Unbind the current render target and bind the default framebuffer
  32341. */
  32342. restoreDefaultFramebuffer(): void;
  32343. /** @hidden */
  32344. protected _resetVertexBufferBinding(): void;
  32345. /**
  32346. * Creates a vertex buffer
  32347. * @param data the data for the vertex buffer
  32348. * @returns the new WebGL static buffer
  32349. */
  32350. createVertexBuffer(data: DataArray): DataBuffer;
  32351. private _createVertexBuffer;
  32352. /**
  32353. * Creates a dynamic vertex buffer
  32354. * @param data the data for the dynamic vertex buffer
  32355. * @returns the new WebGL dynamic buffer
  32356. */
  32357. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32358. protected _resetIndexBufferBinding(): void;
  32359. /**
  32360. * Creates a new index buffer
  32361. * @param indices defines the content of the index buffer
  32362. * @param updatable defines if the index buffer must be updatable
  32363. * @returns a new webGL buffer
  32364. */
  32365. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32366. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32367. /**
  32368. * Bind a webGL buffer to the webGL context
  32369. * @param buffer defines the buffer to bind
  32370. */
  32371. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32372. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32373. private bindBuffer;
  32374. /**
  32375. * update the bound buffer with the given data
  32376. * @param data defines the data to update
  32377. */
  32378. updateArrayBuffer(data: Float32Array): void;
  32379. private _vertexAttribPointer;
  32380. /** @hidden */
  32381. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32382. private _bindVertexBuffersAttributes;
  32383. /**
  32384. * Records a vertex array object
  32385. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32386. * @param vertexBuffers defines the list of vertex buffers to store
  32387. * @param indexBuffer defines the index buffer to store
  32388. * @param effect defines the effect to store
  32389. * @returns the new vertex array object
  32390. */
  32391. recordVertexArrayObject(vertexBuffers: {
  32392. [key: string]: VertexBuffer;
  32393. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32394. /**
  32395. * Bind a specific vertex array object
  32396. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32397. * @param vertexArrayObject defines the vertex array object to bind
  32398. * @param indexBuffer defines the index buffer to bind
  32399. */
  32400. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32401. /**
  32402. * Bind webGl buffers directly to the webGL context
  32403. * @param vertexBuffer defines the vertex buffer to bind
  32404. * @param indexBuffer defines the index buffer to bind
  32405. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32406. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32407. * @param effect defines the effect associated with the vertex buffer
  32408. */
  32409. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32410. private _unbindVertexArrayObject;
  32411. /**
  32412. * Bind a list of vertex buffers to the webGL context
  32413. * @param vertexBuffers defines the list of vertex buffers to bind
  32414. * @param indexBuffer defines the index buffer to bind
  32415. * @param effect defines the effect associated with the vertex buffers
  32416. */
  32417. bindBuffers(vertexBuffers: {
  32418. [key: string]: Nullable<VertexBuffer>;
  32419. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32420. /**
  32421. * Unbind all instance attributes
  32422. */
  32423. unbindInstanceAttributes(): void;
  32424. /**
  32425. * Release and free the memory of a vertex array object
  32426. * @param vao defines the vertex array object to delete
  32427. */
  32428. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32429. /** @hidden */
  32430. _releaseBuffer(buffer: DataBuffer): boolean;
  32431. protected _deleteBuffer(buffer: DataBuffer): void;
  32432. /**
  32433. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32434. * @param instancesBuffer defines the webGL buffer to update and bind
  32435. * @param data defines the data to store in the buffer
  32436. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32437. */
  32438. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32439. /**
  32440. * Bind the content of a webGL buffer used with instantiation
  32441. * @param instancesBuffer defines the webGL buffer to bind
  32442. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32443. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32444. */
  32445. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32446. /**
  32447. * Disable the instance attribute corresponding to the name in parameter
  32448. * @param name defines the name of the attribute to disable
  32449. */
  32450. disableInstanceAttributeByName(name: string): void;
  32451. /**
  32452. * Disable the instance attribute corresponding to the location in parameter
  32453. * @param attributeLocation defines the attribute location of the attribute to disable
  32454. */
  32455. disableInstanceAttribute(attributeLocation: number): void;
  32456. /**
  32457. * Disable the attribute corresponding to the location in parameter
  32458. * @param attributeLocation defines the attribute location of the attribute to disable
  32459. */
  32460. disableAttributeByIndex(attributeLocation: number): void;
  32461. /**
  32462. * Send a draw order
  32463. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32464. * @param indexStart defines the starting index
  32465. * @param indexCount defines the number of index to draw
  32466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32467. */
  32468. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32469. /**
  32470. * Draw a list of points
  32471. * @param verticesStart defines the index of first vertex to draw
  32472. * @param verticesCount defines the count of vertices to draw
  32473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32474. */
  32475. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32476. /**
  32477. * Draw a list of unindexed primitives
  32478. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32479. * @param verticesStart defines the index of first vertex to draw
  32480. * @param verticesCount defines the count of vertices to draw
  32481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32482. */
  32483. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32484. /**
  32485. * Draw a list of indexed primitives
  32486. * @param fillMode defines the primitive to use
  32487. * @param indexStart defines the starting index
  32488. * @param indexCount defines the number of index to draw
  32489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32490. */
  32491. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32492. /**
  32493. * Draw a list of unindexed primitives
  32494. * @param fillMode defines the primitive to use
  32495. * @param verticesStart defines the index of first vertex to draw
  32496. * @param verticesCount defines the count of vertices to draw
  32497. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32498. */
  32499. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32500. private _drawMode;
  32501. /** @hidden */
  32502. protected _reportDrawCall(): void;
  32503. /** @hidden */
  32504. _releaseEffect(effect: Effect): void;
  32505. /** @hidden */
  32506. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32507. /**
  32508. * Create a new effect (used to store vertex/fragment shaders)
  32509. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32510. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32511. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32512. * @param samplers defines an array of string used to represent textures
  32513. * @param defines defines the string containing the defines to use to compile the shaders
  32514. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32515. * @param onCompiled defines a function to call when the effect creation is successful
  32516. * @param onError defines a function to call when the effect creation has failed
  32517. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32518. * @returns the new Effect
  32519. */
  32520. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  32521. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32522. private _compileShader;
  32523. private _compileRawShader;
  32524. /** @hidden */
  32525. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32526. /**
  32527. * Directly creates a webGL program
  32528. * @param pipelineContext defines the pipeline context to attach to
  32529. * @param vertexCode defines the vertex shader code to use
  32530. * @param fragmentCode defines the fragment shader code to use
  32531. * @param context defines the webGL context to use (if not set, the current one will be used)
  32532. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32533. * @returns the new webGL program
  32534. */
  32535. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32536. /**
  32537. * Creates a webGL program
  32538. * @param pipelineContext defines the pipeline context to attach to
  32539. * @param vertexCode defines the vertex shader code to use
  32540. * @param fragmentCode defines the fragment shader code to use
  32541. * @param defines defines the string containing the defines to use to compile the shaders
  32542. * @param context defines the webGL context to use (if not set, the current one will be used)
  32543. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32544. * @returns the new webGL program
  32545. */
  32546. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32547. /**
  32548. * Creates a new pipeline context
  32549. * @returns the new pipeline
  32550. */
  32551. createPipelineContext(): IPipelineContext;
  32552. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32553. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32554. /** @hidden */
  32555. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32556. /** @hidden */
  32557. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32558. /** @hidden */
  32559. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32560. /**
  32561. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32562. * @param pipelineContext defines the pipeline context to use
  32563. * @param uniformsNames defines the list of uniform names
  32564. * @returns an array of webGL uniform locations
  32565. */
  32566. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32567. /**
  32568. * Gets the lsit of active attributes for a given webGL program
  32569. * @param pipelineContext defines the pipeline context to use
  32570. * @param attributesNames defines the list of attribute names to get
  32571. * @returns an array of indices indicating the offset of each attribute
  32572. */
  32573. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32574. /**
  32575. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32576. * @param effect defines the effect to activate
  32577. */
  32578. enableEffect(effect: Nullable<Effect>): void;
  32579. /**
  32580. * Set the value of an uniform to a number (int)
  32581. * @param uniform defines the webGL uniform location where to store the value
  32582. * @param value defines the int number to store
  32583. */
  32584. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32585. /**
  32586. * Set the value of an uniform to an array of int32
  32587. * @param uniform defines the webGL uniform location where to store the value
  32588. * @param array defines the array of int32 to store
  32589. */
  32590. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32591. /**
  32592. * Set the value of an uniform to an array of int32 (stored as vec2)
  32593. * @param uniform defines the webGL uniform location where to store the value
  32594. * @param array defines the array of int32 to store
  32595. */
  32596. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32597. /**
  32598. * Set the value of an uniform to an array of int32 (stored as vec3)
  32599. * @param uniform defines the webGL uniform location where to store the value
  32600. * @param array defines the array of int32 to store
  32601. */
  32602. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32603. /**
  32604. * Set the value of an uniform to an array of int32 (stored as vec4)
  32605. * @param uniform defines the webGL uniform location where to store the value
  32606. * @param array defines the array of int32 to store
  32607. */
  32608. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32609. /**
  32610. * Set the value of an uniform to an array of number
  32611. * @param uniform defines the webGL uniform location where to store the value
  32612. * @param array defines the array of number to store
  32613. */
  32614. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32615. /**
  32616. * Set the value of an uniform to an array of number (stored as vec2)
  32617. * @param uniform defines the webGL uniform location where to store the value
  32618. * @param array defines the array of number to store
  32619. */
  32620. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32621. /**
  32622. * Set the value of an uniform to an array of number (stored as vec3)
  32623. * @param uniform defines the webGL uniform location where to store the value
  32624. * @param array defines the array of number to store
  32625. */
  32626. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32627. /**
  32628. * Set the value of an uniform to an array of number (stored as vec4)
  32629. * @param uniform defines the webGL uniform location where to store the value
  32630. * @param array defines the array of number to store
  32631. */
  32632. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32633. /**
  32634. * Set the value of an uniform to an array of float32 (stored as matrices)
  32635. * @param uniform defines the webGL uniform location where to store the value
  32636. * @param matrices defines the array of float32 to store
  32637. */
  32638. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32639. /**
  32640. * Set the value of an uniform to a matrix (3x3)
  32641. * @param uniform defines the webGL uniform location where to store the value
  32642. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32643. */
  32644. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32645. /**
  32646. * Set the value of an uniform to a matrix (2x2)
  32647. * @param uniform defines the webGL uniform location where to store the value
  32648. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32649. */
  32650. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32651. /**
  32652. * Set the value of an uniform to a number (float)
  32653. * @param uniform defines the webGL uniform location where to store the value
  32654. * @param value defines the float number to store
  32655. */
  32656. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32657. /**
  32658. * Set the value of an uniform to a vec2
  32659. * @param uniform defines the webGL uniform location where to store the value
  32660. * @param x defines the 1st component of the value
  32661. * @param y defines the 2nd component of the value
  32662. */
  32663. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32664. /**
  32665. * Set the value of an uniform to a vec3
  32666. * @param uniform defines the webGL uniform location where to store the value
  32667. * @param x defines the 1st component of the value
  32668. * @param y defines the 2nd component of the value
  32669. * @param z defines the 3rd component of the value
  32670. */
  32671. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32672. /**
  32673. * Set the value of an uniform to a vec4
  32674. * @param uniform defines the webGL uniform location where to store the value
  32675. * @param x defines the 1st component of the value
  32676. * @param y defines the 2nd component of the value
  32677. * @param z defines the 3rd component of the value
  32678. * @param w defines the 4th component of the value
  32679. */
  32680. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32681. /**
  32682. * Apply all cached states (depth, culling, stencil and alpha)
  32683. */
  32684. applyStates(): void;
  32685. /**
  32686. * Enable or disable color writing
  32687. * @param enable defines the state to set
  32688. */
  32689. setColorWrite(enable: boolean): void;
  32690. /**
  32691. * Gets a boolean indicating if color writing is enabled
  32692. * @returns the current color writing state
  32693. */
  32694. getColorWrite(): boolean;
  32695. /**
  32696. * Gets the depth culling state manager
  32697. */
  32698. get depthCullingState(): DepthCullingState;
  32699. /**
  32700. * Gets the alpha state manager
  32701. */
  32702. get alphaState(): AlphaState;
  32703. /**
  32704. * Gets the stencil state manager
  32705. */
  32706. get stencilState(): StencilState;
  32707. /**
  32708. * Clears the list of texture accessible through engine.
  32709. * This can help preventing texture load conflict due to name collision.
  32710. */
  32711. clearInternalTexturesCache(): void;
  32712. /**
  32713. * Force the entire cache to be cleared
  32714. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32715. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32716. */
  32717. wipeCaches(bruteForce?: boolean): void;
  32718. /** @hidden */
  32719. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32720. min: number;
  32721. mag: number;
  32722. };
  32723. /** @hidden */
  32724. _createTexture(): WebGLTexture;
  32725. /**
  32726. * Usually called from Texture.ts.
  32727. * Passed information to create a WebGLTexture
  32728. * @param urlArg defines a value which contains one of the following:
  32729. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32730. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32731. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32733. * @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)
  32734. * @param scene needed for loading to the correct scene
  32735. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32736. * @param onLoad optional callback to be called upon successful completion
  32737. * @param onError optional callback to be called upon failure
  32738. * @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
  32739. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32740. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32741. * @param forcedExtension defines the extension to use to pick the right loader
  32742. * @param mimeType defines an optional mime type
  32743. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32744. */
  32745. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  32746. /**
  32747. * Loads an image as an HTMLImageElement.
  32748. * @param input url string, ArrayBuffer, or Blob to load
  32749. * @param onLoad callback called when the image successfully loads
  32750. * @param onError callback called when the image fails to load
  32751. * @param offlineProvider offline provider for caching
  32752. * @param mimeType optional mime type
  32753. * @returns the HTMLImageElement of the loaded image
  32754. * @hidden
  32755. */
  32756. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32757. /**
  32758. * @hidden
  32759. */
  32760. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32761. /**
  32762. * Creates a raw texture
  32763. * @param data defines the data to store in the texture
  32764. * @param width defines the width of the texture
  32765. * @param height defines the height of the texture
  32766. * @param format defines the format of the data
  32767. * @param generateMipMaps defines if the engine should generate the mip levels
  32768. * @param invertY defines if data must be stored with Y axis inverted
  32769. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32770. * @param compression defines the compression used (null by default)
  32771. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32772. * @returns the raw texture inside an InternalTexture
  32773. */
  32774. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32775. /**
  32776. * Creates a new raw cube texture
  32777. * @param data defines the array of data to use to create each face
  32778. * @param size defines the size of the textures
  32779. * @param format defines the format of the data
  32780. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32781. * @param generateMipMaps defines if the engine should generate the mip levels
  32782. * @param invertY defines if data must be stored with Y axis inverted
  32783. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32784. * @param compression defines the compression used (null by default)
  32785. * @returns the cube texture as an InternalTexture
  32786. */
  32787. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32788. /**
  32789. * Creates a new raw 3D texture
  32790. * @param data defines the data used to create the texture
  32791. * @param width defines the width of the texture
  32792. * @param height defines the height of the texture
  32793. * @param depth defines the depth of the texture
  32794. * @param format defines the format of the texture
  32795. * @param generateMipMaps defines if the engine must generate mip levels
  32796. * @param invertY defines if data must be stored with Y axis inverted
  32797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32798. * @param compression defines the compressed used (can be null)
  32799. * @param textureType defines the compressed used (can be null)
  32800. * @returns a new raw 3D texture (stored in an InternalTexture)
  32801. */
  32802. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32803. /**
  32804. * Creates a new raw 2D array texture
  32805. * @param data defines the data used to create the texture
  32806. * @param width defines the width of the texture
  32807. * @param height defines the height of the texture
  32808. * @param depth defines the number of layers of the texture
  32809. * @param format defines the format of the texture
  32810. * @param generateMipMaps defines if the engine must generate mip levels
  32811. * @param invertY defines if data must be stored with Y axis inverted
  32812. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32813. * @param compression defines the compressed used (can be null)
  32814. * @param textureType defines the compressed used (can be null)
  32815. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32816. */
  32817. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32818. private _unpackFlipYCached;
  32819. /**
  32820. * In case you are sharing the context with other applications, it might
  32821. * be interested to not cache the unpack flip y state to ensure a consistent
  32822. * value would be set.
  32823. */
  32824. enableUnpackFlipYCached: boolean;
  32825. /** @hidden */
  32826. _unpackFlipY(value: boolean): void;
  32827. /** @hidden */
  32828. _getUnpackAlignement(): number;
  32829. private _getTextureTarget;
  32830. /**
  32831. * Update the sampling mode of a given texture
  32832. * @param samplingMode defines the required sampling mode
  32833. * @param texture defines the texture to update
  32834. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32835. */
  32836. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32837. /**
  32838. * Update the sampling mode of a given texture
  32839. * @param texture defines the texture to update
  32840. * @param wrapU defines the texture wrap mode of the u coordinates
  32841. * @param wrapV defines the texture wrap mode of the v coordinates
  32842. * @param wrapR defines the texture wrap mode of the r coordinates
  32843. */
  32844. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32845. /** @hidden */
  32846. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32847. width: number;
  32848. height: number;
  32849. layers?: number;
  32850. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32851. /** @hidden */
  32852. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32853. /** @hidden */
  32854. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32855. /**
  32856. * Update a portion of an internal texture
  32857. * @param texture defines the texture to update
  32858. * @param imageData defines the data to store into the texture
  32859. * @param xOffset defines the x coordinates of the update rectangle
  32860. * @param yOffset defines the y coordinates of the update rectangle
  32861. * @param width defines the width of the update rectangle
  32862. * @param height defines the height of the update rectangle
  32863. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32864. * @param lod defines the lod level to update (0 by default)
  32865. */
  32866. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32867. /** @hidden */
  32868. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32869. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32870. private _prepareWebGLTexture;
  32871. /** @hidden */
  32872. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32873. private _getDepthStencilBuffer;
  32874. /** @hidden */
  32875. _releaseFramebufferObjects(texture: InternalTexture): void;
  32876. /** @hidden */
  32877. _releaseTexture(texture: InternalTexture): void;
  32878. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32879. protected _setProgram(program: WebGLProgram): void;
  32880. protected _boundUniforms: {
  32881. [key: number]: WebGLUniformLocation;
  32882. };
  32883. /**
  32884. * Binds an effect to the webGL context
  32885. * @param effect defines the effect to bind
  32886. */
  32887. bindSamplers(effect: Effect): void;
  32888. private _activateCurrentTexture;
  32889. /** @hidden */
  32890. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32891. /** @hidden */
  32892. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32893. /**
  32894. * Unbind all textures from the webGL context
  32895. */
  32896. unbindAllTextures(): void;
  32897. /**
  32898. * Sets a texture to the according uniform.
  32899. * @param channel The texture channel
  32900. * @param uniform The uniform to set
  32901. * @param texture The texture to apply
  32902. */
  32903. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32904. private _bindSamplerUniformToChannel;
  32905. private _getTextureWrapMode;
  32906. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32907. /**
  32908. * Sets an array of texture to the webGL context
  32909. * @param channel defines the channel where the texture array must be set
  32910. * @param uniform defines the associated uniform location
  32911. * @param textures defines the array of textures to bind
  32912. */
  32913. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32914. /** @hidden */
  32915. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32916. private _setTextureParameterFloat;
  32917. private _setTextureParameterInteger;
  32918. /**
  32919. * Unbind all vertex attributes from the webGL context
  32920. */
  32921. unbindAllAttributes(): void;
  32922. /**
  32923. * 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
  32924. */
  32925. releaseEffects(): void;
  32926. /**
  32927. * Dispose and release all associated resources
  32928. */
  32929. dispose(): void;
  32930. /**
  32931. * Attach a new callback raised when context lost event is fired
  32932. * @param callback defines the callback to call
  32933. */
  32934. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32935. /**
  32936. * Attach a new callback raised when context restored event is fired
  32937. * @param callback defines the callback to call
  32938. */
  32939. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32940. /**
  32941. * Get the current error code of the webGL context
  32942. * @returns the error code
  32943. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32944. */
  32945. getError(): number;
  32946. private _canRenderToFloatFramebuffer;
  32947. private _canRenderToHalfFloatFramebuffer;
  32948. private _canRenderToFramebuffer;
  32949. /** @hidden */
  32950. _getWebGLTextureType(type: number): number;
  32951. /** @hidden */
  32952. _getInternalFormat(format: number): number;
  32953. /** @hidden */
  32954. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32955. /** @hidden */
  32956. _getRGBAMultiSampleBufferFormat(type: number): number;
  32957. /** @hidden */
  32958. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32959. /**
  32960. * Loads a file from a url
  32961. * @param url url to load
  32962. * @param onSuccess callback called when the file successfully loads
  32963. * @param onProgress callback called while file is loading (if the server supports this mode)
  32964. * @param offlineProvider defines the offline provider for caching
  32965. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32966. * @param onError callback called when the file fails to load
  32967. * @returns a file request object
  32968. * @hidden
  32969. */
  32970. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32971. /**
  32972. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32973. * @param x defines the x coordinate of the rectangle where pixels must be read
  32974. * @param y defines the y coordinate of the rectangle where pixels must be read
  32975. * @param width defines the width of the rectangle where pixels must be read
  32976. * @param height defines the height of the rectangle where pixels must be read
  32977. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32978. * @returns a Uint8Array containing RGBA colors
  32979. */
  32980. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32981. private static _isSupported;
  32982. /**
  32983. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32984. * @returns true if the engine can be created
  32985. * @ignorenaming
  32986. */
  32987. static isSupported(): boolean;
  32988. /**
  32989. * Find the next highest power of two.
  32990. * @param x Number to start search from.
  32991. * @return Next highest power of two.
  32992. */
  32993. static CeilingPOT(x: number): number;
  32994. /**
  32995. * Find the next lowest power of two.
  32996. * @param x Number to start search from.
  32997. * @return Next lowest power of two.
  32998. */
  32999. static FloorPOT(x: number): number;
  33000. /**
  33001. * Find the nearest power of two.
  33002. * @param x Number to start search from.
  33003. * @return Next nearest power of two.
  33004. */
  33005. static NearestPOT(x: number): number;
  33006. /**
  33007. * Get the closest exponent of two
  33008. * @param value defines the value to approximate
  33009. * @param max defines the maximum value to return
  33010. * @param mode defines how to define the closest value
  33011. * @returns closest exponent of two of the given value
  33012. */
  33013. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33014. /**
  33015. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33016. * @param func - the function to be called
  33017. * @param requester - the object that will request the next frame. Falls back to window.
  33018. * @returns frame number
  33019. */
  33020. static QueueNewFrame(func: () => void, requester?: any): number;
  33021. /**
  33022. * Gets host document
  33023. * @returns the host document object
  33024. */
  33025. getHostDocument(): Nullable<Document>;
  33026. }
  33027. }
  33028. declare module "babylonjs/Maths/sphericalPolynomial" {
  33029. import { Vector3 } from "babylonjs/Maths/math.vector";
  33030. import { Color3 } from "babylonjs/Maths/math.color";
  33031. /**
  33032. * Class representing spherical harmonics coefficients to the 3rd degree
  33033. */
  33034. export class SphericalHarmonics {
  33035. /**
  33036. * Defines whether or not the harmonics have been prescaled for rendering.
  33037. */
  33038. preScaled: boolean;
  33039. /**
  33040. * The l0,0 coefficients of the spherical harmonics
  33041. */
  33042. l00: Vector3;
  33043. /**
  33044. * The l1,-1 coefficients of the spherical harmonics
  33045. */
  33046. l1_1: Vector3;
  33047. /**
  33048. * The l1,0 coefficients of the spherical harmonics
  33049. */
  33050. l10: Vector3;
  33051. /**
  33052. * The l1,1 coefficients of the spherical harmonics
  33053. */
  33054. l11: Vector3;
  33055. /**
  33056. * The l2,-2 coefficients of the spherical harmonics
  33057. */
  33058. l2_2: Vector3;
  33059. /**
  33060. * The l2,-1 coefficients of the spherical harmonics
  33061. */
  33062. l2_1: Vector3;
  33063. /**
  33064. * The l2,0 coefficients of the spherical harmonics
  33065. */
  33066. l20: Vector3;
  33067. /**
  33068. * The l2,1 coefficients of the spherical harmonics
  33069. */
  33070. l21: Vector3;
  33071. /**
  33072. * The l2,2 coefficients of the spherical harmonics
  33073. */
  33074. l22: Vector3;
  33075. /**
  33076. * Adds a light to the spherical harmonics
  33077. * @param direction the direction of the light
  33078. * @param color the color of the light
  33079. * @param deltaSolidAngle the delta solid angle of the light
  33080. */
  33081. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33082. /**
  33083. * Scales the spherical harmonics by the given amount
  33084. * @param scale the amount to scale
  33085. */
  33086. scaleInPlace(scale: number): void;
  33087. /**
  33088. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33089. *
  33090. * ```
  33091. * E_lm = A_l * L_lm
  33092. * ```
  33093. *
  33094. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33095. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33096. * the scaling factors are given in equation 9.
  33097. */
  33098. convertIncidentRadianceToIrradiance(): void;
  33099. /**
  33100. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33101. *
  33102. * ```
  33103. * L = (1/pi) * E * rho
  33104. * ```
  33105. *
  33106. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33107. */
  33108. convertIrradianceToLambertianRadiance(): void;
  33109. /**
  33110. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33111. * required operations at run time.
  33112. *
  33113. * This is simply done by scaling back the SH with Ylm constants parameter.
  33114. * The trigonometric part being applied by the shader at run time.
  33115. */
  33116. preScaleForRendering(): void;
  33117. /**
  33118. * Constructs a spherical harmonics from an array.
  33119. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33120. * @returns the spherical harmonics
  33121. */
  33122. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33123. /**
  33124. * Gets the spherical harmonics from polynomial
  33125. * @param polynomial the spherical polynomial
  33126. * @returns the spherical harmonics
  33127. */
  33128. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33129. }
  33130. /**
  33131. * Class representing spherical polynomial coefficients to the 3rd degree
  33132. */
  33133. export class SphericalPolynomial {
  33134. private _harmonics;
  33135. /**
  33136. * The spherical harmonics used to create the polynomials.
  33137. */
  33138. get preScaledHarmonics(): SphericalHarmonics;
  33139. /**
  33140. * The x coefficients of the spherical polynomial
  33141. */
  33142. x: Vector3;
  33143. /**
  33144. * The y coefficients of the spherical polynomial
  33145. */
  33146. y: Vector3;
  33147. /**
  33148. * The z coefficients of the spherical polynomial
  33149. */
  33150. z: Vector3;
  33151. /**
  33152. * The xx coefficients of the spherical polynomial
  33153. */
  33154. xx: Vector3;
  33155. /**
  33156. * The yy coefficients of the spherical polynomial
  33157. */
  33158. yy: Vector3;
  33159. /**
  33160. * The zz coefficients of the spherical polynomial
  33161. */
  33162. zz: Vector3;
  33163. /**
  33164. * The xy coefficients of the spherical polynomial
  33165. */
  33166. xy: Vector3;
  33167. /**
  33168. * The yz coefficients of the spherical polynomial
  33169. */
  33170. yz: Vector3;
  33171. /**
  33172. * The zx coefficients of the spherical polynomial
  33173. */
  33174. zx: Vector3;
  33175. /**
  33176. * Adds an ambient color to the spherical polynomial
  33177. * @param color the color to add
  33178. */
  33179. addAmbient(color: Color3): void;
  33180. /**
  33181. * Scales the spherical polynomial by the given amount
  33182. * @param scale the amount to scale
  33183. */
  33184. scaleInPlace(scale: number): void;
  33185. /**
  33186. * Gets the spherical polynomial from harmonics
  33187. * @param harmonics the spherical harmonics
  33188. * @returns the spherical polynomial
  33189. */
  33190. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33191. /**
  33192. * Constructs a spherical polynomial from an array.
  33193. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33194. * @returns the spherical polynomial
  33195. */
  33196. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33197. }
  33198. }
  33199. declare module "babylonjs/Materials/Textures/internalTexture" {
  33200. import { Observable } from "babylonjs/Misc/observable";
  33201. import { Nullable, int } from "babylonjs/types";
  33202. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33204. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33205. /**
  33206. * Defines the source of the internal texture
  33207. */
  33208. export enum InternalTextureSource {
  33209. /**
  33210. * The source of the texture data is unknown
  33211. */
  33212. Unknown = 0,
  33213. /**
  33214. * Texture data comes from an URL
  33215. */
  33216. Url = 1,
  33217. /**
  33218. * Texture data is only used for temporary storage
  33219. */
  33220. Temp = 2,
  33221. /**
  33222. * Texture data comes from raw data (ArrayBuffer)
  33223. */
  33224. Raw = 3,
  33225. /**
  33226. * Texture content is dynamic (video or dynamic texture)
  33227. */
  33228. Dynamic = 4,
  33229. /**
  33230. * Texture content is generated by rendering to it
  33231. */
  33232. RenderTarget = 5,
  33233. /**
  33234. * Texture content is part of a multi render target process
  33235. */
  33236. MultiRenderTarget = 6,
  33237. /**
  33238. * Texture data comes from a cube data file
  33239. */
  33240. Cube = 7,
  33241. /**
  33242. * Texture data comes from a raw cube data
  33243. */
  33244. CubeRaw = 8,
  33245. /**
  33246. * Texture data come from a prefiltered cube data file
  33247. */
  33248. CubePrefiltered = 9,
  33249. /**
  33250. * Texture content is raw 3D data
  33251. */
  33252. Raw3D = 10,
  33253. /**
  33254. * Texture content is raw 2D array data
  33255. */
  33256. Raw2DArray = 11,
  33257. /**
  33258. * Texture content is a depth texture
  33259. */
  33260. Depth = 12,
  33261. /**
  33262. * Texture data comes from a raw cube data encoded with RGBD
  33263. */
  33264. CubeRawRGBD = 13
  33265. }
  33266. /**
  33267. * Class used to store data associated with WebGL texture data for the engine
  33268. * This class should not be used directly
  33269. */
  33270. export class InternalTexture {
  33271. /** @hidden */
  33272. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33273. /**
  33274. * Defines if the texture is ready
  33275. */
  33276. isReady: boolean;
  33277. /**
  33278. * Defines if the texture is a cube texture
  33279. */
  33280. isCube: boolean;
  33281. /**
  33282. * Defines if the texture contains 3D data
  33283. */
  33284. is3D: boolean;
  33285. /**
  33286. * Defines if the texture contains 2D array data
  33287. */
  33288. is2DArray: boolean;
  33289. /**
  33290. * Defines if the texture contains multiview data
  33291. */
  33292. isMultiview: boolean;
  33293. /**
  33294. * Gets the URL used to load this texture
  33295. */
  33296. url: string;
  33297. /**
  33298. * Gets the sampling mode of the texture
  33299. */
  33300. samplingMode: number;
  33301. /**
  33302. * Gets a boolean indicating if the texture needs mipmaps generation
  33303. */
  33304. generateMipMaps: boolean;
  33305. /**
  33306. * Gets the number of samples used by the texture (WebGL2+ only)
  33307. */
  33308. samples: number;
  33309. /**
  33310. * Gets the type of the texture (int, float...)
  33311. */
  33312. type: number;
  33313. /**
  33314. * Gets the format of the texture (RGB, RGBA...)
  33315. */
  33316. format: number;
  33317. /**
  33318. * Observable called when the texture is loaded
  33319. */
  33320. onLoadedObservable: Observable<InternalTexture>;
  33321. /**
  33322. * Gets the width of the texture
  33323. */
  33324. width: number;
  33325. /**
  33326. * Gets the height of the texture
  33327. */
  33328. height: number;
  33329. /**
  33330. * Gets the depth of the texture
  33331. */
  33332. depth: number;
  33333. /**
  33334. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33335. */
  33336. baseWidth: number;
  33337. /**
  33338. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33339. */
  33340. baseHeight: number;
  33341. /**
  33342. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33343. */
  33344. baseDepth: number;
  33345. /**
  33346. * Gets a boolean indicating if the texture is inverted on Y axis
  33347. */
  33348. invertY: boolean;
  33349. /** @hidden */
  33350. _invertVScale: boolean;
  33351. /** @hidden */
  33352. _associatedChannel: number;
  33353. /** @hidden */
  33354. _source: InternalTextureSource;
  33355. /** @hidden */
  33356. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33357. /** @hidden */
  33358. _bufferView: Nullable<ArrayBufferView>;
  33359. /** @hidden */
  33360. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33361. /** @hidden */
  33362. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33363. /** @hidden */
  33364. _size: number;
  33365. /** @hidden */
  33366. _extension: string;
  33367. /** @hidden */
  33368. _files: Nullable<string[]>;
  33369. /** @hidden */
  33370. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33371. /** @hidden */
  33372. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33373. /** @hidden */
  33374. _framebuffer: Nullable<WebGLFramebuffer>;
  33375. /** @hidden */
  33376. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33377. /** @hidden */
  33378. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33379. /** @hidden */
  33380. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33381. /** @hidden */
  33382. _attachments: Nullable<number[]>;
  33383. /** @hidden */
  33384. _cachedCoordinatesMode: Nullable<number>;
  33385. /** @hidden */
  33386. _cachedWrapU: Nullable<number>;
  33387. /** @hidden */
  33388. _cachedWrapV: Nullable<number>;
  33389. /** @hidden */
  33390. _cachedWrapR: Nullable<number>;
  33391. /** @hidden */
  33392. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33393. /** @hidden */
  33394. _isDisabled: boolean;
  33395. /** @hidden */
  33396. _compression: Nullable<string>;
  33397. /** @hidden */
  33398. _generateStencilBuffer: boolean;
  33399. /** @hidden */
  33400. _generateDepthBuffer: boolean;
  33401. /** @hidden */
  33402. _comparisonFunction: number;
  33403. /** @hidden */
  33404. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33405. /** @hidden */
  33406. _lodGenerationScale: number;
  33407. /** @hidden */
  33408. _lodGenerationOffset: number;
  33409. /** @hidden */
  33410. _depthStencilTexture: Nullable<InternalTexture>;
  33411. /** @hidden */
  33412. _colorTextureArray: Nullable<WebGLTexture>;
  33413. /** @hidden */
  33414. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33415. /** @hidden */
  33416. _lodTextureHigh: Nullable<BaseTexture>;
  33417. /** @hidden */
  33418. _lodTextureMid: Nullable<BaseTexture>;
  33419. /** @hidden */
  33420. _lodTextureLow: Nullable<BaseTexture>;
  33421. /** @hidden */
  33422. _isRGBD: boolean;
  33423. /** @hidden */
  33424. _linearSpecularLOD: boolean;
  33425. /** @hidden */
  33426. _irradianceTexture: Nullable<BaseTexture>;
  33427. /** @hidden */
  33428. _webGLTexture: Nullable<WebGLTexture>;
  33429. /** @hidden */
  33430. _references: number;
  33431. private _engine;
  33432. /**
  33433. * Gets the Engine the texture belongs to.
  33434. * @returns The babylon engine
  33435. */
  33436. getEngine(): ThinEngine;
  33437. /**
  33438. * Gets the data source type of the texture
  33439. */
  33440. get source(): InternalTextureSource;
  33441. /**
  33442. * Creates a new InternalTexture
  33443. * @param engine defines the engine to use
  33444. * @param source defines the type of data that will be used
  33445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33446. */
  33447. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33448. /**
  33449. * Increments the number of references (ie. the number of Texture that point to it)
  33450. */
  33451. incrementReferences(): void;
  33452. /**
  33453. * Change the size of the texture (not the size of the content)
  33454. * @param width defines the new width
  33455. * @param height defines the new height
  33456. * @param depth defines the new depth (1 by default)
  33457. */
  33458. updateSize(width: int, height: int, depth?: int): void;
  33459. /** @hidden */
  33460. _rebuild(): void;
  33461. /** @hidden */
  33462. _swapAndDie(target: InternalTexture): void;
  33463. /**
  33464. * Dispose the current allocated resources
  33465. */
  33466. dispose(): void;
  33467. }
  33468. }
  33469. declare module "babylonjs/Audio/analyser" {
  33470. import { Scene } from "babylonjs/scene";
  33471. /**
  33472. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33474. */
  33475. export class Analyser {
  33476. /**
  33477. * Gets or sets the smoothing
  33478. * @ignorenaming
  33479. */
  33480. SMOOTHING: number;
  33481. /**
  33482. * Gets or sets the FFT table size
  33483. * @ignorenaming
  33484. */
  33485. FFT_SIZE: number;
  33486. /**
  33487. * Gets or sets the bar graph amplitude
  33488. * @ignorenaming
  33489. */
  33490. BARGRAPHAMPLITUDE: number;
  33491. /**
  33492. * Gets or sets the position of the debug canvas
  33493. * @ignorenaming
  33494. */
  33495. DEBUGCANVASPOS: {
  33496. x: number;
  33497. y: number;
  33498. };
  33499. /**
  33500. * Gets or sets the debug canvas size
  33501. * @ignorenaming
  33502. */
  33503. DEBUGCANVASSIZE: {
  33504. width: number;
  33505. height: number;
  33506. };
  33507. private _byteFreqs;
  33508. private _byteTime;
  33509. private _floatFreqs;
  33510. private _webAudioAnalyser;
  33511. private _debugCanvas;
  33512. private _debugCanvasContext;
  33513. private _scene;
  33514. private _registerFunc;
  33515. private _audioEngine;
  33516. /**
  33517. * Creates a new analyser
  33518. * @param scene defines hosting scene
  33519. */
  33520. constructor(scene: Scene);
  33521. /**
  33522. * Get the number of data values you will have to play with for the visualization
  33523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33524. * @returns a number
  33525. */
  33526. getFrequencyBinCount(): number;
  33527. /**
  33528. * Gets the current frequency data as a byte array
  33529. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33530. * @returns a Uint8Array
  33531. */
  33532. getByteFrequencyData(): Uint8Array;
  33533. /**
  33534. * Gets the current waveform as a byte array
  33535. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33536. * @returns a Uint8Array
  33537. */
  33538. getByteTimeDomainData(): Uint8Array;
  33539. /**
  33540. * Gets the current frequency data as a float array
  33541. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33542. * @returns a Float32Array
  33543. */
  33544. getFloatFrequencyData(): Float32Array;
  33545. /**
  33546. * Renders the debug canvas
  33547. */
  33548. drawDebugCanvas(): void;
  33549. /**
  33550. * Stops rendering the debug canvas and removes it
  33551. */
  33552. stopDebugCanvas(): void;
  33553. /**
  33554. * Connects two audio nodes
  33555. * @param inputAudioNode defines first node to connect
  33556. * @param outputAudioNode defines second node to connect
  33557. */
  33558. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33559. /**
  33560. * Releases all associated resources
  33561. */
  33562. dispose(): void;
  33563. }
  33564. }
  33565. declare module "babylonjs/Audio/audioEngine" {
  33566. import { IDisposable } from "babylonjs/scene";
  33567. import { Analyser } from "babylonjs/Audio/analyser";
  33568. import { Nullable } from "babylonjs/types";
  33569. import { Observable } from "babylonjs/Misc/observable";
  33570. /**
  33571. * This represents an audio engine and it is responsible
  33572. * to play, synchronize and analyse sounds throughout the application.
  33573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33574. */
  33575. export interface IAudioEngine extends IDisposable {
  33576. /**
  33577. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33578. */
  33579. readonly canUseWebAudio: boolean;
  33580. /**
  33581. * Gets the current AudioContext if available.
  33582. */
  33583. readonly audioContext: Nullable<AudioContext>;
  33584. /**
  33585. * The master gain node defines the global audio volume of your audio engine.
  33586. */
  33587. readonly masterGain: GainNode;
  33588. /**
  33589. * Gets whether or not mp3 are supported by your browser.
  33590. */
  33591. readonly isMP3supported: boolean;
  33592. /**
  33593. * Gets whether or not ogg are supported by your browser.
  33594. */
  33595. readonly isOGGsupported: boolean;
  33596. /**
  33597. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33598. * @ignoreNaming
  33599. */
  33600. WarnedWebAudioUnsupported: boolean;
  33601. /**
  33602. * Defines if the audio engine relies on a custom unlocked button.
  33603. * In this case, the embedded button will not be displayed.
  33604. */
  33605. useCustomUnlockedButton: boolean;
  33606. /**
  33607. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33608. */
  33609. readonly unlocked: boolean;
  33610. /**
  33611. * Event raised when audio has been unlocked on the browser.
  33612. */
  33613. onAudioUnlockedObservable: Observable<AudioEngine>;
  33614. /**
  33615. * Event raised when audio has been locked on the browser.
  33616. */
  33617. onAudioLockedObservable: Observable<AudioEngine>;
  33618. /**
  33619. * Flags the audio engine in Locked state.
  33620. * This happens due to new browser policies preventing audio to autoplay.
  33621. */
  33622. lock(): void;
  33623. /**
  33624. * Unlocks the audio engine once a user action has been done on the dom.
  33625. * This is helpful to resume play once browser policies have been satisfied.
  33626. */
  33627. unlock(): void;
  33628. /**
  33629. * Gets the global volume sets on the master gain.
  33630. * @returns the global volume if set or -1 otherwise
  33631. */
  33632. getGlobalVolume(): number;
  33633. /**
  33634. * Sets the global volume of your experience (sets on the master gain).
  33635. * @param newVolume Defines the new global volume of the application
  33636. */
  33637. setGlobalVolume(newVolume: number): void;
  33638. /**
  33639. * Connect the audio engine to an audio analyser allowing some amazing
  33640. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33642. * @param analyser The analyser to connect to the engine
  33643. */
  33644. connectToAnalyser(analyser: Analyser): void;
  33645. }
  33646. /**
  33647. * This represents the default audio engine used in babylon.
  33648. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33650. */
  33651. export class AudioEngine implements IAudioEngine {
  33652. private _audioContext;
  33653. private _audioContextInitialized;
  33654. private _muteButton;
  33655. private _hostElement;
  33656. /**
  33657. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33658. */
  33659. canUseWebAudio: boolean;
  33660. /**
  33661. * The master gain node defines the global audio volume of your audio engine.
  33662. */
  33663. masterGain: GainNode;
  33664. /**
  33665. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33666. * @ignoreNaming
  33667. */
  33668. WarnedWebAudioUnsupported: boolean;
  33669. /**
  33670. * Gets whether or not mp3 are supported by your browser.
  33671. */
  33672. isMP3supported: boolean;
  33673. /**
  33674. * Gets whether or not ogg are supported by your browser.
  33675. */
  33676. isOGGsupported: boolean;
  33677. /**
  33678. * Gets whether audio has been unlocked on the device.
  33679. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33680. * a user interaction has happened.
  33681. */
  33682. unlocked: boolean;
  33683. /**
  33684. * Defines if the audio engine relies on a custom unlocked button.
  33685. * In this case, the embedded button will not be displayed.
  33686. */
  33687. useCustomUnlockedButton: boolean;
  33688. /**
  33689. * Event raised when audio has been unlocked on the browser.
  33690. */
  33691. onAudioUnlockedObservable: Observable<AudioEngine>;
  33692. /**
  33693. * Event raised when audio has been locked on the browser.
  33694. */
  33695. onAudioLockedObservable: Observable<AudioEngine>;
  33696. /**
  33697. * Gets the current AudioContext if available.
  33698. */
  33699. get audioContext(): Nullable<AudioContext>;
  33700. private _connectedAnalyser;
  33701. /**
  33702. * Instantiates a new audio engine.
  33703. *
  33704. * There should be only one per page as some browsers restrict the number
  33705. * of audio contexts you can create.
  33706. * @param hostElement defines the host element where to display the mute icon if necessary
  33707. */
  33708. constructor(hostElement?: Nullable<HTMLElement>);
  33709. /**
  33710. * Flags the audio engine in Locked state.
  33711. * This happens due to new browser policies preventing audio to autoplay.
  33712. */
  33713. lock(): void;
  33714. /**
  33715. * Unlocks the audio engine once a user action has been done on the dom.
  33716. * This is helpful to resume play once browser policies have been satisfied.
  33717. */
  33718. unlock(): void;
  33719. private _resumeAudioContext;
  33720. private _initializeAudioContext;
  33721. private _tryToRun;
  33722. private _triggerRunningState;
  33723. private _triggerSuspendedState;
  33724. private _displayMuteButton;
  33725. private _moveButtonToTopLeft;
  33726. private _onResize;
  33727. private _hideMuteButton;
  33728. /**
  33729. * Destroy and release the resources associated with the audio ccontext.
  33730. */
  33731. dispose(): void;
  33732. /**
  33733. * Gets the global volume sets on the master gain.
  33734. * @returns the global volume if set or -1 otherwise
  33735. */
  33736. getGlobalVolume(): number;
  33737. /**
  33738. * Sets the global volume of your experience (sets on the master gain).
  33739. * @param newVolume Defines the new global volume of the application
  33740. */
  33741. setGlobalVolume(newVolume: number): void;
  33742. /**
  33743. * Connect the audio engine to an audio analyser allowing some amazing
  33744. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33746. * @param analyser The analyser to connect to the engine
  33747. */
  33748. connectToAnalyser(analyser: Analyser): void;
  33749. }
  33750. }
  33751. declare module "babylonjs/Loading/loadingScreen" {
  33752. /**
  33753. * Interface used to present a loading screen while loading a scene
  33754. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33755. */
  33756. export interface ILoadingScreen {
  33757. /**
  33758. * Function called to display the loading screen
  33759. */
  33760. displayLoadingUI: () => void;
  33761. /**
  33762. * Function called to hide the loading screen
  33763. */
  33764. hideLoadingUI: () => void;
  33765. /**
  33766. * Gets or sets the color to use for the background
  33767. */
  33768. loadingUIBackgroundColor: string;
  33769. /**
  33770. * Gets or sets the text to display while loading
  33771. */
  33772. loadingUIText: string;
  33773. }
  33774. /**
  33775. * Class used for the default loading screen
  33776. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33777. */
  33778. export class DefaultLoadingScreen implements ILoadingScreen {
  33779. private _renderingCanvas;
  33780. private _loadingText;
  33781. private _loadingDivBackgroundColor;
  33782. private _loadingDiv;
  33783. private _loadingTextDiv;
  33784. /** Gets or sets the logo url to use for the default loading screen */
  33785. static DefaultLogoUrl: string;
  33786. /** Gets or sets the spinner url to use for the default loading screen */
  33787. static DefaultSpinnerUrl: string;
  33788. /**
  33789. * Creates a new default loading screen
  33790. * @param _renderingCanvas defines the canvas used to render the scene
  33791. * @param _loadingText defines the default text to display
  33792. * @param _loadingDivBackgroundColor defines the default background color
  33793. */
  33794. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33795. /**
  33796. * Function called to display the loading screen
  33797. */
  33798. displayLoadingUI(): void;
  33799. /**
  33800. * Function called to hide the loading screen
  33801. */
  33802. hideLoadingUI(): void;
  33803. /**
  33804. * Gets or sets the text to display while loading
  33805. */
  33806. set loadingUIText(text: string);
  33807. get loadingUIText(): string;
  33808. /**
  33809. * Gets or sets the color to use for the background
  33810. */
  33811. get loadingUIBackgroundColor(): string;
  33812. set loadingUIBackgroundColor(color: string);
  33813. private _resizeLoadingUI;
  33814. }
  33815. }
  33816. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33817. /**
  33818. * Interface for any object that can request an animation frame
  33819. */
  33820. export interface ICustomAnimationFrameRequester {
  33821. /**
  33822. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33823. */
  33824. renderFunction?: Function;
  33825. /**
  33826. * Called to request the next frame to render to
  33827. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33828. */
  33829. requestAnimationFrame: Function;
  33830. /**
  33831. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33832. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33833. */
  33834. requestID?: number;
  33835. }
  33836. }
  33837. declare module "babylonjs/Misc/performanceMonitor" {
  33838. /**
  33839. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33840. */
  33841. export class PerformanceMonitor {
  33842. private _enabled;
  33843. private _rollingFrameTime;
  33844. private _lastFrameTimeMs;
  33845. /**
  33846. * constructor
  33847. * @param frameSampleSize The number of samples required to saturate the sliding window
  33848. */
  33849. constructor(frameSampleSize?: number);
  33850. /**
  33851. * Samples current frame
  33852. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33853. */
  33854. sampleFrame(timeMs?: number): void;
  33855. /**
  33856. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33857. */
  33858. get averageFrameTime(): number;
  33859. /**
  33860. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33861. */
  33862. get averageFrameTimeVariance(): number;
  33863. /**
  33864. * Returns the frame time of the most recent frame
  33865. */
  33866. get instantaneousFrameTime(): number;
  33867. /**
  33868. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33869. */
  33870. get averageFPS(): number;
  33871. /**
  33872. * Returns the average framerate in frames per second using the most recent frame time
  33873. */
  33874. get instantaneousFPS(): number;
  33875. /**
  33876. * Returns true if enough samples have been taken to completely fill the sliding window
  33877. */
  33878. get isSaturated(): boolean;
  33879. /**
  33880. * Enables contributions to the sliding window sample set
  33881. */
  33882. enable(): void;
  33883. /**
  33884. * Disables contributions to the sliding window sample set
  33885. * Samples will not be interpolated over the disabled period
  33886. */
  33887. disable(): void;
  33888. /**
  33889. * Returns true if sampling is enabled
  33890. */
  33891. get isEnabled(): boolean;
  33892. /**
  33893. * Resets performance monitor
  33894. */
  33895. reset(): void;
  33896. }
  33897. /**
  33898. * RollingAverage
  33899. *
  33900. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33901. */
  33902. export class RollingAverage {
  33903. /**
  33904. * Current average
  33905. */
  33906. average: number;
  33907. /**
  33908. * Current variance
  33909. */
  33910. variance: number;
  33911. protected _samples: Array<number>;
  33912. protected _sampleCount: number;
  33913. protected _pos: number;
  33914. protected _m2: number;
  33915. /**
  33916. * constructor
  33917. * @param length The number of samples required to saturate the sliding window
  33918. */
  33919. constructor(length: number);
  33920. /**
  33921. * Adds a sample to the sample set
  33922. * @param v The sample value
  33923. */
  33924. add(v: number): void;
  33925. /**
  33926. * Returns previously added values or null if outside of history or outside the sliding window domain
  33927. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33928. * @return Value previously recorded with add() or null if outside of range
  33929. */
  33930. history(i: number): number;
  33931. /**
  33932. * Returns true if enough samples have been taken to completely fill the sliding window
  33933. * @return true if sample-set saturated
  33934. */
  33935. isSaturated(): boolean;
  33936. /**
  33937. * Resets the rolling average (equivalent to 0 samples taken so far)
  33938. */
  33939. reset(): void;
  33940. /**
  33941. * Wraps a value around the sample range boundaries
  33942. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33943. * @return Wrapped position in sample range
  33944. */
  33945. protected _wrapPosition(i: number): number;
  33946. }
  33947. }
  33948. declare module "babylonjs/Misc/perfCounter" {
  33949. /**
  33950. * This class is used to track a performance counter which is number based.
  33951. * The user has access to many properties which give statistics of different nature.
  33952. *
  33953. * The implementer can track two kinds of Performance Counter: time and count.
  33954. * 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.
  33955. * 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.
  33956. */
  33957. export class PerfCounter {
  33958. /**
  33959. * Gets or sets a global boolean to turn on and off all the counters
  33960. */
  33961. static Enabled: boolean;
  33962. /**
  33963. * Returns the smallest value ever
  33964. */
  33965. get min(): number;
  33966. /**
  33967. * Returns the biggest value ever
  33968. */
  33969. get max(): number;
  33970. /**
  33971. * Returns the average value since the performance counter is running
  33972. */
  33973. get average(): number;
  33974. /**
  33975. * Returns the average value of the last second the counter was monitored
  33976. */
  33977. get lastSecAverage(): number;
  33978. /**
  33979. * Returns the current value
  33980. */
  33981. get current(): number;
  33982. /**
  33983. * Gets the accumulated total
  33984. */
  33985. get total(): number;
  33986. /**
  33987. * Gets the total value count
  33988. */
  33989. get count(): number;
  33990. /**
  33991. * Creates a new counter
  33992. */
  33993. constructor();
  33994. /**
  33995. * Call this method to start monitoring a new frame.
  33996. * 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.
  33997. */
  33998. fetchNewFrame(): void;
  33999. /**
  34000. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34001. * @param newCount the count value to add to the monitored count
  34002. * @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.
  34003. */
  34004. addCount(newCount: number, fetchResult: boolean): void;
  34005. /**
  34006. * Start monitoring this performance counter
  34007. */
  34008. beginMonitoring(): void;
  34009. /**
  34010. * Compute the time lapsed since the previous beginMonitoring() call.
  34011. * @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
  34012. */
  34013. endMonitoring(newFrame?: boolean): void;
  34014. private _fetchResult;
  34015. private _startMonitoringTime;
  34016. private _min;
  34017. private _max;
  34018. private _average;
  34019. private _current;
  34020. private _totalValueCount;
  34021. private _totalAccumulated;
  34022. private _lastSecAverage;
  34023. private _lastSecAccumulated;
  34024. private _lastSecTime;
  34025. private _lastSecValueCount;
  34026. }
  34027. }
  34028. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34029. module "babylonjs/Engines/thinEngine" {
  34030. interface ThinEngine {
  34031. /**
  34032. * Sets alpha constants used by some alpha blending modes
  34033. * @param r defines the red component
  34034. * @param g defines the green component
  34035. * @param b defines the blue component
  34036. * @param a defines the alpha component
  34037. */
  34038. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34039. /**
  34040. * Sets the current alpha mode
  34041. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34042. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34043. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34044. */
  34045. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34046. /**
  34047. * Gets the current alpha mode
  34048. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34049. * @returns the current alpha mode
  34050. */
  34051. getAlphaMode(): number;
  34052. /**
  34053. * Sets the current alpha equation
  34054. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34055. */
  34056. setAlphaEquation(equation: number): void;
  34057. /**
  34058. * Gets the current alpha equation.
  34059. * @returns the current alpha equation
  34060. */
  34061. getAlphaEquation(): number;
  34062. }
  34063. }
  34064. }
  34065. declare module "babylonjs/Engines/engine" {
  34066. import { Observable } from "babylonjs/Misc/observable";
  34067. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34068. import { Scene } from "babylonjs/scene";
  34069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34070. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34071. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34072. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34073. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34074. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34075. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34076. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34077. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34078. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34079. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34080. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34081. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34082. import "babylonjs/Engines/Extensions/engine.alpha";
  34083. import { Material } from "babylonjs/Materials/material";
  34084. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34085. /**
  34086. * Defines the interface used by display changed events
  34087. */
  34088. export interface IDisplayChangedEventArgs {
  34089. /** Gets the vrDisplay object (if any) */
  34090. vrDisplay: Nullable<any>;
  34091. /** Gets a boolean indicating if webVR is supported */
  34092. vrSupported: boolean;
  34093. }
  34094. /**
  34095. * Defines the interface used by objects containing a viewport (like a camera)
  34096. */
  34097. interface IViewportOwnerLike {
  34098. /**
  34099. * Gets or sets the viewport
  34100. */
  34101. viewport: IViewportLike;
  34102. }
  34103. /**
  34104. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34105. */
  34106. export class Engine extends ThinEngine {
  34107. /** Defines that alpha blending is disabled */
  34108. static readonly ALPHA_DISABLE: number;
  34109. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34110. static readonly ALPHA_ADD: number;
  34111. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34112. static readonly ALPHA_COMBINE: number;
  34113. /** Defines that alpha blending to DEST - SRC * DEST */
  34114. static readonly ALPHA_SUBTRACT: number;
  34115. /** Defines that alpha blending to SRC * DEST */
  34116. static readonly ALPHA_MULTIPLY: number;
  34117. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34118. static readonly ALPHA_MAXIMIZED: number;
  34119. /** Defines that alpha blending to SRC + DEST */
  34120. static readonly ALPHA_ONEONE: number;
  34121. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34122. static readonly ALPHA_PREMULTIPLIED: number;
  34123. /**
  34124. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34125. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34126. */
  34127. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34128. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34129. static readonly ALPHA_INTERPOLATE: number;
  34130. /**
  34131. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34132. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34133. */
  34134. static readonly ALPHA_SCREENMODE: number;
  34135. /** Defines that the ressource is not delayed*/
  34136. static readonly DELAYLOADSTATE_NONE: number;
  34137. /** Defines that the ressource was successfully delay loaded */
  34138. static readonly DELAYLOADSTATE_LOADED: number;
  34139. /** Defines that the ressource is currently delay loading */
  34140. static readonly DELAYLOADSTATE_LOADING: number;
  34141. /** Defines that the ressource is delayed and has not started loading */
  34142. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34143. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34144. static readonly NEVER: number;
  34145. /** 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 */
  34146. static readonly ALWAYS: number;
  34147. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34148. static readonly LESS: number;
  34149. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34150. static readonly EQUAL: number;
  34151. /** 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 */
  34152. static readonly LEQUAL: number;
  34153. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34154. static readonly GREATER: number;
  34155. /** 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 */
  34156. static readonly GEQUAL: number;
  34157. /** 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 */
  34158. static readonly NOTEQUAL: number;
  34159. /** Passed to stencilOperation to specify that stencil value must be kept */
  34160. static readonly KEEP: number;
  34161. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34162. static readonly REPLACE: number;
  34163. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34164. static readonly INCR: number;
  34165. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34166. static readonly DECR: number;
  34167. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34168. static readonly INVERT: number;
  34169. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34170. static readonly INCR_WRAP: number;
  34171. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34172. static readonly DECR_WRAP: number;
  34173. /** Texture is not repeating outside of 0..1 UVs */
  34174. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34175. /** Texture is repeating outside of 0..1 UVs */
  34176. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34177. /** Texture is repeating and mirrored */
  34178. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34179. /** ALPHA */
  34180. static readonly TEXTUREFORMAT_ALPHA: number;
  34181. /** LUMINANCE */
  34182. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34183. /** LUMINANCE_ALPHA */
  34184. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34185. /** RGB */
  34186. static readonly TEXTUREFORMAT_RGB: number;
  34187. /** RGBA */
  34188. static readonly TEXTUREFORMAT_RGBA: number;
  34189. /** RED */
  34190. static readonly TEXTUREFORMAT_RED: number;
  34191. /** RED (2nd reference) */
  34192. static readonly TEXTUREFORMAT_R: number;
  34193. /** RG */
  34194. static readonly TEXTUREFORMAT_RG: number;
  34195. /** RED_INTEGER */
  34196. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34197. /** RED_INTEGER (2nd reference) */
  34198. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34199. /** RG_INTEGER */
  34200. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34201. /** RGB_INTEGER */
  34202. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34203. /** RGBA_INTEGER */
  34204. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34205. /** UNSIGNED_BYTE */
  34206. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34207. /** UNSIGNED_BYTE (2nd reference) */
  34208. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34209. /** FLOAT */
  34210. static readonly TEXTURETYPE_FLOAT: number;
  34211. /** HALF_FLOAT */
  34212. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34213. /** BYTE */
  34214. static readonly TEXTURETYPE_BYTE: number;
  34215. /** SHORT */
  34216. static readonly TEXTURETYPE_SHORT: number;
  34217. /** UNSIGNED_SHORT */
  34218. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34219. /** INT */
  34220. static readonly TEXTURETYPE_INT: number;
  34221. /** UNSIGNED_INT */
  34222. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34223. /** UNSIGNED_SHORT_4_4_4_4 */
  34224. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34225. /** UNSIGNED_SHORT_5_5_5_1 */
  34226. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34227. /** UNSIGNED_SHORT_5_6_5 */
  34228. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34229. /** UNSIGNED_INT_2_10_10_10_REV */
  34230. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34231. /** UNSIGNED_INT_24_8 */
  34232. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34233. /** UNSIGNED_INT_10F_11F_11F_REV */
  34234. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34235. /** UNSIGNED_INT_5_9_9_9_REV */
  34236. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34237. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34238. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34239. /** nearest is mag = nearest and min = nearest and mip = linear */
  34240. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34241. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34242. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34243. /** Trilinear is mag = linear and min = linear and mip = linear */
  34244. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34245. /** nearest is mag = nearest and min = nearest and mip = linear */
  34246. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34247. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34248. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34249. /** Trilinear is mag = linear and min = linear and mip = linear */
  34250. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34251. /** mag = nearest and min = nearest and mip = nearest */
  34252. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34253. /** mag = nearest and min = linear and mip = nearest */
  34254. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34255. /** mag = nearest and min = linear and mip = linear */
  34256. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34257. /** mag = nearest and min = linear and mip = none */
  34258. static readonly TEXTURE_NEAREST_LINEAR: number;
  34259. /** mag = nearest and min = nearest and mip = none */
  34260. static readonly TEXTURE_NEAREST_NEAREST: number;
  34261. /** mag = linear and min = nearest and mip = nearest */
  34262. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34263. /** mag = linear and min = nearest and mip = linear */
  34264. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34265. /** mag = linear and min = linear and mip = none */
  34266. static readonly TEXTURE_LINEAR_LINEAR: number;
  34267. /** mag = linear and min = nearest and mip = none */
  34268. static readonly TEXTURE_LINEAR_NEAREST: number;
  34269. /** Explicit coordinates mode */
  34270. static readonly TEXTURE_EXPLICIT_MODE: number;
  34271. /** Spherical coordinates mode */
  34272. static readonly TEXTURE_SPHERICAL_MODE: number;
  34273. /** Planar coordinates mode */
  34274. static readonly TEXTURE_PLANAR_MODE: number;
  34275. /** Cubic coordinates mode */
  34276. static readonly TEXTURE_CUBIC_MODE: number;
  34277. /** Projection coordinates mode */
  34278. static readonly TEXTURE_PROJECTION_MODE: number;
  34279. /** Skybox coordinates mode */
  34280. static readonly TEXTURE_SKYBOX_MODE: number;
  34281. /** Inverse Cubic coordinates mode */
  34282. static readonly TEXTURE_INVCUBIC_MODE: number;
  34283. /** Equirectangular coordinates mode */
  34284. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34285. /** Equirectangular Fixed coordinates mode */
  34286. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34287. /** Equirectangular Fixed Mirrored coordinates mode */
  34288. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34289. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34290. static readonly SCALEMODE_FLOOR: number;
  34291. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34292. static readonly SCALEMODE_NEAREST: number;
  34293. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34294. static readonly SCALEMODE_CEILING: number;
  34295. /**
  34296. * Returns the current npm package of the sdk
  34297. */
  34298. static get NpmPackage(): string;
  34299. /**
  34300. * Returns the current version of the framework
  34301. */
  34302. static get Version(): string;
  34303. /** Gets the list of created engines */
  34304. static get Instances(): Engine[];
  34305. /**
  34306. * Gets the latest created engine
  34307. */
  34308. static get LastCreatedEngine(): Nullable<Engine>;
  34309. /**
  34310. * Gets the latest created scene
  34311. */
  34312. static get LastCreatedScene(): Nullable<Scene>;
  34313. /**
  34314. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34315. * @param flag defines which part of the materials must be marked as dirty
  34316. * @param predicate defines a predicate used to filter which materials should be affected
  34317. */
  34318. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34319. /**
  34320. * Method called to create the default loading screen.
  34321. * This can be overriden in your own app.
  34322. * @param canvas The rendering canvas element
  34323. * @returns The loading screen
  34324. */
  34325. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34326. /**
  34327. * Method called to create the default rescale post process on each engine.
  34328. */
  34329. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34330. /**
  34331. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34332. **/
  34333. enableOfflineSupport: boolean;
  34334. /**
  34335. * 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)
  34336. **/
  34337. disableManifestCheck: boolean;
  34338. /**
  34339. * Gets the list of created scenes
  34340. */
  34341. scenes: Scene[];
  34342. /**
  34343. * Event raised when a new scene is created
  34344. */
  34345. onNewSceneAddedObservable: Observable<Scene>;
  34346. /**
  34347. * Gets the list of created postprocesses
  34348. */
  34349. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34350. /**
  34351. * Gets a boolean indicating if the pointer is currently locked
  34352. */
  34353. isPointerLock: boolean;
  34354. /**
  34355. * Observable event triggered each time the rendering canvas is resized
  34356. */
  34357. onResizeObservable: Observable<Engine>;
  34358. /**
  34359. * Observable event triggered each time the canvas loses focus
  34360. */
  34361. onCanvasBlurObservable: Observable<Engine>;
  34362. /**
  34363. * Observable event triggered each time the canvas gains focus
  34364. */
  34365. onCanvasFocusObservable: Observable<Engine>;
  34366. /**
  34367. * Observable event triggered each time the canvas receives pointerout event
  34368. */
  34369. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34370. /**
  34371. * Observable raised when the engine begins a new frame
  34372. */
  34373. onBeginFrameObservable: Observable<Engine>;
  34374. /**
  34375. * If set, will be used to request the next animation frame for the render loop
  34376. */
  34377. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34378. /**
  34379. * Observable raised when the engine ends the current frame
  34380. */
  34381. onEndFrameObservable: Observable<Engine>;
  34382. /**
  34383. * Observable raised when the engine is about to compile a shader
  34384. */
  34385. onBeforeShaderCompilationObservable: Observable<Engine>;
  34386. /**
  34387. * Observable raised when the engine has jsut compiled a shader
  34388. */
  34389. onAfterShaderCompilationObservable: Observable<Engine>;
  34390. /**
  34391. * Gets the audio engine
  34392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34393. * @ignorenaming
  34394. */
  34395. static audioEngine: IAudioEngine;
  34396. /**
  34397. * Default AudioEngine factory responsible of creating the Audio Engine.
  34398. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34399. */
  34400. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34401. /**
  34402. * Default offline support factory responsible of creating a tool used to store data locally.
  34403. * By default, this will create a Database object if the workload has been embedded.
  34404. */
  34405. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34406. private _loadingScreen;
  34407. private _pointerLockRequested;
  34408. private _dummyFramebuffer;
  34409. private _rescalePostProcess;
  34410. private _deterministicLockstep;
  34411. private _lockstepMaxSteps;
  34412. private _timeStep;
  34413. protected get _supportsHardwareTextureRescaling(): boolean;
  34414. private _fps;
  34415. private _deltaTime;
  34416. /** @hidden */
  34417. _drawCalls: PerfCounter;
  34418. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  34419. canvasTabIndex: number;
  34420. /**
  34421. * Turn this value on if you want to pause FPS computation when in background
  34422. */
  34423. disablePerformanceMonitorInBackground: boolean;
  34424. private _performanceMonitor;
  34425. /**
  34426. * Gets the performance monitor attached to this engine
  34427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34428. */
  34429. get performanceMonitor(): PerformanceMonitor;
  34430. private _onFocus;
  34431. private _onBlur;
  34432. private _onCanvasPointerOut;
  34433. private _onCanvasBlur;
  34434. private _onCanvasFocus;
  34435. private _onFullscreenChange;
  34436. private _onPointerLockChange;
  34437. /**
  34438. * Gets the HTML element used to attach event listeners
  34439. * @returns a HTML element
  34440. */
  34441. getInputElement(): Nullable<HTMLElement>;
  34442. /**
  34443. * Creates a new engine
  34444. * @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
  34445. * @param antialias defines enable antialiasing (default: false)
  34446. * @param options defines further options to be sent to the getContext() function
  34447. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34448. */
  34449. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34450. /**
  34451. * Gets current aspect ratio
  34452. * @param viewportOwner defines the camera to use to get the aspect ratio
  34453. * @param useScreen defines if screen size must be used (or the current render target if any)
  34454. * @returns a number defining the aspect ratio
  34455. */
  34456. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34457. /**
  34458. * Gets current screen aspect ratio
  34459. * @returns a number defining the aspect ratio
  34460. */
  34461. getScreenAspectRatio(): number;
  34462. /**
  34463. * Gets the client rect of the HTML canvas attached with the current webGL context
  34464. * @returns a client rectanglee
  34465. */
  34466. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34467. /**
  34468. * Gets the client rect of the HTML element used for events
  34469. * @returns a client rectanglee
  34470. */
  34471. getInputElementClientRect(): Nullable<ClientRect>;
  34472. /**
  34473. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34475. * @returns true if engine is in deterministic lock step mode
  34476. */
  34477. isDeterministicLockStep(): boolean;
  34478. /**
  34479. * Gets the max steps when engine is running in deterministic lock step
  34480. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34481. * @returns the max steps
  34482. */
  34483. getLockstepMaxSteps(): number;
  34484. /**
  34485. * Returns the time in ms between steps when using deterministic lock step.
  34486. * @returns time step in (ms)
  34487. */
  34488. getTimeStep(): number;
  34489. /**
  34490. * Force the mipmap generation for the given render target texture
  34491. * @param texture defines the render target texture to use
  34492. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34493. */
  34494. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34495. /** States */
  34496. /**
  34497. * Set various states to the webGL context
  34498. * @param culling defines backface culling state
  34499. * @param zOffset defines the value to apply to zOffset (0 by default)
  34500. * @param force defines if states must be applied even if cache is up to date
  34501. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34502. */
  34503. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34504. /**
  34505. * Set the z offset to apply to current rendering
  34506. * @param value defines the offset to apply
  34507. */
  34508. setZOffset(value: number): void;
  34509. /**
  34510. * Gets the current value of the zOffset
  34511. * @returns the current zOffset state
  34512. */
  34513. getZOffset(): number;
  34514. /**
  34515. * Enable or disable depth buffering
  34516. * @param enable defines the state to set
  34517. */
  34518. setDepthBuffer(enable: boolean): void;
  34519. /**
  34520. * Gets a boolean indicating if depth writing is enabled
  34521. * @returns the current depth writing state
  34522. */
  34523. getDepthWrite(): boolean;
  34524. /**
  34525. * Enable or disable depth writing
  34526. * @param enable defines the state to set
  34527. */
  34528. setDepthWrite(enable: boolean): void;
  34529. /**
  34530. * Gets a boolean indicating if stencil buffer is enabled
  34531. * @returns the current stencil buffer state
  34532. */
  34533. getStencilBuffer(): boolean;
  34534. /**
  34535. * Enable or disable the stencil buffer
  34536. * @param enable defines if the stencil buffer must be enabled or disabled
  34537. */
  34538. setStencilBuffer(enable: boolean): void;
  34539. /**
  34540. * Gets the current stencil mask
  34541. * @returns a number defining the new stencil mask to use
  34542. */
  34543. getStencilMask(): number;
  34544. /**
  34545. * Sets the current stencil mask
  34546. * @param mask defines the new stencil mask to use
  34547. */
  34548. setStencilMask(mask: number): void;
  34549. /**
  34550. * Gets the current stencil function
  34551. * @returns a number defining the stencil function to use
  34552. */
  34553. getStencilFunction(): number;
  34554. /**
  34555. * Gets the current stencil reference value
  34556. * @returns a number defining the stencil reference value to use
  34557. */
  34558. getStencilFunctionReference(): number;
  34559. /**
  34560. * Gets the current stencil mask
  34561. * @returns a number defining the stencil mask to use
  34562. */
  34563. getStencilFunctionMask(): number;
  34564. /**
  34565. * Sets the current stencil function
  34566. * @param stencilFunc defines the new stencil function to use
  34567. */
  34568. setStencilFunction(stencilFunc: number): void;
  34569. /**
  34570. * Sets the current stencil reference
  34571. * @param reference defines the new stencil reference to use
  34572. */
  34573. setStencilFunctionReference(reference: number): void;
  34574. /**
  34575. * Sets the current stencil mask
  34576. * @param mask defines the new stencil mask to use
  34577. */
  34578. setStencilFunctionMask(mask: number): void;
  34579. /**
  34580. * Gets the current stencil operation when stencil fails
  34581. * @returns a number defining stencil operation to use when stencil fails
  34582. */
  34583. getStencilOperationFail(): number;
  34584. /**
  34585. * Gets the current stencil operation when depth fails
  34586. * @returns a number defining stencil operation to use when depth fails
  34587. */
  34588. getStencilOperationDepthFail(): number;
  34589. /**
  34590. * Gets the current stencil operation when stencil passes
  34591. * @returns a number defining stencil operation to use when stencil passes
  34592. */
  34593. getStencilOperationPass(): number;
  34594. /**
  34595. * Sets the stencil operation to use when stencil fails
  34596. * @param operation defines the stencil operation to use when stencil fails
  34597. */
  34598. setStencilOperationFail(operation: number): void;
  34599. /**
  34600. * Sets the stencil operation to use when depth fails
  34601. * @param operation defines the stencil operation to use when depth fails
  34602. */
  34603. setStencilOperationDepthFail(operation: number): void;
  34604. /**
  34605. * Sets the stencil operation to use when stencil passes
  34606. * @param operation defines the stencil operation to use when stencil passes
  34607. */
  34608. setStencilOperationPass(operation: number): void;
  34609. /**
  34610. * Sets a boolean indicating if the dithering state is enabled or disabled
  34611. * @param value defines the dithering state
  34612. */
  34613. setDitheringState(value: boolean): void;
  34614. /**
  34615. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34616. * @param value defines the rasterizer state
  34617. */
  34618. setRasterizerState(value: boolean): void;
  34619. /**
  34620. * Gets the current depth function
  34621. * @returns a number defining the depth function
  34622. */
  34623. getDepthFunction(): Nullable<number>;
  34624. /**
  34625. * Sets the current depth function
  34626. * @param depthFunc defines the function to use
  34627. */
  34628. setDepthFunction(depthFunc: number): void;
  34629. /**
  34630. * Sets the current depth function to GREATER
  34631. */
  34632. setDepthFunctionToGreater(): void;
  34633. /**
  34634. * Sets the current depth function to GEQUAL
  34635. */
  34636. setDepthFunctionToGreaterOrEqual(): void;
  34637. /**
  34638. * Sets the current depth function to LESS
  34639. */
  34640. setDepthFunctionToLess(): void;
  34641. /**
  34642. * Sets the current depth function to LEQUAL
  34643. */
  34644. setDepthFunctionToLessOrEqual(): void;
  34645. private _cachedStencilBuffer;
  34646. private _cachedStencilFunction;
  34647. private _cachedStencilMask;
  34648. private _cachedStencilOperationPass;
  34649. private _cachedStencilOperationFail;
  34650. private _cachedStencilOperationDepthFail;
  34651. private _cachedStencilReference;
  34652. /**
  34653. * Caches the the state of the stencil buffer
  34654. */
  34655. cacheStencilState(): void;
  34656. /**
  34657. * Restores the state of the stencil buffer
  34658. */
  34659. restoreStencilState(): void;
  34660. /**
  34661. * Directly set the WebGL Viewport
  34662. * @param x defines the x coordinate of the viewport (in screen space)
  34663. * @param y defines the y coordinate of the viewport (in screen space)
  34664. * @param width defines the width of the viewport (in screen space)
  34665. * @param height defines the height of the viewport (in screen space)
  34666. * @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
  34667. */
  34668. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34669. /**
  34670. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34671. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34672. * @param y defines the y-coordinate of the corner of the clear rectangle
  34673. * @param width defines the width of the clear rectangle
  34674. * @param height defines the height of the clear rectangle
  34675. * @param clearColor defines the clear color
  34676. */
  34677. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34678. /**
  34679. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34680. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34681. * @param y defines the y-coordinate of the corner of the clear rectangle
  34682. * @param width defines the width of the clear rectangle
  34683. * @param height defines the height of the clear rectangle
  34684. */
  34685. enableScissor(x: number, y: number, width: number, height: number): void;
  34686. /**
  34687. * Disable previously set scissor test rectangle
  34688. */
  34689. disableScissor(): void;
  34690. protected _reportDrawCall(): void;
  34691. /**
  34692. * Initializes a webVR display and starts listening to display change events
  34693. * The onVRDisplayChangedObservable will be notified upon these changes
  34694. * @returns The onVRDisplayChangedObservable
  34695. */
  34696. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34697. /** @hidden */
  34698. _prepareVRComponent(): void;
  34699. /** @hidden */
  34700. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34701. /** @hidden */
  34702. _submitVRFrame(): void;
  34703. /**
  34704. * Call this function to leave webVR mode
  34705. * Will do nothing if webVR is not supported or if there is no webVR device
  34706. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34707. */
  34708. disableVR(): void;
  34709. /**
  34710. * Gets a boolean indicating that the system is in VR mode and is presenting
  34711. * @returns true if VR mode is engaged
  34712. */
  34713. isVRPresenting(): boolean;
  34714. /** @hidden */
  34715. _requestVRFrame(): void;
  34716. /** @hidden */
  34717. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34718. /**
  34719. * Gets the source code of the vertex shader associated with a specific webGL program
  34720. * @param program defines the program to use
  34721. * @returns a string containing the source code of the vertex shader associated with the program
  34722. */
  34723. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34724. /**
  34725. * Gets the source code of the fragment shader associated with a specific webGL program
  34726. * @param program defines the program to use
  34727. * @returns a string containing the source code of the fragment shader associated with the program
  34728. */
  34729. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34730. /**
  34731. * Sets a depth stencil texture from a render target to the according uniform.
  34732. * @param channel The texture channel
  34733. * @param uniform The uniform to set
  34734. * @param texture The render target texture containing the depth stencil texture to apply
  34735. */
  34736. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34737. /**
  34738. * Sets a texture to the webGL context from a postprocess
  34739. * @param channel defines the channel to use
  34740. * @param postProcess defines the source postprocess
  34741. */
  34742. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34743. /**
  34744. * Binds the output of the passed in post process to the texture channel specified
  34745. * @param channel The channel the texture should be bound to
  34746. * @param postProcess The post process which's output should be bound
  34747. */
  34748. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34749. /** @hidden */
  34750. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34751. protected _rebuildBuffers(): void;
  34752. /** @hidden */
  34753. _renderFrame(): void;
  34754. _renderLoop(): void;
  34755. /** @hidden */
  34756. _renderViews(): boolean;
  34757. /**
  34758. * Toggle full screen mode
  34759. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34760. */
  34761. switchFullscreen(requestPointerLock: boolean): void;
  34762. /**
  34763. * Enters full screen mode
  34764. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34765. */
  34766. enterFullscreen(requestPointerLock: boolean): void;
  34767. /**
  34768. * Exits full screen mode
  34769. */
  34770. exitFullscreen(): void;
  34771. /**
  34772. * Enters Pointerlock mode
  34773. */
  34774. enterPointerlock(): void;
  34775. /**
  34776. * Exits Pointerlock mode
  34777. */
  34778. exitPointerlock(): void;
  34779. /**
  34780. * Begin a new frame
  34781. */
  34782. beginFrame(): void;
  34783. /**
  34784. * Enf the current frame
  34785. */
  34786. endFrame(): void;
  34787. resize(): void;
  34788. /**
  34789. * Force a specific size of the canvas
  34790. * @param width defines the new canvas' width
  34791. * @param height defines the new canvas' height
  34792. */
  34793. setSize(width: number, height: number): void;
  34794. /**
  34795. * Updates a dynamic vertex buffer.
  34796. * @param vertexBuffer the vertex buffer to update
  34797. * @param data the data used to update the vertex buffer
  34798. * @param byteOffset the byte offset of the data
  34799. * @param byteLength the byte length of the data
  34800. */
  34801. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34802. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34803. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34804. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34805. _releaseTexture(texture: InternalTexture): void;
  34806. /**
  34807. * @hidden
  34808. * Rescales a texture
  34809. * @param source input texutre
  34810. * @param destination destination texture
  34811. * @param scene scene to use to render the resize
  34812. * @param internalFormat format to use when resizing
  34813. * @param onComplete callback to be called when resize has completed
  34814. */
  34815. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34816. /**
  34817. * Gets the current framerate
  34818. * @returns a number representing the framerate
  34819. */
  34820. getFps(): number;
  34821. /**
  34822. * Gets the time spent between current and previous frame
  34823. * @returns a number representing the delta time in ms
  34824. */
  34825. getDeltaTime(): number;
  34826. private _measureFps;
  34827. /** @hidden */
  34828. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34829. /**
  34830. * Update a dynamic index buffer
  34831. * @param indexBuffer defines the target index buffer
  34832. * @param indices defines the data to update
  34833. * @param offset defines the offset in the target index buffer where update should start
  34834. */
  34835. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34836. /**
  34837. * Updates the sample count of a render target texture
  34838. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34839. * @param texture defines the texture to update
  34840. * @param samples defines the sample count to set
  34841. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34842. */
  34843. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34844. /**
  34845. * Updates a depth texture Comparison Mode and Function.
  34846. * If the comparison Function is equal to 0, the mode will be set to none.
  34847. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34848. * @param texture The texture to set the comparison function for
  34849. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34850. */
  34851. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34852. /**
  34853. * Creates a webGL buffer to use with instanciation
  34854. * @param capacity defines the size of the buffer
  34855. * @returns the webGL buffer
  34856. */
  34857. createInstancesBuffer(capacity: number): DataBuffer;
  34858. /**
  34859. * Delete a webGL buffer used with instanciation
  34860. * @param buffer defines the webGL buffer to delete
  34861. */
  34862. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34863. private _clientWaitAsync;
  34864. /** @hidden */
  34865. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34866. /** @hidden */
  34867. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34868. dispose(): void;
  34869. private _disableTouchAction;
  34870. /**
  34871. * Display the loading screen
  34872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34873. */
  34874. displayLoadingUI(): void;
  34875. /**
  34876. * Hide the loading screen
  34877. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34878. */
  34879. hideLoadingUI(): void;
  34880. /**
  34881. * Gets the current loading screen object
  34882. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34883. */
  34884. get loadingScreen(): ILoadingScreen;
  34885. /**
  34886. * Sets the current loading screen object
  34887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34888. */
  34889. set loadingScreen(loadingScreen: ILoadingScreen);
  34890. /**
  34891. * Sets the current loading screen text
  34892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34893. */
  34894. set loadingUIText(text: string);
  34895. /**
  34896. * Sets the current loading screen background color
  34897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34898. */
  34899. set loadingUIBackgroundColor(color: string);
  34900. /** Pointerlock and fullscreen */
  34901. /**
  34902. * Ask the browser to promote the current element to pointerlock mode
  34903. * @param element defines the DOM element to promote
  34904. */
  34905. static _RequestPointerlock(element: HTMLElement): void;
  34906. /**
  34907. * Asks the browser to exit pointerlock mode
  34908. */
  34909. static _ExitPointerlock(): void;
  34910. /**
  34911. * Ask the browser to promote the current element to fullscreen rendering mode
  34912. * @param element defines the DOM element to promote
  34913. */
  34914. static _RequestFullscreen(element: HTMLElement): void;
  34915. /**
  34916. * Asks the browser to exit fullscreen mode
  34917. */
  34918. static _ExitFullscreen(): void;
  34919. }
  34920. }
  34921. declare module "babylonjs/Engines/engineStore" {
  34922. import { Nullable } from "babylonjs/types";
  34923. import { Engine } from "babylonjs/Engines/engine";
  34924. import { Scene } from "babylonjs/scene";
  34925. /**
  34926. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34927. * during the life time of the application.
  34928. */
  34929. export class EngineStore {
  34930. /** Gets the list of created engines */
  34931. static Instances: import("babylonjs/Engines/engine").Engine[];
  34932. /** @hidden */
  34933. static _LastCreatedScene: Nullable<Scene>;
  34934. /**
  34935. * Gets the latest created engine
  34936. */
  34937. static get LastCreatedEngine(): Nullable<Engine>;
  34938. /**
  34939. * Gets the latest created scene
  34940. */
  34941. static get LastCreatedScene(): Nullable<Scene>;
  34942. /**
  34943. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34944. * @ignorenaming
  34945. */
  34946. static UseFallbackTexture: boolean;
  34947. /**
  34948. * Texture content used if a texture cannot loaded
  34949. * @ignorenaming
  34950. */
  34951. static FallbackTexture: string;
  34952. }
  34953. }
  34954. declare module "babylonjs/Misc/promise" {
  34955. /**
  34956. * Helper class that provides a small promise polyfill
  34957. */
  34958. export class PromisePolyfill {
  34959. /**
  34960. * Static function used to check if the polyfill is required
  34961. * If this is the case then the function will inject the polyfill to window.Promise
  34962. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34963. */
  34964. static Apply(force?: boolean): void;
  34965. }
  34966. }
  34967. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34968. /**
  34969. * Interface for screenshot methods with describe argument called `size` as object with options
  34970. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34971. */
  34972. export interface IScreenshotSize {
  34973. /**
  34974. * number in pixels for canvas height
  34975. */
  34976. height?: number;
  34977. /**
  34978. * multiplier allowing render at a higher or lower resolution
  34979. * If value is defined then height and width will be ignored and taken from camera
  34980. */
  34981. precision?: number;
  34982. /**
  34983. * number in pixels for canvas width
  34984. */
  34985. width?: number;
  34986. }
  34987. }
  34988. declare module "babylonjs/Misc/tools" {
  34989. import { Nullable, float } from "babylonjs/types";
  34990. import { DomManagement } from "babylonjs/Misc/domManagement";
  34991. import { WebRequest } from "babylonjs/Misc/webRequest";
  34992. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34993. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34994. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34995. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34996. import { Camera } from "babylonjs/Cameras/camera";
  34997. import { Engine } from "babylonjs/Engines/engine";
  34998. interface IColor4Like {
  34999. r: float;
  35000. g: float;
  35001. b: float;
  35002. a: float;
  35003. }
  35004. /**
  35005. * Class containing a set of static utilities functions
  35006. */
  35007. export class Tools {
  35008. /**
  35009. * Gets or sets the base URL to use to load assets
  35010. */
  35011. static get BaseUrl(): string;
  35012. static set BaseUrl(value: string);
  35013. /**
  35014. * Enable/Disable Custom HTTP Request Headers globally.
  35015. * default = false
  35016. * @see CustomRequestHeaders
  35017. */
  35018. static UseCustomRequestHeaders: boolean;
  35019. /**
  35020. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35021. * i.e. when loading files, where the server/service expects an Authorization header
  35022. */
  35023. static CustomRequestHeaders: {
  35024. [key: string]: string;
  35025. };
  35026. /**
  35027. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35028. */
  35029. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35030. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35031. /**
  35032. * Default behaviour for cors in the application.
  35033. * It can be a string if the expected behavior is identical in the entire app.
  35034. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35035. */
  35036. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35037. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35038. /**
  35039. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35040. * @ignorenaming
  35041. */
  35042. static get UseFallbackTexture(): boolean;
  35043. static set UseFallbackTexture(value: boolean);
  35044. /**
  35045. * Use this object to register external classes like custom textures or material
  35046. * to allow the laoders to instantiate them
  35047. */
  35048. static get RegisteredExternalClasses(): {
  35049. [key: string]: Object;
  35050. };
  35051. static set RegisteredExternalClasses(classes: {
  35052. [key: string]: Object;
  35053. });
  35054. /**
  35055. * Texture content used if a texture cannot loaded
  35056. * @ignorenaming
  35057. */
  35058. static get fallbackTexture(): string;
  35059. static set fallbackTexture(value: string);
  35060. /**
  35061. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35062. * @param u defines the coordinate on X axis
  35063. * @param v defines the coordinate on Y axis
  35064. * @param width defines the width of the source data
  35065. * @param height defines the height of the source data
  35066. * @param pixels defines the source byte array
  35067. * @param color defines the output color
  35068. */
  35069. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35070. /**
  35071. * Interpolates between a and b via alpha
  35072. * @param a The lower value (returned when alpha = 0)
  35073. * @param b The upper value (returned when alpha = 1)
  35074. * @param alpha The interpolation-factor
  35075. * @return The mixed value
  35076. */
  35077. static Mix(a: number, b: number, alpha: number): number;
  35078. /**
  35079. * Tries to instantiate a new object from a given class name
  35080. * @param className defines the class name to instantiate
  35081. * @returns the new object or null if the system was not able to do the instantiation
  35082. */
  35083. static Instantiate(className: string): any;
  35084. /**
  35085. * Provides a slice function that will work even on IE
  35086. * @param data defines the array to slice
  35087. * @param start defines the start of the data (optional)
  35088. * @param end defines the end of the data (optional)
  35089. * @returns the new sliced array
  35090. */
  35091. static Slice<T>(data: T, start?: number, end?: number): T;
  35092. /**
  35093. * Polyfill for setImmediate
  35094. * @param action defines the action to execute after the current execution block
  35095. */
  35096. static SetImmediate(action: () => void): void;
  35097. /**
  35098. * Function indicating if a number is an exponent of 2
  35099. * @param value defines the value to test
  35100. * @returns true if the value is an exponent of 2
  35101. */
  35102. static IsExponentOfTwo(value: number): boolean;
  35103. private static _tmpFloatArray;
  35104. /**
  35105. * Returns the nearest 32-bit single precision float representation of a Number
  35106. * @param value A Number. If the parameter is of a different type, it will get converted
  35107. * to a number or to NaN if it cannot be converted
  35108. * @returns number
  35109. */
  35110. static FloatRound(value: number): number;
  35111. /**
  35112. * Extracts the filename from a path
  35113. * @param path defines the path to use
  35114. * @returns the filename
  35115. */
  35116. static GetFilename(path: string): string;
  35117. /**
  35118. * Extracts the "folder" part of a path (everything before the filename).
  35119. * @param uri The URI to extract the info from
  35120. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35121. * @returns The "folder" part of the path
  35122. */
  35123. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35124. /**
  35125. * Extracts text content from a DOM element hierarchy
  35126. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35127. */
  35128. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35129. /**
  35130. * Convert an angle in radians to degrees
  35131. * @param angle defines the angle to convert
  35132. * @returns the angle in degrees
  35133. */
  35134. static ToDegrees(angle: number): number;
  35135. /**
  35136. * Convert an angle in degrees to radians
  35137. * @param angle defines the angle to convert
  35138. * @returns the angle in radians
  35139. */
  35140. static ToRadians(angle: number): number;
  35141. /**
  35142. * Returns an array if obj is not an array
  35143. * @param obj defines the object to evaluate as an array
  35144. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35145. * @returns either obj directly if obj is an array or a new array containing obj
  35146. */
  35147. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35148. /**
  35149. * Gets the pointer prefix to use
  35150. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35151. */
  35152. static GetPointerPrefix(): string;
  35153. /**
  35154. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35155. * @param url define the url we are trying
  35156. * @param element define the dom element where to configure the cors policy
  35157. */
  35158. static SetCorsBehavior(url: string | string[], element: {
  35159. crossOrigin: string | null;
  35160. }): void;
  35161. /**
  35162. * Removes unwanted characters from an url
  35163. * @param url defines the url to clean
  35164. * @returns the cleaned url
  35165. */
  35166. static CleanUrl(url: string): string;
  35167. /**
  35168. * Gets or sets a function used to pre-process url before using them to load assets
  35169. */
  35170. static get PreprocessUrl(): (url: string) => string;
  35171. static set PreprocessUrl(processor: (url: string) => string);
  35172. /**
  35173. * Loads an image as an HTMLImageElement.
  35174. * @param input url string, ArrayBuffer, or Blob to load
  35175. * @param onLoad callback called when the image successfully loads
  35176. * @param onError callback called when the image fails to load
  35177. * @param offlineProvider offline provider for caching
  35178. * @param mimeType optional mime type
  35179. * @returns the HTMLImageElement of the loaded image
  35180. */
  35181. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35182. /**
  35183. * Loads a file from a url
  35184. * @param url url string, ArrayBuffer, or Blob to load
  35185. * @param onSuccess callback called when the file successfully loads
  35186. * @param onProgress callback called while file is loading (if the server supports this mode)
  35187. * @param offlineProvider defines the offline provider for caching
  35188. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35189. * @param onError callback called when the file fails to load
  35190. * @returns a file request object
  35191. */
  35192. 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;
  35193. /**
  35194. * Loads a file from a url
  35195. * @param url the file url to load
  35196. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35197. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35198. */
  35199. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35200. /**
  35201. * Load a script (identified by an url). When the url returns, the
  35202. * content of this file is added into a new script element, attached to the DOM (body element)
  35203. * @param scriptUrl defines the url of the script to laod
  35204. * @param onSuccess defines the callback called when the script is loaded
  35205. * @param onError defines the callback to call if an error occurs
  35206. * @param scriptId defines the id of the script element
  35207. */
  35208. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35209. /**
  35210. * Load an asynchronous script (identified by an url). When the url returns, the
  35211. * content of this file is added into a new script element, attached to the DOM (body element)
  35212. * @param scriptUrl defines the url of the script to laod
  35213. * @param scriptId defines the id of the script element
  35214. * @returns a promise request object
  35215. */
  35216. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35217. /**
  35218. * Loads a file from a blob
  35219. * @param fileToLoad defines the blob to use
  35220. * @param callback defines the callback to call when data is loaded
  35221. * @param progressCallback defines the callback to call during loading process
  35222. * @returns a file request object
  35223. */
  35224. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35225. /**
  35226. * Reads a file from a File object
  35227. * @param file defines the file to load
  35228. * @param onSuccess defines the callback to call when data is loaded
  35229. * @param onProgress defines the callback to call during loading process
  35230. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35231. * @param onError defines the callback to call when an error occurs
  35232. * @returns a file request object
  35233. */
  35234. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35235. /**
  35236. * Creates a data url from a given string content
  35237. * @param content defines the content to convert
  35238. * @returns the new data url link
  35239. */
  35240. static FileAsURL(content: string): string;
  35241. /**
  35242. * Format the given number to a specific decimal format
  35243. * @param value defines the number to format
  35244. * @param decimals defines the number of decimals to use
  35245. * @returns the formatted string
  35246. */
  35247. static Format(value: number, decimals?: number): string;
  35248. /**
  35249. * Tries to copy an object by duplicating every property
  35250. * @param source defines the source object
  35251. * @param destination defines the target object
  35252. * @param doNotCopyList defines a list of properties to avoid
  35253. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35254. */
  35255. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35256. /**
  35257. * Gets a boolean indicating if the given object has no own property
  35258. * @param obj defines the object to test
  35259. * @returns true if object has no own property
  35260. */
  35261. static IsEmpty(obj: any): boolean;
  35262. /**
  35263. * Function used to register events at window level
  35264. * @param windowElement defines the Window object to use
  35265. * @param events defines the events to register
  35266. */
  35267. static RegisterTopRootEvents(windowElement: Window, events: {
  35268. name: string;
  35269. handler: Nullable<(e: FocusEvent) => any>;
  35270. }[]): void;
  35271. /**
  35272. * Function used to unregister events from window level
  35273. * @param windowElement defines the Window object to use
  35274. * @param events defines the events to unregister
  35275. */
  35276. static UnregisterTopRootEvents(windowElement: Window, events: {
  35277. name: string;
  35278. handler: Nullable<(e: FocusEvent) => any>;
  35279. }[]): void;
  35280. /**
  35281. * @ignore
  35282. */
  35283. static _ScreenshotCanvas: HTMLCanvasElement;
  35284. /**
  35285. * Dumps the current bound framebuffer
  35286. * @param width defines the rendering width
  35287. * @param height defines the rendering height
  35288. * @param engine defines the hosting engine
  35289. * @param successCallback defines the callback triggered once the data are available
  35290. * @param mimeType defines the mime type of the result
  35291. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35292. */
  35293. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35294. /**
  35295. * Converts the canvas data to blob.
  35296. * This acts as a polyfill for browsers not supporting the to blob function.
  35297. * @param canvas Defines the canvas to extract the data from
  35298. * @param successCallback Defines the callback triggered once the data are available
  35299. * @param mimeType Defines the mime type of the result
  35300. */
  35301. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35302. /**
  35303. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35304. * @param successCallback defines the callback triggered once the data are available
  35305. * @param mimeType defines the mime type of the result
  35306. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35307. */
  35308. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35309. /**
  35310. * Downloads a blob in the browser
  35311. * @param blob defines the blob to download
  35312. * @param fileName defines the name of the downloaded file
  35313. */
  35314. static Download(blob: Blob, fileName: string): void;
  35315. /**
  35316. * Captures a screenshot of the current rendering
  35317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35318. * @param engine defines the rendering engine
  35319. * @param camera defines the source camera
  35320. * @param size This parameter can be set to a single number or to an object with the
  35321. * following (optional) properties: precision, width, height. If a single number is passed,
  35322. * it will be used for both width and height. If an object is passed, the screenshot size
  35323. * will be derived from the parameters. The precision property is a multiplier allowing
  35324. * rendering at a higher or lower resolution
  35325. * @param successCallback defines the callback receives a single parameter which contains the
  35326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35327. * src parameter of an <img> to display it
  35328. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35329. * Check your browser for supported MIME types
  35330. */
  35331. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35332. /**
  35333. * Captures a screenshot of the current rendering
  35334. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35335. * @param engine defines the rendering engine
  35336. * @param camera defines the source camera
  35337. * @param size This parameter can be set to a single number or to an object with the
  35338. * following (optional) properties: precision, width, height. If a single number is passed,
  35339. * it will be used for both width and height. If an object is passed, the screenshot size
  35340. * will be derived from the parameters. The precision property is a multiplier allowing
  35341. * rendering at a higher or lower resolution
  35342. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35343. * Check your browser for supported MIME types
  35344. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35345. * to the src parameter of an <img> to display it
  35346. */
  35347. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35348. /**
  35349. * Generates an image screenshot from the specified camera.
  35350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35351. * @param engine The engine to use for rendering
  35352. * @param camera The camera to use for rendering
  35353. * @param size This parameter can be set to a single number or to an object with the
  35354. * following (optional) properties: precision, width, height. If a single number is passed,
  35355. * it will be used for both width and height. If an object is passed, the screenshot size
  35356. * will be derived from the parameters. The precision property is a multiplier allowing
  35357. * rendering at a higher or lower resolution
  35358. * @param successCallback The callback receives a single parameter which contains the
  35359. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35360. * src parameter of an <img> to display it
  35361. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35362. * Check your browser for supported MIME types
  35363. * @param samples Texture samples (default: 1)
  35364. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35365. * @param fileName A name for for the downloaded file.
  35366. */
  35367. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35368. /**
  35369. * Generates an image screenshot from the specified camera.
  35370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35371. * @param engine The engine to use for rendering
  35372. * @param camera The camera to use for rendering
  35373. * @param size This parameter can be set to a single number or to an object with the
  35374. * following (optional) properties: precision, width, height. If a single number is passed,
  35375. * it will be used for both width and height. If an object is passed, the screenshot size
  35376. * will be derived from the parameters. The precision property is a multiplier allowing
  35377. * rendering at a higher or lower resolution
  35378. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35379. * Check your browser for supported MIME types
  35380. * @param samples Texture samples (default: 1)
  35381. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35382. * @param fileName A name for for the downloaded file.
  35383. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35384. * to the src parameter of an <img> to display it
  35385. */
  35386. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35387. /**
  35388. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35389. * Be aware Math.random() could cause collisions, but:
  35390. * "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"
  35391. * @returns a pseudo random id
  35392. */
  35393. static RandomId(): string;
  35394. /**
  35395. * Test if the given uri is a base64 string
  35396. * @param uri The uri to test
  35397. * @return True if the uri is a base64 string or false otherwise
  35398. */
  35399. static IsBase64(uri: string): boolean;
  35400. /**
  35401. * Decode the given base64 uri.
  35402. * @param uri The uri to decode
  35403. * @return The decoded base64 data.
  35404. */
  35405. static DecodeBase64(uri: string): ArrayBuffer;
  35406. /**
  35407. * Gets the absolute url.
  35408. * @param url the input url
  35409. * @return the absolute url
  35410. */
  35411. static GetAbsoluteUrl(url: string): string;
  35412. /**
  35413. * No log
  35414. */
  35415. static readonly NoneLogLevel: number;
  35416. /**
  35417. * Only message logs
  35418. */
  35419. static readonly MessageLogLevel: number;
  35420. /**
  35421. * Only warning logs
  35422. */
  35423. static readonly WarningLogLevel: number;
  35424. /**
  35425. * Only error logs
  35426. */
  35427. static readonly ErrorLogLevel: number;
  35428. /**
  35429. * All logs
  35430. */
  35431. static readonly AllLogLevel: number;
  35432. /**
  35433. * Gets a value indicating the number of loading errors
  35434. * @ignorenaming
  35435. */
  35436. static get errorsCount(): number;
  35437. /**
  35438. * Callback called when a new log is added
  35439. */
  35440. static OnNewCacheEntry: (entry: string) => void;
  35441. /**
  35442. * Log a message to the console
  35443. * @param message defines the message to log
  35444. */
  35445. static Log(message: string): void;
  35446. /**
  35447. * Write a warning message to the console
  35448. * @param message defines the message to log
  35449. */
  35450. static Warn(message: string): void;
  35451. /**
  35452. * Write an error message to the console
  35453. * @param message defines the message to log
  35454. */
  35455. static Error(message: string): void;
  35456. /**
  35457. * Gets current log cache (list of logs)
  35458. */
  35459. static get LogCache(): string;
  35460. /**
  35461. * Clears the log cache
  35462. */
  35463. static ClearLogCache(): void;
  35464. /**
  35465. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35466. */
  35467. static set LogLevels(level: number);
  35468. /**
  35469. * Checks if the window object exists
  35470. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35471. */
  35472. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35473. /**
  35474. * No performance log
  35475. */
  35476. static readonly PerformanceNoneLogLevel: number;
  35477. /**
  35478. * Use user marks to log performance
  35479. */
  35480. static readonly PerformanceUserMarkLogLevel: number;
  35481. /**
  35482. * Log performance to the console
  35483. */
  35484. static readonly PerformanceConsoleLogLevel: number;
  35485. private static _performance;
  35486. /**
  35487. * Sets the current performance log level
  35488. */
  35489. static set PerformanceLogLevel(level: number);
  35490. private static _StartPerformanceCounterDisabled;
  35491. private static _EndPerformanceCounterDisabled;
  35492. private static _StartUserMark;
  35493. private static _EndUserMark;
  35494. private static _StartPerformanceConsole;
  35495. private static _EndPerformanceConsole;
  35496. /**
  35497. * Starts a performance counter
  35498. */
  35499. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35500. /**
  35501. * Ends a specific performance coutner
  35502. */
  35503. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35504. /**
  35505. * Gets either window.performance.now() if supported or Date.now() else
  35506. */
  35507. static get Now(): number;
  35508. /**
  35509. * This method will return the name of the class used to create the instance of the given object.
  35510. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35511. * @param object the object to get the class name from
  35512. * @param isType defines if the object is actually a type
  35513. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35514. */
  35515. static GetClassName(object: any, isType?: boolean): string;
  35516. /**
  35517. * Gets the first element of an array satisfying a given predicate
  35518. * @param array defines the array to browse
  35519. * @param predicate defines the predicate to use
  35520. * @returns null if not found or the element
  35521. */
  35522. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35523. /**
  35524. * This method will return the name of the full name of the class, including its owning module (if any).
  35525. * 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).
  35526. * @param object the object to get the class name from
  35527. * @param isType defines if the object is actually a type
  35528. * @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.
  35529. * @ignorenaming
  35530. */
  35531. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35532. /**
  35533. * Returns a promise that resolves after the given amount of time.
  35534. * @param delay Number of milliseconds to delay
  35535. * @returns Promise that resolves after the given amount of time
  35536. */
  35537. static DelayAsync(delay: number): Promise<void>;
  35538. /**
  35539. * Utility function to detect if the current user agent is Safari
  35540. * @returns whether or not the current user agent is safari
  35541. */
  35542. static IsSafari(): boolean;
  35543. }
  35544. /**
  35545. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35546. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35547. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35548. * @param name The name of the class, case should be preserved
  35549. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35550. */
  35551. export function className(name: string, module?: string): (target: Object) => void;
  35552. /**
  35553. * An implementation of a loop for asynchronous functions.
  35554. */
  35555. export class AsyncLoop {
  35556. /**
  35557. * Defines the number of iterations for the loop
  35558. */
  35559. iterations: number;
  35560. /**
  35561. * Defines the current index of the loop.
  35562. */
  35563. index: number;
  35564. private _done;
  35565. private _fn;
  35566. private _successCallback;
  35567. /**
  35568. * Constructor.
  35569. * @param iterations the number of iterations.
  35570. * @param func the function to run each iteration
  35571. * @param successCallback the callback that will be called upon succesful execution
  35572. * @param offset starting offset.
  35573. */
  35574. constructor(
  35575. /**
  35576. * Defines the number of iterations for the loop
  35577. */
  35578. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35579. /**
  35580. * Execute the next iteration. Must be called after the last iteration was finished.
  35581. */
  35582. executeNext(): void;
  35583. /**
  35584. * Break the loop and run the success callback.
  35585. */
  35586. breakLoop(): void;
  35587. /**
  35588. * Create and run an async loop.
  35589. * @param iterations the number of iterations.
  35590. * @param fn the function to run each iteration
  35591. * @param successCallback the callback that will be called upon succesful execution
  35592. * @param offset starting offset.
  35593. * @returns the created async loop object
  35594. */
  35595. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35596. /**
  35597. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35598. * @param iterations total number of iterations
  35599. * @param syncedIterations number of synchronous iterations in each async iteration.
  35600. * @param fn the function to call each iteration.
  35601. * @param callback a success call back that will be called when iterating stops.
  35602. * @param breakFunction a break condition (optional)
  35603. * @param timeout timeout settings for the setTimeout function. default - 0.
  35604. * @returns the created async loop object
  35605. */
  35606. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35607. }
  35608. }
  35609. declare module "babylonjs/Misc/stringDictionary" {
  35610. import { Nullable } from "babylonjs/types";
  35611. /**
  35612. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35613. * The underlying implementation relies on an associative array to ensure the best performances.
  35614. * The value can be anything including 'null' but except 'undefined'
  35615. */
  35616. export class StringDictionary<T> {
  35617. /**
  35618. * This will clear this dictionary and copy the content from the 'source' one.
  35619. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35620. * @param source the dictionary to take the content from and copy to this dictionary
  35621. */
  35622. copyFrom(source: StringDictionary<T>): void;
  35623. /**
  35624. * Get a value based from its key
  35625. * @param key the given key to get the matching value from
  35626. * @return the value if found, otherwise undefined is returned
  35627. */
  35628. get(key: string): T | undefined;
  35629. /**
  35630. * Get a value from its key or add it if it doesn't exist.
  35631. * This method will ensure you that a given key/data will be present in the dictionary.
  35632. * @param key the given key to get the matching value from
  35633. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35634. * The factory will only be invoked if there's no data for the given key.
  35635. * @return the value corresponding to the key.
  35636. */
  35637. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35638. /**
  35639. * Get a value from its key if present in the dictionary otherwise add it
  35640. * @param key the key to get the value from
  35641. * @param val if there's no such key/value pair in the dictionary add it with this value
  35642. * @return the value corresponding to the key
  35643. */
  35644. getOrAdd(key: string, val: T): T;
  35645. /**
  35646. * Check if there's a given key in the dictionary
  35647. * @param key the key to check for
  35648. * @return true if the key is present, false otherwise
  35649. */
  35650. contains(key: string): boolean;
  35651. /**
  35652. * Add a new key and its corresponding value
  35653. * @param key the key to add
  35654. * @param value the value corresponding to the key
  35655. * @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
  35656. */
  35657. add(key: string, value: T): boolean;
  35658. /**
  35659. * Update a specific value associated to a key
  35660. * @param key defines the key to use
  35661. * @param value defines the value to store
  35662. * @returns true if the value was updated (or false if the key was not found)
  35663. */
  35664. set(key: string, value: T): boolean;
  35665. /**
  35666. * Get the element of the given key and remove it from the dictionary
  35667. * @param key defines the key to search
  35668. * @returns the value associated with the key or null if not found
  35669. */
  35670. getAndRemove(key: string): Nullable<T>;
  35671. /**
  35672. * Remove a key/value from the dictionary.
  35673. * @param key the key to remove
  35674. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35675. */
  35676. remove(key: string): boolean;
  35677. /**
  35678. * Clear the whole content of the dictionary
  35679. */
  35680. clear(): void;
  35681. /**
  35682. * Gets the current count
  35683. */
  35684. get count(): number;
  35685. /**
  35686. * Execute a callback on each key/val of the dictionary.
  35687. * Note that you can remove any element in this dictionary in the callback implementation
  35688. * @param callback the callback to execute on a given key/value pair
  35689. */
  35690. forEach(callback: (key: string, val: T) => void): void;
  35691. /**
  35692. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35693. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35694. * Note that you can remove any element in this dictionary in the callback implementation
  35695. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35696. * @returns the first item
  35697. */
  35698. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35699. private _count;
  35700. private _data;
  35701. }
  35702. }
  35703. declare module "babylonjs/Collisions/collisionCoordinator" {
  35704. import { Nullable } from "babylonjs/types";
  35705. import { Scene } from "babylonjs/scene";
  35706. import { Vector3 } from "babylonjs/Maths/math.vector";
  35707. import { Collider } from "babylonjs/Collisions/collider";
  35708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35709. /** @hidden */
  35710. export interface ICollisionCoordinator {
  35711. createCollider(): Collider;
  35712. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35713. init(scene: Scene): void;
  35714. }
  35715. /** @hidden */
  35716. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35717. private _scene;
  35718. private _scaledPosition;
  35719. private _scaledVelocity;
  35720. private _finalPosition;
  35721. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35722. createCollider(): Collider;
  35723. init(scene: Scene): void;
  35724. private _collideWithWorld;
  35725. }
  35726. }
  35727. declare module "babylonjs/Inputs/scene.inputManager" {
  35728. import { Nullable } from "babylonjs/types";
  35729. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35730. import { Vector2 } from "babylonjs/Maths/math.vector";
  35731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35732. import { Scene } from "babylonjs/scene";
  35733. /**
  35734. * Class used to manage all inputs for the scene.
  35735. */
  35736. export class InputManager {
  35737. /** The distance in pixel that you have to move to prevent some events */
  35738. static DragMovementThreshold: number;
  35739. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35740. static LongPressDelay: number;
  35741. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35742. static DoubleClickDelay: number;
  35743. /** If you need to check double click without raising a single click at first click, enable this flag */
  35744. static ExclusiveDoubleClickMode: boolean;
  35745. private _wheelEventName;
  35746. private _onPointerMove;
  35747. private _onPointerDown;
  35748. private _onPointerUp;
  35749. private _initClickEvent;
  35750. private _initActionManager;
  35751. private _delayedSimpleClick;
  35752. private _delayedSimpleClickTimeout;
  35753. private _previousDelayedSimpleClickTimeout;
  35754. private _meshPickProceed;
  35755. private _previousButtonPressed;
  35756. private _currentPickResult;
  35757. private _previousPickResult;
  35758. private _totalPointersPressed;
  35759. private _doubleClickOccured;
  35760. private _pointerOverMesh;
  35761. private _pickedDownMesh;
  35762. private _pickedUpMesh;
  35763. private _pointerX;
  35764. private _pointerY;
  35765. private _unTranslatedPointerX;
  35766. private _unTranslatedPointerY;
  35767. private _startingPointerPosition;
  35768. private _previousStartingPointerPosition;
  35769. private _startingPointerTime;
  35770. private _previousStartingPointerTime;
  35771. private _pointerCaptures;
  35772. private _onKeyDown;
  35773. private _onKeyUp;
  35774. private _onCanvasFocusObserver;
  35775. private _onCanvasBlurObserver;
  35776. private _scene;
  35777. /**
  35778. * Creates a new InputManager
  35779. * @param scene defines the hosting scene
  35780. */
  35781. constructor(scene: Scene);
  35782. /**
  35783. * Gets the mesh that is currently under the pointer
  35784. */
  35785. get meshUnderPointer(): Nullable<AbstractMesh>;
  35786. /**
  35787. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35788. */
  35789. get unTranslatedPointer(): Vector2;
  35790. /**
  35791. * Gets or sets the current on-screen X position of the pointer
  35792. */
  35793. get pointerX(): number;
  35794. set pointerX(value: number);
  35795. /**
  35796. * Gets or sets the current on-screen Y position of the pointer
  35797. */
  35798. get pointerY(): number;
  35799. set pointerY(value: number);
  35800. private _updatePointerPosition;
  35801. private _processPointerMove;
  35802. private _setRayOnPointerInfo;
  35803. private _checkPrePointerObservable;
  35804. /**
  35805. * Use this method to simulate a pointer move on a mesh
  35806. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35807. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35808. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35809. */
  35810. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35811. /**
  35812. * Use this method to simulate a pointer down on a mesh
  35813. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35814. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35815. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35816. */
  35817. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35818. private _processPointerDown;
  35819. /** @hidden */
  35820. _isPointerSwiping(): boolean;
  35821. /**
  35822. * Use this method to simulate a pointer up on a mesh
  35823. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35824. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35825. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35826. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35827. */
  35828. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35829. private _processPointerUp;
  35830. /**
  35831. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35832. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35833. * @returns true if the pointer was captured
  35834. */
  35835. isPointerCaptured(pointerId?: number): boolean;
  35836. /**
  35837. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35838. * @param attachUp defines if you want to attach events to pointerup
  35839. * @param attachDown defines if you want to attach events to pointerdown
  35840. * @param attachMove defines if you want to attach events to pointermove
  35841. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35842. */
  35843. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35844. /**
  35845. * Detaches all event handlers
  35846. */
  35847. detachControl(): void;
  35848. /**
  35849. * Force the value of meshUnderPointer
  35850. * @param mesh defines the mesh to use
  35851. */
  35852. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35853. /**
  35854. * Gets the mesh under the pointer
  35855. * @returns a Mesh or null if no mesh is under the pointer
  35856. */
  35857. getPointerOverMesh(): Nullable<AbstractMesh>;
  35858. }
  35859. }
  35860. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35861. /**
  35862. * Helper class used to generate session unique ID
  35863. */
  35864. export class UniqueIdGenerator {
  35865. private static _UniqueIdCounter;
  35866. /**
  35867. * Gets an unique (relatively to the current scene) Id
  35868. */
  35869. static get UniqueId(): number;
  35870. }
  35871. }
  35872. declare module "babylonjs/Animations/animationGroup" {
  35873. import { Animatable } from "babylonjs/Animations/animatable";
  35874. import { Animation } from "babylonjs/Animations/animation";
  35875. import { Scene, IDisposable } from "babylonjs/scene";
  35876. import { Observable } from "babylonjs/Misc/observable";
  35877. import { Nullable } from "babylonjs/types";
  35878. import "babylonjs/Animations/animatable";
  35879. /**
  35880. * This class defines the direct association between an animation and a target
  35881. */
  35882. export class TargetedAnimation {
  35883. /**
  35884. * Animation to perform
  35885. */
  35886. animation: Animation;
  35887. /**
  35888. * Target to animate
  35889. */
  35890. target: any;
  35891. /**
  35892. * Serialize the object
  35893. * @returns the JSON object representing the current entity
  35894. */
  35895. serialize(): any;
  35896. }
  35897. /**
  35898. * Use this class to create coordinated animations on multiple targets
  35899. */
  35900. export class AnimationGroup implements IDisposable {
  35901. /** The name of the animation group */
  35902. name: string;
  35903. private _scene;
  35904. private _targetedAnimations;
  35905. private _animatables;
  35906. private _from;
  35907. private _to;
  35908. private _isStarted;
  35909. private _isPaused;
  35910. private _speedRatio;
  35911. private _loopAnimation;
  35912. /**
  35913. * Gets or sets the unique id of the node
  35914. */
  35915. uniqueId: number;
  35916. /**
  35917. * This observable will notify when one animation have ended
  35918. */
  35919. onAnimationEndObservable: Observable<TargetedAnimation>;
  35920. /**
  35921. * Observer raised when one animation loops
  35922. */
  35923. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35924. /**
  35925. * Observer raised when all animations have looped
  35926. */
  35927. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35928. /**
  35929. * This observable will notify when all animations have ended.
  35930. */
  35931. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35932. /**
  35933. * This observable will notify when all animations have paused.
  35934. */
  35935. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35936. /**
  35937. * This observable will notify when all animations are playing.
  35938. */
  35939. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35940. /**
  35941. * Gets the first frame
  35942. */
  35943. get from(): number;
  35944. /**
  35945. * Gets the last frame
  35946. */
  35947. get to(): number;
  35948. /**
  35949. * Define if the animations are started
  35950. */
  35951. get isStarted(): boolean;
  35952. /**
  35953. * Gets a value indicating that the current group is playing
  35954. */
  35955. get isPlaying(): boolean;
  35956. /**
  35957. * Gets or sets the speed ratio to use for all animations
  35958. */
  35959. get speedRatio(): number;
  35960. /**
  35961. * Gets or sets the speed ratio to use for all animations
  35962. */
  35963. set speedRatio(value: number);
  35964. /**
  35965. * Gets or sets if all animations should loop or not
  35966. */
  35967. get loopAnimation(): boolean;
  35968. set loopAnimation(value: boolean);
  35969. /**
  35970. * Gets the targeted animations for this animation group
  35971. */
  35972. get targetedAnimations(): Array<TargetedAnimation>;
  35973. /**
  35974. * returning the list of animatables controlled by this animation group.
  35975. */
  35976. get animatables(): Array<Animatable>;
  35977. /**
  35978. * Instantiates a new Animation Group.
  35979. * This helps managing several animations at once.
  35980. * @see http://doc.babylonjs.com/how_to/group
  35981. * @param name Defines the name of the group
  35982. * @param scene Defines the scene the group belongs to
  35983. */
  35984. constructor(
  35985. /** The name of the animation group */
  35986. name: string, scene?: Nullable<Scene>);
  35987. /**
  35988. * Add an animation (with its target) in the group
  35989. * @param animation defines the animation we want to add
  35990. * @param target defines the target of the animation
  35991. * @returns the TargetedAnimation object
  35992. */
  35993. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35994. /**
  35995. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35996. * It can add constant keys at begin or end
  35997. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35998. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35999. * @returns the animation group
  36000. */
  36001. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36002. private _animationLoopCount;
  36003. private _animationLoopFlags;
  36004. private _processLoop;
  36005. /**
  36006. * Start all animations on given targets
  36007. * @param loop defines if animations must loop
  36008. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36009. * @param from defines the from key (optional)
  36010. * @param to defines the to key (optional)
  36011. * @returns the current animation group
  36012. */
  36013. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  36014. /**
  36015. * Pause all animations
  36016. * @returns the animation group
  36017. */
  36018. pause(): AnimationGroup;
  36019. /**
  36020. * Play all animations to initial state
  36021. * This function will start() the animations if they were not started or will restart() them if they were paused
  36022. * @param loop defines if animations must loop
  36023. * @returns the animation group
  36024. */
  36025. play(loop?: boolean): AnimationGroup;
  36026. /**
  36027. * Reset all animations to initial state
  36028. * @returns the animation group
  36029. */
  36030. reset(): AnimationGroup;
  36031. /**
  36032. * Restart animations from key 0
  36033. * @returns the animation group
  36034. */
  36035. restart(): AnimationGroup;
  36036. /**
  36037. * Stop all animations
  36038. * @returns the animation group
  36039. */
  36040. stop(): AnimationGroup;
  36041. /**
  36042. * Set animation weight for all animatables
  36043. * @param weight defines the weight to use
  36044. * @return the animationGroup
  36045. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36046. */
  36047. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36048. /**
  36049. * Synchronize and normalize all animatables with a source animatable
  36050. * @param root defines the root animatable to synchronize with
  36051. * @return the animationGroup
  36052. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36053. */
  36054. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36055. /**
  36056. * Goes to a specific frame in this animation group
  36057. * @param frame the frame number to go to
  36058. * @return the animationGroup
  36059. */
  36060. goToFrame(frame: number): AnimationGroup;
  36061. /**
  36062. * Dispose all associated resources
  36063. */
  36064. dispose(): void;
  36065. private _checkAnimationGroupEnded;
  36066. /**
  36067. * Clone the current animation group and returns a copy
  36068. * @param newName defines the name of the new group
  36069. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36070. * @returns the new aniamtion group
  36071. */
  36072. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36073. /**
  36074. * Serializes the animationGroup to an object
  36075. * @returns Serialized object
  36076. */
  36077. serialize(): any;
  36078. /**
  36079. * Returns a new AnimationGroup object parsed from the source provided.
  36080. * @param parsedAnimationGroup defines the source
  36081. * @param scene defines the scene that will receive the animationGroup
  36082. * @returns a new AnimationGroup
  36083. */
  36084. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36085. /**
  36086. * Returns the string "AnimationGroup"
  36087. * @returns "AnimationGroup"
  36088. */
  36089. getClassName(): string;
  36090. /**
  36091. * Creates a detailled string about the object
  36092. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36093. * @returns a string representing the object
  36094. */
  36095. toString(fullDetails?: boolean): string;
  36096. }
  36097. }
  36098. declare module "babylonjs/scene" {
  36099. import { Nullable } from "babylonjs/types";
  36100. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36101. import { Observable } from "babylonjs/Misc/observable";
  36102. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36103. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36104. import { Geometry } from "babylonjs/Meshes/geometry";
  36105. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36106. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36108. import { Mesh } from "babylonjs/Meshes/mesh";
  36109. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36110. import { Bone } from "babylonjs/Bones/bone";
  36111. import { Skeleton } from "babylonjs/Bones/skeleton";
  36112. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36113. import { Camera } from "babylonjs/Cameras/camera";
  36114. import { AbstractScene } from "babylonjs/abstractScene";
  36115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36116. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36117. import { Material } from "babylonjs/Materials/material";
  36118. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36119. import { Effect } from "babylonjs/Materials/effect";
  36120. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36121. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36122. import { Light } from "babylonjs/Lights/light";
  36123. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36124. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36125. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36126. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36127. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36128. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36129. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36130. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36131. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36132. import { Engine } from "babylonjs/Engines/engine";
  36133. import { Node } from "babylonjs/node";
  36134. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36135. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36136. import { WebRequest } from "babylonjs/Misc/webRequest";
  36137. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36138. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36139. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36140. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36141. import { Plane } from "babylonjs/Maths/math.plane";
  36142. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36143. import { Ray } from "babylonjs/Culling/ray";
  36144. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36145. import { Animation } from "babylonjs/Animations/animation";
  36146. import { Animatable } from "babylonjs/Animations/animatable";
  36147. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36148. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36149. import { Collider } from "babylonjs/Collisions/collider";
  36150. /**
  36151. * Define an interface for all classes that will hold resources
  36152. */
  36153. export interface IDisposable {
  36154. /**
  36155. * Releases all held resources
  36156. */
  36157. dispose(): void;
  36158. }
  36159. /** Interface defining initialization parameters for Scene class */
  36160. export interface SceneOptions {
  36161. /**
  36162. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36163. * It will improve performance when the number of geometries becomes important.
  36164. */
  36165. useGeometryUniqueIdsMap?: boolean;
  36166. /**
  36167. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36168. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36169. */
  36170. useMaterialMeshMap?: boolean;
  36171. /**
  36172. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36173. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36174. */
  36175. useClonedMeshMap?: boolean;
  36176. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36177. virtual?: boolean;
  36178. }
  36179. /**
  36180. * Represents a scene to be rendered by the engine.
  36181. * @see http://doc.babylonjs.com/features/scene
  36182. */
  36183. export class Scene extends AbstractScene implements IAnimatable {
  36184. /** The fog is deactivated */
  36185. static readonly FOGMODE_NONE: number;
  36186. /** The fog density is following an exponential function */
  36187. static readonly FOGMODE_EXP: number;
  36188. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36189. static readonly FOGMODE_EXP2: number;
  36190. /** The fog density is following a linear function. */
  36191. static readonly FOGMODE_LINEAR: number;
  36192. /**
  36193. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36194. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36195. */
  36196. static MinDeltaTime: number;
  36197. /**
  36198. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36200. */
  36201. static MaxDeltaTime: number;
  36202. /**
  36203. * Factory used to create the default material.
  36204. * @param name The name of the material to create
  36205. * @param scene The scene to create the material for
  36206. * @returns The default material
  36207. */
  36208. static DefaultMaterialFactory(scene: Scene): Material;
  36209. /**
  36210. * Factory used to create the a collision coordinator.
  36211. * @returns The collision coordinator
  36212. */
  36213. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36214. /** @hidden */
  36215. _inputManager: InputManager;
  36216. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36217. cameraToUseForPointers: Nullable<Camera>;
  36218. /** @hidden */
  36219. readonly _isScene: boolean;
  36220. /** @hidden */
  36221. _blockEntityCollection: boolean;
  36222. /**
  36223. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36224. */
  36225. autoClear: boolean;
  36226. /**
  36227. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36228. */
  36229. autoClearDepthAndStencil: boolean;
  36230. /**
  36231. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36232. */
  36233. clearColor: Color4;
  36234. /**
  36235. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36236. */
  36237. ambientColor: Color3;
  36238. /**
  36239. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36240. * It should only be one of the following (if not the default embedded one):
  36241. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36242. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36243. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36244. * The material properties need to be setup according to the type of texture in use.
  36245. */
  36246. environmentBRDFTexture: BaseTexture;
  36247. /** @hidden */
  36248. protected _environmentTexture: Nullable<BaseTexture>;
  36249. /**
  36250. * Texture used in all pbr material as the reflection texture.
  36251. * As in the majority of the scene they are the same (exception for multi room and so on),
  36252. * this is easier to reference from here than from all the materials.
  36253. */
  36254. get environmentTexture(): Nullable<BaseTexture>;
  36255. /**
  36256. * Texture used in all pbr material as the reflection texture.
  36257. * As in the majority of the scene they are the same (exception for multi room and so on),
  36258. * this is easier to set here than in all the materials.
  36259. */
  36260. set environmentTexture(value: Nullable<BaseTexture>);
  36261. /** @hidden */
  36262. protected _environmentIntensity: number;
  36263. /**
  36264. * Intensity of the environment in all pbr material.
  36265. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36266. * As in the majority of the scene they are the same (exception for multi room and so on),
  36267. * this is easier to reference from here than from all the materials.
  36268. */
  36269. get environmentIntensity(): number;
  36270. /**
  36271. * Intensity of the environment in all pbr material.
  36272. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36273. * As in the majority of the scene they are the same (exception for multi room and so on),
  36274. * this is easier to set here than in all the materials.
  36275. */
  36276. set environmentIntensity(value: number);
  36277. /** @hidden */
  36278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36279. /**
  36280. * Default image processing configuration used either in the rendering
  36281. * Forward main pass or through the imageProcessingPostProcess if present.
  36282. * As in the majority of the scene they are the same (exception for multi camera),
  36283. * this is easier to reference from here than from all the materials and post process.
  36284. *
  36285. * No setter as we it is a shared configuration, you can set the values instead.
  36286. */
  36287. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36288. private _forceWireframe;
  36289. /**
  36290. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36291. */
  36292. set forceWireframe(value: boolean);
  36293. get forceWireframe(): boolean;
  36294. private _skipFrustumClipping;
  36295. /**
  36296. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36297. */
  36298. set skipFrustumClipping(value: boolean);
  36299. get skipFrustumClipping(): boolean;
  36300. private _forcePointsCloud;
  36301. /**
  36302. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36303. */
  36304. set forcePointsCloud(value: boolean);
  36305. get forcePointsCloud(): boolean;
  36306. /**
  36307. * Gets or sets the active clipplane 1
  36308. */
  36309. clipPlane: Nullable<Plane>;
  36310. /**
  36311. * Gets or sets the active clipplane 2
  36312. */
  36313. clipPlane2: Nullable<Plane>;
  36314. /**
  36315. * Gets or sets the active clipplane 3
  36316. */
  36317. clipPlane3: Nullable<Plane>;
  36318. /**
  36319. * Gets or sets the active clipplane 4
  36320. */
  36321. clipPlane4: Nullable<Plane>;
  36322. /**
  36323. * Gets or sets the active clipplane 5
  36324. */
  36325. clipPlane5: Nullable<Plane>;
  36326. /**
  36327. * Gets or sets the active clipplane 6
  36328. */
  36329. clipPlane6: Nullable<Plane>;
  36330. /**
  36331. * Gets or sets a boolean indicating if animations are enabled
  36332. */
  36333. animationsEnabled: boolean;
  36334. private _animationPropertiesOverride;
  36335. /**
  36336. * Gets or sets the animation properties override
  36337. */
  36338. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36339. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36340. /**
  36341. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36342. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36343. */
  36344. useConstantAnimationDeltaTime: boolean;
  36345. /**
  36346. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36347. * Please note that it requires to run a ray cast through the scene on every frame
  36348. */
  36349. constantlyUpdateMeshUnderPointer: boolean;
  36350. /**
  36351. * Defines the HTML cursor to use when hovering over interactive elements
  36352. */
  36353. hoverCursor: string;
  36354. /**
  36355. * Defines the HTML default cursor to use (empty by default)
  36356. */
  36357. defaultCursor: string;
  36358. /**
  36359. * Defines whether cursors are handled by the scene.
  36360. */
  36361. doNotHandleCursors: boolean;
  36362. /**
  36363. * This is used to call preventDefault() on pointer down
  36364. * in order to block unwanted artifacts like system double clicks
  36365. */
  36366. preventDefaultOnPointerDown: boolean;
  36367. /**
  36368. * This is used to call preventDefault() on pointer up
  36369. * in order to block unwanted artifacts like system double clicks
  36370. */
  36371. preventDefaultOnPointerUp: boolean;
  36372. /**
  36373. * Gets or sets user defined metadata
  36374. */
  36375. metadata: any;
  36376. /**
  36377. * For internal use only. Please do not use.
  36378. */
  36379. reservedDataStore: any;
  36380. /**
  36381. * Gets the name of the plugin used to load this scene (null by default)
  36382. */
  36383. loadingPluginName: string;
  36384. /**
  36385. * Use this array to add regular expressions used to disable offline support for specific urls
  36386. */
  36387. disableOfflineSupportExceptionRules: RegExp[];
  36388. /**
  36389. * An event triggered when the scene is disposed.
  36390. */
  36391. onDisposeObservable: Observable<Scene>;
  36392. private _onDisposeObserver;
  36393. /** Sets a function to be executed when this scene is disposed. */
  36394. set onDispose(callback: () => void);
  36395. /**
  36396. * An event triggered before rendering the scene (right after animations and physics)
  36397. */
  36398. onBeforeRenderObservable: Observable<Scene>;
  36399. private _onBeforeRenderObserver;
  36400. /** Sets a function to be executed before rendering this scene */
  36401. set beforeRender(callback: Nullable<() => void>);
  36402. /**
  36403. * An event triggered after rendering the scene
  36404. */
  36405. onAfterRenderObservable: Observable<Scene>;
  36406. /**
  36407. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36408. */
  36409. onAfterRenderCameraObservable: Observable<Camera>;
  36410. private _onAfterRenderObserver;
  36411. /** Sets a function to be executed after rendering this scene */
  36412. set afterRender(callback: Nullable<() => void>);
  36413. /**
  36414. * An event triggered before animating the scene
  36415. */
  36416. onBeforeAnimationsObservable: Observable<Scene>;
  36417. /**
  36418. * An event triggered after animations processing
  36419. */
  36420. onAfterAnimationsObservable: Observable<Scene>;
  36421. /**
  36422. * An event triggered before draw calls are ready to be sent
  36423. */
  36424. onBeforeDrawPhaseObservable: Observable<Scene>;
  36425. /**
  36426. * An event triggered after draw calls have been sent
  36427. */
  36428. onAfterDrawPhaseObservable: Observable<Scene>;
  36429. /**
  36430. * An event triggered when the scene is ready
  36431. */
  36432. onReadyObservable: Observable<Scene>;
  36433. /**
  36434. * An event triggered before rendering a camera
  36435. */
  36436. onBeforeCameraRenderObservable: Observable<Camera>;
  36437. private _onBeforeCameraRenderObserver;
  36438. /** Sets a function to be executed before rendering a camera*/
  36439. set beforeCameraRender(callback: () => void);
  36440. /**
  36441. * An event triggered after rendering a camera
  36442. */
  36443. onAfterCameraRenderObservable: Observable<Camera>;
  36444. private _onAfterCameraRenderObserver;
  36445. /** Sets a function to be executed after rendering a camera*/
  36446. set afterCameraRender(callback: () => void);
  36447. /**
  36448. * An event triggered when active meshes evaluation is about to start
  36449. */
  36450. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36451. /**
  36452. * An event triggered when active meshes evaluation is done
  36453. */
  36454. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36455. /**
  36456. * An event triggered when particles rendering is about to start
  36457. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36458. */
  36459. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36460. /**
  36461. * An event triggered when particles rendering is done
  36462. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36463. */
  36464. onAfterParticlesRenderingObservable: Observable<Scene>;
  36465. /**
  36466. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36467. */
  36468. onDataLoadedObservable: Observable<Scene>;
  36469. /**
  36470. * An event triggered when a camera is created
  36471. */
  36472. onNewCameraAddedObservable: Observable<Camera>;
  36473. /**
  36474. * An event triggered when a camera is removed
  36475. */
  36476. onCameraRemovedObservable: Observable<Camera>;
  36477. /**
  36478. * An event triggered when a light is created
  36479. */
  36480. onNewLightAddedObservable: Observable<Light>;
  36481. /**
  36482. * An event triggered when a light is removed
  36483. */
  36484. onLightRemovedObservable: Observable<Light>;
  36485. /**
  36486. * An event triggered when a geometry is created
  36487. */
  36488. onNewGeometryAddedObservable: Observable<Geometry>;
  36489. /**
  36490. * An event triggered when a geometry is removed
  36491. */
  36492. onGeometryRemovedObservable: Observable<Geometry>;
  36493. /**
  36494. * An event triggered when a transform node is created
  36495. */
  36496. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36497. /**
  36498. * An event triggered when a transform node is removed
  36499. */
  36500. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36501. /**
  36502. * An event triggered when a mesh is created
  36503. */
  36504. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36505. /**
  36506. * An event triggered when a mesh is removed
  36507. */
  36508. onMeshRemovedObservable: Observable<AbstractMesh>;
  36509. /**
  36510. * An event triggered when a skeleton is created
  36511. */
  36512. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36513. /**
  36514. * An event triggered when a skeleton is removed
  36515. */
  36516. onSkeletonRemovedObservable: Observable<Skeleton>;
  36517. /**
  36518. * An event triggered when a material is created
  36519. */
  36520. onNewMaterialAddedObservable: Observable<Material>;
  36521. /**
  36522. * An event triggered when a material is removed
  36523. */
  36524. onMaterialRemovedObservable: Observable<Material>;
  36525. /**
  36526. * An event triggered when a texture is created
  36527. */
  36528. onNewTextureAddedObservable: Observable<BaseTexture>;
  36529. /**
  36530. * An event triggered when a texture is removed
  36531. */
  36532. onTextureRemovedObservable: Observable<BaseTexture>;
  36533. /**
  36534. * An event triggered when render targets are about to be rendered
  36535. * Can happen multiple times per frame.
  36536. */
  36537. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36538. /**
  36539. * An event triggered when render targets were rendered.
  36540. * Can happen multiple times per frame.
  36541. */
  36542. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36543. /**
  36544. * An event triggered before calculating deterministic simulation step
  36545. */
  36546. onBeforeStepObservable: Observable<Scene>;
  36547. /**
  36548. * An event triggered after calculating deterministic simulation step
  36549. */
  36550. onAfterStepObservable: Observable<Scene>;
  36551. /**
  36552. * An event triggered when the activeCamera property is updated
  36553. */
  36554. onActiveCameraChanged: Observable<Scene>;
  36555. /**
  36556. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36557. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36558. * 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)
  36559. */
  36560. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36561. /**
  36562. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36563. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36564. * 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)
  36565. */
  36566. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36567. /**
  36568. * This Observable will when a mesh has been imported into the scene.
  36569. */
  36570. onMeshImportedObservable: Observable<AbstractMesh>;
  36571. /**
  36572. * This Observable will when an animation file has been imported into the scene.
  36573. */
  36574. onAnimationFileImportedObservable: Observable<Scene>;
  36575. /**
  36576. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36577. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36578. */
  36579. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36580. /** @hidden */
  36581. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36582. /**
  36583. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36584. */
  36585. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36586. /**
  36587. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36588. */
  36589. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36590. /**
  36591. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36592. */
  36593. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36594. /** Callback called when a pointer move is detected */
  36595. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36596. /** Callback called when a pointer down is detected */
  36597. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36598. /** Callback called when a pointer up is detected */
  36599. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36600. /** Callback called when a pointer pick is detected */
  36601. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36602. /**
  36603. * 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).
  36604. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36605. */
  36606. onPrePointerObservable: Observable<PointerInfoPre>;
  36607. /**
  36608. * Observable event triggered each time an input event is received from the rendering canvas
  36609. */
  36610. onPointerObservable: Observable<PointerInfo>;
  36611. /**
  36612. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36613. */
  36614. get unTranslatedPointer(): Vector2;
  36615. /**
  36616. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36617. */
  36618. static get DragMovementThreshold(): number;
  36619. static set DragMovementThreshold(value: number);
  36620. /**
  36621. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36622. */
  36623. static get LongPressDelay(): number;
  36624. static set LongPressDelay(value: number);
  36625. /**
  36626. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36627. */
  36628. static get DoubleClickDelay(): number;
  36629. static set DoubleClickDelay(value: number);
  36630. /** If you need to check double click without raising a single click at first click, enable this flag */
  36631. static get ExclusiveDoubleClickMode(): boolean;
  36632. static set ExclusiveDoubleClickMode(value: boolean);
  36633. /** @hidden */
  36634. _mirroredCameraPosition: Nullable<Vector3>;
  36635. /**
  36636. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36637. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36638. */
  36639. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36640. /**
  36641. * Observable event triggered each time an keyboard event is received from the hosting window
  36642. */
  36643. onKeyboardObservable: Observable<KeyboardInfo>;
  36644. private _useRightHandedSystem;
  36645. /**
  36646. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36647. */
  36648. set useRightHandedSystem(value: boolean);
  36649. get useRightHandedSystem(): boolean;
  36650. private _timeAccumulator;
  36651. private _currentStepId;
  36652. private _currentInternalStep;
  36653. /**
  36654. * Sets the step Id used by deterministic lock step
  36655. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36656. * @param newStepId defines the step Id
  36657. */
  36658. setStepId(newStepId: number): void;
  36659. /**
  36660. * Gets the step Id used by deterministic lock step
  36661. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36662. * @returns the step Id
  36663. */
  36664. getStepId(): number;
  36665. /**
  36666. * Gets the internal step used by deterministic lock step
  36667. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36668. * @returns the internal step
  36669. */
  36670. getInternalStep(): number;
  36671. private _fogEnabled;
  36672. /**
  36673. * Gets or sets a boolean indicating if fog is enabled on this scene
  36674. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36675. * (Default is true)
  36676. */
  36677. set fogEnabled(value: boolean);
  36678. get fogEnabled(): boolean;
  36679. private _fogMode;
  36680. /**
  36681. * Gets or sets the fog mode to use
  36682. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36683. * | mode | value |
  36684. * | --- | --- |
  36685. * | FOGMODE_NONE | 0 |
  36686. * | FOGMODE_EXP | 1 |
  36687. * | FOGMODE_EXP2 | 2 |
  36688. * | FOGMODE_LINEAR | 3 |
  36689. */
  36690. set fogMode(value: number);
  36691. get fogMode(): number;
  36692. /**
  36693. * Gets or sets the fog color to use
  36694. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36695. * (Default is Color3(0.2, 0.2, 0.3))
  36696. */
  36697. fogColor: Color3;
  36698. /**
  36699. * Gets or sets the fog density to use
  36700. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36701. * (Default is 0.1)
  36702. */
  36703. fogDensity: number;
  36704. /**
  36705. * Gets or sets the fog start distance to use
  36706. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36707. * (Default is 0)
  36708. */
  36709. fogStart: number;
  36710. /**
  36711. * Gets or sets the fog end distance to use
  36712. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36713. * (Default is 1000)
  36714. */
  36715. fogEnd: number;
  36716. private _shadowsEnabled;
  36717. /**
  36718. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36719. */
  36720. set shadowsEnabled(value: boolean);
  36721. get shadowsEnabled(): boolean;
  36722. private _lightsEnabled;
  36723. /**
  36724. * Gets or sets a boolean indicating if lights are enabled on this scene
  36725. */
  36726. set lightsEnabled(value: boolean);
  36727. get lightsEnabled(): boolean;
  36728. /** All of the active cameras added to this scene. */
  36729. activeCameras: Camera[];
  36730. /** @hidden */
  36731. _activeCamera: Nullable<Camera>;
  36732. /** Gets or sets the current active camera */
  36733. get activeCamera(): Nullable<Camera>;
  36734. set activeCamera(value: Nullable<Camera>);
  36735. private _defaultMaterial;
  36736. /** The default material used on meshes when no material is affected */
  36737. get defaultMaterial(): Material;
  36738. /** The default material used on meshes when no material is affected */
  36739. set defaultMaterial(value: Material);
  36740. private _texturesEnabled;
  36741. /**
  36742. * Gets or sets a boolean indicating if textures are enabled on this scene
  36743. */
  36744. set texturesEnabled(value: boolean);
  36745. get texturesEnabled(): boolean;
  36746. /**
  36747. * Gets or sets a boolean indicating if particles are enabled on this scene
  36748. */
  36749. particlesEnabled: boolean;
  36750. /**
  36751. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36752. */
  36753. spritesEnabled: boolean;
  36754. private _skeletonsEnabled;
  36755. /**
  36756. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36757. */
  36758. set skeletonsEnabled(value: boolean);
  36759. get skeletonsEnabled(): boolean;
  36760. /**
  36761. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36762. */
  36763. lensFlaresEnabled: boolean;
  36764. /**
  36765. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36767. */
  36768. collisionsEnabled: boolean;
  36769. private _collisionCoordinator;
  36770. /** @hidden */
  36771. get collisionCoordinator(): ICollisionCoordinator;
  36772. /**
  36773. * Defines the gravity applied to this scene (used only for collisions)
  36774. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36775. */
  36776. gravity: Vector3;
  36777. /**
  36778. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36779. */
  36780. postProcessesEnabled: boolean;
  36781. /**
  36782. * The list of postprocesses added to the scene
  36783. */
  36784. postProcesses: PostProcess[];
  36785. /**
  36786. * Gets the current postprocess manager
  36787. */
  36788. postProcessManager: PostProcessManager;
  36789. /**
  36790. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36791. */
  36792. renderTargetsEnabled: boolean;
  36793. /**
  36794. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36795. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36796. */
  36797. dumpNextRenderTargets: boolean;
  36798. /**
  36799. * The list of user defined render targets added to the scene
  36800. */
  36801. customRenderTargets: RenderTargetTexture[];
  36802. /**
  36803. * Defines if texture loading must be delayed
  36804. * If true, textures will only be loaded when they need to be rendered
  36805. */
  36806. useDelayedTextureLoading: boolean;
  36807. /**
  36808. * Gets the list of meshes imported to the scene through SceneLoader
  36809. */
  36810. importedMeshesFiles: String[];
  36811. /**
  36812. * Gets or sets a boolean indicating if probes are enabled on this scene
  36813. */
  36814. probesEnabled: boolean;
  36815. /**
  36816. * Gets or sets the current offline provider to use to store scene data
  36817. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36818. */
  36819. offlineProvider: IOfflineProvider;
  36820. /**
  36821. * Gets or sets the action manager associated with the scene
  36822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36823. */
  36824. actionManager: AbstractActionManager;
  36825. private _meshesForIntersections;
  36826. /**
  36827. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36828. */
  36829. proceduralTexturesEnabled: boolean;
  36830. private _engine;
  36831. private _totalVertices;
  36832. /** @hidden */
  36833. _activeIndices: PerfCounter;
  36834. /** @hidden */
  36835. _activeParticles: PerfCounter;
  36836. /** @hidden */
  36837. _activeBones: PerfCounter;
  36838. private _animationRatio;
  36839. /** @hidden */
  36840. _animationTimeLast: number;
  36841. /** @hidden */
  36842. _animationTime: number;
  36843. /**
  36844. * Gets or sets a general scale for animation speed
  36845. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36846. */
  36847. animationTimeScale: number;
  36848. /** @hidden */
  36849. _cachedMaterial: Nullable<Material>;
  36850. /** @hidden */
  36851. _cachedEffect: Nullable<Effect>;
  36852. /** @hidden */
  36853. _cachedVisibility: Nullable<number>;
  36854. private _renderId;
  36855. private _frameId;
  36856. private _executeWhenReadyTimeoutId;
  36857. private _intermediateRendering;
  36858. private _viewUpdateFlag;
  36859. private _projectionUpdateFlag;
  36860. /** @hidden */
  36861. _toBeDisposed: Nullable<IDisposable>[];
  36862. private _activeRequests;
  36863. /** @hidden */
  36864. _pendingData: any[];
  36865. private _isDisposed;
  36866. /**
  36867. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36868. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36869. */
  36870. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36871. private _activeMeshes;
  36872. private _processedMaterials;
  36873. private _renderTargets;
  36874. /** @hidden */
  36875. _activeParticleSystems: SmartArray<IParticleSystem>;
  36876. private _activeSkeletons;
  36877. private _softwareSkinnedMeshes;
  36878. private _renderingManager;
  36879. /** @hidden */
  36880. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36881. private _transformMatrix;
  36882. private _sceneUbo;
  36883. /** @hidden */
  36884. _viewMatrix: Matrix;
  36885. private _projectionMatrix;
  36886. /** @hidden */
  36887. _forcedViewPosition: Nullable<Vector3>;
  36888. /** @hidden */
  36889. _frustumPlanes: Plane[];
  36890. /**
  36891. * Gets the list of frustum planes (built from the active camera)
  36892. */
  36893. get frustumPlanes(): Plane[];
  36894. /**
  36895. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36896. * This is useful if there are more lights that the maximum simulteanous authorized
  36897. */
  36898. requireLightSorting: boolean;
  36899. /** @hidden */
  36900. readonly useMaterialMeshMap: boolean;
  36901. /** @hidden */
  36902. readonly useClonedMeshMap: boolean;
  36903. private _externalData;
  36904. private _uid;
  36905. /**
  36906. * @hidden
  36907. * Backing store of defined scene components.
  36908. */
  36909. _components: ISceneComponent[];
  36910. /**
  36911. * @hidden
  36912. * Backing store of defined scene components.
  36913. */
  36914. _serializableComponents: ISceneSerializableComponent[];
  36915. /**
  36916. * List of components to register on the next registration step.
  36917. */
  36918. private _transientComponents;
  36919. /**
  36920. * Registers the transient components if needed.
  36921. */
  36922. private _registerTransientComponents;
  36923. /**
  36924. * @hidden
  36925. * Add a component to the scene.
  36926. * Note that the ccomponent could be registered on th next frame if this is called after
  36927. * the register component stage.
  36928. * @param component Defines the component to add to the scene
  36929. */
  36930. _addComponent(component: ISceneComponent): void;
  36931. /**
  36932. * @hidden
  36933. * Gets a component from the scene.
  36934. * @param name defines the name of the component to retrieve
  36935. * @returns the component or null if not present
  36936. */
  36937. _getComponent(name: string): Nullable<ISceneComponent>;
  36938. /**
  36939. * @hidden
  36940. * Defines the actions happening before camera updates.
  36941. */
  36942. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36943. /**
  36944. * @hidden
  36945. * Defines the actions happening before clear the canvas.
  36946. */
  36947. _beforeClearStage: Stage<SimpleStageAction>;
  36948. /**
  36949. * @hidden
  36950. * Defines the actions when collecting render targets for the frame.
  36951. */
  36952. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36953. /**
  36954. * @hidden
  36955. * Defines the actions happening for one camera in the frame.
  36956. */
  36957. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36958. /**
  36959. * @hidden
  36960. * Defines the actions happening during the per mesh ready checks.
  36961. */
  36962. _isReadyForMeshStage: Stage<MeshStageAction>;
  36963. /**
  36964. * @hidden
  36965. * Defines the actions happening before evaluate active mesh checks.
  36966. */
  36967. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36968. /**
  36969. * @hidden
  36970. * Defines the actions happening during the evaluate sub mesh checks.
  36971. */
  36972. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36973. /**
  36974. * @hidden
  36975. * Defines the actions happening during the active mesh stage.
  36976. */
  36977. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36978. /**
  36979. * @hidden
  36980. * Defines the actions happening during the per camera render target step.
  36981. */
  36982. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36983. /**
  36984. * @hidden
  36985. * Defines the actions happening just before the active camera is drawing.
  36986. */
  36987. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36988. /**
  36989. * @hidden
  36990. * Defines the actions happening just before a render target is drawing.
  36991. */
  36992. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36993. /**
  36994. * @hidden
  36995. * Defines the actions happening just before a rendering group is drawing.
  36996. */
  36997. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36998. /**
  36999. * @hidden
  37000. * Defines the actions happening just before a mesh is drawing.
  37001. */
  37002. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37003. /**
  37004. * @hidden
  37005. * Defines the actions happening just after a mesh has been drawn.
  37006. */
  37007. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37008. /**
  37009. * @hidden
  37010. * Defines the actions happening just after a rendering group has been drawn.
  37011. */
  37012. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37013. /**
  37014. * @hidden
  37015. * Defines the actions happening just after the active camera has been drawn.
  37016. */
  37017. _afterCameraDrawStage: Stage<CameraStageAction>;
  37018. /**
  37019. * @hidden
  37020. * Defines the actions happening just after a render target has been drawn.
  37021. */
  37022. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37023. /**
  37024. * @hidden
  37025. * Defines the actions happening just after rendering all cameras and computing intersections.
  37026. */
  37027. _afterRenderStage: Stage<SimpleStageAction>;
  37028. /**
  37029. * @hidden
  37030. * Defines the actions happening when a pointer move event happens.
  37031. */
  37032. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37033. /**
  37034. * @hidden
  37035. * Defines the actions happening when a pointer down event happens.
  37036. */
  37037. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37038. /**
  37039. * @hidden
  37040. * Defines the actions happening when a pointer up event happens.
  37041. */
  37042. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37043. /**
  37044. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37045. */
  37046. private geometriesByUniqueId;
  37047. /**
  37048. * Creates a new Scene
  37049. * @param engine defines the engine to use to render this scene
  37050. * @param options defines the scene options
  37051. */
  37052. constructor(engine: Engine, options?: SceneOptions);
  37053. /**
  37054. * Gets a string idenfifying the name of the class
  37055. * @returns "Scene" string
  37056. */
  37057. getClassName(): string;
  37058. private _defaultMeshCandidates;
  37059. /**
  37060. * @hidden
  37061. */
  37062. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37063. private _defaultSubMeshCandidates;
  37064. /**
  37065. * @hidden
  37066. */
  37067. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37068. /**
  37069. * Sets the default candidate providers for the scene.
  37070. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37071. * and getCollidingSubMeshCandidates to their default function
  37072. */
  37073. setDefaultCandidateProviders(): void;
  37074. /**
  37075. * Gets the mesh that is currently under the pointer
  37076. */
  37077. get meshUnderPointer(): Nullable<AbstractMesh>;
  37078. /**
  37079. * Gets or sets the current on-screen X position of the pointer
  37080. */
  37081. get pointerX(): number;
  37082. set pointerX(value: number);
  37083. /**
  37084. * Gets or sets the current on-screen Y position of the pointer
  37085. */
  37086. get pointerY(): number;
  37087. set pointerY(value: number);
  37088. /**
  37089. * Gets the cached material (ie. the latest rendered one)
  37090. * @returns the cached material
  37091. */
  37092. getCachedMaterial(): Nullable<Material>;
  37093. /**
  37094. * Gets the cached effect (ie. the latest rendered one)
  37095. * @returns the cached effect
  37096. */
  37097. getCachedEffect(): Nullable<Effect>;
  37098. /**
  37099. * Gets the cached visibility state (ie. the latest rendered one)
  37100. * @returns the cached visibility state
  37101. */
  37102. getCachedVisibility(): Nullable<number>;
  37103. /**
  37104. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37105. * @param material defines the current material
  37106. * @param effect defines the current effect
  37107. * @param visibility defines the current visibility state
  37108. * @returns true if one parameter is not cached
  37109. */
  37110. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37111. /**
  37112. * Gets the engine associated with the scene
  37113. * @returns an Engine
  37114. */
  37115. getEngine(): Engine;
  37116. /**
  37117. * Gets the total number of vertices rendered per frame
  37118. * @returns the total number of vertices rendered per frame
  37119. */
  37120. getTotalVertices(): number;
  37121. /**
  37122. * Gets the performance counter for total vertices
  37123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37124. */
  37125. get totalVerticesPerfCounter(): PerfCounter;
  37126. /**
  37127. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37128. * @returns the total number of active indices rendered per frame
  37129. */
  37130. getActiveIndices(): number;
  37131. /**
  37132. * Gets the performance counter for active indices
  37133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37134. */
  37135. get totalActiveIndicesPerfCounter(): PerfCounter;
  37136. /**
  37137. * Gets the total number of active particles rendered per frame
  37138. * @returns the total number of active particles rendered per frame
  37139. */
  37140. getActiveParticles(): number;
  37141. /**
  37142. * Gets the performance counter for active particles
  37143. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37144. */
  37145. get activeParticlesPerfCounter(): PerfCounter;
  37146. /**
  37147. * Gets the total number of active bones rendered per frame
  37148. * @returns the total number of active bones rendered per frame
  37149. */
  37150. getActiveBones(): number;
  37151. /**
  37152. * Gets the performance counter for active bones
  37153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37154. */
  37155. get activeBonesPerfCounter(): PerfCounter;
  37156. /**
  37157. * Gets the array of active meshes
  37158. * @returns an array of AbstractMesh
  37159. */
  37160. getActiveMeshes(): SmartArray<AbstractMesh>;
  37161. /**
  37162. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37163. * @returns a number
  37164. */
  37165. getAnimationRatio(): number;
  37166. /**
  37167. * Gets an unique Id for the current render phase
  37168. * @returns a number
  37169. */
  37170. getRenderId(): number;
  37171. /**
  37172. * Gets an unique Id for the current frame
  37173. * @returns a number
  37174. */
  37175. getFrameId(): number;
  37176. /** Call this function if you want to manually increment the render Id*/
  37177. incrementRenderId(): void;
  37178. private _createUbo;
  37179. /**
  37180. * Use this method to simulate a pointer move on a mesh
  37181. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37182. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37183. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37184. * @returns the current scene
  37185. */
  37186. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37187. /**
  37188. * Use this method to simulate a pointer down on a mesh
  37189. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37190. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37191. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37192. * @returns the current scene
  37193. */
  37194. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37195. /**
  37196. * Use this method to simulate a pointer up on a mesh
  37197. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37198. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37199. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37200. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37201. * @returns the current scene
  37202. */
  37203. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37204. /**
  37205. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37206. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37207. * @returns true if the pointer was captured
  37208. */
  37209. isPointerCaptured(pointerId?: number): boolean;
  37210. /**
  37211. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37212. * @param attachUp defines if you want to attach events to pointerup
  37213. * @param attachDown defines if you want to attach events to pointerdown
  37214. * @param attachMove defines if you want to attach events to pointermove
  37215. */
  37216. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37217. /** Detaches all event handlers*/
  37218. detachControl(): void;
  37219. /**
  37220. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37221. * Delay loaded resources are not taking in account
  37222. * @return true if all required resources are ready
  37223. */
  37224. isReady(): boolean;
  37225. /** Resets all cached information relative to material (including effect and visibility) */
  37226. resetCachedMaterial(): void;
  37227. /**
  37228. * Registers a function to be called before every frame render
  37229. * @param func defines the function to register
  37230. */
  37231. registerBeforeRender(func: () => void): void;
  37232. /**
  37233. * Unregisters a function called before every frame render
  37234. * @param func defines the function to unregister
  37235. */
  37236. unregisterBeforeRender(func: () => void): void;
  37237. /**
  37238. * Registers a function to be called after every frame render
  37239. * @param func defines the function to register
  37240. */
  37241. registerAfterRender(func: () => void): void;
  37242. /**
  37243. * Unregisters a function called after every frame render
  37244. * @param func defines the function to unregister
  37245. */
  37246. unregisterAfterRender(func: () => void): void;
  37247. private _executeOnceBeforeRender;
  37248. /**
  37249. * The provided function will run before render once and will be disposed afterwards.
  37250. * A timeout delay can be provided so that the function will be executed in N ms.
  37251. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37252. * @param func The function to be executed.
  37253. * @param timeout optional delay in ms
  37254. */
  37255. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37256. /** @hidden */
  37257. _addPendingData(data: any): void;
  37258. /** @hidden */
  37259. _removePendingData(data: any): void;
  37260. /**
  37261. * Returns the number of items waiting to be loaded
  37262. * @returns the number of items waiting to be loaded
  37263. */
  37264. getWaitingItemsCount(): number;
  37265. /**
  37266. * Returns a boolean indicating if the scene is still loading data
  37267. */
  37268. get isLoading(): boolean;
  37269. /**
  37270. * Registers a function to be executed when the scene is ready
  37271. * @param {Function} func - the function to be executed
  37272. */
  37273. executeWhenReady(func: () => void): void;
  37274. /**
  37275. * Returns a promise that resolves when the scene is ready
  37276. * @returns A promise that resolves when the scene is ready
  37277. */
  37278. whenReadyAsync(): Promise<void>;
  37279. /** @hidden */
  37280. _checkIsReady(): void;
  37281. /**
  37282. * Gets all animatable attached to the scene
  37283. */
  37284. get animatables(): Animatable[];
  37285. /**
  37286. * Resets the last animation time frame.
  37287. * Useful to override when animations start running when loading a scene for the first time.
  37288. */
  37289. resetLastAnimationTimeFrame(): void;
  37290. /**
  37291. * Gets the current view matrix
  37292. * @returns a Matrix
  37293. */
  37294. getViewMatrix(): Matrix;
  37295. /**
  37296. * Gets the current projection matrix
  37297. * @returns a Matrix
  37298. */
  37299. getProjectionMatrix(): Matrix;
  37300. /**
  37301. * Gets the current transform matrix
  37302. * @returns a Matrix made of View * Projection
  37303. */
  37304. getTransformMatrix(): Matrix;
  37305. /**
  37306. * Sets the current transform matrix
  37307. * @param viewL defines the View matrix to use
  37308. * @param projectionL defines the Projection matrix to use
  37309. * @param viewR defines the right View matrix to use (if provided)
  37310. * @param projectionR defines the right Projection matrix to use (if provided)
  37311. */
  37312. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37313. /**
  37314. * Gets the uniform buffer used to store scene data
  37315. * @returns a UniformBuffer
  37316. */
  37317. getSceneUniformBuffer(): UniformBuffer;
  37318. /**
  37319. * Gets an unique (relatively to the current scene) Id
  37320. * @returns an unique number for the scene
  37321. */
  37322. getUniqueId(): number;
  37323. /**
  37324. * Add a mesh to the list of scene's meshes
  37325. * @param newMesh defines the mesh to add
  37326. * @param recursive if all child meshes should also be added to the scene
  37327. */
  37328. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37329. /**
  37330. * Remove a mesh for the list of scene's meshes
  37331. * @param toRemove defines the mesh to remove
  37332. * @param recursive if all child meshes should also be removed from the scene
  37333. * @returns the index where the mesh was in the mesh list
  37334. */
  37335. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37336. /**
  37337. * Add a transform node to the list of scene's transform nodes
  37338. * @param newTransformNode defines the transform node to add
  37339. */
  37340. addTransformNode(newTransformNode: TransformNode): void;
  37341. /**
  37342. * Remove a transform node for the list of scene's transform nodes
  37343. * @param toRemove defines the transform node to remove
  37344. * @returns the index where the transform node was in the transform node list
  37345. */
  37346. removeTransformNode(toRemove: TransformNode): number;
  37347. /**
  37348. * Remove a skeleton for the list of scene's skeletons
  37349. * @param toRemove defines the skeleton to remove
  37350. * @returns the index where the skeleton was in the skeleton list
  37351. */
  37352. removeSkeleton(toRemove: Skeleton): number;
  37353. /**
  37354. * Remove a morph target for the list of scene's morph targets
  37355. * @param toRemove defines the morph target to remove
  37356. * @returns the index where the morph target was in the morph target list
  37357. */
  37358. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37359. /**
  37360. * Remove a light for the list of scene's lights
  37361. * @param toRemove defines the light to remove
  37362. * @returns the index where the light was in the light list
  37363. */
  37364. removeLight(toRemove: Light): number;
  37365. /**
  37366. * Remove a camera for the list of scene's cameras
  37367. * @param toRemove defines the camera to remove
  37368. * @returns the index where the camera was in the camera list
  37369. */
  37370. removeCamera(toRemove: Camera): number;
  37371. /**
  37372. * Remove a particle system for the list of scene's particle systems
  37373. * @param toRemove defines the particle system to remove
  37374. * @returns the index where the particle system was in the particle system list
  37375. */
  37376. removeParticleSystem(toRemove: IParticleSystem): number;
  37377. /**
  37378. * Remove a animation for the list of scene's animations
  37379. * @param toRemove defines the animation to remove
  37380. * @returns the index where the animation was in the animation list
  37381. */
  37382. removeAnimation(toRemove: Animation): number;
  37383. /**
  37384. * Will stop the animation of the given target
  37385. * @param target - the target
  37386. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37387. * @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)
  37388. */
  37389. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37390. /**
  37391. * Removes the given animation group from this scene.
  37392. * @param toRemove The animation group to remove
  37393. * @returns The index of the removed animation group
  37394. */
  37395. removeAnimationGroup(toRemove: AnimationGroup): number;
  37396. /**
  37397. * Removes the given multi-material from this scene.
  37398. * @param toRemove The multi-material to remove
  37399. * @returns The index of the removed multi-material
  37400. */
  37401. removeMultiMaterial(toRemove: MultiMaterial): number;
  37402. /**
  37403. * Removes the given material from this scene.
  37404. * @param toRemove The material to remove
  37405. * @returns The index of the removed material
  37406. */
  37407. removeMaterial(toRemove: Material): number;
  37408. /**
  37409. * Removes the given action manager from this scene.
  37410. * @param toRemove The action manager to remove
  37411. * @returns The index of the removed action manager
  37412. */
  37413. removeActionManager(toRemove: AbstractActionManager): number;
  37414. /**
  37415. * Removes the given texture from this scene.
  37416. * @param toRemove The texture to remove
  37417. * @returns The index of the removed texture
  37418. */
  37419. removeTexture(toRemove: BaseTexture): number;
  37420. /**
  37421. * Adds the given light to this scene
  37422. * @param newLight The light to add
  37423. */
  37424. addLight(newLight: Light): void;
  37425. /**
  37426. * Sorts the list list based on light priorities
  37427. */
  37428. sortLightsByPriority(): void;
  37429. /**
  37430. * Adds the given camera to this scene
  37431. * @param newCamera The camera to add
  37432. */
  37433. addCamera(newCamera: Camera): void;
  37434. /**
  37435. * Adds the given skeleton to this scene
  37436. * @param newSkeleton The skeleton to add
  37437. */
  37438. addSkeleton(newSkeleton: Skeleton): void;
  37439. /**
  37440. * Adds the given particle system to this scene
  37441. * @param newParticleSystem The particle system to add
  37442. */
  37443. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37444. /**
  37445. * Adds the given animation to this scene
  37446. * @param newAnimation The animation to add
  37447. */
  37448. addAnimation(newAnimation: Animation): void;
  37449. /**
  37450. * Adds the given animation group to this scene.
  37451. * @param newAnimationGroup The animation group to add
  37452. */
  37453. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37454. /**
  37455. * Adds the given multi-material to this scene
  37456. * @param newMultiMaterial The multi-material to add
  37457. */
  37458. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37459. /**
  37460. * Adds the given material to this scene
  37461. * @param newMaterial The material to add
  37462. */
  37463. addMaterial(newMaterial: Material): void;
  37464. /**
  37465. * Adds the given morph target to this scene
  37466. * @param newMorphTargetManager The morph target to add
  37467. */
  37468. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37469. /**
  37470. * Adds the given geometry to this scene
  37471. * @param newGeometry The geometry to add
  37472. */
  37473. addGeometry(newGeometry: Geometry): void;
  37474. /**
  37475. * Adds the given action manager to this scene
  37476. * @param newActionManager The action manager to add
  37477. */
  37478. addActionManager(newActionManager: AbstractActionManager): void;
  37479. /**
  37480. * Adds the given texture to this scene.
  37481. * @param newTexture The texture to add
  37482. */
  37483. addTexture(newTexture: BaseTexture): void;
  37484. /**
  37485. * Switch active camera
  37486. * @param newCamera defines the new active camera
  37487. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37488. */
  37489. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37490. /**
  37491. * sets the active camera of the scene using its ID
  37492. * @param id defines the camera's ID
  37493. * @return the new active camera or null if none found.
  37494. */
  37495. setActiveCameraByID(id: string): Nullable<Camera>;
  37496. /**
  37497. * sets the active camera of the scene using its name
  37498. * @param name defines the camera's name
  37499. * @returns the new active camera or null if none found.
  37500. */
  37501. setActiveCameraByName(name: string): Nullable<Camera>;
  37502. /**
  37503. * get an animation group using its name
  37504. * @param name defines the material's name
  37505. * @return the animation group or null if none found.
  37506. */
  37507. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37508. /**
  37509. * Get a material using its unique id
  37510. * @param uniqueId defines the material's unique id
  37511. * @return the material or null if none found.
  37512. */
  37513. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37514. /**
  37515. * get a material using its id
  37516. * @param id defines the material's ID
  37517. * @return the material or null if none found.
  37518. */
  37519. getMaterialByID(id: string): Nullable<Material>;
  37520. /**
  37521. * Gets a the last added material using a given id
  37522. * @param id defines the material's ID
  37523. * @return the last material with the given id or null if none found.
  37524. */
  37525. getLastMaterialByID(id: string): Nullable<Material>;
  37526. /**
  37527. * Gets a material using its name
  37528. * @param name defines the material's name
  37529. * @return the material or null if none found.
  37530. */
  37531. getMaterialByName(name: string): Nullable<Material>;
  37532. /**
  37533. * Get a texture using its unique id
  37534. * @param uniqueId defines the texture's unique id
  37535. * @return the texture or null if none found.
  37536. */
  37537. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37538. /**
  37539. * Gets a camera using its id
  37540. * @param id defines the id to look for
  37541. * @returns the camera or null if not found
  37542. */
  37543. getCameraByID(id: string): Nullable<Camera>;
  37544. /**
  37545. * Gets a camera using its unique id
  37546. * @param uniqueId defines the unique id to look for
  37547. * @returns the camera or null if not found
  37548. */
  37549. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37550. /**
  37551. * Gets a camera using its name
  37552. * @param name defines the camera's name
  37553. * @return the camera or null if none found.
  37554. */
  37555. getCameraByName(name: string): Nullable<Camera>;
  37556. /**
  37557. * Gets a bone using its id
  37558. * @param id defines the bone's id
  37559. * @return the bone or null if not found
  37560. */
  37561. getBoneByID(id: string): Nullable<Bone>;
  37562. /**
  37563. * Gets a bone using its id
  37564. * @param name defines the bone's name
  37565. * @return the bone or null if not found
  37566. */
  37567. getBoneByName(name: string): Nullable<Bone>;
  37568. /**
  37569. * Gets a light node using its name
  37570. * @param name defines the the light's name
  37571. * @return the light or null if none found.
  37572. */
  37573. getLightByName(name: string): Nullable<Light>;
  37574. /**
  37575. * Gets a light node using its id
  37576. * @param id defines the light's id
  37577. * @return the light or null if none found.
  37578. */
  37579. getLightByID(id: string): Nullable<Light>;
  37580. /**
  37581. * Gets a light node using its scene-generated unique ID
  37582. * @param uniqueId defines the light's unique id
  37583. * @return the light or null if none found.
  37584. */
  37585. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37586. /**
  37587. * Gets a particle system by id
  37588. * @param id defines the particle system id
  37589. * @return the corresponding system or null if none found
  37590. */
  37591. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37592. /**
  37593. * Gets a geometry using its ID
  37594. * @param id defines the geometry's id
  37595. * @return the geometry or null if none found.
  37596. */
  37597. getGeometryByID(id: string): Nullable<Geometry>;
  37598. private _getGeometryByUniqueID;
  37599. /**
  37600. * Add a new geometry to this scene
  37601. * @param geometry defines the geometry to be added to the scene.
  37602. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37603. * @return a boolean defining if the geometry was added or not
  37604. */
  37605. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37606. /**
  37607. * Removes an existing geometry
  37608. * @param geometry defines the geometry to be removed from the scene
  37609. * @return a boolean defining if the geometry was removed or not
  37610. */
  37611. removeGeometry(geometry: Geometry): boolean;
  37612. /**
  37613. * Gets the list of geometries attached to the scene
  37614. * @returns an array of Geometry
  37615. */
  37616. getGeometries(): Geometry[];
  37617. /**
  37618. * Gets the first added mesh found of a given ID
  37619. * @param id defines the id to search for
  37620. * @return the mesh found or null if not found at all
  37621. */
  37622. getMeshByID(id: string): Nullable<AbstractMesh>;
  37623. /**
  37624. * Gets a list of meshes using their id
  37625. * @param id defines the id to search for
  37626. * @returns a list of meshes
  37627. */
  37628. getMeshesByID(id: string): Array<AbstractMesh>;
  37629. /**
  37630. * Gets the first added transform node found of a given ID
  37631. * @param id defines the id to search for
  37632. * @return the found transform node or null if not found at all.
  37633. */
  37634. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37635. /**
  37636. * Gets a transform node with its auto-generated unique id
  37637. * @param uniqueId efines the unique id to search for
  37638. * @return the found transform node or null if not found at all.
  37639. */
  37640. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37641. /**
  37642. * Gets a list of transform nodes using their id
  37643. * @param id defines the id to search for
  37644. * @returns a list of transform nodes
  37645. */
  37646. getTransformNodesByID(id: string): Array<TransformNode>;
  37647. /**
  37648. * Gets a mesh with its auto-generated unique id
  37649. * @param uniqueId defines the unique id to search for
  37650. * @return the found mesh or null if not found at all.
  37651. */
  37652. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37653. /**
  37654. * Gets a the last added mesh using a given id
  37655. * @param id defines the id to search for
  37656. * @return the found mesh or null if not found at all.
  37657. */
  37658. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37659. /**
  37660. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37661. * @param id defines the id to search for
  37662. * @return the found node or null if not found at all
  37663. */
  37664. getLastEntryByID(id: string): Nullable<Node>;
  37665. /**
  37666. * Gets a node (Mesh, Camera, Light) using a given id
  37667. * @param id defines the id to search for
  37668. * @return the found node or null if not found at all
  37669. */
  37670. getNodeByID(id: string): Nullable<Node>;
  37671. /**
  37672. * Gets a node (Mesh, Camera, Light) using a given name
  37673. * @param name defines the name to search for
  37674. * @return the found node or null if not found at all.
  37675. */
  37676. getNodeByName(name: string): Nullable<Node>;
  37677. /**
  37678. * Gets a mesh using a given name
  37679. * @param name defines the name to search for
  37680. * @return the found mesh or null if not found at all.
  37681. */
  37682. getMeshByName(name: string): Nullable<AbstractMesh>;
  37683. /**
  37684. * Gets a transform node using a given name
  37685. * @param name defines the name to search for
  37686. * @return the found transform node or null if not found at all.
  37687. */
  37688. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37689. /**
  37690. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37691. * @param id defines the id to search for
  37692. * @return the found skeleton or null if not found at all.
  37693. */
  37694. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37695. /**
  37696. * Gets a skeleton using a given auto generated unique id
  37697. * @param uniqueId defines the unique id to search for
  37698. * @return the found skeleton or null if not found at all.
  37699. */
  37700. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37701. /**
  37702. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37703. * @param id defines the id to search for
  37704. * @return the found skeleton or null if not found at all.
  37705. */
  37706. getSkeletonById(id: string): Nullable<Skeleton>;
  37707. /**
  37708. * Gets a skeleton using a given name
  37709. * @param name defines the name to search for
  37710. * @return the found skeleton or null if not found at all.
  37711. */
  37712. getSkeletonByName(name: string): Nullable<Skeleton>;
  37713. /**
  37714. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37715. * @param id defines the id to search for
  37716. * @return the found morph target manager or null if not found at all.
  37717. */
  37718. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37719. /**
  37720. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37721. * @param id defines the id to search for
  37722. * @return the found morph target or null if not found at all.
  37723. */
  37724. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37725. /**
  37726. * Gets a boolean indicating if the given mesh is active
  37727. * @param mesh defines the mesh to look for
  37728. * @returns true if the mesh is in the active list
  37729. */
  37730. isActiveMesh(mesh: AbstractMesh): boolean;
  37731. /**
  37732. * Return a unique id as a string which can serve as an identifier for the scene
  37733. */
  37734. get uid(): string;
  37735. /**
  37736. * Add an externaly attached data from its key.
  37737. * This method call will fail and return false, if such key already exists.
  37738. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37739. * @param key the unique key that identifies the data
  37740. * @param data the data object to associate to the key for this Engine instance
  37741. * @return true if no such key were already present and the data was added successfully, false otherwise
  37742. */
  37743. addExternalData<T>(key: string, data: T): boolean;
  37744. /**
  37745. * Get an externaly attached data from its key
  37746. * @param key the unique key that identifies the data
  37747. * @return the associated data, if present (can be null), or undefined if not present
  37748. */
  37749. getExternalData<T>(key: string): Nullable<T>;
  37750. /**
  37751. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37752. * @param key the unique key that identifies the data
  37753. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37754. * @return the associated data, can be null if the factory returned null.
  37755. */
  37756. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37757. /**
  37758. * Remove an externaly attached data from the Engine instance
  37759. * @param key the unique key that identifies the data
  37760. * @return true if the data was successfully removed, false if it doesn't exist
  37761. */
  37762. removeExternalData(key: string): boolean;
  37763. private _evaluateSubMesh;
  37764. /**
  37765. * Clear the processed materials smart array preventing retention point in material dispose.
  37766. */
  37767. freeProcessedMaterials(): void;
  37768. private _preventFreeActiveMeshesAndRenderingGroups;
  37769. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37770. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37771. * when disposing several meshes in a row or a hierarchy of meshes.
  37772. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37773. */
  37774. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37775. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37776. /**
  37777. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37778. */
  37779. freeActiveMeshes(): void;
  37780. /**
  37781. * Clear the info related to rendering groups preventing retention points during dispose.
  37782. */
  37783. freeRenderingGroups(): void;
  37784. /** @hidden */
  37785. _isInIntermediateRendering(): boolean;
  37786. /**
  37787. * Lambda returning the list of potentially active meshes.
  37788. */
  37789. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37790. /**
  37791. * Lambda returning the list of potentially active sub meshes.
  37792. */
  37793. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37794. /**
  37795. * Lambda returning the list of potentially intersecting sub meshes.
  37796. */
  37797. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37798. /**
  37799. * Lambda returning the list of potentially colliding sub meshes.
  37800. */
  37801. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37802. private _activeMeshesFrozen;
  37803. private _skipEvaluateActiveMeshesCompletely;
  37804. /**
  37805. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37806. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37807. * @returns the current scene
  37808. */
  37809. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37810. /**
  37811. * Use this function to restart evaluating active meshes on every frame
  37812. * @returns the current scene
  37813. */
  37814. unfreezeActiveMeshes(): Scene;
  37815. private _evaluateActiveMeshes;
  37816. private _activeMesh;
  37817. /**
  37818. * Update the transform matrix to update from the current active camera
  37819. * @param force defines a boolean used to force the update even if cache is up to date
  37820. */
  37821. updateTransformMatrix(force?: boolean): void;
  37822. private _bindFrameBuffer;
  37823. /** @hidden */
  37824. _allowPostProcessClearColor: boolean;
  37825. /** @hidden */
  37826. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37827. private _processSubCameras;
  37828. private _checkIntersections;
  37829. /** @hidden */
  37830. _advancePhysicsEngineStep(step: number): void;
  37831. /**
  37832. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37833. */
  37834. getDeterministicFrameTime: () => number;
  37835. /** @hidden */
  37836. _animate(): void;
  37837. /** Execute all animations (for a frame) */
  37838. animate(): void;
  37839. /**
  37840. * Render the scene
  37841. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37842. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37843. */
  37844. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37845. /**
  37846. * Freeze all materials
  37847. * A frozen material will not be updatable but should be faster to render
  37848. */
  37849. freezeMaterials(): void;
  37850. /**
  37851. * Unfreeze all materials
  37852. * A frozen material will not be updatable but should be faster to render
  37853. */
  37854. unfreezeMaterials(): void;
  37855. /**
  37856. * Releases all held ressources
  37857. */
  37858. dispose(): void;
  37859. /**
  37860. * Gets if the scene is already disposed
  37861. */
  37862. get isDisposed(): boolean;
  37863. /**
  37864. * Call this function to reduce memory footprint of the scene.
  37865. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37866. */
  37867. clearCachedVertexData(): void;
  37868. /**
  37869. * This function will remove the local cached buffer data from texture.
  37870. * It will save memory but will prevent the texture from being rebuilt
  37871. */
  37872. cleanCachedTextureBuffer(): void;
  37873. /**
  37874. * Get the world extend vectors with an optional filter
  37875. *
  37876. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37877. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37878. */
  37879. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37880. min: Vector3;
  37881. max: Vector3;
  37882. };
  37883. /**
  37884. * Creates a ray that can be used to pick in the scene
  37885. * @param x defines the x coordinate of the origin (on-screen)
  37886. * @param y defines the y coordinate of the origin (on-screen)
  37887. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37888. * @param camera defines the camera to use for the picking
  37889. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37890. * @returns a Ray
  37891. */
  37892. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37893. /**
  37894. * Creates a ray that can be used to pick in the scene
  37895. * @param x defines the x coordinate of the origin (on-screen)
  37896. * @param y defines the y coordinate of the origin (on-screen)
  37897. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37898. * @param result defines the ray where to store the picking ray
  37899. * @param camera defines the camera to use for the picking
  37900. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37901. * @returns the current scene
  37902. */
  37903. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37904. /**
  37905. * Creates a ray that can be used to pick in the scene
  37906. * @param x defines the x coordinate of the origin (on-screen)
  37907. * @param y defines the y coordinate of the origin (on-screen)
  37908. * @param camera defines the camera to use for the picking
  37909. * @returns a Ray
  37910. */
  37911. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37912. /**
  37913. * Creates a ray that can be used to pick in the scene
  37914. * @param x defines the x coordinate of the origin (on-screen)
  37915. * @param y defines the y coordinate of the origin (on-screen)
  37916. * @param result defines the ray where to store the picking ray
  37917. * @param camera defines the camera to use for the picking
  37918. * @returns the current scene
  37919. */
  37920. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37921. /** Launch a ray to try to pick a mesh in the scene
  37922. * @param x position on screen
  37923. * @param y position on screen
  37924. * @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
  37925. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37926. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37927. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37928. * @returns a PickingInfo
  37929. */
  37930. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37931. /** Use the given ray to pick a mesh in the scene
  37932. * @param ray The ray to use to pick meshes
  37933. * @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
  37934. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37935. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37936. * @returns a PickingInfo
  37937. */
  37938. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37939. /**
  37940. * Launch a ray to try to pick a mesh in the scene
  37941. * @param x X position on screen
  37942. * @param y Y position on screen
  37943. * @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
  37944. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37945. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37946. * @returns an array of PickingInfo
  37947. */
  37948. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37949. /**
  37950. * Launch a ray to try to pick a mesh in the scene
  37951. * @param ray Ray to use
  37952. * @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
  37953. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37954. * @returns an array of PickingInfo
  37955. */
  37956. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37957. /**
  37958. * Force the value of meshUnderPointer
  37959. * @param mesh defines the mesh to use
  37960. */
  37961. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37962. /**
  37963. * Gets the mesh under the pointer
  37964. * @returns a Mesh or null if no mesh is under the pointer
  37965. */
  37966. getPointerOverMesh(): Nullable<AbstractMesh>;
  37967. /** @hidden */
  37968. _rebuildGeometries(): void;
  37969. /** @hidden */
  37970. _rebuildTextures(): void;
  37971. private _getByTags;
  37972. /**
  37973. * Get a list of meshes by tags
  37974. * @param tagsQuery defines the tags query to use
  37975. * @param forEach defines a predicate used to filter results
  37976. * @returns an array of Mesh
  37977. */
  37978. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37979. /**
  37980. * Get a list of cameras by tags
  37981. * @param tagsQuery defines the tags query to use
  37982. * @param forEach defines a predicate used to filter results
  37983. * @returns an array of Camera
  37984. */
  37985. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37986. /**
  37987. * Get a list of lights by tags
  37988. * @param tagsQuery defines the tags query to use
  37989. * @param forEach defines a predicate used to filter results
  37990. * @returns an array of Light
  37991. */
  37992. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37993. /**
  37994. * Get a list of materials by tags
  37995. * @param tagsQuery defines the tags query to use
  37996. * @param forEach defines a predicate used to filter results
  37997. * @returns an array of Material
  37998. */
  37999. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38000. /**
  38001. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38002. * This allowed control for front to back rendering or reversly depending of the special needs.
  38003. *
  38004. * @param renderingGroupId The rendering group id corresponding to its index
  38005. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38006. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38007. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38008. */
  38009. 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;
  38010. /**
  38011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38012. *
  38013. * @param renderingGroupId The rendering group id corresponding to its index
  38014. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38015. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38016. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38017. */
  38018. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38019. /**
  38020. * Gets the current auto clear configuration for one rendering group of the rendering
  38021. * manager.
  38022. * @param index the rendering group index to get the information for
  38023. * @returns The auto clear setup for the requested rendering group
  38024. */
  38025. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38026. private _blockMaterialDirtyMechanism;
  38027. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38028. get blockMaterialDirtyMechanism(): boolean;
  38029. set blockMaterialDirtyMechanism(value: boolean);
  38030. /**
  38031. * Will flag all materials as dirty to trigger new shader compilation
  38032. * @param flag defines the flag used to specify which material part must be marked as dirty
  38033. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38034. */
  38035. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38036. /** @hidden */
  38037. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  38038. /** @hidden */
  38039. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38040. /** @hidden */
  38041. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  38042. /** @hidden */
  38043. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38044. /** @hidden */
  38045. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38046. /** @hidden */
  38047. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38048. }
  38049. }
  38050. declare module "babylonjs/assetContainer" {
  38051. import { AbstractScene } from "babylonjs/abstractScene";
  38052. import { Scene } from "babylonjs/scene";
  38053. import { Mesh } from "babylonjs/Meshes/mesh";
  38054. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38055. import { Skeleton } from "babylonjs/Bones/skeleton";
  38056. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38057. import { Animatable } from "babylonjs/Animations/animatable";
  38058. import { Nullable } from "babylonjs/types";
  38059. import { Node } from "babylonjs/node";
  38060. /**
  38061. * Set of assets to keep when moving a scene into an asset container.
  38062. */
  38063. export class KeepAssets extends AbstractScene {
  38064. }
  38065. /**
  38066. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38067. */
  38068. export class InstantiatedEntries {
  38069. /**
  38070. * List of new root nodes (eg. nodes with no parent)
  38071. */
  38072. rootNodes: TransformNode[];
  38073. /**
  38074. * List of new skeletons
  38075. */
  38076. skeletons: Skeleton[];
  38077. /**
  38078. * List of new animation groups
  38079. */
  38080. animationGroups: AnimationGroup[];
  38081. }
  38082. /**
  38083. * Container with a set of assets that can be added or removed from a scene.
  38084. */
  38085. export class AssetContainer extends AbstractScene {
  38086. private _wasAddedToScene;
  38087. /**
  38088. * The scene the AssetContainer belongs to.
  38089. */
  38090. scene: Scene;
  38091. /**
  38092. * Instantiates an AssetContainer.
  38093. * @param scene The scene the AssetContainer belongs to.
  38094. */
  38095. constructor(scene: Scene);
  38096. /**
  38097. * Instantiate or clone all meshes and add the new ones to the scene.
  38098. * Skeletons and animation groups will all be cloned
  38099. * @param nameFunction defines an optional function used to get new names for clones
  38100. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38101. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38102. */
  38103. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38104. /**
  38105. * Adds all the assets from the container to the scene.
  38106. */
  38107. addAllToScene(): void;
  38108. /**
  38109. * Removes all the assets in the container from the scene
  38110. */
  38111. removeAllFromScene(): void;
  38112. /**
  38113. * Disposes all the assets in the container
  38114. */
  38115. dispose(): void;
  38116. private _moveAssets;
  38117. /**
  38118. * Removes all the assets contained in the scene and adds them to the container.
  38119. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38120. */
  38121. moveAllFromScene(keepAssets?: KeepAssets): void;
  38122. /**
  38123. * 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.
  38124. * @returns the root mesh
  38125. */
  38126. createRootMesh(): Mesh;
  38127. /**
  38128. * Merge animations from this asset container into a scene
  38129. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38130. * @param animatables set of animatables to retarget to a node from the scene
  38131. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38132. */
  38133. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38134. }
  38135. }
  38136. declare module "babylonjs/abstractScene" {
  38137. import { Scene } from "babylonjs/scene";
  38138. import { Nullable } from "babylonjs/types";
  38139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38140. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38141. import { Geometry } from "babylonjs/Meshes/geometry";
  38142. import { Skeleton } from "babylonjs/Bones/skeleton";
  38143. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38144. import { AssetContainer } from "babylonjs/assetContainer";
  38145. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38146. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38148. import { Material } from "babylonjs/Materials/material";
  38149. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38150. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38151. import { Camera } from "babylonjs/Cameras/camera";
  38152. import { Light } from "babylonjs/Lights/light";
  38153. import { Node } from "babylonjs/node";
  38154. import { Animation } from "babylonjs/Animations/animation";
  38155. /**
  38156. * Defines how the parser contract is defined.
  38157. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38158. */
  38159. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38160. /**
  38161. * Defines how the individual parser contract is defined.
  38162. * These parser can parse an individual asset
  38163. */
  38164. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38165. /**
  38166. * Base class of the scene acting as a container for the different elements composing a scene.
  38167. * This class is dynamically extended by the different components of the scene increasing
  38168. * flexibility and reducing coupling
  38169. */
  38170. export abstract class AbstractScene {
  38171. /**
  38172. * Stores the list of available parsers in the application.
  38173. */
  38174. private static _BabylonFileParsers;
  38175. /**
  38176. * Stores the list of available individual parsers in the application.
  38177. */
  38178. private static _IndividualBabylonFileParsers;
  38179. /**
  38180. * Adds a parser in the list of available ones
  38181. * @param name Defines the name of the parser
  38182. * @param parser Defines the parser to add
  38183. */
  38184. static AddParser(name: string, parser: BabylonFileParser): void;
  38185. /**
  38186. * Gets a general parser from the list of avaialble ones
  38187. * @param name Defines the name of the parser
  38188. * @returns the requested parser or null
  38189. */
  38190. static GetParser(name: string): Nullable<BabylonFileParser>;
  38191. /**
  38192. * Adds n individual parser in the list of available ones
  38193. * @param name Defines the name of the parser
  38194. * @param parser Defines the parser to add
  38195. */
  38196. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38197. /**
  38198. * Gets an individual parser from the list of avaialble ones
  38199. * @param name Defines the name of the parser
  38200. * @returns the requested parser or null
  38201. */
  38202. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38203. /**
  38204. * Parser json data and populate both a scene and its associated container object
  38205. * @param jsonData Defines the data to parse
  38206. * @param scene Defines the scene to parse the data for
  38207. * @param container Defines the container attached to the parsing sequence
  38208. * @param rootUrl Defines the root url of the data
  38209. */
  38210. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38211. /**
  38212. * Gets the list of root nodes (ie. nodes with no parent)
  38213. */
  38214. rootNodes: Node[];
  38215. /** All of the cameras added to this scene
  38216. * @see http://doc.babylonjs.com/babylon101/cameras
  38217. */
  38218. cameras: Camera[];
  38219. /**
  38220. * All of the lights added to this scene
  38221. * @see http://doc.babylonjs.com/babylon101/lights
  38222. */
  38223. lights: Light[];
  38224. /**
  38225. * All of the (abstract) meshes added to this scene
  38226. */
  38227. meshes: AbstractMesh[];
  38228. /**
  38229. * The list of skeletons added to the scene
  38230. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38231. */
  38232. skeletons: Skeleton[];
  38233. /**
  38234. * All of the particle systems added to this scene
  38235. * @see http://doc.babylonjs.com/babylon101/particles
  38236. */
  38237. particleSystems: IParticleSystem[];
  38238. /**
  38239. * Gets a list of Animations associated with the scene
  38240. */
  38241. animations: Animation[];
  38242. /**
  38243. * All of the animation groups added to this scene
  38244. * @see http://doc.babylonjs.com/how_to/group
  38245. */
  38246. animationGroups: AnimationGroup[];
  38247. /**
  38248. * All of the multi-materials added to this scene
  38249. * @see http://doc.babylonjs.com/how_to/multi_materials
  38250. */
  38251. multiMaterials: MultiMaterial[];
  38252. /**
  38253. * All of the materials added to this scene
  38254. * In the context of a Scene, it is not supposed to be modified manually.
  38255. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38256. * Note also that the order of the Material within the array is not significant and might change.
  38257. * @see http://doc.babylonjs.com/babylon101/materials
  38258. */
  38259. materials: Material[];
  38260. /**
  38261. * The list of morph target managers added to the scene
  38262. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38263. */
  38264. morphTargetManagers: MorphTargetManager[];
  38265. /**
  38266. * The list of geometries used in the scene.
  38267. */
  38268. geometries: Geometry[];
  38269. /**
  38270. * All of the tranform nodes added to this scene
  38271. * In the context of a Scene, it is not supposed to be modified manually.
  38272. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38273. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38274. * @see http://doc.babylonjs.com/how_to/transformnode
  38275. */
  38276. transformNodes: TransformNode[];
  38277. /**
  38278. * ActionManagers available on the scene.
  38279. */
  38280. actionManagers: AbstractActionManager[];
  38281. /**
  38282. * Textures to keep.
  38283. */
  38284. textures: BaseTexture[];
  38285. /**
  38286. * Environment texture for the scene
  38287. */
  38288. environmentTexture: Nullable<BaseTexture>;
  38289. /**
  38290. * @returns all meshes, lights, cameras, transformNodes and bones
  38291. */
  38292. getNodes(): Array<Node>;
  38293. }
  38294. }
  38295. declare module "babylonjs/Audio/sound" {
  38296. import { Observable } from "babylonjs/Misc/observable";
  38297. import { Vector3 } from "babylonjs/Maths/math.vector";
  38298. import { Nullable } from "babylonjs/types";
  38299. import { Scene } from "babylonjs/scene";
  38300. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38301. /**
  38302. * Interface used to define options for Sound class
  38303. */
  38304. export interface ISoundOptions {
  38305. /**
  38306. * Does the sound autoplay once loaded.
  38307. */
  38308. autoplay?: boolean;
  38309. /**
  38310. * Does the sound loop after it finishes playing once.
  38311. */
  38312. loop?: boolean;
  38313. /**
  38314. * Sound's volume
  38315. */
  38316. volume?: number;
  38317. /**
  38318. * Is it a spatial sound?
  38319. */
  38320. spatialSound?: boolean;
  38321. /**
  38322. * Maximum distance to hear that sound
  38323. */
  38324. maxDistance?: number;
  38325. /**
  38326. * Uses user defined attenuation function
  38327. */
  38328. useCustomAttenuation?: boolean;
  38329. /**
  38330. * Define the roll off factor of spatial sounds.
  38331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38332. */
  38333. rolloffFactor?: number;
  38334. /**
  38335. * Define the reference distance the sound should be heard perfectly.
  38336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38337. */
  38338. refDistance?: number;
  38339. /**
  38340. * Define the distance attenuation model the sound will follow.
  38341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38342. */
  38343. distanceModel?: string;
  38344. /**
  38345. * Defines the playback speed (1 by default)
  38346. */
  38347. playbackRate?: number;
  38348. /**
  38349. * Defines if the sound is from a streaming source
  38350. */
  38351. streaming?: boolean;
  38352. /**
  38353. * Defines an optional length (in seconds) inside the sound file
  38354. */
  38355. length?: number;
  38356. /**
  38357. * Defines an optional offset (in seconds) inside the sound file
  38358. */
  38359. offset?: number;
  38360. /**
  38361. * If true, URLs will not be required to state the audio file codec to use.
  38362. */
  38363. skipCodecCheck?: boolean;
  38364. }
  38365. /**
  38366. * Defines a sound that can be played in the application.
  38367. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38369. */
  38370. export class Sound {
  38371. /**
  38372. * The name of the sound in the scene.
  38373. */
  38374. name: string;
  38375. /**
  38376. * Does the sound autoplay once loaded.
  38377. */
  38378. autoplay: boolean;
  38379. /**
  38380. * Does the sound loop after it finishes playing once.
  38381. */
  38382. loop: boolean;
  38383. /**
  38384. * Does the sound use a custom attenuation curve to simulate the falloff
  38385. * happening when the source gets further away from the camera.
  38386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38387. */
  38388. useCustomAttenuation: boolean;
  38389. /**
  38390. * The sound track id this sound belongs to.
  38391. */
  38392. soundTrackId: number;
  38393. /**
  38394. * Is this sound currently played.
  38395. */
  38396. isPlaying: boolean;
  38397. /**
  38398. * Is this sound currently paused.
  38399. */
  38400. isPaused: boolean;
  38401. /**
  38402. * Does this sound enables spatial sound.
  38403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38404. */
  38405. spatialSound: boolean;
  38406. /**
  38407. * Define the reference distance the sound should be heard perfectly.
  38408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38409. */
  38410. refDistance: number;
  38411. /**
  38412. * Define the roll off factor of spatial sounds.
  38413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38414. */
  38415. rolloffFactor: number;
  38416. /**
  38417. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38419. */
  38420. maxDistance: number;
  38421. /**
  38422. * Define the distance attenuation model the sound will follow.
  38423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38424. */
  38425. distanceModel: string;
  38426. /**
  38427. * @hidden
  38428. * Back Compat
  38429. **/
  38430. onended: () => any;
  38431. /**
  38432. * Observable event when the current playing sound finishes.
  38433. */
  38434. onEndedObservable: Observable<Sound>;
  38435. private _panningModel;
  38436. private _playbackRate;
  38437. private _streaming;
  38438. private _startTime;
  38439. private _startOffset;
  38440. private _position;
  38441. /** @hidden */
  38442. _positionInEmitterSpace: boolean;
  38443. private _localDirection;
  38444. private _volume;
  38445. private _isReadyToPlay;
  38446. private _isDirectional;
  38447. private _readyToPlayCallback;
  38448. private _audioBuffer;
  38449. private _soundSource;
  38450. private _streamingSource;
  38451. private _soundPanner;
  38452. private _soundGain;
  38453. private _inputAudioNode;
  38454. private _outputAudioNode;
  38455. private _coneInnerAngle;
  38456. private _coneOuterAngle;
  38457. private _coneOuterGain;
  38458. private _scene;
  38459. private _connectedTransformNode;
  38460. private _customAttenuationFunction;
  38461. private _registerFunc;
  38462. private _isOutputConnected;
  38463. private _htmlAudioElement;
  38464. private _urlType;
  38465. private _length?;
  38466. private _offset?;
  38467. /** @hidden */
  38468. static _SceneComponentInitialization: (scene: Scene) => void;
  38469. /**
  38470. * Create a sound and attach it to a scene
  38471. * @param name Name of your sound
  38472. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38473. * @param scene defines the scene the sound belongs to
  38474. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38475. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38476. */
  38477. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38478. /**
  38479. * Release the sound and its associated resources
  38480. */
  38481. dispose(): void;
  38482. /**
  38483. * Gets if the sounds is ready to be played or not.
  38484. * @returns true if ready, otherwise false
  38485. */
  38486. isReady(): boolean;
  38487. private _soundLoaded;
  38488. /**
  38489. * Sets the data of the sound from an audiobuffer
  38490. * @param audioBuffer The audioBuffer containing the data
  38491. */
  38492. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38493. /**
  38494. * Updates the current sounds options such as maxdistance, loop...
  38495. * @param options A JSON object containing values named as the object properties
  38496. */
  38497. updateOptions(options: ISoundOptions): void;
  38498. private _createSpatialParameters;
  38499. private _updateSpatialParameters;
  38500. /**
  38501. * Switch the panning model to HRTF:
  38502. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38504. */
  38505. switchPanningModelToHRTF(): void;
  38506. /**
  38507. * Switch the panning model to Equal Power:
  38508. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38510. */
  38511. switchPanningModelToEqualPower(): void;
  38512. private _switchPanningModel;
  38513. /**
  38514. * Connect this sound to a sound track audio node like gain...
  38515. * @param soundTrackAudioNode the sound track audio node to connect to
  38516. */
  38517. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38518. /**
  38519. * Transform this sound into a directional source
  38520. * @param coneInnerAngle Size of the inner cone in degree
  38521. * @param coneOuterAngle Size of the outer cone in degree
  38522. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38523. */
  38524. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38525. /**
  38526. * Gets or sets the inner angle for the directional cone.
  38527. */
  38528. get directionalConeInnerAngle(): number;
  38529. /**
  38530. * Gets or sets the inner angle for the directional cone.
  38531. */
  38532. set directionalConeInnerAngle(value: number);
  38533. /**
  38534. * Gets or sets the outer angle for the directional cone.
  38535. */
  38536. get directionalConeOuterAngle(): number;
  38537. /**
  38538. * Gets or sets the outer angle for the directional cone.
  38539. */
  38540. set directionalConeOuterAngle(value: number);
  38541. /**
  38542. * Sets the position of the emitter if spatial sound is enabled
  38543. * @param newPosition Defines the new posisiton
  38544. */
  38545. setPosition(newPosition: Vector3): void;
  38546. /**
  38547. * Sets the local direction of the emitter if spatial sound is enabled
  38548. * @param newLocalDirection Defines the new local direction
  38549. */
  38550. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38551. private _updateDirection;
  38552. /** @hidden */
  38553. updateDistanceFromListener(): void;
  38554. /**
  38555. * Sets a new custom attenuation function for the sound.
  38556. * @param callback Defines the function used for the attenuation
  38557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38558. */
  38559. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38560. /**
  38561. * Play the sound
  38562. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38563. * @param offset (optional) Start the sound at a specific time in seconds
  38564. * @param length (optional) Sound duration (in seconds)
  38565. */
  38566. play(time?: number, offset?: number, length?: number): void;
  38567. private _onended;
  38568. /**
  38569. * Stop the sound
  38570. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38571. */
  38572. stop(time?: number): void;
  38573. /**
  38574. * Put the sound in pause
  38575. */
  38576. pause(): void;
  38577. /**
  38578. * Sets a dedicated volume for this sounds
  38579. * @param newVolume Define the new volume of the sound
  38580. * @param time Define time for gradual change to new volume
  38581. */
  38582. setVolume(newVolume: number, time?: number): void;
  38583. /**
  38584. * Set the sound play back rate
  38585. * @param newPlaybackRate Define the playback rate the sound should be played at
  38586. */
  38587. setPlaybackRate(newPlaybackRate: number): void;
  38588. /**
  38589. * Gets the volume of the sound.
  38590. * @returns the volume of the sound
  38591. */
  38592. getVolume(): number;
  38593. /**
  38594. * Attach the sound to a dedicated mesh
  38595. * @param transformNode The transform node to connect the sound with
  38596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38597. */
  38598. attachToMesh(transformNode: TransformNode): void;
  38599. /**
  38600. * Detach the sound from the previously attached mesh
  38601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38602. */
  38603. detachFromMesh(): void;
  38604. private _onRegisterAfterWorldMatrixUpdate;
  38605. /**
  38606. * Clone the current sound in the scene.
  38607. * @returns the new sound clone
  38608. */
  38609. clone(): Nullable<Sound>;
  38610. /**
  38611. * Gets the current underlying audio buffer containing the data
  38612. * @returns the audio buffer
  38613. */
  38614. getAudioBuffer(): Nullable<AudioBuffer>;
  38615. /**
  38616. * Serializes the Sound in a JSON representation
  38617. * @returns the JSON representation of the sound
  38618. */
  38619. serialize(): any;
  38620. /**
  38621. * Parse a JSON representation of a sound to innstantiate in a given scene
  38622. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38623. * @param scene Define the scene the new parsed sound should be created in
  38624. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38625. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38626. * @returns the newly parsed sound
  38627. */
  38628. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38629. }
  38630. }
  38631. declare module "babylonjs/Actions/directAudioActions" {
  38632. import { Action } from "babylonjs/Actions/action";
  38633. import { Condition } from "babylonjs/Actions/condition";
  38634. import { Sound } from "babylonjs/Audio/sound";
  38635. /**
  38636. * This defines an action helpful to play a defined sound on a triggered action.
  38637. */
  38638. export class PlaySoundAction extends Action {
  38639. private _sound;
  38640. /**
  38641. * Instantiate the action
  38642. * @param triggerOptions defines the trigger options
  38643. * @param sound defines the sound to play
  38644. * @param condition defines the trigger related conditions
  38645. */
  38646. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38647. /** @hidden */
  38648. _prepare(): void;
  38649. /**
  38650. * Execute the action and play the sound.
  38651. */
  38652. execute(): void;
  38653. /**
  38654. * Serializes the actions and its related information.
  38655. * @param parent defines the object to serialize in
  38656. * @returns the serialized object
  38657. */
  38658. serialize(parent: any): any;
  38659. }
  38660. /**
  38661. * This defines an action helpful to stop a defined sound on a triggered action.
  38662. */
  38663. export class StopSoundAction extends Action {
  38664. private _sound;
  38665. /**
  38666. * Instantiate the action
  38667. * @param triggerOptions defines the trigger options
  38668. * @param sound defines the sound to stop
  38669. * @param condition defines the trigger related conditions
  38670. */
  38671. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38672. /** @hidden */
  38673. _prepare(): void;
  38674. /**
  38675. * Execute the action and stop the sound.
  38676. */
  38677. execute(): void;
  38678. /**
  38679. * Serializes the actions and its related information.
  38680. * @param parent defines the object to serialize in
  38681. * @returns the serialized object
  38682. */
  38683. serialize(parent: any): any;
  38684. }
  38685. }
  38686. declare module "babylonjs/Actions/interpolateValueAction" {
  38687. import { Action } from "babylonjs/Actions/action";
  38688. import { Condition } from "babylonjs/Actions/condition";
  38689. import { Observable } from "babylonjs/Misc/observable";
  38690. /**
  38691. * This defines an action responsible to change the value of a property
  38692. * by interpolating between its current value and the newly set one once triggered.
  38693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38694. */
  38695. export class InterpolateValueAction extends Action {
  38696. /**
  38697. * Defines the path of the property where the value should be interpolated
  38698. */
  38699. propertyPath: string;
  38700. /**
  38701. * Defines the target value at the end of the interpolation.
  38702. */
  38703. value: any;
  38704. /**
  38705. * Defines the time it will take for the property to interpolate to the value.
  38706. */
  38707. duration: number;
  38708. /**
  38709. * Defines if the other scene animations should be stopped when the action has been triggered
  38710. */
  38711. stopOtherAnimations?: boolean;
  38712. /**
  38713. * Defines a callback raised once the interpolation animation has been done.
  38714. */
  38715. onInterpolationDone?: () => void;
  38716. /**
  38717. * Observable triggered once the interpolation animation has been done.
  38718. */
  38719. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38720. private _target;
  38721. private _effectiveTarget;
  38722. private _property;
  38723. /**
  38724. * Instantiate the action
  38725. * @param triggerOptions defines the trigger options
  38726. * @param target defines the object containing the value to interpolate
  38727. * @param propertyPath defines the path to the property in the target object
  38728. * @param value defines the target value at the end of the interpolation
  38729. * @param duration deines the time it will take for the property to interpolate to the value.
  38730. * @param condition defines the trigger related conditions
  38731. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38732. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38733. */
  38734. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38735. /** @hidden */
  38736. _prepare(): void;
  38737. /**
  38738. * Execute the action starts the value interpolation.
  38739. */
  38740. execute(): void;
  38741. /**
  38742. * Serializes the actions and its related information.
  38743. * @param parent defines the object to serialize in
  38744. * @returns the serialized object
  38745. */
  38746. serialize(parent: any): any;
  38747. }
  38748. }
  38749. declare module "babylonjs/Actions/index" {
  38750. export * from "babylonjs/Actions/abstractActionManager";
  38751. export * from "babylonjs/Actions/action";
  38752. export * from "babylonjs/Actions/actionEvent";
  38753. export * from "babylonjs/Actions/actionManager";
  38754. export * from "babylonjs/Actions/condition";
  38755. export * from "babylonjs/Actions/directActions";
  38756. export * from "babylonjs/Actions/directAudioActions";
  38757. export * from "babylonjs/Actions/interpolateValueAction";
  38758. }
  38759. declare module "babylonjs/Animations/index" {
  38760. export * from "babylonjs/Animations/animatable";
  38761. export * from "babylonjs/Animations/animation";
  38762. export * from "babylonjs/Animations/animationGroup";
  38763. export * from "babylonjs/Animations/animationPropertiesOverride";
  38764. export * from "babylonjs/Animations/easing";
  38765. export * from "babylonjs/Animations/runtimeAnimation";
  38766. export * from "babylonjs/Animations/animationEvent";
  38767. export * from "babylonjs/Animations/animationGroup";
  38768. export * from "babylonjs/Animations/animationKey";
  38769. export * from "babylonjs/Animations/animationRange";
  38770. export * from "babylonjs/Animations/animatable.interface";
  38771. }
  38772. declare module "babylonjs/Audio/soundTrack" {
  38773. import { Sound } from "babylonjs/Audio/sound";
  38774. import { Analyser } from "babylonjs/Audio/analyser";
  38775. import { Scene } from "babylonjs/scene";
  38776. /**
  38777. * Options allowed during the creation of a sound track.
  38778. */
  38779. export interface ISoundTrackOptions {
  38780. /**
  38781. * The volume the sound track should take during creation
  38782. */
  38783. volume?: number;
  38784. /**
  38785. * Define if the sound track is the main sound track of the scene
  38786. */
  38787. mainTrack?: boolean;
  38788. }
  38789. /**
  38790. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38791. * It will be also used in a future release to apply effects on a specific track.
  38792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38793. */
  38794. export class SoundTrack {
  38795. /**
  38796. * The unique identifier of the sound track in the scene.
  38797. */
  38798. id: number;
  38799. /**
  38800. * The list of sounds included in the sound track.
  38801. */
  38802. soundCollection: Array<Sound>;
  38803. private _outputAudioNode;
  38804. private _scene;
  38805. private _connectedAnalyser;
  38806. private _options;
  38807. private _isInitialized;
  38808. /**
  38809. * Creates a new sound track.
  38810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38811. * @param scene Define the scene the sound track belongs to
  38812. * @param options
  38813. */
  38814. constructor(scene: Scene, options?: ISoundTrackOptions);
  38815. private _initializeSoundTrackAudioGraph;
  38816. /**
  38817. * Release the sound track and its associated resources
  38818. */
  38819. dispose(): void;
  38820. /**
  38821. * Adds a sound to this sound track
  38822. * @param sound define the cound to add
  38823. * @ignoreNaming
  38824. */
  38825. AddSound(sound: Sound): void;
  38826. /**
  38827. * Removes a sound to this sound track
  38828. * @param sound define the cound to remove
  38829. * @ignoreNaming
  38830. */
  38831. RemoveSound(sound: Sound): void;
  38832. /**
  38833. * Set a global volume for the full sound track.
  38834. * @param newVolume Define the new volume of the sound track
  38835. */
  38836. setVolume(newVolume: number): void;
  38837. /**
  38838. * Switch the panning model to HRTF:
  38839. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38841. */
  38842. switchPanningModelToHRTF(): void;
  38843. /**
  38844. * Switch the panning model to Equal Power:
  38845. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38847. */
  38848. switchPanningModelToEqualPower(): void;
  38849. /**
  38850. * Connect the sound track to an audio analyser allowing some amazing
  38851. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38853. * @param analyser The analyser to connect to the engine
  38854. */
  38855. connectToAnalyser(analyser: Analyser): void;
  38856. }
  38857. }
  38858. declare module "babylonjs/Audio/audioSceneComponent" {
  38859. import { Sound } from "babylonjs/Audio/sound";
  38860. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38861. import { Nullable } from "babylonjs/types";
  38862. import { Vector3 } from "babylonjs/Maths/math.vector";
  38863. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38864. import { Scene } from "babylonjs/scene";
  38865. import { AbstractScene } from "babylonjs/abstractScene";
  38866. import "babylonjs/Audio/audioEngine";
  38867. module "babylonjs/abstractScene" {
  38868. interface AbstractScene {
  38869. /**
  38870. * The list of sounds used in the scene.
  38871. */
  38872. sounds: Nullable<Array<Sound>>;
  38873. }
  38874. }
  38875. module "babylonjs/scene" {
  38876. interface Scene {
  38877. /**
  38878. * @hidden
  38879. * Backing field
  38880. */
  38881. _mainSoundTrack: SoundTrack;
  38882. /**
  38883. * The main sound track played by the scene.
  38884. * It cotains your primary collection of sounds.
  38885. */
  38886. mainSoundTrack: SoundTrack;
  38887. /**
  38888. * The list of sound tracks added to the scene
  38889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38890. */
  38891. soundTracks: Nullable<Array<SoundTrack>>;
  38892. /**
  38893. * Gets a sound using a given name
  38894. * @param name defines the name to search for
  38895. * @return the found sound or null if not found at all.
  38896. */
  38897. getSoundByName(name: string): Nullable<Sound>;
  38898. /**
  38899. * Gets or sets if audio support is enabled
  38900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38901. */
  38902. audioEnabled: boolean;
  38903. /**
  38904. * Gets or sets if audio will be output to headphones
  38905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38906. */
  38907. headphone: boolean;
  38908. /**
  38909. * Gets or sets custom audio listener position provider
  38910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38911. */
  38912. audioListenerPositionProvider: Nullable<() => Vector3>;
  38913. /**
  38914. * Gets or sets a refresh rate when using 3D audio positioning
  38915. */
  38916. audioPositioningRefreshRate: number;
  38917. }
  38918. }
  38919. /**
  38920. * Defines the sound scene component responsible to manage any sounds
  38921. * in a given scene.
  38922. */
  38923. export class AudioSceneComponent implements ISceneSerializableComponent {
  38924. /**
  38925. * The component name helpfull to identify the component in the list of scene components.
  38926. */
  38927. readonly name: string;
  38928. /**
  38929. * The scene the component belongs to.
  38930. */
  38931. scene: Scene;
  38932. private _audioEnabled;
  38933. /**
  38934. * Gets whether audio is enabled or not.
  38935. * Please use related enable/disable method to switch state.
  38936. */
  38937. get audioEnabled(): boolean;
  38938. private _headphone;
  38939. /**
  38940. * Gets whether audio is outputing to headphone or not.
  38941. * Please use the according Switch methods to change output.
  38942. */
  38943. get headphone(): boolean;
  38944. /**
  38945. * Gets or sets a refresh rate when using 3D audio positioning
  38946. */
  38947. audioPositioningRefreshRate: number;
  38948. private _audioListenerPositionProvider;
  38949. /**
  38950. * Gets the current audio listener position provider
  38951. */
  38952. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38953. /**
  38954. * Sets a custom listener position for all sounds in the scene
  38955. * By default, this is the position of the first active camera
  38956. */
  38957. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38958. /**
  38959. * Creates a new instance of the component for the given scene
  38960. * @param scene Defines the scene to register the component in
  38961. */
  38962. constructor(scene: Scene);
  38963. /**
  38964. * Registers the component in a given scene
  38965. */
  38966. register(): void;
  38967. /**
  38968. * Rebuilds the elements related to this component in case of
  38969. * context lost for instance.
  38970. */
  38971. rebuild(): void;
  38972. /**
  38973. * Serializes the component data to the specified json object
  38974. * @param serializationObject The object to serialize to
  38975. */
  38976. serialize(serializationObject: any): void;
  38977. /**
  38978. * Adds all the elements from the container to the scene
  38979. * @param container the container holding the elements
  38980. */
  38981. addFromContainer(container: AbstractScene): void;
  38982. /**
  38983. * Removes all the elements in the container from the scene
  38984. * @param container contains the elements to remove
  38985. * @param dispose if the removed element should be disposed (default: false)
  38986. */
  38987. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38988. /**
  38989. * Disposes the component and the associated ressources.
  38990. */
  38991. dispose(): void;
  38992. /**
  38993. * Disables audio in the associated scene.
  38994. */
  38995. disableAudio(): void;
  38996. /**
  38997. * Enables audio in the associated scene.
  38998. */
  38999. enableAudio(): void;
  39000. /**
  39001. * Switch audio to headphone output.
  39002. */
  39003. switchAudioModeForHeadphones(): void;
  39004. /**
  39005. * Switch audio to normal speakers.
  39006. */
  39007. switchAudioModeForNormalSpeakers(): void;
  39008. private _cachedCameraDirection;
  39009. private _cachedCameraPosition;
  39010. private _lastCheck;
  39011. private _afterRender;
  39012. }
  39013. }
  39014. declare module "babylonjs/Audio/weightedsound" {
  39015. import { Sound } from "babylonjs/Audio/sound";
  39016. /**
  39017. * Wraps one or more Sound objects and selects one with random weight for playback.
  39018. */
  39019. export class WeightedSound {
  39020. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39021. loop: boolean;
  39022. private _coneInnerAngle;
  39023. private _coneOuterAngle;
  39024. private _volume;
  39025. /** A Sound is currently playing. */
  39026. isPlaying: boolean;
  39027. /** A Sound is currently paused. */
  39028. isPaused: boolean;
  39029. private _sounds;
  39030. private _weights;
  39031. private _currentIndex?;
  39032. /**
  39033. * Creates a new WeightedSound from the list of sounds given.
  39034. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39035. * @param sounds Array of Sounds that will be selected from.
  39036. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39037. */
  39038. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39039. /**
  39040. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39041. */
  39042. get directionalConeInnerAngle(): number;
  39043. /**
  39044. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39045. */
  39046. set directionalConeInnerAngle(value: number);
  39047. /**
  39048. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39049. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39050. */
  39051. get directionalConeOuterAngle(): number;
  39052. /**
  39053. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39054. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39055. */
  39056. set directionalConeOuterAngle(value: number);
  39057. /**
  39058. * Playback volume.
  39059. */
  39060. get volume(): number;
  39061. /**
  39062. * Playback volume.
  39063. */
  39064. set volume(value: number);
  39065. private _onended;
  39066. /**
  39067. * Suspend playback
  39068. */
  39069. pause(): void;
  39070. /**
  39071. * Stop playback
  39072. */
  39073. stop(): void;
  39074. /**
  39075. * Start playback.
  39076. * @param startOffset Position the clip head at a specific time in seconds.
  39077. */
  39078. play(startOffset?: number): void;
  39079. }
  39080. }
  39081. declare module "babylonjs/Audio/index" {
  39082. export * from "babylonjs/Audio/analyser";
  39083. export * from "babylonjs/Audio/audioEngine";
  39084. export * from "babylonjs/Audio/audioSceneComponent";
  39085. export * from "babylonjs/Audio/sound";
  39086. export * from "babylonjs/Audio/soundTrack";
  39087. export * from "babylonjs/Audio/weightedsound";
  39088. }
  39089. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39090. import { Behavior } from "babylonjs/Behaviors/behavior";
  39091. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39092. import { BackEase } from "babylonjs/Animations/easing";
  39093. /**
  39094. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39095. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39096. */
  39097. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39098. /**
  39099. * Gets the name of the behavior.
  39100. */
  39101. get name(): string;
  39102. /**
  39103. * The easing function used by animations
  39104. */
  39105. static EasingFunction: BackEase;
  39106. /**
  39107. * The easing mode used by animations
  39108. */
  39109. static EasingMode: number;
  39110. /**
  39111. * The duration of the animation, in milliseconds
  39112. */
  39113. transitionDuration: number;
  39114. /**
  39115. * Length of the distance animated by the transition when lower radius is reached
  39116. */
  39117. lowerRadiusTransitionRange: number;
  39118. /**
  39119. * Length of the distance animated by the transition when upper radius is reached
  39120. */
  39121. upperRadiusTransitionRange: number;
  39122. private _autoTransitionRange;
  39123. /**
  39124. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39125. */
  39126. get autoTransitionRange(): boolean;
  39127. /**
  39128. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39129. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39130. */
  39131. set autoTransitionRange(value: boolean);
  39132. private _attachedCamera;
  39133. private _onAfterCheckInputsObserver;
  39134. private _onMeshTargetChangedObserver;
  39135. /**
  39136. * Initializes the behavior.
  39137. */
  39138. init(): void;
  39139. /**
  39140. * Attaches the behavior to its arc rotate camera.
  39141. * @param camera Defines the camera to attach the behavior to
  39142. */
  39143. attach(camera: ArcRotateCamera): void;
  39144. /**
  39145. * Detaches the behavior from its current arc rotate camera.
  39146. */
  39147. detach(): void;
  39148. private _radiusIsAnimating;
  39149. private _radiusBounceTransition;
  39150. private _animatables;
  39151. private _cachedWheelPrecision;
  39152. /**
  39153. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39154. * @param radiusLimit The limit to check against.
  39155. * @return Bool to indicate if at limit.
  39156. */
  39157. private _isRadiusAtLimit;
  39158. /**
  39159. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39160. * @param radiusDelta The delta by which to animate to. Can be negative.
  39161. */
  39162. private _applyBoundRadiusAnimation;
  39163. /**
  39164. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39165. */
  39166. protected _clearAnimationLocks(): void;
  39167. /**
  39168. * Stops and removes all animations that have been applied to the camera
  39169. */
  39170. stopAllAnimations(): void;
  39171. }
  39172. }
  39173. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39174. import { Behavior } from "babylonjs/Behaviors/behavior";
  39175. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39176. import { ExponentialEase } from "babylonjs/Animations/easing";
  39177. import { Nullable } from "babylonjs/types";
  39178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39179. import { Vector3 } from "babylonjs/Maths/math.vector";
  39180. /**
  39181. * 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.
  39182. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39183. */
  39184. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39185. /**
  39186. * Gets the name of the behavior.
  39187. */
  39188. get name(): string;
  39189. private _mode;
  39190. private _radiusScale;
  39191. private _positionScale;
  39192. private _defaultElevation;
  39193. private _elevationReturnTime;
  39194. private _elevationReturnWaitTime;
  39195. private _zoomStopsAnimation;
  39196. private _framingTime;
  39197. /**
  39198. * The easing function used by animations
  39199. */
  39200. static EasingFunction: ExponentialEase;
  39201. /**
  39202. * The easing mode used by animations
  39203. */
  39204. static EasingMode: number;
  39205. /**
  39206. * Sets the current mode used by the behavior
  39207. */
  39208. set mode(mode: number);
  39209. /**
  39210. * Gets current mode used by the behavior.
  39211. */
  39212. get mode(): number;
  39213. /**
  39214. * Sets the scale applied to the radius (1 by default)
  39215. */
  39216. set radiusScale(radius: number);
  39217. /**
  39218. * Gets the scale applied to the radius
  39219. */
  39220. get radiusScale(): number;
  39221. /**
  39222. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39223. */
  39224. set positionScale(scale: number);
  39225. /**
  39226. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39227. */
  39228. get positionScale(): number;
  39229. /**
  39230. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39231. * behaviour is triggered, in radians.
  39232. */
  39233. set defaultElevation(elevation: number);
  39234. /**
  39235. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39236. * behaviour is triggered, in radians.
  39237. */
  39238. get defaultElevation(): number;
  39239. /**
  39240. * Sets the time (in milliseconds) taken to return to the default beta position.
  39241. * Negative value indicates camera should not return to default.
  39242. */
  39243. set elevationReturnTime(speed: number);
  39244. /**
  39245. * Gets the time (in milliseconds) taken to return to the default beta position.
  39246. * Negative value indicates camera should not return to default.
  39247. */
  39248. get elevationReturnTime(): number;
  39249. /**
  39250. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39251. */
  39252. set elevationReturnWaitTime(time: number);
  39253. /**
  39254. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39255. */
  39256. get elevationReturnWaitTime(): number;
  39257. /**
  39258. * Sets the flag that indicates if user zooming should stop animation.
  39259. */
  39260. set zoomStopsAnimation(flag: boolean);
  39261. /**
  39262. * Gets the flag that indicates if user zooming should stop animation.
  39263. */
  39264. get zoomStopsAnimation(): boolean;
  39265. /**
  39266. * Sets the transition time when framing the mesh, in milliseconds
  39267. */
  39268. set framingTime(time: number);
  39269. /**
  39270. * Gets the transition time when framing the mesh, in milliseconds
  39271. */
  39272. get framingTime(): number;
  39273. /**
  39274. * Define if the behavior should automatically change the configured
  39275. * camera limits and sensibilities.
  39276. */
  39277. autoCorrectCameraLimitsAndSensibility: boolean;
  39278. private _onPrePointerObservableObserver;
  39279. private _onAfterCheckInputsObserver;
  39280. private _onMeshTargetChangedObserver;
  39281. private _attachedCamera;
  39282. private _isPointerDown;
  39283. private _lastInteractionTime;
  39284. /**
  39285. * Initializes the behavior.
  39286. */
  39287. init(): void;
  39288. /**
  39289. * Attaches the behavior to its arc rotate camera.
  39290. * @param camera Defines the camera to attach the behavior to
  39291. */
  39292. attach(camera: ArcRotateCamera): void;
  39293. /**
  39294. * Detaches the behavior from its current arc rotate camera.
  39295. */
  39296. detach(): void;
  39297. private _animatables;
  39298. private _betaIsAnimating;
  39299. private _betaTransition;
  39300. private _radiusTransition;
  39301. private _vectorTransition;
  39302. /**
  39303. * Targets the given mesh and updates zoom level accordingly.
  39304. * @param mesh The mesh to target.
  39305. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39306. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39307. */
  39308. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39309. /**
  39310. * Targets the given mesh with its children and updates zoom level accordingly.
  39311. * @param mesh The mesh to target.
  39312. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39313. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39314. */
  39315. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39316. /**
  39317. * Targets the given meshes with their children and updates zoom level accordingly.
  39318. * @param meshes The mesh to target.
  39319. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39320. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39321. */
  39322. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39323. /**
  39324. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39325. * @param minimumWorld Determines the smaller position of the bounding box extend
  39326. * @param maximumWorld Determines the bigger position of the bounding box extend
  39327. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39328. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39329. */
  39330. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39331. /**
  39332. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39333. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39334. * frustum width.
  39335. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39336. * to fully enclose the mesh in the viewing frustum.
  39337. */
  39338. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39339. /**
  39340. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39341. * is automatically returned to its default position (expected to be above ground plane).
  39342. */
  39343. private _maintainCameraAboveGround;
  39344. /**
  39345. * Returns the frustum slope based on the canvas ratio and camera FOV
  39346. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39347. */
  39348. private _getFrustumSlope;
  39349. /**
  39350. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39351. */
  39352. private _clearAnimationLocks;
  39353. /**
  39354. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39355. */
  39356. private _applyUserInteraction;
  39357. /**
  39358. * Stops and removes all animations that have been applied to the camera
  39359. */
  39360. stopAllAnimations(): void;
  39361. /**
  39362. * Gets a value indicating if the user is moving the camera
  39363. */
  39364. get isUserIsMoving(): boolean;
  39365. /**
  39366. * The camera can move all the way towards the mesh.
  39367. */
  39368. static IgnoreBoundsSizeMode: number;
  39369. /**
  39370. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39371. */
  39372. static FitFrustumSidesMode: number;
  39373. }
  39374. }
  39375. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39376. import { Nullable } from "babylonjs/types";
  39377. import { Camera } from "babylonjs/Cameras/camera";
  39378. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39379. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39380. /**
  39381. * Base class for Camera Pointer Inputs.
  39382. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39383. * for example usage.
  39384. */
  39385. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39386. /**
  39387. * Defines the camera the input is attached to.
  39388. */
  39389. abstract camera: Camera;
  39390. /**
  39391. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39392. */
  39393. protected _altKey: boolean;
  39394. protected _ctrlKey: boolean;
  39395. protected _metaKey: boolean;
  39396. protected _shiftKey: boolean;
  39397. /**
  39398. * Which mouse buttons were pressed at time of last mouse event.
  39399. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39400. */
  39401. protected _buttonsPressed: number;
  39402. /**
  39403. * Defines the buttons associated with the input to handle camera move.
  39404. */
  39405. buttons: number[];
  39406. /**
  39407. * Attach the input controls to a specific dom element to get the input from.
  39408. * @param element Defines the element the controls should be listened from
  39409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39410. */
  39411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39412. /**
  39413. * Detach the current controls from the specified dom element.
  39414. * @param element Defines the element to stop listening the inputs from
  39415. */
  39416. detachControl(element: Nullable<HTMLElement>): void;
  39417. /**
  39418. * Gets the class name of the current input.
  39419. * @returns the class name
  39420. */
  39421. getClassName(): string;
  39422. /**
  39423. * Get the friendly name associated with the input class.
  39424. * @returns the input friendly name
  39425. */
  39426. getSimpleName(): string;
  39427. /**
  39428. * Called on pointer POINTERDOUBLETAP event.
  39429. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39430. */
  39431. protected onDoubleTap(type: string): void;
  39432. /**
  39433. * Called on pointer POINTERMOVE event if only a single touch is active.
  39434. * Override this method to provide functionality.
  39435. */
  39436. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39437. /**
  39438. * Called on pointer POINTERMOVE event if multiple touches are active.
  39439. * Override this method to provide functionality.
  39440. */
  39441. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39442. /**
  39443. * Called on JS contextmenu event.
  39444. * Override this method to provide functionality.
  39445. */
  39446. protected onContextMenu(evt: PointerEvent): void;
  39447. /**
  39448. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39449. * press.
  39450. * Override this method to provide functionality.
  39451. */
  39452. protected onButtonDown(evt: PointerEvent): void;
  39453. /**
  39454. * Called each time a new POINTERUP event occurs. Ie, for each button
  39455. * release.
  39456. * Override this method to provide functionality.
  39457. */
  39458. protected onButtonUp(evt: PointerEvent): void;
  39459. /**
  39460. * Called when window becomes inactive.
  39461. * Override this method to provide functionality.
  39462. */
  39463. protected onLostFocus(): void;
  39464. private _pointerInput;
  39465. private _observer;
  39466. private _onLostFocus;
  39467. private pointA;
  39468. private pointB;
  39469. }
  39470. }
  39471. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39472. import { Nullable } from "babylonjs/types";
  39473. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39474. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39475. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39476. /**
  39477. * Manage the pointers inputs to control an arc rotate camera.
  39478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39479. */
  39480. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39481. /**
  39482. * Defines the camera the input is attached to.
  39483. */
  39484. camera: ArcRotateCamera;
  39485. /**
  39486. * Gets the class name of the current input.
  39487. * @returns the class name
  39488. */
  39489. getClassName(): string;
  39490. /**
  39491. * Defines the buttons associated with the input to handle camera move.
  39492. */
  39493. buttons: number[];
  39494. /**
  39495. * Defines the pointer angular sensibility along the X axis or how fast is
  39496. * the camera rotating.
  39497. */
  39498. angularSensibilityX: number;
  39499. /**
  39500. * Defines the pointer angular sensibility along the Y axis or how fast is
  39501. * the camera rotating.
  39502. */
  39503. angularSensibilityY: number;
  39504. /**
  39505. * Defines the pointer pinch precision or how fast is the camera zooming.
  39506. */
  39507. pinchPrecision: number;
  39508. /**
  39509. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39510. * from 0.
  39511. * It defines the percentage of current camera.radius to use as delta when
  39512. * pinch zoom is used.
  39513. */
  39514. pinchDeltaPercentage: number;
  39515. /**
  39516. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39517. * that any object in the plane at the camera's target point will scale
  39518. * perfectly with finger motion.
  39519. * Overrides pinchDeltaPercentage and pinchPrecision.
  39520. */
  39521. useNaturalPinchZoom: boolean;
  39522. /**
  39523. * Defines the pointer panning sensibility or how fast is the camera moving.
  39524. */
  39525. panningSensibility: number;
  39526. /**
  39527. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39528. */
  39529. multiTouchPanning: boolean;
  39530. /**
  39531. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39532. * zoom (pinch) through multitouch.
  39533. */
  39534. multiTouchPanAndZoom: boolean;
  39535. /**
  39536. * Revers pinch action direction.
  39537. */
  39538. pinchInwards: boolean;
  39539. private _isPanClick;
  39540. private _twoFingerActivityCount;
  39541. private _isPinching;
  39542. /**
  39543. * Called on pointer POINTERMOVE event if only a single touch is active.
  39544. */
  39545. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39546. /**
  39547. * Called on pointer POINTERDOUBLETAP event.
  39548. */
  39549. protected onDoubleTap(type: string): void;
  39550. /**
  39551. * Called on pointer POINTERMOVE event if multiple touches are active.
  39552. */
  39553. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39554. /**
  39555. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39556. * press.
  39557. */
  39558. protected onButtonDown(evt: PointerEvent): void;
  39559. /**
  39560. * Called each time a new POINTERUP event occurs. Ie, for each button
  39561. * release.
  39562. */
  39563. protected onButtonUp(evt: PointerEvent): void;
  39564. /**
  39565. * Called when window becomes inactive.
  39566. */
  39567. protected onLostFocus(): void;
  39568. }
  39569. }
  39570. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39571. import { Nullable } from "babylonjs/types";
  39572. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39573. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39574. /**
  39575. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39577. */
  39578. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39579. /**
  39580. * Defines the camera the input is attached to.
  39581. */
  39582. camera: ArcRotateCamera;
  39583. /**
  39584. * Defines the list of key codes associated with the up action (increase alpha)
  39585. */
  39586. keysUp: number[];
  39587. /**
  39588. * Defines the list of key codes associated with the down action (decrease alpha)
  39589. */
  39590. keysDown: number[];
  39591. /**
  39592. * Defines the list of key codes associated with the left action (increase beta)
  39593. */
  39594. keysLeft: number[];
  39595. /**
  39596. * Defines the list of key codes associated with the right action (decrease beta)
  39597. */
  39598. keysRight: number[];
  39599. /**
  39600. * Defines the list of key codes associated with the reset action.
  39601. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39602. */
  39603. keysReset: number[];
  39604. /**
  39605. * Defines the panning sensibility of the inputs.
  39606. * (How fast is the camera panning)
  39607. */
  39608. panningSensibility: number;
  39609. /**
  39610. * Defines the zooming sensibility of the inputs.
  39611. * (How fast is the camera zooming)
  39612. */
  39613. zoomingSensibility: number;
  39614. /**
  39615. * Defines whether maintaining the alt key down switch the movement mode from
  39616. * orientation to zoom.
  39617. */
  39618. useAltToZoom: boolean;
  39619. /**
  39620. * Rotation speed of the camera
  39621. */
  39622. angularSpeed: number;
  39623. private _keys;
  39624. private _ctrlPressed;
  39625. private _altPressed;
  39626. private _onCanvasBlurObserver;
  39627. private _onKeyboardObserver;
  39628. private _engine;
  39629. private _scene;
  39630. /**
  39631. * Attach the input controls to a specific dom element to get the input from.
  39632. * @param element Defines the element the controls should be listened from
  39633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39634. */
  39635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39636. /**
  39637. * Detach the current controls from the specified dom element.
  39638. * @param element Defines the element to stop listening the inputs from
  39639. */
  39640. detachControl(element: Nullable<HTMLElement>): void;
  39641. /**
  39642. * Update the current camera state depending on the inputs that have been used this frame.
  39643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39644. */
  39645. checkInputs(): void;
  39646. /**
  39647. * Gets the class name of the current intput.
  39648. * @returns the class name
  39649. */
  39650. getClassName(): string;
  39651. /**
  39652. * Get the friendly name associated with the input class.
  39653. * @returns the input friendly name
  39654. */
  39655. getSimpleName(): string;
  39656. }
  39657. }
  39658. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39659. import { Nullable } from "babylonjs/types";
  39660. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39661. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39662. /**
  39663. * Manage the mouse wheel inputs to control an arc rotate camera.
  39664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39665. */
  39666. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39667. /**
  39668. * Defines the camera the input is attached to.
  39669. */
  39670. camera: ArcRotateCamera;
  39671. /**
  39672. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39673. */
  39674. wheelPrecision: number;
  39675. /**
  39676. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39677. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39678. */
  39679. wheelDeltaPercentage: number;
  39680. private _wheel;
  39681. private _observer;
  39682. private computeDeltaFromMouseWheelLegacyEvent;
  39683. /**
  39684. * Attach the input controls to a specific dom element to get the input from.
  39685. * @param element Defines the element the controls should be listened from
  39686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39687. */
  39688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39689. /**
  39690. * Detach the current controls from the specified dom element.
  39691. * @param element Defines the element to stop listening the inputs from
  39692. */
  39693. detachControl(element: Nullable<HTMLElement>): void;
  39694. /**
  39695. * Gets the class name of the current intput.
  39696. * @returns the class name
  39697. */
  39698. getClassName(): string;
  39699. /**
  39700. * Get the friendly name associated with the input class.
  39701. * @returns the input friendly name
  39702. */
  39703. getSimpleName(): string;
  39704. }
  39705. }
  39706. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39707. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39708. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39709. /**
  39710. * Default Inputs manager for the ArcRotateCamera.
  39711. * It groups all the default supported inputs for ease of use.
  39712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39713. */
  39714. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39715. /**
  39716. * Instantiates a new ArcRotateCameraInputsManager.
  39717. * @param camera Defines the camera the inputs belong to
  39718. */
  39719. constructor(camera: ArcRotateCamera);
  39720. /**
  39721. * Add mouse wheel input support to the input manager.
  39722. * @returns the current input manager
  39723. */
  39724. addMouseWheel(): ArcRotateCameraInputsManager;
  39725. /**
  39726. * Add pointers input support to the input manager.
  39727. * @returns the current input manager
  39728. */
  39729. addPointers(): ArcRotateCameraInputsManager;
  39730. /**
  39731. * Add keyboard input support to the input manager.
  39732. * @returns the current input manager
  39733. */
  39734. addKeyboard(): ArcRotateCameraInputsManager;
  39735. }
  39736. }
  39737. declare module "babylonjs/Cameras/arcRotateCamera" {
  39738. import { Observable } from "babylonjs/Misc/observable";
  39739. import { Nullable } from "babylonjs/types";
  39740. import { Scene } from "babylonjs/scene";
  39741. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39743. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39744. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39745. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39746. import { Camera } from "babylonjs/Cameras/camera";
  39747. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39748. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39749. import { Collider } from "babylonjs/Collisions/collider";
  39750. /**
  39751. * This represents an orbital type of camera.
  39752. *
  39753. * 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.
  39754. * 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.
  39755. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39756. */
  39757. export class ArcRotateCamera extends TargetCamera {
  39758. /**
  39759. * Defines the rotation angle of the camera along the longitudinal axis.
  39760. */
  39761. alpha: number;
  39762. /**
  39763. * Defines the rotation angle of the camera along the latitudinal axis.
  39764. */
  39765. beta: number;
  39766. /**
  39767. * Defines the radius of the camera from it s target point.
  39768. */
  39769. radius: number;
  39770. protected _target: Vector3;
  39771. protected _targetHost: Nullable<AbstractMesh>;
  39772. /**
  39773. * Defines the target point of the camera.
  39774. * The camera looks towards it form the radius distance.
  39775. */
  39776. get target(): Vector3;
  39777. set target(value: Vector3);
  39778. /**
  39779. * Define the current local position of the camera in the scene
  39780. */
  39781. get position(): Vector3;
  39782. set position(newPosition: Vector3);
  39783. protected _upVector: Vector3;
  39784. protected _upToYMatrix: Matrix;
  39785. protected _YToUpMatrix: Matrix;
  39786. /**
  39787. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39788. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39789. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39790. */
  39791. set upVector(vec: Vector3);
  39792. get upVector(): Vector3;
  39793. /**
  39794. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39795. */
  39796. setMatUp(): void;
  39797. /**
  39798. * Current inertia value on the longitudinal axis.
  39799. * The bigger this number the longer it will take for the camera to stop.
  39800. */
  39801. inertialAlphaOffset: number;
  39802. /**
  39803. * Current inertia value on the latitudinal axis.
  39804. * The bigger this number the longer it will take for the camera to stop.
  39805. */
  39806. inertialBetaOffset: number;
  39807. /**
  39808. * Current inertia value on the radius axis.
  39809. * The bigger this number the longer it will take for the camera to stop.
  39810. */
  39811. inertialRadiusOffset: number;
  39812. /**
  39813. * Minimum allowed angle on the longitudinal axis.
  39814. * This can help limiting how the Camera is able to move in the scene.
  39815. */
  39816. lowerAlphaLimit: Nullable<number>;
  39817. /**
  39818. * Maximum allowed angle on the longitudinal axis.
  39819. * This can help limiting how the Camera is able to move in the scene.
  39820. */
  39821. upperAlphaLimit: Nullable<number>;
  39822. /**
  39823. * Minimum allowed angle on the latitudinal axis.
  39824. * This can help limiting how the Camera is able to move in the scene.
  39825. */
  39826. lowerBetaLimit: number;
  39827. /**
  39828. * Maximum allowed angle on the latitudinal axis.
  39829. * This can help limiting how the Camera is able to move in the scene.
  39830. */
  39831. upperBetaLimit: number;
  39832. /**
  39833. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39834. * This can help limiting how the Camera is able to move in the scene.
  39835. */
  39836. lowerRadiusLimit: Nullable<number>;
  39837. /**
  39838. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39839. * This can help limiting how the Camera is able to move in the scene.
  39840. */
  39841. upperRadiusLimit: Nullable<number>;
  39842. /**
  39843. * Defines the current inertia value used during panning of the camera along the X axis.
  39844. */
  39845. inertialPanningX: number;
  39846. /**
  39847. * Defines the current inertia value used during panning of the camera along the Y axis.
  39848. */
  39849. inertialPanningY: number;
  39850. /**
  39851. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39852. * Basically if your fingers moves away from more than this distance you will be considered
  39853. * in pinch mode.
  39854. */
  39855. pinchToPanMaxDistance: number;
  39856. /**
  39857. * Defines the maximum distance the camera can pan.
  39858. * This could help keeping the cammera always in your scene.
  39859. */
  39860. panningDistanceLimit: Nullable<number>;
  39861. /**
  39862. * Defines the target of the camera before paning.
  39863. */
  39864. panningOriginTarget: Vector3;
  39865. /**
  39866. * Defines the value of the inertia used during panning.
  39867. * 0 would mean stop inertia and one would mean no decelleration at all.
  39868. */
  39869. panningInertia: number;
  39870. /**
  39871. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39872. */
  39873. get angularSensibilityX(): number;
  39874. set angularSensibilityX(value: number);
  39875. /**
  39876. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39877. */
  39878. get angularSensibilityY(): number;
  39879. set angularSensibilityY(value: number);
  39880. /**
  39881. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39882. */
  39883. get pinchPrecision(): number;
  39884. set pinchPrecision(value: number);
  39885. /**
  39886. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39887. * It will be used instead of pinchDeltaPrecision if different from 0.
  39888. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39889. */
  39890. get pinchDeltaPercentage(): number;
  39891. set pinchDeltaPercentage(value: number);
  39892. /**
  39893. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39894. * and pinch delta percentage.
  39895. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39896. * that any object in the plane at the camera's target point will scale
  39897. * perfectly with finger motion.
  39898. */
  39899. get useNaturalPinchZoom(): boolean;
  39900. set useNaturalPinchZoom(value: boolean);
  39901. /**
  39902. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39903. */
  39904. get panningSensibility(): number;
  39905. set panningSensibility(value: number);
  39906. /**
  39907. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39908. */
  39909. get keysUp(): number[];
  39910. set keysUp(value: number[]);
  39911. /**
  39912. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39913. */
  39914. get keysDown(): number[];
  39915. set keysDown(value: number[]);
  39916. /**
  39917. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39918. */
  39919. get keysLeft(): number[];
  39920. set keysLeft(value: number[]);
  39921. /**
  39922. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39923. */
  39924. get keysRight(): number[];
  39925. set keysRight(value: number[]);
  39926. /**
  39927. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39928. */
  39929. get wheelPrecision(): number;
  39930. set wheelPrecision(value: number);
  39931. /**
  39932. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39933. * It will be used instead of pinchDeltaPrecision if different from 0.
  39934. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39935. */
  39936. get wheelDeltaPercentage(): number;
  39937. set wheelDeltaPercentage(value: number);
  39938. /**
  39939. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39940. */
  39941. zoomOnFactor: number;
  39942. /**
  39943. * Defines a screen offset for the camera position.
  39944. */
  39945. targetScreenOffset: Vector2;
  39946. /**
  39947. * Allows the camera to be completely reversed.
  39948. * If false the camera can not arrive upside down.
  39949. */
  39950. allowUpsideDown: boolean;
  39951. /**
  39952. * Define if double tap/click is used to restore the previously saved state of the camera.
  39953. */
  39954. useInputToRestoreState: boolean;
  39955. /** @hidden */
  39956. _viewMatrix: Matrix;
  39957. /** @hidden */
  39958. _useCtrlForPanning: boolean;
  39959. /** @hidden */
  39960. _panningMouseButton: number;
  39961. /**
  39962. * Defines the input associated to the camera.
  39963. */
  39964. inputs: ArcRotateCameraInputsManager;
  39965. /** @hidden */
  39966. _reset: () => void;
  39967. /**
  39968. * Defines the allowed panning axis.
  39969. */
  39970. panningAxis: Vector3;
  39971. protected _localDirection: Vector3;
  39972. protected _transformedDirection: Vector3;
  39973. private _bouncingBehavior;
  39974. /**
  39975. * Gets the bouncing behavior of the camera if it has been enabled.
  39976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39977. */
  39978. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39979. /**
  39980. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39981. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39982. */
  39983. get useBouncingBehavior(): boolean;
  39984. set useBouncingBehavior(value: boolean);
  39985. private _framingBehavior;
  39986. /**
  39987. * Gets the framing behavior of the camera if it has been enabled.
  39988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39989. */
  39990. get framingBehavior(): Nullable<FramingBehavior>;
  39991. /**
  39992. * Defines if the framing behavior of the camera is enabled on the camera.
  39993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39994. */
  39995. get useFramingBehavior(): boolean;
  39996. set useFramingBehavior(value: boolean);
  39997. private _autoRotationBehavior;
  39998. /**
  39999. * Gets the auto rotation behavior of the camera if it has been enabled.
  40000. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40001. */
  40002. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40003. /**
  40004. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40005. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40006. */
  40007. get useAutoRotationBehavior(): boolean;
  40008. set useAutoRotationBehavior(value: boolean);
  40009. /**
  40010. * Observable triggered when the mesh target has been changed on the camera.
  40011. */
  40012. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40013. /**
  40014. * Event raised when the camera is colliding with a mesh.
  40015. */
  40016. onCollide: (collidedMesh: AbstractMesh) => void;
  40017. /**
  40018. * Defines whether the camera should check collision with the objects oh the scene.
  40019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40020. */
  40021. checkCollisions: boolean;
  40022. /**
  40023. * Defines the collision radius of the camera.
  40024. * This simulates a sphere around the camera.
  40025. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40026. */
  40027. collisionRadius: Vector3;
  40028. protected _collider: Collider;
  40029. protected _previousPosition: Vector3;
  40030. protected _collisionVelocity: Vector3;
  40031. protected _newPosition: Vector3;
  40032. protected _previousAlpha: number;
  40033. protected _previousBeta: number;
  40034. protected _previousRadius: number;
  40035. protected _collisionTriggered: boolean;
  40036. protected _targetBoundingCenter: Nullable<Vector3>;
  40037. private _computationVector;
  40038. /**
  40039. * Instantiates a new ArcRotateCamera in a given scene
  40040. * @param name Defines the name of the camera
  40041. * @param alpha Defines the camera rotation along the logitudinal axis
  40042. * @param beta Defines the camera rotation along the latitudinal axis
  40043. * @param radius Defines the camera distance from its target
  40044. * @param target Defines the camera target
  40045. * @param scene Defines the scene the camera belongs to
  40046. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40047. */
  40048. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40049. /** @hidden */
  40050. _initCache(): void;
  40051. /** @hidden */
  40052. _updateCache(ignoreParentClass?: boolean): void;
  40053. protected _getTargetPosition(): Vector3;
  40054. private _storedAlpha;
  40055. private _storedBeta;
  40056. private _storedRadius;
  40057. private _storedTarget;
  40058. private _storedTargetScreenOffset;
  40059. /**
  40060. * Stores the current state of the camera (alpha, beta, radius and target)
  40061. * @returns the camera itself
  40062. */
  40063. storeState(): Camera;
  40064. /**
  40065. * @hidden
  40066. * Restored camera state. You must call storeState() first
  40067. */
  40068. _restoreStateValues(): boolean;
  40069. /** @hidden */
  40070. _isSynchronizedViewMatrix(): boolean;
  40071. /**
  40072. * Attached controls to the current camera.
  40073. * @param element Defines the element the controls should be listened from
  40074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40075. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40076. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40077. */
  40078. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40079. /**
  40080. * Detach the current controls from the camera.
  40081. * The camera will stop reacting to inputs.
  40082. * @param element Defines the element to stop listening the inputs from
  40083. */
  40084. detachControl(element: HTMLElement): void;
  40085. /** @hidden */
  40086. _checkInputs(): void;
  40087. protected _checkLimits(): void;
  40088. /**
  40089. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40090. */
  40091. rebuildAnglesAndRadius(): void;
  40092. /**
  40093. * Use a position to define the current camera related information like alpha, beta and radius
  40094. * @param position Defines the position to set the camera at
  40095. */
  40096. setPosition(position: Vector3): void;
  40097. /**
  40098. * Defines the target the camera should look at.
  40099. * This will automatically adapt alpha beta and radius to fit within the new target.
  40100. * @param target Defines the new target as a Vector or a mesh
  40101. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40102. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40103. */
  40104. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40105. /** @hidden */
  40106. _getViewMatrix(): Matrix;
  40107. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40108. /**
  40109. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40110. * @param meshes Defines the mesh to zoom on
  40111. * @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)
  40112. */
  40113. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40114. /**
  40115. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40116. * The target will be changed but the radius
  40117. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40118. * @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)
  40119. */
  40120. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40121. min: Vector3;
  40122. max: Vector3;
  40123. distance: number;
  40124. }, doNotUpdateMaxZ?: boolean): void;
  40125. /**
  40126. * @override
  40127. * Override Camera.createRigCamera
  40128. */
  40129. createRigCamera(name: string, cameraIndex: number): Camera;
  40130. /**
  40131. * @hidden
  40132. * @override
  40133. * Override Camera._updateRigCameras
  40134. */
  40135. _updateRigCameras(): void;
  40136. /**
  40137. * Destroy the camera and release the current resources hold by it.
  40138. */
  40139. dispose(): void;
  40140. /**
  40141. * Gets the current object class name.
  40142. * @return the class name
  40143. */
  40144. getClassName(): string;
  40145. }
  40146. }
  40147. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40148. import { Behavior } from "babylonjs/Behaviors/behavior";
  40149. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40150. /**
  40151. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40153. */
  40154. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40155. /**
  40156. * Gets the name of the behavior.
  40157. */
  40158. get name(): string;
  40159. private _zoomStopsAnimation;
  40160. private _idleRotationSpeed;
  40161. private _idleRotationWaitTime;
  40162. private _idleRotationSpinupTime;
  40163. /**
  40164. * Sets the flag that indicates if user zooming should stop animation.
  40165. */
  40166. set zoomStopsAnimation(flag: boolean);
  40167. /**
  40168. * Gets the flag that indicates if user zooming should stop animation.
  40169. */
  40170. get zoomStopsAnimation(): boolean;
  40171. /**
  40172. * Sets the default speed at which the camera rotates around the model.
  40173. */
  40174. set idleRotationSpeed(speed: number);
  40175. /**
  40176. * Gets the default speed at which the camera rotates around the model.
  40177. */
  40178. get idleRotationSpeed(): number;
  40179. /**
  40180. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40181. */
  40182. set idleRotationWaitTime(time: number);
  40183. /**
  40184. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40185. */
  40186. get idleRotationWaitTime(): number;
  40187. /**
  40188. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40189. */
  40190. set idleRotationSpinupTime(time: number);
  40191. /**
  40192. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40193. */
  40194. get idleRotationSpinupTime(): number;
  40195. /**
  40196. * Gets a value indicating if the camera is currently rotating because of this behavior
  40197. */
  40198. get rotationInProgress(): boolean;
  40199. private _onPrePointerObservableObserver;
  40200. private _onAfterCheckInputsObserver;
  40201. private _attachedCamera;
  40202. private _isPointerDown;
  40203. private _lastFrameTime;
  40204. private _lastInteractionTime;
  40205. private _cameraRotationSpeed;
  40206. /**
  40207. * Initializes the behavior.
  40208. */
  40209. init(): void;
  40210. /**
  40211. * Attaches the behavior to its arc rotate camera.
  40212. * @param camera Defines the camera to attach the behavior to
  40213. */
  40214. attach(camera: ArcRotateCamera): void;
  40215. /**
  40216. * Detaches the behavior from its current arc rotate camera.
  40217. */
  40218. detach(): void;
  40219. /**
  40220. * Returns true if user is scrolling.
  40221. * @return true if user is scrolling.
  40222. */
  40223. private _userIsZooming;
  40224. private _lastFrameRadius;
  40225. private _shouldAnimationStopForInteraction;
  40226. /**
  40227. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40228. */
  40229. private _applyUserInteraction;
  40230. private _userIsMoving;
  40231. }
  40232. }
  40233. declare module "babylonjs/Behaviors/Cameras/index" {
  40234. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40235. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40236. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40237. }
  40238. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40239. import { Mesh } from "babylonjs/Meshes/mesh";
  40240. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40241. import { Behavior } from "babylonjs/Behaviors/behavior";
  40242. /**
  40243. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40244. */
  40245. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40246. private ui;
  40247. /**
  40248. * The name of the behavior
  40249. */
  40250. name: string;
  40251. /**
  40252. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40253. */
  40254. distanceAwayFromFace: number;
  40255. /**
  40256. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40257. */
  40258. distanceAwayFromBottomOfFace: number;
  40259. private _faceVectors;
  40260. private _target;
  40261. private _scene;
  40262. private _onRenderObserver;
  40263. private _tmpMatrix;
  40264. private _tmpVector;
  40265. /**
  40266. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40267. * @param ui The transform node that should be attched to the mesh
  40268. */
  40269. constructor(ui: TransformNode);
  40270. /**
  40271. * Initializes the behavior
  40272. */
  40273. init(): void;
  40274. private _closestFace;
  40275. private _zeroVector;
  40276. private _lookAtTmpMatrix;
  40277. private _lookAtToRef;
  40278. /**
  40279. * Attaches the AttachToBoxBehavior to the passed in mesh
  40280. * @param target The mesh that the specified node will be attached to
  40281. */
  40282. attach(target: Mesh): void;
  40283. /**
  40284. * Detaches the behavior from the mesh
  40285. */
  40286. detach(): void;
  40287. }
  40288. }
  40289. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40290. import { Behavior } from "babylonjs/Behaviors/behavior";
  40291. import { Mesh } from "babylonjs/Meshes/mesh";
  40292. /**
  40293. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40294. */
  40295. export class FadeInOutBehavior implements Behavior<Mesh> {
  40296. /**
  40297. * Time in milliseconds to delay before fading in (Default: 0)
  40298. */
  40299. delay: number;
  40300. /**
  40301. * Time in milliseconds for the mesh to fade in (Default: 300)
  40302. */
  40303. fadeInTime: number;
  40304. private _millisecondsPerFrame;
  40305. private _hovered;
  40306. private _hoverValue;
  40307. private _ownerNode;
  40308. /**
  40309. * Instatiates the FadeInOutBehavior
  40310. */
  40311. constructor();
  40312. /**
  40313. * The name of the behavior
  40314. */
  40315. get name(): string;
  40316. /**
  40317. * Initializes the behavior
  40318. */
  40319. init(): void;
  40320. /**
  40321. * Attaches the fade behavior on the passed in mesh
  40322. * @param ownerNode The mesh that will be faded in/out once attached
  40323. */
  40324. attach(ownerNode: Mesh): void;
  40325. /**
  40326. * Detaches the behavior from the mesh
  40327. */
  40328. detach(): void;
  40329. /**
  40330. * Triggers the mesh to begin fading in or out
  40331. * @param value if the object should fade in or out (true to fade in)
  40332. */
  40333. fadeIn(value: boolean): void;
  40334. private _update;
  40335. private _setAllVisibility;
  40336. }
  40337. }
  40338. declare module "babylonjs/Misc/pivotTools" {
  40339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40340. /**
  40341. * Class containing a set of static utilities functions for managing Pivots
  40342. * @hidden
  40343. */
  40344. export class PivotTools {
  40345. private static _PivotCached;
  40346. private static _OldPivotPoint;
  40347. private static _PivotTranslation;
  40348. private static _PivotTmpVector;
  40349. /** @hidden */
  40350. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40351. /** @hidden */
  40352. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40353. }
  40354. }
  40355. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40356. import { Scene } from "babylonjs/scene";
  40357. import { Vector4 } from "babylonjs/Maths/math.vector";
  40358. import { Mesh } from "babylonjs/Meshes/mesh";
  40359. import { Nullable } from "babylonjs/types";
  40360. import { Plane } from "babylonjs/Maths/math.plane";
  40361. /**
  40362. * Class containing static functions to help procedurally build meshes
  40363. */
  40364. export class PlaneBuilder {
  40365. /**
  40366. * Creates a plane mesh
  40367. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40368. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40369. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40373. * @param name defines the name of the mesh
  40374. * @param options defines the options used to create the mesh
  40375. * @param scene defines the hosting scene
  40376. * @returns the plane mesh
  40377. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40378. */
  40379. static CreatePlane(name: string, options: {
  40380. size?: number;
  40381. width?: number;
  40382. height?: number;
  40383. sideOrientation?: number;
  40384. frontUVs?: Vector4;
  40385. backUVs?: Vector4;
  40386. updatable?: boolean;
  40387. sourcePlane?: Plane;
  40388. }, scene?: Nullable<Scene>): Mesh;
  40389. }
  40390. }
  40391. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40392. import { Behavior } from "babylonjs/Behaviors/behavior";
  40393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40394. import { Observable } from "babylonjs/Misc/observable";
  40395. import { Vector3 } from "babylonjs/Maths/math.vector";
  40396. import { Ray } from "babylonjs/Culling/ray";
  40397. import "babylonjs/Meshes/Builders/planeBuilder";
  40398. /**
  40399. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40400. */
  40401. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40402. private static _AnyMouseID;
  40403. /**
  40404. * Abstract mesh the behavior is set on
  40405. */
  40406. attachedNode: AbstractMesh;
  40407. private _dragPlane;
  40408. private _scene;
  40409. private _pointerObserver;
  40410. private _beforeRenderObserver;
  40411. private static _planeScene;
  40412. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40413. /**
  40414. * 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)
  40415. */
  40416. maxDragAngle: number;
  40417. /**
  40418. * @hidden
  40419. */
  40420. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40421. /**
  40422. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40423. */
  40424. currentDraggingPointerID: number;
  40425. /**
  40426. * The last position where the pointer hit the drag plane in world space
  40427. */
  40428. lastDragPosition: Vector3;
  40429. /**
  40430. * If the behavior is currently in a dragging state
  40431. */
  40432. dragging: boolean;
  40433. /**
  40434. * 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)
  40435. */
  40436. dragDeltaRatio: number;
  40437. /**
  40438. * If the drag plane orientation should be updated during the dragging (Default: true)
  40439. */
  40440. updateDragPlane: boolean;
  40441. private _debugMode;
  40442. private _moving;
  40443. /**
  40444. * Fires each time the attached mesh is dragged with the pointer
  40445. * * delta between last drag position and current drag position in world space
  40446. * * dragDistance along the drag axis
  40447. * * dragPlaneNormal normal of the current drag plane used during the drag
  40448. * * dragPlanePoint in world space where the drag intersects the drag plane
  40449. */
  40450. onDragObservable: Observable<{
  40451. delta: Vector3;
  40452. dragPlanePoint: Vector3;
  40453. dragPlaneNormal: Vector3;
  40454. dragDistance: number;
  40455. pointerId: number;
  40456. }>;
  40457. /**
  40458. * Fires each time a drag begins (eg. mouse down on mesh)
  40459. */
  40460. onDragStartObservable: Observable<{
  40461. dragPlanePoint: Vector3;
  40462. pointerId: number;
  40463. }>;
  40464. /**
  40465. * Fires each time a drag ends (eg. mouse release after drag)
  40466. */
  40467. onDragEndObservable: Observable<{
  40468. dragPlanePoint: Vector3;
  40469. pointerId: number;
  40470. }>;
  40471. /**
  40472. * If the attached mesh should be moved when dragged
  40473. */
  40474. moveAttached: boolean;
  40475. /**
  40476. * If the drag behavior will react to drag events (Default: true)
  40477. */
  40478. enabled: boolean;
  40479. /**
  40480. * If pointer events should start and release the drag (Default: true)
  40481. */
  40482. startAndReleaseDragOnPointerEvents: boolean;
  40483. /**
  40484. * If camera controls should be detached during the drag
  40485. */
  40486. detachCameraControls: boolean;
  40487. /**
  40488. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40489. */
  40490. useObjectOrientationForDragging: boolean;
  40491. private _options;
  40492. /**
  40493. * Gets the options used by the behavior
  40494. */
  40495. get options(): {
  40496. dragAxis?: Vector3;
  40497. dragPlaneNormal?: Vector3;
  40498. };
  40499. /**
  40500. * Sets the options used by the behavior
  40501. */
  40502. set options(options: {
  40503. dragAxis?: Vector3;
  40504. dragPlaneNormal?: Vector3;
  40505. });
  40506. /**
  40507. * Creates a pointer drag behavior that can be attached to a mesh
  40508. * @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)
  40509. */
  40510. constructor(options?: {
  40511. dragAxis?: Vector3;
  40512. dragPlaneNormal?: Vector3;
  40513. });
  40514. /**
  40515. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40516. */
  40517. validateDrag: (targetPosition: Vector3) => boolean;
  40518. /**
  40519. * The name of the behavior
  40520. */
  40521. get name(): string;
  40522. /**
  40523. * Initializes the behavior
  40524. */
  40525. init(): void;
  40526. private _tmpVector;
  40527. private _alternatePickedPoint;
  40528. private _worldDragAxis;
  40529. private _targetPosition;
  40530. private _attachedElement;
  40531. /**
  40532. * Attaches the drag behavior the passed in mesh
  40533. * @param ownerNode The mesh that will be dragged around once attached
  40534. * @param predicate Predicate to use for pick filtering
  40535. */
  40536. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40537. /**
  40538. * Force relase the drag action by code.
  40539. */
  40540. releaseDrag(): void;
  40541. private _startDragRay;
  40542. private _lastPointerRay;
  40543. /**
  40544. * Simulates the start of a pointer drag event on the behavior
  40545. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40546. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40547. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40548. */
  40549. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40550. private _startDrag;
  40551. private _dragDelta;
  40552. private _moveDrag;
  40553. private _pickWithRayOnDragPlane;
  40554. private _pointA;
  40555. private _pointB;
  40556. private _pointC;
  40557. private _lineA;
  40558. private _lineB;
  40559. private _localAxis;
  40560. private _lookAt;
  40561. private _updateDragPlanePosition;
  40562. /**
  40563. * Detaches the behavior from the mesh
  40564. */
  40565. detach(): void;
  40566. }
  40567. }
  40568. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40569. import { Mesh } from "babylonjs/Meshes/mesh";
  40570. import { Behavior } from "babylonjs/Behaviors/behavior";
  40571. /**
  40572. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40573. */
  40574. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40575. private _dragBehaviorA;
  40576. private _dragBehaviorB;
  40577. private _startDistance;
  40578. private _initialScale;
  40579. private _targetScale;
  40580. private _ownerNode;
  40581. private _sceneRenderObserver;
  40582. /**
  40583. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40584. */
  40585. constructor();
  40586. /**
  40587. * The name of the behavior
  40588. */
  40589. get name(): string;
  40590. /**
  40591. * Initializes the behavior
  40592. */
  40593. init(): void;
  40594. private _getCurrentDistance;
  40595. /**
  40596. * Attaches the scale behavior the passed in mesh
  40597. * @param ownerNode The mesh that will be scaled around once attached
  40598. */
  40599. attach(ownerNode: Mesh): void;
  40600. /**
  40601. * Detaches the behavior from the mesh
  40602. */
  40603. detach(): void;
  40604. }
  40605. }
  40606. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40607. import { Behavior } from "babylonjs/Behaviors/behavior";
  40608. import { Mesh } from "babylonjs/Meshes/mesh";
  40609. import { Observable } from "babylonjs/Misc/observable";
  40610. /**
  40611. * 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
  40612. */
  40613. export class SixDofDragBehavior implements Behavior<Mesh> {
  40614. private static _virtualScene;
  40615. private _ownerNode;
  40616. private _sceneRenderObserver;
  40617. private _scene;
  40618. private _targetPosition;
  40619. private _virtualOriginMesh;
  40620. private _virtualDragMesh;
  40621. private _pointerObserver;
  40622. private _moving;
  40623. private _startingOrientation;
  40624. /**
  40625. * 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)
  40626. */
  40627. private zDragFactor;
  40628. /**
  40629. * If the object should rotate to face the drag origin
  40630. */
  40631. rotateDraggedObject: boolean;
  40632. /**
  40633. * If the behavior is currently in a dragging state
  40634. */
  40635. dragging: boolean;
  40636. /**
  40637. * 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)
  40638. */
  40639. dragDeltaRatio: number;
  40640. /**
  40641. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40642. */
  40643. currentDraggingPointerID: number;
  40644. /**
  40645. * If camera controls should be detached during the drag
  40646. */
  40647. detachCameraControls: boolean;
  40648. /**
  40649. * Fires each time a drag starts
  40650. */
  40651. onDragStartObservable: Observable<{}>;
  40652. /**
  40653. * Fires each time a drag ends (eg. mouse release after drag)
  40654. */
  40655. onDragEndObservable: Observable<{}>;
  40656. /**
  40657. * 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
  40658. */
  40659. constructor();
  40660. /**
  40661. * The name of the behavior
  40662. */
  40663. get name(): string;
  40664. /**
  40665. * Initializes the behavior
  40666. */
  40667. init(): void;
  40668. /**
  40669. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40670. */
  40671. private get _pointerCamera();
  40672. /**
  40673. * Attaches the scale behavior the passed in mesh
  40674. * @param ownerNode The mesh that will be scaled around once attached
  40675. */
  40676. attach(ownerNode: Mesh): void;
  40677. /**
  40678. * Detaches the behavior from the mesh
  40679. */
  40680. detach(): void;
  40681. }
  40682. }
  40683. declare module "babylonjs/Behaviors/Meshes/index" {
  40684. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40685. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40686. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40687. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40688. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40689. }
  40690. declare module "babylonjs/Behaviors/index" {
  40691. export * from "babylonjs/Behaviors/behavior";
  40692. export * from "babylonjs/Behaviors/Cameras/index";
  40693. export * from "babylonjs/Behaviors/Meshes/index";
  40694. }
  40695. declare module "babylonjs/Bones/boneIKController" {
  40696. import { Bone } from "babylonjs/Bones/bone";
  40697. import { Vector3 } from "babylonjs/Maths/math.vector";
  40698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40699. import { Nullable } from "babylonjs/types";
  40700. /**
  40701. * Class used to apply inverse kinematics to bones
  40702. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40703. */
  40704. export class BoneIKController {
  40705. private static _tmpVecs;
  40706. private static _tmpQuat;
  40707. private static _tmpMats;
  40708. /**
  40709. * Gets or sets the target mesh
  40710. */
  40711. targetMesh: AbstractMesh;
  40712. /** Gets or sets the mesh used as pole */
  40713. poleTargetMesh: AbstractMesh;
  40714. /**
  40715. * Gets or sets the bone used as pole
  40716. */
  40717. poleTargetBone: Nullable<Bone>;
  40718. /**
  40719. * Gets or sets the target position
  40720. */
  40721. targetPosition: Vector3;
  40722. /**
  40723. * Gets or sets the pole target position
  40724. */
  40725. poleTargetPosition: Vector3;
  40726. /**
  40727. * Gets or sets the pole target local offset
  40728. */
  40729. poleTargetLocalOffset: Vector3;
  40730. /**
  40731. * Gets or sets the pole angle
  40732. */
  40733. poleAngle: number;
  40734. /**
  40735. * Gets or sets the mesh associated with the controller
  40736. */
  40737. mesh: AbstractMesh;
  40738. /**
  40739. * 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)
  40740. */
  40741. slerpAmount: number;
  40742. private _bone1Quat;
  40743. private _bone1Mat;
  40744. private _bone2Ang;
  40745. private _bone1;
  40746. private _bone2;
  40747. private _bone1Length;
  40748. private _bone2Length;
  40749. private _maxAngle;
  40750. private _maxReach;
  40751. private _rightHandedSystem;
  40752. private _bendAxis;
  40753. private _slerping;
  40754. private _adjustRoll;
  40755. /**
  40756. * Gets or sets maximum allowed angle
  40757. */
  40758. get maxAngle(): number;
  40759. set maxAngle(value: number);
  40760. /**
  40761. * Creates a new BoneIKController
  40762. * @param mesh defines the mesh to control
  40763. * @param bone defines the bone to control
  40764. * @param options defines options to set up the controller
  40765. */
  40766. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40767. targetMesh?: AbstractMesh;
  40768. poleTargetMesh?: AbstractMesh;
  40769. poleTargetBone?: Bone;
  40770. poleTargetLocalOffset?: Vector3;
  40771. poleAngle?: number;
  40772. bendAxis?: Vector3;
  40773. maxAngle?: number;
  40774. slerpAmount?: number;
  40775. });
  40776. private _setMaxAngle;
  40777. /**
  40778. * Force the controller to update the bones
  40779. */
  40780. update(): void;
  40781. }
  40782. }
  40783. declare module "babylonjs/Bones/boneLookController" {
  40784. import { Vector3 } from "babylonjs/Maths/math.vector";
  40785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40786. import { Bone } from "babylonjs/Bones/bone";
  40787. import { Space } from "babylonjs/Maths/math.axis";
  40788. /**
  40789. * Class used to make a bone look toward a point in space
  40790. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40791. */
  40792. export class BoneLookController {
  40793. private static _tmpVecs;
  40794. private static _tmpQuat;
  40795. private static _tmpMats;
  40796. /**
  40797. * The target Vector3 that the bone will look at
  40798. */
  40799. target: Vector3;
  40800. /**
  40801. * The mesh that the bone is attached to
  40802. */
  40803. mesh: AbstractMesh;
  40804. /**
  40805. * The bone that will be looking to the target
  40806. */
  40807. bone: Bone;
  40808. /**
  40809. * The up axis of the coordinate system that is used when the bone is rotated
  40810. */
  40811. upAxis: Vector3;
  40812. /**
  40813. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40814. */
  40815. upAxisSpace: Space;
  40816. /**
  40817. * Used to make an adjustment to the yaw of the bone
  40818. */
  40819. adjustYaw: number;
  40820. /**
  40821. * Used to make an adjustment to the pitch of the bone
  40822. */
  40823. adjustPitch: number;
  40824. /**
  40825. * Used to make an adjustment to the roll of the bone
  40826. */
  40827. adjustRoll: number;
  40828. /**
  40829. * 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)
  40830. */
  40831. slerpAmount: number;
  40832. private _minYaw;
  40833. private _maxYaw;
  40834. private _minPitch;
  40835. private _maxPitch;
  40836. private _minYawSin;
  40837. private _minYawCos;
  40838. private _maxYawSin;
  40839. private _maxYawCos;
  40840. private _midYawConstraint;
  40841. private _minPitchTan;
  40842. private _maxPitchTan;
  40843. private _boneQuat;
  40844. private _slerping;
  40845. private _transformYawPitch;
  40846. private _transformYawPitchInv;
  40847. private _firstFrameSkipped;
  40848. private _yawRange;
  40849. private _fowardAxis;
  40850. /**
  40851. * Gets or sets the minimum yaw angle that the bone can look to
  40852. */
  40853. get minYaw(): number;
  40854. set minYaw(value: number);
  40855. /**
  40856. * Gets or sets the maximum yaw angle that the bone can look to
  40857. */
  40858. get maxYaw(): number;
  40859. set maxYaw(value: number);
  40860. /**
  40861. * Gets or sets the minimum pitch angle that the bone can look to
  40862. */
  40863. get minPitch(): number;
  40864. set minPitch(value: number);
  40865. /**
  40866. * Gets or sets the maximum pitch angle that the bone can look to
  40867. */
  40868. get maxPitch(): number;
  40869. set maxPitch(value: number);
  40870. /**
  40871. * Create a BoneLookController
  40872. * @param mesh the mesh that the bone belongs to
  40873. * @param bone the bone that will be looking to the target
  40874. * @param target the target Vector3 to look at
  40875. * @param options optional settings:
  40876. * * maxYaw: the maximum angle the bone will yaw to
  40877. * * minYaw: the minimum angle the bone will yaw to
  40878. * * maxPitch: the maximum angle the bone will pitch to
  40879. * * minPitch: the minimum angle the bone will yaw to
  40880. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40881. * * upAxis: the up axis of the coordinate system
  40882. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40883. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40884. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40885. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40886. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40887. * * adjustRoll: used to make an adjustment to the roll of the bone
  40888. **/
  40889. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40890. maxYaw?: number;
  40891. minYaw?: number;
  40892. maxPitch?: number;
  40893. minPitch?: number;
  40894. slerpAmount?: number;
  40895. upAxis?: Vector3;
  40896. upAxisSpace?: Space;
  40897. yawAxis?: Vector3;
  40898. pitchAxis?: Vector3;
  40899. adjustYaw?: number;
  40900. adjustPitch?: number;
  40901. adjustRoll?: number;
  40902. });
  40903. /**
  40904. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40905. */
  40906. update(): void;
  40907. private _getAngleDiff;
  40908. private _getAngleBetween;
  40909. private _isAngleBetween;
  40910. }
  40911. }
  40912. declare module "babylonjs/Bones/index" {
  40913. export * from "babylonjs/Bones/bone";
  40914. export * from "babylonjs/Bones/boneIKController";
  40915. export * from "babylonjs/Bones/boneLookController";
  40916. export * from "babylonjs/Bones/skeleton";
  40917. }
  40918. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40919. import { Nullable } from "babylonjs/types";
  40920. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40921. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40922. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40923. /**
  40924. * Manage the gamepad inputs to control an arc rotate camera.
  40925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40926. */
  40927. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40928. /**
  40929. * Defines the camera the input is attached to.
  40930. */
  40931. camera: ArcRotateCamera;
  40932. /**
  40933. * Defines the gamepad the input is gathering event from.
  40934. */
  40935. gamepad: Nullable<Gamepad>;
  40936. /**
  40937. * Defines the gamepad rotation sensiblity.
  40938. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40939. */
  40940. gamepadRotationSensibility: number;
  40941. /**
  40942. * Defines the gamepad move sensiblity.
  40943. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40944. */
  40945. gamepadMoveSensibility: number;
  40946. private _yAxisScale;
  40947. /**
  40948. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40949. */
  40950. get invertYAxis(): boolean;
  40951. set invertYAxis(value: boolean);
  40952. private _onGamepadConnectedObserver;
  40953. private _onGamepadDisconnectedObserver;
  40954. /**
  40955. * Attach the input controls to a specific dom element to get the input from.
  40956. * @param element Defines the element the controls should be listened from
  40957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40958. */
  40959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40960. /**
  40961. * Detach the current controls from the specified dom element.
  40962. * @param element Defines the element to stop listening the inputs from
  40963. */
  40964. detachControl(element: Nullable<HTMLElement>): void;
  40965. /**
  40966. * Update the current camera state depending on the inputs that have been used this frame.
  40967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40968. */
  40969. checkInputs(): void;
  40970. /**
  40971. * Gets the class name of the current intput.
  40972. * @returns the class name
  40973. */
  40974. getClassName(): string;
  40975. /**
  40976. * Get the friendly name associated with the input class.
  40977. * @returns the input friendly name
  40978. */
  40979. getSimpleName(): string;
  40980. }
  40981. }
  40982. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40983. import { Nullable } from "babylonjs/types";
  40984. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40985. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40986. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40987. interface ArcRotateCameraInputsManager {
  40988. /**
  40989. * Add orientation input support to the input manager.
  40990. * @returns the current input manager
  40991. */
  40992. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40993. }
  40994. }
  40995. /**
  40996. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40998. */
  40999. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41000. /**
  41001. * Defines the camera the input is attached to.
  41002. */
  41003. camera: ArcRotateCamera;
  41004. /**
  41005. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41006. */
  41007. alphaCorrection: number;
  41008. /**
  41009. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41010. */
  41011. gammaCorrection: number;
  41012. private _alpha;
  41013. private _gamma;
  41014. private _dirty;
  41015. private _deviceOrientationHandler;
  41016. /**
  41017. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41018. */
  41019. constructor();
  41020. /**
  41021. * Attach the input controls to a specific dom element to get the input from.
  41022. * @param element Defines the element the controls should be listened from
  41023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41024. */
  41025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41026. /** @hidden */
  41027. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41028. /**
  41029. * Update the current camera state depending on the inputs that have been used this frame.
  41030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41031. */
  41032. checkInputs(): void;
  41033. /**
  41034. * Detach the current controls from the specified dom element.
  41035. * @param element Defines the element to stop listening the inputs from
  41036. */
  41037. detachControl(element: Nullable<HTMLElement>): void;
  41038. /**
  41039. * Gets the class name of the current intput.
  41040. * @returns the class name
  41041. */
  41042. getClassName(): string;
  41043. /**
  41044. * Get the friendly name associated with the input class.
  41045. * @returns the input friendly name
  41046. */
  41047. getSimpleName(): string;
  41048. }
  41049. }
  41050. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41051. import { Nullable } from "babylonjs/types";
  41052. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41053. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41054. /**
  41055. * Listen to mouse events to control the camera.
  41056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41057. */
  41058. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41059. /**
  41060. * Defines the camera the input is attached to.
  41061. */
  41062. camera: FlyCamera;
  41063. /**
  41064. * Defines if touch is enabled. (Default is true.)
  41065. */
  41066. touchEnabled: boolean;
  41067. /**
  41068. * Defines the buttons associated with the input to handle camera rotation.
  41069. */
  41070. buttons: number[];
  41071. /**
  41072. * Assign buttons for Yaw control.
  41073. */
  41074. buttonsYaw: number[];
  41075. /**
  41076. * Assign buttons for Pitch control.
  41077. */
  41078. buttonsPitch: number[];
  41079. /**
  41080. * Assign buttons for Roll control.
  41081. */
  41082. buttonsRoll: number[];
  41083. /**
  41084. * Detect if any button is being pressed while mouse is moved.
  41085. * -1 = Mouse locked.
  41086. * 0 = Left button.
  41087. * 1 = Middle Button.
  41088. * 2 = Right Button.
  41089. */
  41090. activeButton: number;
  41091. /**
  41092. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41093. * Higher values reduce its sensitivity.
  41094. */
  41095. angularSensibility: number;
  41096. private _mousemoveCallback;
  41097. private _observer;
  41098. private _rollObserver;
  41099. private previousPosition;
  41100. private noPreventDefault;
  41101. private element;
  41102. /**
  41103. * Listen to mouse events to control the camera.
  41104. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41106. */
  41107. constructor(touchEnabled?: boolean);
  41108. /**
  41109. * Attach the mouse control to the HTML DOM element.
  41110. * @param element Defines the element that listens to the input events.
  41111. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41112. */
  41113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41114. /**
  41115. * Detach the current controls from the specified dom element.
  41116. * @param element Defines the element to stop listening the inputs from
  41117. */
  41118. detachControl(element: Nullable<HTMLElement>): void;
  41119. /**
  41120. * Gets the class name of the current input.
  41121. * @returns the class name.
  41122. */
  41123. getClassName(): string;
  41124. /**
  41125. * Get the friendly name associated with the input class.
  41126. * @returns the input's friendly name.
  41127. */
  41128. getSimpleName(): string;
  41129. private _pointerInput;
  41130. private _onMouseMove;
  41131. /**
  41132. * Rotate camera by mouse offset.
  41133. */
  41134. private rotateCamera;
  41135. }
  41136. }
  41137. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41138. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41139. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41140. /**
  41141. * Default Inputs manager for the FlyCamera.
  41142. * It groups all the default supported inputs for ease of use.
  41143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41144. */
  41145. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41146. /**
  41147. * Instantiates a new FlyCameraInputsManager.
  41148. * @param camera Defines the camera the inputs belong to.
  41149. */
  41150. constructor(camera: FlyCamera);
  41151. /**
  41152. * Add keyboard input support to the input manager.
  41153. * @returns the new FlyCameraKeyboardMoveInput().
  41154. */
  41155. addKeyboard(): FlyCameraInputsManager;
  41156. /**
  41157. * Add mouse input support to the input manager.
  41158. * @param touchEnabled Enable touch screen support.
  41159. * @returns the new FlyCameraMouseInput().
  41160. */
  41161. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41162. }
  41163. }
  41164. declare module "babylonjs/Cameras/flyCamera" {
  41165. import { Scene } from "babylonjs/scene";
  41166. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41168. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41169. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41170. /**
  41171. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41172. * such as in a 3D Space Shooter or a Flight Simulator.
  41173. */
  41174. export class FlyCamera extends TargetCamera {
  41175. /**
  41176. * Define the collision ellipsoid of the camera.
  41177. * This is helpful for simulating a camera body, like a player's body.
  41178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41179. */
  41180. ellipsoid: Vector3;
  41181. /**
  41182. * Define an offset for the position of the ellipsoid around the camera.
  41183. * This can be helpful if the camera is attached away from the player's body center,
  41184. * such as at its head.
  41185. */
  41186. ellipsoidOffset: Vector3;
  41187. /**
  41188. * Enable or disable collisions of the camera with the rest of the scene objects.
  41189. */
  41190. checkCollisions: boolean;
  41191. /**
  41192. * Enable or disable gravity on the camera.
  41193. */
  41194. applyGravity: boolean;
  41195. /**
  41196. * Define the current direction the camera is moving to.
  41197. */
  41198. cameraDirection: Vector3;
  41199. /**
  41200. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41201. * This overrides and empties cameraRotation.
  41202. */
  41203. rotationQuaternion: Quaternion;
  41204. /**
  41205. * Track Roll to maintain the wanted Rolling when looking around.
  41206. */
  41207. _trackRoll: number;
  41208. /**
  41209. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41210. */
  41211. rollCorrect: number;
  41212. /**
  41213. * Mimic a banked turn, Rolling the camera when Yawing.
  41214. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41215. */
  41216. bankedTurn: boolean;
  41217. /**
  41218. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41219. */
  41220. bankedTurnLimit: number;
  41221. /**
  41222. * Value of 0 disables the banked Roll.
  41223. * Value of 1 is equal to the Yaw angle in radians.
  41224. */
  41225. bankedTurnMultiplier: number;
  41226. /**
  41227. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41228. */
  41229. inputs: FlyCameraInputsManager;
  41230. /**
  41231. * Gets the input sensibility for mouse input.
  41232. * Higher values reduce sensitivity.
  41233. */
  41234. get angularSensibility(): number;
  41235. /**
  41236. * Sets the input sensibility for a mouse input.
  41237. * Higher values reduce sensitivity.
  41238. */
  41239. set angularSensibility(value: number);
  41240. /**
  41241. * Get the keys for camera movement forward.
  41242. */
  41243. get keysForward(): number[];
  41244. /**
  41245. * Set the keys for camera movement forward.
  41246. */
  41247. set keysForward(value: number[]);
  41248. /**
  41249. * Get the keys for camera movement backward.
  41250. */
  41251. get keysBackward(): number[];
  41252. set keysBackward(value: number[]);
  41253. /**
  41254. * Get the keys for camera movement up.
  41255. */
  41256. get keysUp(): number[];
  41257. /**
  41258. * Set the keys for camera movement up.
  41259. */
  41260. set keysUp(value: number[]);
  41261. /**
  41262. * Get the keys for camera movement down.
  41263. */
  41264. get keysDown(): number[];
  41265. /**
  41266. * Set the keys for camera movement down.
  41267. */
  41268. set keysDown(value: number[]);
  41269. /**
  41270. * Get the keys for camera movement left.
  41271. */
  41272. get keysLeft(): number[];
  41273. /**
  41274. * Set the keys for camera movement left.
  41275. */
  41276. set keysLeft(value: number[]);
  41277. /**
  41278. * Set the keys for camera movement right.
  41279. */
  41280. get keysRight(): number[];
  41281. /**
  41282. * Set the keys for camera movement right.
  41283. */
  41284. set keysRight(value: number[]);
  41285. /**
  41286. * Event raised when the camera collides with a mesh in the scene.
  41287. */
  41288. onCollide: (collidedMesh: AbstractMesh) => void;
  41289. private _collider;
  41290. private _needMoveForGravity;
  41291. private _oldPosition;
  41292. private _diffPosition;
  41293. private _newPosition;
  41294. /** @hidden */
  41295. _localDirection: Vector3;
  41296. /** @hidden */
  41297. _transformedDirection: Vector3;
  41298. /**
  41299. * Instantiates a FlyCamera.
  41300. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41301. * such as in a 3D Space Shooter or a Flight Simulator.
  41302. * @param name Define the name of the camera in the scene.
  41303. * @param position Define the starting position of the camera in the scene.
  41304. * @param scene Define the scene the camera belongs to.
  41305. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41306. */
  41307. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41308. /**
  41309. * Attach a control to the HTML DOM element.
  41310. * @param element Defines the element that listens to the input events.
  41311. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41312. */
  41313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41314. /**
  41315. * Detach a control from the HTML DOM element.
  41316. * The camera will stop reacting to that input.
  41317. * @param element Defines the element that listens to the input events.
  41318. */
  41319. detachControl(element: HTMLElement): void;
  41320. private _collisionMask;
  41321. /**
  41322. * Get the mask that the camera ignores in collision events.
  41323. */
  41324. get collisionMask(): number;
  41325. /**
  41326. * Set the mask that the camera ignores in collision events.
  41327. */
  41328. set collisionMask(mask: number);
  41329. /** @hidden */
  41330. _collideWithWorld(displacement: Vector3): void;
  41331. /** @hidden */
  41332. private _onCollisionPositionChange;
  41333. /** @hidden */
  41334. _checkInputs(): void;
  41335. /** @hidden */
  41336. _decideIfNeedsToMove(): boolean;
  41337. /** @hidden */
  41338. _updatePosition(): void;
  41339. /**
  41340. * Restore the Roll to its target value at the rate specified.
  41341. * @param rate - Higher means slower restoring.
  41342. * @hidden
  41343. */
  41344. restoreRoll(rate: number): void;
  41345. /**
  41346. * Destroy the camera and release the current resources held by it.
  41347. */
  41348. dispose(): void;
  41349. /**
  41350. * Get the current object class name.
  41351. * @returns the class name.
  41352. */
  41353. getClassName(): string;
  41354. }
  41355. }
  41356. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41357. import { Nullable } from "babylonjs/types";
  41358. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41359. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41360. /**
  41361. * Listen to keyboard events to control the camera.
  41362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41363. */
  41364. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41365. /**
  41366. * Defines the camera the input is attached to.
  41367. */
  41368. camera: FlyCamera;
  41369. /**
  41370. * The list of keyboard keys used to control the forward move of the camera.
  41371. */
  41372. keysForward: number[];
  41373. /**
  41374. * The list of keyboard keys used to control the backward move of the camera.
  41375. */
  41376. keysBackward: number[];
  41377. /**
  41378. * The list of keyboard keys used to control the forward move of the camera.
  41379. */
  41380. keysUp: number[];
  41381. /**
  41382. * The list of keyboard keys used to control the backward move of the camera.
  41383. */
  41384. keysDown: number[];
  41385. /**
  41386. * The list of keyboard keys used to control the right strafe move of the camera.
  41387. */
  41388. keysRight: number[];
  41389. /**
  41390. * The list of keyboard keys used to control the left strafe move of the camera.
  41391. */
  41392. keysLeft: number[];
  41393. private _keys;
  41394. private _onCanvasBlurObserver;
  41395. private _onKeyboardObserver;
  41396. private _engine;
  41397. private _scene;
  41398. /**
  41399. * Attach the input controls to a specific dom element to get the input from.
  41400. * @param element Defines the element the controls should be listened from
  41401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41402. */
  41403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41404. /**
  41405. * Detach the current controls from the specified dom element.
  41406. * @param element Defines the element to stop listening the inputs from
  41407. */
  41408. detachControl(element: Nullable<HTMLElement>): void;
  41409. /**
  41410. * Gets the class name of the current intput.
  41411. * @returns the class name
  41412. */
  41413. getClassName(): string;
  41414. /** @hidden */
  41415. _onLostFocus(e: FocusEvent): void;
  41416. /**
  41417. * Get the friendly name associated with the input class.
  41418. * @returns the input friendly name
  41419. */
  41420. getSimpleName(): string;
  41421. /**
  41422. * Update the current camera state depending on the inputs that have been used this frame.
  41423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41424. */
  41425. checkInputs(): void;
  41426. }
  41427. }
  41428. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41429. import { Nullable } from "babylonjs/types";
  41430. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41431. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41432. /**
  41433. * Manage the mouse wheel inputs to control a follow camera.
  41434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41435. */
  41436. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41437. /**
  41438. * Defines the camera the input is attached to.
  41439. */
  41440. camera: FollowCamera;
  41441. /**
  41442. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41443. */
  41444. axisControlRadius: boolean;
  41445. /**
  41446. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41447. */
  41448. axisControlHeight: boolean;
  41449. /**
  41450. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41451. */
  41452. axisControlRotation: boolean;
  41453. /**
  41454. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41455. * relation to mouseWheel events.
  41456. */
  41457. wheelPrecision: number;
  41458. /**
  41459. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41460. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41461. */
  41462. wheelDeltaPercentage: number;
  41463. private _wheel;
  41464. private _observer;
  41465. /**
  41466. * Attach the input controls to a specific dom element to get the input from.
  41467. * @param element Defines the element the controls should be listened from
  41468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41469. */
  41470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41471. /**
  41472. * Detach the current controls from the specified dom element.
  41473. * @param element Defines the element to stop listening the inputs from
  41474. */
  41475. detachControl(element: Nullable<HTMLElement>): void;
  41476. /**
  41477. * Gets the class name of the current intput.
  41478. * @returns the class name
  41479. */
  41480. getClassName(): string;
  41481. /**
  41482. * Get the friendly name associated with the input class.
  41483. * @returns the input friendly name
  41484. */
  41485. getSimpleName(): string;
  41486. }
  41487. }
  41488. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41489. import { Nullable } from "babylonjs/types";
  41490. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41491. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41492. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41493. /**
  41494. * Manage the pointers inputs to control an follow camera.
  41495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41496. */
  41497. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41498. /**
  41499. * Defines the camera the input is attached to.
  41500. */
  41501. camera: FollowCamera;
  41502. /**
  41503. * Gets the class name of the current input.
  41504. * @returns the class name
  41505. */
  41506. getClassName(): string;
  41507. /**
  41508. * Defines the pointer angular sensibility along the X axis or how fast is
  41509. * the camera rotating.
  41510. * A negative number will reverse the axis direction.
  41511. */
  41512. angularSensibilityX: number;
  41513. /**
  41514. * Defines the pointer angular sensibility along the Y axis or how fast is
  41515. * the camera rotating.
  41516. * A negative number will reverse the axis direction.
  41517. */
  41518. angularSensibilityY: number;
  41519. /**
  41520. * Defines the pointer pinch precision or how fast is the camera zooming.
  41521. * A negative number will reverse the axis direction.
  41522. */
  41523. pinchPrecision: number;
  41524. /**
  41525. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41526. * from 0.
  41527. * It defines the percentage of current camera.radius to use as delta when
  41528. * pinch zoom is used.
  41529. */
  41530. pinchDeltaPercentage: number;
  41531. /**
  41532. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41533. */
  41534. axisXControlRadius: boolean;
  41535. /**
  41536. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41537. */
  41538. axisXControlHeight: boolean;
  41539. /**
  41540. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41541. */
  41542. axisXControlRotation: boolean;
  41543. /**
  41544. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41545. */
  41546. axisYControlRadius: boolean;
  41547. /**
  41548. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41549. */
  41550. axisYControlHeight: boolean;
  41551. /**
  41552. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41553. */
  41554. axisYControlRotation: boolean;
  41555. /**
  41556. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41557. */
  41558. axisPinchControlRadius: boolean;
  41559. /**
  41560. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41561. */
  41562. axisPinchControlHeight: boolean;
  41563. /**
  41564. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41565. */
  41566. axisPinchControlRotation: boolean;
  41567. /**
  41568. * Log error messages if basic misconfiguration has occurred.
  41569. */
  41570. warningEnable: boolean;
  41571. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41572. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41573. private _warningCounter;
  41574. private _warning;
  41575. }
  41576. }
  41577. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41578. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41579. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41580. /**
  41581. * Default Inputs manager for the FollowCamera.
  41582. * It groups all the default supported inputs for ease of use.
  41583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41584. */
  41585. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41586. /**
  41587. * Instantiates a new FollowCameraInputsManager.
  41588. * @param camera Defines the camera the inputs belong to
  41589. */
  41590. constructor(camera: FollowCamera);
  41591. /**
  41592. * Add keyboard input support to the input manager.
  41593. * @returns the current input manager
  41594. */
  41595. addKeyboard(): FollowCameraInputsManager;
  41596. /**
  41597. * Add mouse wheel input support to the input manager.
  41598. * @returns the current input manager
  41599. */
  41600. addMouseWheel(): FollowCameraInputsManager;
  41601. /**
  41602. * Add pointers input support to the input manager.
  41603. * @returns the current input manager
  41604. */
  41605. addPointers(): FollowCameraInputsManager;
  41606. /**
  41607. * Add orientation input support to the input manager.
  41608. * @returns the current input manager
  41609. */
  41610. addVRDeviceOrientation(): FollowCameraInputsManager;
  41611. }
  41612. }
  41613. declare module "babylonjs/Cameras/followCamera" {
  41614. import { Nullable } from "babylonjs/types";
  41615. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41616. import { Scene } from "babylonjs/scene";
  41617. import { Vector3 } from "babylonjs/Maths/math.vector";
  41618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41619. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41620. /**
  41621. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41622. * an arc rotate version arcFollowCamera are available.
  41623. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41624. */
  41625. export class FollowCamera extends TargetCamera {
  41626. /**
  41627. * Distance the follow camera should follow an object at
  41628. */
  41629. radius: number;
  41630. /**
  41631. * Minimum allowed distance of the camera to the axis of rotation
  41632. * (The camera can not get closer).
  41633. * This can help limiting how the Camera is able to move in the scene.
  41634. */
  41635. lowerRadiusLimit: Nullable<number>;
  41636. /**
  41637. * Maximum allowed distance of the camera to the axis of rotation
  41638. * (The camera can not get further).
  41639. * This can help limiting how the Camera is able to move in the scene.
  41640. */
  41641. upperRadiusLimit: Nullable<number>;
  41642. /**
  41643. * Define a rotation offset between the camera and the object it follows
  41644. */
  41645. rotationOffset: number;
  41646. /**
  41647. * Minimum allowed angle to camera position relative to target object.
  41648. * This can help limiting how the Camera is able to move in the scene.
  41649. */
  41650. lowerRotationOffsetLimit: Nullable<number>;
  41651. /**
  41652. * Maximum allowed angle to camera position relative to target object.
  41653. * This can help limiting how the Camera is able to move in the scene.
  41654. */
  41655. upperRotationOffsetLimit: Nullable<number>;
  41656. /**
  41657. * Define a height offset between the camera and the object it follows.
  41658. * It can help following an object from the top (like a car chaing a plane)
  41659. */
  41660. heightOffset: number;
  41661. /**
  41662. * Minimum allowed height of camera position relative to target object.
  41663. * This can help limiting how the Camera is able to move in the scene.
  41664. */
  41665. lowerHeightOffsetLimit: Nullable<number>;
  41666. /**
  41667. * Maximum allowed height of camera position relative to target object.
  41668. * This can help limiting how the Camera is able to move in the scene.
  41669. */
  41670. upperHeightOffsetLimit: Nullable<number>;
  41671. /**
  41672. * Define how fast the camera can accelerate to follow it s target.
  41673. */
  41674. cameraAcceleration: number;
  41675. /**
  41676. * Define the speed limit of the camera following an object.
  41677. */
  41678. maxCameraSpeed: number;
  41679. /**
  41680. * Define the target of the camera.
  41681. */
  41682. lockedTarget: Nullable<AbstractMesh>;
  41683. /**
  41684. * Defines the input associated with the camera.
  41685. */
  41686. inputs: FollowCameraInputsManager;
  41687. /**
  41688. * Instantiates the follow camera.
  41689. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41690. * @param name Define the name of the camera in the scene
  41691. * @param position Define the position of the camera
  41692. * @param scene Define the scene the camera belong to
  41693. * @param lockedTarget Define the target of the camera
  41694. */
  41695. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41696. private _follow;
  41697. /**
  41698. * Attached controls to the current camera.
  41699. * @param element Defines the element the controls should be listened from
  41700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41701. */
  41702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41703. /**
  41704. * Detach the current controls from the camera.
  41705. * The camera will stop reacting to inputs.
  41706. * @param element Defines the element to stop listening the inputs from
  41707. */
  41708. detachControl(element: HTMLElement): void;
  41709. /** @hidden */
  41710. _checkInputs(): void;
  41711. private _checkLimits;
  41712. /**
  41713. * Gets the camera class name.
  41714. * @returns the class name
  41715. */
  41716. getClassName(): string;
  41717. }
  41718. /**
  41719. * Arc Rotate version of the follow camera.
  41720. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41721. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41722. */
  41723. export class ArcFollowCamera extends TargetCamera {
  41724. /** The longitudinal angle of the camera */
  41725. alpha: number;
  41726. /** The latitudinal angle of the camera */
  41727. beta: number;
  41728. /** The radius of the camera from its target */
  41729. radius: number;
  41730. /** Define the camera target (the messh it should follow) */
  41731. target: Nullable<AbstractMesh>;
  41732. private _cartesianCoordinates;
  41733. /**
  41734. * Instantiates a new ArcFollowCamera
  41735. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41736. * @param name Define the name of the camera
  41737. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41738. * @param beta Define the rotation angle of the camera around the elevation axis
  41739. * @param radius Define the radius of the camera from its target point
  41740. * @param target Define the target of the camera
  41741. * @param scene Define the scene the camera belongs to
  41742. */
  41743. constructor(name: string,
  41744. /** The longitudinal angle of the camera */
  41745. alpha: number,
  41746. /** The latitudinal angle of the camera */
  41747. beta: number,
  41748. /** The radius of the camera from its target */
  41749. radius: number,
  41750. /** Define the camera target (the messh it should follow) */
  41751. target: Nullable<AbstractMesh>, scene: Scene);
  41752. private _follow;
  41753. /** @hidden */
  41754. _checkInputs(): void;
  41755. /**
  41756. * Returns the class name of the object.
  41757. * It is mostly used internally for serialization purposes.
  41758. */
  41759. getClassName(): string;
  41760. }
  41761. }
  41762. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41763. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41764. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41765. import { Nullable } from "babylonjs/types";
  41766. /**
  41767. * Manage the keyboard inputs to control the movement of a follow camera.
  41768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41769. */
  41770. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41771. /**
  41772. * Defines the camera the input is attached to.
  41773. */
  41774. camera: FollowCamera;
  41775. /**
  41776. * Defines the list of key codes associated with the up action (increase heightOffset)
  41777. */
  41778. keysHeightOffsetIncr: number[];
  41779. /**
  41780. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41781. */
  41782. keysHeightOffsetDecr: number[];
  41783. /**
  41784. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41785. */
  41786. keysHeightOffsetModifierAlt: boolean;
  41787. /**
  41788. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41789. */
  41790. keysHeightOffsetModifierCtrl: boolean;
  41791. /**
  41792. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41793. */
  41794. keysHeightOffsetModifierShift: boolean;
  41795. /**
  41796. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41797. */
  41798. keysRotationOffsetIncr: number[];
  41799. /**
  41800. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41801. */
  41802. keysRotationOffsetDecr: number[];
  41803. /**
  41804. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41805. */
  41806. keysRotationOffsetModifierAlt: boolean;
  41807. /**
  41808. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41809. */
  41810. keysRotationOffsetModifierCtrl: boolean;
  41811. /**
  41812. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41813. */
  41814. keysRotationOffsetModifierShift: boolean;
  41815. /**
  41816. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41817. */
  41818. keysRadiusIncr: number[];
  41819. /**
  41820. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41821. */
  41822. keysRadiusDecr: number[];
  41823. /**
  41824. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41825. */
  41826. keysRadiusModifierAlt: boolean;
  41827. /**
  41828. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41829. */
  41830. keysRadiusModifierCtrl: boolean;
  41831. /**
  41832. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41833. */
  41834. keysRadiusModifierShift: boolean;
  41835. /**
  41836. * Defines the rate of change of heightOffset.
  41837. */
  41838. heightSensibility: number;
  41839. /**
  41840. * Defines the rate of change of rotationOffset.
  41841. */
  41842. rotationSensibility: number;
  41843. /**
  41844. * Defines the rate of change of radius.
  41845. */
  41846. radiusSensibility: number;
  41847. private _keys;
  41848. private _ctrlPressed;
  41849. private _altPressed;
  41850. private _shiftPressed;
  41851. private _onCanvasBlurObserver;
  41852. private _onKeyboardObserver;
  41853. private _engine;
  41854. private _scene;
  41855. /**
  41856. * Attach the input controls to a specific dom element to get the input from.
  41857. * @param element Defines the element the controls should be listened from
  41858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41859. */
  41860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41861. /**
  41862. * Detach the current controls from the specified dom element.
  41863. * @param element Defines the element to stop listening the inputs from
  41864. */
  41865. detachControl(element: Nullable<HTMLElement>): void;
  41866. /**
  41867. * Update the current camera state depending on the inputs that have been used this frame.
  41868. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41869. */
  41870. checkInputs(): void;
  41871. /**
  41872. * Gets the class name of the current input.
  41873. * @returns the class name
  41874. */
  41875. getClassName(): string;
  41876. /**
  41877. * Get the friendly name associated with the input class.
  41878. * @returns the input friendly name
  41879. */
  41880. getSimpleName(): string;
  41881. /**
  41882. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41883. * allow modification of the heightOffset value.
  41884. */
  41885. private _modifierHeightOffset;
  41886. /**
  41887. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41888. * allow modification of the rotationOffset value.
  41889. */
  41890. private _modifierRotationOffset;
  41891. /**
  41892. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41893. * allow modification of the radius value.
  41894. */
  41895. private _modifierRadius;
  41896. }
  41897. }
  41898. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41899. import { Nullable } from "babylonjs/types";
  41900. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41901. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41902. import { Observable } from "babylonjs/Misc/observable";
  41903. module "babylonjs/Cameras/freeCameraInputsManager" {
  41904. interface FreeCameraInputsManager {
  41905. /**
  41906. * @hidden
  41907. */
  41908. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41909. /**
  41910. * Add orientation input support to the input manager.
  41911. * @returns the current input manager
  41912. */
  41913. addDeviceOrientation(): FreeCameraInputsManager;
  41914. }
  41915. }
  41916. /**
  41917. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41918. * Screen rotation is taken into account.
  41919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41920. */
  41921. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41922. private _camera;
  41923. private _screenOrientationAngle;
  41924. private _constantTranform;
  41925. private _screenQuaternion;
  41926. private _alpha;
  41927. private _beta;
  41928. private _gamma;
  41929. /**
  41930. * Can be used to detect if a device orientation sensor is available on a device
  41931. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41932. * @returns a promise that will resolve on orientation change
  41933. */
  41934. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41935. /**
  41936. * @hidden
  41937. */
  41938. _onDeviceOrientationChangedObservable: Observable<void>;
  41939. /**
  41940. * Instantiates a new input
  41941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41942. */
  41943. constructor();
  41944. /**
  41945. * Define the camera controlled by the input.
  41946. */
  41947. get camera(): FreeCamera;
  41948. set camera(camera: FreeCamera);
  41949. /**
  41950. * Attach the input controls to a specific dom element to get the input from.
  41951. * @param element Defines the element the controls should be listened from
  41952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41953. */
  41954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41955. private _orientationChanged;
  41956. private _deviceOrientation;
  41957. /**
  41958. * Detach the current controls from the specified dom element.
  41959. * @param element Defines the element to stop listening the inputs from
  41960. */
  41961. detachControl(element: Nullable<HTMLElement>): void;
  41962. /**
  41963. * Update the current camera state depending on the inputs that have been used this frame.
  41964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41965. */
  41966. checkInputs(): void;
  41967. /**
  41968. * Gets the class name of the current intput.
  41969. * @returns the class name
  41970. */
  41971. getClassName(): string;
  41972. /**
  41973. * Get the friendly name associated with the input class.
  41974. * @returns the input friendly name
  41975. */
  41976. getSimpleName(): string;
  41977. }
  41978. }
  41979. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41980. import { Nullable } from "babylonjs/types";
  41981. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41982. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41983. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41984. /**
  41985. * Manage the gamepad inputs to control a free camera.
  41986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41987. */
  41988. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41989. /**
  41990. * Define the camera the input is attached to.
  41991. */
  41992. camera: FreeCamera;
  41993. /**
  41994. * Define the Gamepad controlling the input
  41995. */
  41996. gamepad: Nullable<Gamepad>;
  41997. /**
  41998. * Defines the gamepad rotation sensiblity.
  41999. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42000. */
  42001. gamepadAngularSensibility: number;
  42002. /**
  42003. * Defines the gamepad move sensiblity.
  42004. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42005. */
  42006. gamepadMoveSensibility: number;
  42007. private _yAxisScale;
  42008. /**
  42009. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42010. */
  42011. get invertYAxis(): boolean;
  42012. set invertYAxis(value: boolean);
  42013. private _onGamepadConnectedObserver;
  42014. private _onGamepadDisconnectedObserver;
  42015. private _cameraTransform;
  42016. private _deltaTransform;
  42017. private _vector3;
  42018. private _vector2;
  42019. /**
  42020. * Attach the input controls to a specific dom element to get the input from.
  42021. * @param element Defines the element the controls should be listened from
  42022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42023. */
  42024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42025. /**
  42026. * Detach the current controls from the specified dom element.
  42027. * @param element Defines the element to stop listening the inputs from
  42028. */
  42029. detachControl(element: Nullable<HTMLElement>): void;
  42030. /**
  42031. * Update the current camera state depending on the inputs that have been used this frame.
  42032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42033. */
  42034. checkInputs(): void;
  42035. /**
  42036. * Gets the class name of the current intput.
  42037. * @returns the class name
  42038. */
  42039. getClassName(): string;
  42040. /**
  42041. * Get the friendly name associated with the input class.
  42042. * @returns the input friendly name
  42043. */
  42044. getSimpleName(): string;
  42045. }
  42046. }
  42047. declare module "babylonjs/Misc/virtualJoystick" {
  42048. import { Nullable } from "babylonjs/types";
  42049. import { Vector3 } from "babylonjs/Maths/math.vector";
  42050. /**
  42051. * Defines the potential axis of a Joystick
  42052. */
  42053. export enum JoystickAxis {
  42054. /** X axis */
  42055. X = 0,
  42056. /** Y axis */
  42057. Y = 1,
  42058. /** Z axis */
  42059. Z = 2
  42060. }
  42061. /**
  42062. * Class used to define virtual joystick (used in touch mode)
  42063. */
  42064. export class VirtualJoystick {
  42065. /**
  42066. * Gets or sets a boolean indicating that left and right values must be inverted
  42067. */
  42068. reverseLeftRight: boolean;
  42069. /**
  42070. * Gets or sets a boolean indicating that up and down values must be inverted
  42071. */
  42072. reverseUpDown: boolean;
  42073. /**
  42074. * Gets the offset value for the position (ie. the change of the position value)
  42075. */
  42076. deltaPosition: Vector3;
  42077. /**
  42078. * Gets a boolean indicating if the virtual joystick was pressed
  42079. */
  42080. pressed: boolean;
  42081. /**
  42082. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42083. */
  42084. static Canvas: Nullable<HTMLCanvasElement>;
  42085. private static _globalJoystickIndex;
  42086. private static vjCanvasContext;
  42087. private static vjCanvasWidth;
  42088. private static vjCanvasHeight;
  42089. private static halfWidth;
  42090. private _action;
  42091. private _axisTargetedByLeftAndRight;
  42092. private _axisTargetedByUpAndDown;
  42093. private _joystickSensibility;
  42094. private _inversedSensibility;
  42095. private _joystickPointerID;
  42096. private _joystickColor;
  42097. private _joystickPointerPos;
  42098. private _joystickPreviousPointerPos;
  42099. private _joystickPointerStartPos;
  42100. private _deltaJoystickVector;
  42101. private _leftJoystick;
  42102. private _touches;
  42103. private _onPointerDownHandlerRef;
  42104. private _onPointerMoveHandlerRef;
  42105. private _onPointerUpHandlerRef;
  42106. private _onResize;
  42107. /**
  42108. * Creates a new virtual joystick
  42109. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42110. */
  42111. constructor(leftJoystick?: boolean);
  42112. /**
  42113. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42114. * @param newJoystickSensibility defines the new sensibility
  42115. */
  42116. setJoystickSensibility(newJoystickSensibility: number): void;
  42117. private _onPointerDown;
  42118. private _onPointerMove;
  42119. private _onPointerUp;
  42120. /**
  42121. * Change the color of the virtual joystick
  42122. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42123. */
  42124. setJoystickColor(newColor: string): void;
  42125. /**
  42126. * Defines a callback to call when the joystick is touched
  42127. * @param action defines the callback
  42128. */
  42129. setActionOnTouch(action: () => any): void;
  42130. /**
  42131. * Defines which axis you'd like to control for left & right
  42132. * @param axis defines the axis to use
  42133. */
  42134. setAxisForLeftRight(axis: JoystickAxis): void;
  42135. /**
  42136. * Defines which axis you'd like to control for up & down
  42137. * @param axis defines the axis to use
  42138. */
  42139. setAxisForUpDown(axis: JoystickAxis): void;
  42140. private _drawVirtualJoystick;
  42141. /**
  42142. * Release internal HTML canvas
  42143. */
  42144. releaseCanvas(): void;
  42145. }
  42146. }
  42147. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42148. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42149. import { Nullable } from "babylonjs/types";
  42150. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42151. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42152. module "babylonjs/Cameras/freeCameraInputsManager" {
  42153. interface FreeCameraInputsManager {
  42154. /**
  42155. * Add virtual joystick input support to the input manager.
  42156. * @returns the current input manager
  42157. */
  42158. addVirtualJoystick(): FreeCameraInputsManager;
  42159. }
  42160. }
  42161. /**
  42162. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42164. */
  42165. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42166. /**
  42167. * Defines the camera the input is attached to.
  42168. */
  42169. camera: FreeCamera;
  42170. private _leftjoystick;
  42171. private _rightjoystick;
  42172. /**
  42173. * Gets the left stick of the virtual joystick.
  42174. * @returns The virtual Joystick
  42175. */
  42176. getLeftJoystick(): VirtualJoystick;
  42177. /**
  42178. * Gets the right stick of the virtual joystick.
  42179. * @returns The virtual Joystick
  42180. */
  42181. getRightJoystick(): VirtualJoystick;
  42182. /**
  42183. * Update the current camera state depending on the inputs that have been used this frame.
  42184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42185. */
  42186. checkInputs(): void;
  42187. /**
  42188. * Attach the input controls to a specific dom element to get the input from.
  42189. * @param element Defines the element the controls should be listened from
  42190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42191. */
  42192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42193. /**
  42194. * Detach the current controls from the specified dom element.
  42195. * @param element Defines the element to stop listening the inputs from
  42196. */
  42197. detachControl(element: Nullable<HTMLElement>): void;
  42198. /**
  42199. * Gets the class name of the current intput.
  42200. * @returns the class name
  42201. */
  42202. getClassName(): string;
  42203. /**
  42204. * Get the friendly name associated with the input class.
  42205. * @returns the input friendly name
  42206. */
  42207. getSimpleName(): string;
  42208. }
  42209. }
  42210. declare module "babylonjs/Cameras/Inputs/index" {
  42211. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42212. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42213. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42214. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42215. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42216. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42217. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42218. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42219. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42220. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42221. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42222. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42223. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42224. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42225. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42226. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42227. }
  42228. declare module "babylonjs/Cameras/touchCamera" {
  42229. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42230. import { Scene } from "babylonjs/scene";
  42231. import { Vector3 } from "babylonjs/Maths/math.vector";
  42232. /**
  42233. * This represents a FPS type of camera controlled by touch.
  42234. * This is like a universal camera minus the Gamepad controls.
  42235. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42236. */
  42237. export class TouchCamera extends FreeCamera {
  42238. /**
  42239. * Defines the touch sensibility for rotation.
  42240. * The higher the faster.
  42241. */
  42242. get touchAngularSensibility(): number;
  42243. set touchAngularSensibility(value: number);
  42244. /**
  42245. * Defines the touch sensibility for move.
  42246. * The higher the faster.
  42247. */
  42248. get touchMoveSensibility(): number;
  42249. set touchMoveSensibility(value: number);
  42250. /**
  42251. * Instantiates a new touch camera.
  42252. * This represents a FPS type of camera controlled by touch.
  42253. * This is like a universal camera minus the Gamepad controls.
  42254. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42255. * @param name Define the name of the camera in the scene
  42256. * @param position Define the start position of the camera in the scene
  42257. * @param scene Define the scene the camera belongs to
  42258. */
  42259. constructor(name: string, position: Vector3, scene: Scene);
  42260. /**
  42261. * Gets the current object class name.
  42262. * @return the class name
  42263. */
  42264. getClassName(): string;
  42265. /** @hidden */
  42266. _setupInputs(): void;
  42267. }
  42268. }
  42269. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42270. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42271. import { Scene } from "babylonjs/scene";
  42272. import { Vector3 } from "babylonjs/Maths/math.vector";
  42273. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42274. import { Axis } from "babylonjs/Maths/math.axis";
  42275. /**
  42276. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42277. * being tilted forward or back and left or right.
  42278. */
  42279. export class DeviceOrientationCamera extends FreeCamera {
  42280. private _initialQuaternion;
  42281. private _quaternionCache;
  42282. private _tmpDragQuaternion;
  42283. private _disablePointerInputWhenUsingDeviceOrientation;
  42284. /**
  42285. * Creates a new device orientation camera
  42286. * @param name The name of the camera
  42287. * @param position The start position camera
  42288. * @param scene The scene the camera belongs to
  42289. */
  42290. constructor(name: string, position: Vector3, scene: Scene);
  42291. /**
  42292. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42293. */
  42294. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42295. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42296. private _dragFactor;
  42297. /**
  42298. * Enabled turning on the y axis when the orientation sensor is active
  42299. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42300. */
  42301. enableHorizontalDragging(dragFactor?: number): void;
  42302. /**
  42303. * Gets the current instance class name ("DeviceOrientationCamera").
  42304. * This helps avoiding instanceof at run time.
  42305. * @returns the class name
  42306. */
  42307. getClassName(): string;
  42308. /**
  42309. * @hidden
  42310. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42311. */
  42312. _checkInputs(): void;
  42313. /**
  42314. * Reset the camera to its default orientation on the specified axis only.
  42315. * @param axis The axis to reset
  42316. */
  42317. resetToCurrentRotation(axis?: Axis): void;
  42318. }
  42319. }
  42320. declare module "babylonjs/Gamepads/xboxGamepad" {
  42321. import { Observable } from "babylonjs/Misc/observable";
  42322. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42323. /**
  42324. * Defines supported buttons for XBox360 compatible gamepads
  42325. */
  42326. export enum Xbox360Button {
  42327. /** A */
  42328. A = 0,
  42329. /** B */
  42330. B = 1,
  42331. /** X */
  42332. X = 2,
  42333. /** Y */
  42334. Y = 3,
  42335. /** Left button */
  42336. LB = 4,
  42337. /** Right button */
  42338. RB = 5,
  42339. /** Back */
  42340. Back = 8,
  42341. /** Start */
  42342. Start = 9,
  42343. /** Left stick */
  42344. LeftStick = 10,
  42345. /** Right stick */
  42346. RightStick = 11
  42347. }
  42348. /** Defines values for XBox360 DPad */
  42349. export enum Xbox360Dpad {
  42350. /** Up */
  42351. Up = 12,
  42352. /** Down */
  42353. Down = 13,
  42354. /** Left */
  42355. Left = 14,
  42356. /** Right */
  42357. Right = 15
  42358. }
  42359. /**
  42360. * Defines a XBox360 gamepad
  42361. */
  42362. export class Xbox360Pad extends Gamepad {
  42363. private _leftTrigger;
  42364. private _rightTrigger;
  42365. private _onlefttriggerchanged;
  42366. private _onrighttriggerchanged;
  42367. private _onbuttondown;
  42368. private _onbuttonup;
  42369. private _ondpaddown;
  42370. private _ondpadup;
  42371. /** Observable raised when a button is pressed */
  42372. onButtonDownObservable: Observable<Xbox360Button>;
  42373. /** Observable raised when a button is released */
  42374. onButtonUpObservable: Observable<Xbox360Button>;
  42375. /** Observable raised when a pad is pressed */
  42376. onPadDownObservable: Observable<Xbox360Dpad>;
  42377. /** Observable raised when a pad is released */
  42378. onPadUpObservable: Observable<Xbox360Dpad>;
  42379. private _buttonA;
  42380. private _buttonB;
  42381. private _buttonX;
  42382. private _buttonY;
  42383. private _buttonBack;
  42384. private _buttonStart;
  42385. private _buttonLB;
  42386. private _buttonRB;
  42387. private _buttonLeftStick;
  42388. private _buttonRightStick;
  42389. private _dPadUp;
  42390. private _dPadDown;
  42391. private _dPadLeft;
  42392. private _dPadRight;
  42393. private _isXboxOnePad;
  42394. /**
  42395. * Creates a new XBox360 gamepad object
  42396. * @param id defines the id of this gamepad
  42397. * @param index defines its index
  42398. * @param gamepad defines the internal HTML gamepad object
  42399. * @param xboxOne defines if it is a XBox One gamepad
  42400. */
  42401. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42402. /**
  42403. * Defines the callback to call when left trigger is pressed
  42404. * @param callback defines the callback to use
  42405. */
  42406. onlefttriggerchanged(callback: (value: number) => void): void;
  42407. /**
  42408. * Defines the callback to call when right trigger is pressed
  42409. * @param callback defines the callback to use
  42410. */
  42411. onrighttriggerchanged(callback: (value: number) => void): void;
  42412. /**
  42413. * Gets the left trigger value
  42414. */
  42415. get leftTrigger(): number;
  42416. /**
  42417. * Sets the left trigger value
  42418. */
  42419. set leftTrigger(newValue: number);
  42420. /**
  42421. * Gets the right trigger value
  42422. */
  42423. get rightTrigger(): number;
  42424. /**
  42425. * Sets the right trigger value
  42426. */
  42427. set rightTrigger(newValue: number);
  42428. /**
  42429. * Defines the callback to call when a button is pressed
  42430. * @param callback defines the callback to use
  42431. */
  42432. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42433. /**
  42434. * Defines the callback to call when a button is released
  42435. * @param callback defines the callback to use
  42436. */
  42437. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42438. /**
  42439. * Defines the callback to call when a pad is pressed
  42440. * @param callback defines the callback to use
  42441. */
  42442. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42443. /**
  42444. * Defines the callback to call when a pad is released
  42445. * @param callback defines the callback to use
  42446. */
  42447. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42448. private _setButtonValue;
  42449. private _setDPadValue;
  42450. /**
  42451. * Gets the value of the `A` button
  42452. */
  42453. get buttonA(): number;
  42454. /**
  42455. * Sets the value of the `A` button
  42456. */
  42457. set buttonA(value: number);
  42458. /**
  42459. * Gets the value of the `B` button
  42460. */
  42461. get buttonB(): number;
  42462. /**
  42463. * Sets the value of the `B` button
  42464. */
  42465. set buttonB(value: number);
  42466. /**
  42467. * Gets the value of the `X` button
  42468. */
  42469. get buttonX(): number;
  42470. /**
  42471. * Sets the value of the `X` button
  42472. */
  42473. set buttonX(value: number);
  42474. /**
  42475. * Gets the value of the `Y` button
  42476. */
  42477. get buttonY(): number;
  42478. /**
  42479. * Sets the value of the `Y` button
  42480. */
  42481. set buttonY(value: number);
  42482. /**
  42483. * Gets the value of the `Start` button
  42484. */
  42485. get buttonStart(): number;
  42486. /**
  42487. * Sets the value of the `Start` button
  42488. */
  42489. set buttonStart(value: number);
  42490. /**
  42491. * Gets the value of the `Back` button
  42492. */
  42493. get buttonBack(): number;
  42494. /**
  42495. * Sets the value of the `Back` button
  42496. */
  42497. set buttonBack(value: number);
  42498. /**
  42499. * Gets the value of the `Left` button
  42500. */
  42501. get buttonLB(): number;
  42502. /**
  42503. * Sets the value of the `Left` button
  42504. */
  42505. set buttonLB(value: number);
  42506. /**
  42507. * Gets the value of the `Right` button
  42508. */
  42509. get buttonRB(): number;
  42510. /**
  42511. * Sets the value of the `Right` button
  42512. */
  42513. set buttonRB(value: number);
  42514. /**
  42515. * Gets the value of the Left joystick
  42516. */
  42517. get buttonLeftStick(): number;
  42518. /**
  42519. * Sets the value of the Left joystick
  42520. */
  42521. set buttonLeftStick(value: number);
  42522. /**
  42523. * Gets the value of the Right joystick
  42524. */
  42525. get buttonRightStick(): number;
  42526. /**
  42527. * Sets the value of the Right joystick
  42528. */
  42529. set buttonRightStick(value: number);
  42530. /**
  42531. * Gets the value of D-pad up
  42532. */
  42533. get dPadUp(): number;
  42534. /**
  42535. * Sets the value of D-pad up
  42536. */
  42537. set dPadUp(value: number);
  42538. /**
  42539. * Gets the value of D-pad down
  42540. */
  42541. get dPadDown(): number;
  42542. /**
  42543. * Sets the value of D-pad down
  42544. */
  42545. set dPadDown(value: number);
  42546. /**
  42547. * Gets the value of D-pad left
  42548. */
  42549. get dPadLeft(): number;
  42550. /**
  42551. * Sets the value of D-pad left
  42552. */
  42553. set dPadLeft(value: number);
  42554. /**
  42555. * Gets the value of D-pad right
  42556. */
  42557. get dPadRight(): number;
  42558. /**
  42559. * Sets the value of D-pad right
  42560. */
  42561. set dPadRight(value: number);
  42562. /**
  42563. * Force the gamepad to synchronize with device values
  42564. */
  42565. update(): void;
  42566. /**
  42567. * Disposes the gamepad
  42568. */
  42569. dispose(): void;
  42570. }
  42571. }
  42572. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42573. import { Observable } from "babylonjs/Misc/observable";
  42574. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42575. /**
  42576. * Defines supported buttons for DualShock compatible gamepads
  42577. */
  42578. export enum DualShockButton {
  42579. /** Cross */
  42580. Cross = 0,
  42581. /** Circle */
  42582. Circle = 1,
  42583. /** Square */
  42584. Square = 2,
  42585. /** Triangle */
  42586. Triangle = 3,
  42587. /** L1 */
  42588. L1 = 4,
  42589. /** R1 */
  42590. R1 = 5,
  42591. /** Share */
  42592. Share = 8,
  42593. /** Options */
  42594. Options = 9,
  42595. /** Left stick */
  42596. LeftStick = 10,
  42597. /** Right stick */
  42598. RightStick = 11
  42599. }
  42600. /** Defines values for DualShock DPad */
  42601. export enum DualShockDpad {
  42602. /** Up */
  42603. Up = 12,
  42604. /** Down */
  42605. Down = 13,
  42606. /** Left */
  42607. Left = 14,
  42608. /** Right */
  42609. Right = 15
  42610. }
  42611. /**
  42612. * Defines a DualShock gamepad
  42613. */
  42614. export class DualShockPad extends Gamepad {
  42615. private _leftTrigger;
  42616. private _rightTrigger;
  42617. private _onlefttriggerchanged;
  42618. private _onrighttriggerchanged;
  42619. private _onbuttondown;
  42620. private _onbuttonup;
  42621. private _ondpaddown;
  42622. private _ondpadup;
  42623. /** Observable raised when a button is pressed */
  42624. onButtonDownObservable: Observable<DualShockButton>;
  42625. /** Observable raised when a button is released */
  42626. onButtonUpObservable: Observable<DualShockButton>;
  42627. /** Observable raised when a pad is pressed */
  42628. onPadDownObservable: Observable<DualShockDpad>;
  42629. /** Observable raised when a pad is released */
  42630. onPadUpObservable: Observable<DualShockDpad>;
  42631. private _buttonCross;
  42632. private _buttonCircle;
  42633. private _buttonSquare;
  42634. private _buttonTriangle;
  42635. private _buttonShare;
  42636. private _buttonOptions;
  42637. private _buttonL1;
  42638. private _buttonR1;
  42639. private _buttonLeftStick;
  42640. private _buttonRightStick;
  42641. private _dPadUp;
  42642. private _dPadDown;
  42643. private _dPadLeft;
  42644. private _dPadRight;
  42645. /**
  42646. * Creates a new DualShock gamepad object
  42647. * @param id defines the id of this gamepad
  42648. * @param index defines its index
  42649. * @param gamepad defines the internal HTML gamepad object
  42650. */
  42651. constructor(id: string, index: number, gamepad: any);
  42652. /**
  42653. * Defines the callback to call when left trigger is pressed
  42654. * @param callback defines the callback to use
  42655. */
  42656. onlefttriggerchanged(callback: (value: number) => void): void;
  42657. /**
  42658. * Defines the callback to call when right trigger is pressed
  42659. * @param callback defines the callback to use
  42660. */
  42661. onrighttriggerchanged(callback: (value: number) => void): void;
  42662. /**
  42663. * Gets the left trigger value
  42664. */
  42665. get leftTrigger(): number;
  42666. /**
  42667. * Sets the left trigger value
  42668. */
  42669. set leftTrigger(newValue: number);
  42670. /**
  42671. * Gets the right trigger value
  42672. */
  42673. get rightTrigger(): number;
  42674. /**
  42675. * Sets the right trigger value
  42676. */
  42677. set rightTrigger(newValue: number);
  42678. /**
  42679. * Defines the callback to call when a button is pressed
  42680. * @param callback defines the callback to use
  42681. */
  42682. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42683. /**
  42684. * Defines the callback to call when a button is released
  42685. * @param callback defines the callback to use
  42686. */
  42687. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42688. /**
  42689. * Defines the callback to call when a pad is pressed
  42690. * @param callback defines the callback to use
  42691. */
  42692. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42693. /**
  42694. * Defines the callback to call when a pad is released
  42695. * @param callback defines the callback to use
  42696. */
  42697. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42698. private _setButtonValue;
  42699. private _setDPadValue;
  42700. /**
  42701. * Gets the value of the `Cross` button
  42702. */
  42703. get buttonCross(): number;
  42704. /**
  42705. * Sets the value of the `Cross` button
  42706. */
  42707. set buttonCross(value: number);
  42708. /**
  42709. * Gets the value of the `Circle` button
  42710. */
  42711. get buttonCircle(): number;
  42712. /**
  42713. * Sets the value of the `Circle` button
  42714. */
  42715. set buttonCircle(value: number);
  42716. /**
  42717. * Gets the value of the `Square` button
  42718. */
  42719. get buttonSquare(): number;
  42720. /**
  42721. * Sets the value of the `Square` button
  42722. */
  42723. set buttonSquare(value: number);
  42724. /**
  42725. * Gets the value of the `Triangle` button
  42726. */
  42727. get buttonTriangle(): number;
  42728. /**
  42729. * Sets the value of the `Triangle` button
  42730. */
  42731. set buttonTriangle(value: number);
  42732. /**
  42733. * Gets the value of the `Options` button
  42734. */
  42735. get buttonOptions(): number;
  42736. /**
  42737. * Sets the value of the `Options` button
  42738. */
  42739. set buttonOptions(value: number);
  42740. /**
  42741. * Gets the value of the `Share` button
  42742. */
  42743. get buttonShare(): number;
  42744. /**
  42745. * Sets the value of the `Share` button
  42746. */
  42747. set buttonShare(value: number);
  42748. /**
  42749. * Gets the value of the `L1` button
  42750. */
  42751. get buttonL1(): number;
  42752. /**
  42753. * Sets the value of the `L1` button
  42754. */
  42755. set buttonL1(value: number);
  42756. /**
  42757. * Gets the value of the `R1` button
  42758. */
  42759. get buttonR1(): number;
  42760. /**
  42761. * Sets the value of the `R1` button
  42762. */
  42763. set buttonR1(value: number);
  42764. /**
  42765. * Gets the value of the Left joystick
  42766. */
  42767. get buttonLeftStick(): number;
  42768. /**
  42769. * Sets the value of the Left joystick
  42770. */
  42771. set buttonLeftStick(value: number);
  42772. /**
  42773. * Gets the value of the Right joystick
  42774. */
  42775. get buttonRightStick(): number;
  42776. /**
  42777. * Sets the value of the Right joystick
  42778. */
  42779. set buttonRightStick(value: number);
  42780. /**
  42781. * Gets the value of D-pad up
  42782. */
  42783. get dPadUp(): number;
  42784. /**
  42785. * Sets the value of D-pad up
  42786. */
  42787. set dPadUp(value: number);
  42788. /**
  42789. * Gets the value of D-pad down
  42790. */
  42791. get dPadDown(): number;
  42792. /**
  42793. * Sets the value of D-pad down
  42794. */
  42795. set dPadDown(value: number);
  42796. /**
  42797. * Gets the value of D-pad left
  42798. */
  42799. get dPadLeft(): number;
  42800. /**
  42801. * Sets the value of D-pad left
  42802. */
  42803. set dPadLeft(value: number);
  42804. /**
  42805. * Gets the value of D-pad right
  42806. */
  42807. get dPadRight(): number;
  42808. /**
  42809. * Sets the value of D-pad right
  42810. */
  42811. set dPadRight(value: number);
  42812. /**
  42813. * Force the gamepad to synchronize with device values
  42814. */
  42815. update(): void;
  42816. /**
  42817. * Disposes the gamepad
  42818. */
  42819. dispose(): void;
  42820. }
  42821. }
  42822. declare module "babylonjs/Gamepads/gamepadManager" {
  42823. import { Observable } from "babylonjs/Misc/observable";
  42824. import { Nullable } from "babylonjs/types";
  42825. import { Scene } from "babylonjs/scene";
  42826. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42827. /**
  42828. * Manager for handling gamepads
  42829. */
  42830. export class GamepadManager {
  42831. private _scene?;
  42832. private _babylonGamepads;
  42833. private _oneGamepadConnected;
  42834. /** @hidden */
  42835. _isMonitoring: boolean;
  42836. private _gamepadEventSupported;
  42837. private _gamepadSupport?;
  42838. /**
  42839. * observable to be triggered when the gamepad controller has been connected
  42840. */
  42841. onGamepadConnectedObservable: Observable<Gamepad>;
  42842. /**
  42843. * observable to be triggered when the gamepad controller has been disconnected
  42844. */
  42845. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42846. private _onGamepadConnectedEvent;
  42847. private _onGamepadDisconnectedEvent;
  42848. /**
  42849. * Initializes the gamepad manager
  42850. * @param _scene BabylonJS scene
  42851. */
  42852. constructor(_scene?: Scene | undefined);
  42853. /**
  42854. * The gamepads in the game pad manager
  42855. */
  42856. get gamepads(): Gamepad[];
  42857. /**
  42858. * Get the gamepad controllers based on type
  42859. * @param type The type of gamepad controller
  42860. * @returns Nullable gamepad
  42861. */
  42862. getGamepadByType(type?: number): Nullable<Gamepad>;
  42863. /**
  42864. * Disposes the gamepad manager
  42865. */
  42866. dispose(): void;
  42867. private _addNewGamepad;
  42868. private _startMonitoringGamepads;
  42869. private _stopMonitoringGamepads;
  42870. /** @hidden */
  42871. _checkGamepadsStatus(): void;
  42872. private _updateGamepadObjects;
  42873. }
  42874. }
  42875. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42876. import { Nullable } from "babylonjs/types";
  42877. import { Scene } from "babylonjs/scene";
  42878. import { ISceneComponent } from "babylonjs/sceneComponent";
  42879. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42880. module "babylonjs/scene" {
  42881. interface Scene {
  42882. /** @hidden */
  42883. _gamepadManager: Nullable<GamepadManager>;
  42884. /**
  42885. * Gets the gamepad manager associated with the scene
  42886. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42887. */
  42888. gamepadManager: GamepadManager;
  42889. }
  42890. }
  42891. module "babylonjs/Cameras/freeCameraInputsManager" {
  42892. /**
  42893. * Interface representing a free camera inputs manager
  42894. */
  42895. interface FreeCameraInputsManager {
  42896. /**
  42897. * Adds gamepad input support to the FreeCameraInputsManager.
  42898. * @returns the FreeCameraInputsManager
  42899. */
  42900. addGamepad(): FreeCameraInputsManager;
  42901. }
  42902. }
  42903. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42904. /**
  42905. * Interface representing an arc rotate camera inputs manager
  42906. */
  42907. interface ArcRotateCameraInputsManager {
  42908. /**
  42909. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42910. * @returns the camera inputs manager
  42911. */
  42912. addGamepad(): ArcRotateCameraInputsManager;
  42913. }
  42914. }
  42915. /**
  42916. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42917. */
  42918. export class GamepadSystemSceneComponent implements ISceneComponent {
  42919. /**
  42920. * The component name helpfull to identify the component in the list of scene components.
  42921. */
  42922. readonly name: string;
  42923. /**
  42924. * The scene the component belongs to.
  42925. */
  42926. scene: Scene;
  42927. /**
  42928. * Creates a new instance of the component for the given scene
  42929. * @param scene Defines the scene to register the component in
  42930. */
  42931. constructor(scene: Scene);
  42932. /**
  42933. * Registers the component in a given scene
  42934. */
  42935. register(): void;
  42936. /**
  42937. * Rebuilds the elements related to this component in case of
  42938. * context lost for instance.
  42939. */
  42940. rebuild(): void;
  42941. /**
  42942. * Disposes the component and the associated ressources
  42943. */
  42944. dispose(): void;
  42945. private _beforeCameraUpdate;
  42946. }
  42947. }
  42948. declare module "babylonjs/Cameras/universalCamera" {
  42949. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42950. import { Scene } from "babylonjs/scene";
  42951. import { Vector3 } from "babylonjs/Maths/math.vector";
  42952. import "babylonjs/Gamepads/gamepadSceneComponent";
  42953. /**
  42954. * 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,
  42955. * which still works and will still be found in many Playgrounds.
  42956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42957. */
  42958. export class UniversalCamera extends TouchCamera {
  42959. /**
  42960. * Defines the gamepad rotation sensiblity.
  42961. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42962. */
  42963. get gamepadAngularSensibility(): number;
  42964. set gamepadAngularSensibility(value: number);
  42965. /**
  42966. * Defines the gamepad move sensiblity.
  42967. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42968. */
  42969. get gamepadMoveSensibility(): number;
  42970. set gamepadMoveSensibility(value: number);
  42971. /**
  42972. * 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,
  42973. * which still works and will still be found in many Playgrounds.
  42974. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42975. * @param name Define the name of the camera in the scene
  42976. * @param position Define the start position of the camera in the scene
  42977. * @param scene Define the scene the camera belongs to
  42978. */
  42979. constructor(name: string, position: Vector3, scene: Scene);
  42980. /**
  42981. * Gets the current object class name.
  42982. * @return the class name
  42983. */
  42984. getClassName(): string;
  42985. }
  42986. }
  42987. declare module "babylonjs/Cameras/gamepadCamera" {
  42988. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42989. import { Scene } from "babylonjs/scene";
  42990. import { Vector3 } from "babylonjs/Maths/math.vector";
  42991. /**
  42992. * This represents a FPS type of camera. This is only here for back compat purpose.
  42993. * Please use the UniversalCamera instead as both are identical.
  42994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42995. */
  42996. export class GamepadCamera extends UniversalCamera {
  42997. /**
  42998. * Instantiates a new Gamepad Camera
  42999. * This represents a FPS type of camera. This is only here for back compat purpose.
  43000. * Please use the UniversalCamera instead as both are identical.
  43001. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43002. * @param name Define the name of the camera in the scene
  43003. * @param position Define the start position of the camera in the scene
  43004. * @param scene Define the scene the camera belongs to
  43005. */
  43006. constructor(name: string, position: Vector3, scene: Scene);
  43007. /**
  43008. * Gets the current object class name.
  43009. * @return the class name
  43010. */
  43011. getClassName(): string;
  43012. }
  43013. }
  43014. declare module "babylonjs/Shaders/pass.fragment" {
  43015. /** @hidden */
  43016. export var passPixelShader: {
  43017. name: string;
  43018. shader: string;
  43019. };
  43020. }
  43021. declare module "babylonjs/Shaders/passCube.fragment" {
  43022. /** @hidden */
  43023. export var passCubePixelShader: {
  43024. name: string;
  43025. shader: string;
  43026. };
  43027. }
  43028. declare module "babylonjs/PostProcesses/passPostProcess" {
  43029. import { Nullable } from "babylonjs/types";
  43030. import { Camera } from "babylonjs/Cameras/camera";
  43031. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43032. import { Engine } from "babylonjs/Engines/engine";
  43033. import "babylonjs/Shaders/pass.fragment";
  43034. import "babylonjs/Shaders/passCube.fragment";
  43035. /**
  43036. * PassPostProcess which produces an output the same as it's input
  43037. */
  43038. export class PassPostProcess extends PostProcess {
  43039. /**
  43040. * Creates the PassPostProcess
  43041. * @param name The name of the effect.
  43042. * @param options The required width/height ratio to downsize to before computing the render pass.
  43043. * @param camera The camera to apply the render pass to.
  43044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43045. * @param engine The engine which the post process will be applied. (default: current engine)
  43046. * @param reusable If the post process can be reused on the same frame. (default: false)
  43047. * @param textureType The type of texture to be used when performing the post processing.
  43048. * @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)
  43049. */
  43050. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43051. }
  43052. /**
  43053. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43054. */
  43055. export class PassCubePostProcess extends PostProcess {
  43056. private _face;
  43057. /**
  43058. * Gets or sets the cube face to display.
  43059. * * 0 is +X
  43060. * * 1 is -X
  43061. * * 2 is +Y
  43062. * * 3 is -Y
  43063. * * 4 is +Z
  43064. * * 5 is -Z
  43065. */
  43066. get face(): number;
  43067. set face(value: number);
  43068. /**
  43069. * Creates the PassCubePostProcess
  43070. * @param name The name of the effect.
  43071. * @param options The required width/height ratio to downsize to before computing the render pass.
  43072. * @param camera The camera to apply the render pass to.
  43073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43074. * @param engine The engine which the post process will be applied. (default: current engine)
  43075. * @param reusable If the post process can be reused on the same frame. (default: false)
  43076. * @param textureType The type of texture to be used when performing the post processing.
  43077. * @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)
  43078. */
  43079. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43080. }
  43081. }
  43082. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43083. /** @hidden */
  43084. export var anaglyphPixelShader: {
  43085. name: string;
  43086. shader: string;
  43087. };
  43088. }
  43089. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43090. import { Engine } from "babylonjs/Engines/engine";
  43091. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43092. import { Camera } from "babylonjs/Cameras/camera";
  43093. import "babylonjs/Shaders/anaglyph.fragment";
  43094. /**
  43095. * Postprocess used to generate anaglyphic rendering
  43096. */
  43097. export class AnaglyphPostProcess extends PostProcess {
  43098. private _passedProcess;
  43099. /**
  43100. * Creates a new AnaglyphPostProcess
  43101. * @param name defines postprocess name
  43102. * @param options defines creation options or target ratio scale
  43103. * @param rigCameras defines cameras using this postprocess
  43104. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43105. * @param engine defines hosting engine
  43106. * @param reusable defines if the postprocess will be reused multiple times per frame
  43107. */
  43108. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43109. }
  43110. }
  43111. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43112. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43113. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43114. import { Scene } from "babylonjs/scene";
  43115. import { Vector3 } from "babylonjs/Maths/math.vector";
  43116. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43117. /**
  43118. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43119. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43120. */
  43121. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43122. /**
  43123. * Creates a new AnaglyphArcRotateCamera
  43124. * @param name defines camera name
  43125. * @param alpha defines alpha angle (in radians)
  43126. * @param beta defines beta angle (in radians)
  43127. * @param radius defines radius
  43128. * @param target defines camera target
  43129. * @param interaxialDistance defines distance between each color axis
  43130. * @param scene defines the hosting scene
  43131. */
  43132. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43133. /**
  43134. * Gets camera class name
  43135. * @returns AnaglyphArcRotateCamera
  43136. */
  43137. getClassName(): string;
  43138. }
  43139. }
  43140. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43141. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43142. import { Scene } from "babylonjs/scene";
  43143. import { Vector3 } from "babylonjs/Maths/math.vector";
  43144. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43145. /**
  43146. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43147. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43148. */
  43149. export class AnaglyphFreeCamera extends FreeCamera {
  43150. /**
  43151. * Creates a new AnaglyphFreeCamera
  43152. * @param name defines camera name
  43153. * @param position defines initial position
  43154. * @param interaxialDistance defines distance between each color axis
  43155. * @param scene defines the hosting scene
  43156. */
  43157. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43158. /**
  43159. * Gets camera class name
  43160. * @returns AnaglyphFreeCamera
  43161. */
  43162. getClassName(): string;
  43163. }
  43164. }
  43165. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43166. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43167. import { Scene } from "babylonjs/scene";
  43168. import { Vector3 } from "babylonjs/Maths/math.vector";
  43169. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43170. /**
  43171. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43172. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43173. */
  43174. export class AnaglyphGamepadCamera extends GamepadCamera {
  43175. /**
  43176. * Creates a new AnaglyphGamepadCamera
  43177. * @param name defines camera name
  43178. * @param position defines initial position
  43179. * @param interaxialDistance defines distance between each color axis
  43180. * @param scene defines the hosting scene
  43181. */
  43182. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43183. /**
  43184. * Gets camera class name
  43185. * @returns AnaglyphGamepadCamera
  43186. */
  43187. getClassName(): string;
  43188. }
  43189. }
  43190. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43191. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43192. import { Scene } from "babylonjs/scene";
  43193. import { Vector3 } from "babylonjs/Maths/math.vector";
  43194. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43195. /**
  43196. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43197. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43198. */
  43199. export class AnaglyphUniversalCamera extends UniversalCamera {
  43200. /**
  43201. * Creates a new AnaglyphUniversalCamera
  43202. * @param name defines camera name
  43203. * @param position defines initial position
  43204. * @param interaxialDistance defines distance between each color axis
  43205. * @param scene defines the hosting scene
  43206. */
  43207. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43208. /**
  43209. * Gets camera class name
  43210. * @returns AnaglyphUniversalCamera
  43211. */
  43212. getClassName(): string;
  43213. }
  43214. }
  43215. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43216. /** @hidden */
  43217. export var stereoscopicInterlacePixelShader: {
  43218. name: string;
  43219. shader: string;
  43220. };
  43221. }
  43222. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43223. import { Camera } from "babylonjs/Cameras/camera";
  43224. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43225. import { Engine } from "babylonjs/Engines/engine";
  43226. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43227. /**
  43228. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43229. */
  43230. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43231. private _stepSize;
  43232. private _passedProcess;
  43233. /**
  43234. * Initializes a StereoscopicInterlacePostProcessI
  43235. * @param name The name of the effect.
  43236. * @param rigCameras The rig cameras to be appled to the post process
  43237. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43238. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43240. * @param engine The engine which the post process will be applied. (default: current engine)
  43241. * @param reusable If the post process can be reused on the same frame. (default: false)
  43242. */
  43243. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43244. }
  43245. /**
  43246. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43247. */
  43248. export class StereoscopicInterlacePostProcess extends PostProcess {
  43249. private _stepSize;
  43250. private _passedProcess;
  43251. /**
  43252. * Initializes a StereoscopicInterlacePostProcess
  43253. * @param name The name of the effect.
  43254. * @param rigCameras The rig cameras to be appled to the post process
  43255. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43257. * @param engine The engine which the post process will be applied. (default: current engine)
  43258. * @param reusable If the post process can be reused on the same frame. (default: false)
  43259. */
  43260. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43261. }
  43262. }
  43263. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43264. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43265. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43266. import { Scene } from "babylonjs/scene";
  43267. import { Vector3 } from "babylonjs/Maths/math.vector";
  43268. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43269. /**
  43270. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43271. * @see http://doc.babylonjs.com/features/cameras
  43272. */
  43273. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43274. /**
  43275. * Creates a new StereoscopicArcRotateCamera
  43276. * @param name defines camera name
  43277. * @param alpha defines alpha angle (in radians)
  43278. * @param beta defines beta angle (in radians)
  43279. * @param radius defines radius
  43280. * @param target defines camera target
  43281. * @param interaxialDistance defines distance between each color axis
  43282. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43283. * @param scene defines the hosting scene
  43284. */
  43285. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43286. /**
  43287. * Gets camera class name
  43288. * @returns StereoscopicArcRotateCamera
  43289. */
  43290. getClassName(): string;
  43291. }
  43292. }
  43293. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43294. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43295. import { Scene } from "babylonjs/scene";
  43296. import { Vector3 } from "babylonjs/Maths/math.vector";
  43297. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43298. /**
  43299. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43300. * @see http://doc.babylonjs.com/features/cameras
  43301. */
  43302. export class StereoscopicFreeCamera extends FreeCamera {
  43303. /**
  43304. * Creates a new StereoscopicFreeCamera
  43305. * @param name defines camera name
  43306. * @param position defines initial position
  43307. * @param interaxialDistance defines distance between each color axis
  43308. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43309. * @param scene defines the hosting scene
  43310. */
  43311. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43312. /**
  43313. * Gets camera class name
  43314. * @returns StereoscopicFreeCamera
  43315. */
  43316. getClassName(): string;
  43317. }
  43318. }
  43319. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43320. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43321. import { Scene } from "babylonjs/scene";
  43322. import { Vector3 } from "babylonjs/Maths/math.vector";
  43323. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43324. /**
  43325. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43326. * @see http://doc.babylonjs.com/features/cameras
  43327. */
  43328. export class StereoscopicGamepadCamera extends GamepadCamera {
  43329. /**
  43330. * Creates a new StereoscopicGamepadCamera
  43331. * @param name defines camera name
  43332. * @param position defines initial position
  43333. * @param interaxialDistance defines distance between each color axis
  43334. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43335. * @param scene defines the hosting scene
  43336. */
  43337. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43338. /**
  43339. * Gets camera class name
  43340. * @returns StereoscopicGamepadCamera
  43341. */
  43342. getClassName(): string;
  43343. }
  43344. }
  43345. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43346. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43347. import { Scene } from "babylonjs/scene";
  43348. import { Vector3 } from "babylonjs/Maths/math.vector";
  43349. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43350. /**
  43351. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43352. * @see http://doc.babylonjs.com/features/cameras
  43353. */
  43354. export class StereoscopicUniversalCamera extends UniversalCamera {
  43355. /**
  43356. * Creates a new StereoscopicUniversalCamera
  43357. * @param name defines camera name
  43358. * @param position defines initial position
  43359. * @param interaxialDistance defines distance between each color axis
  43360. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43361. * @param scene defines the hosting scene
  43362. */
  43363. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43364. /**
  43365. * Gets camera class name
  43366. * @returns StereoscopicUniversalCamera
  43367. */
  43368. getClassName(): string;
  43369. }
  43370. }
  43371. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43372. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43373. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43374. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43375. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43376. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43377. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43378. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43379. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43380. }
  43381. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43382. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43383. import { Scene } from "babylonjs/scene";
  43384. import { Vector3 } from "babylonjs/Maths/math.vector";
  43385. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43386. /**
  43387. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43388. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43389. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43390. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43391. */
  43392. export class VirtualJoysticksCamera extends FreeCamera {
  43393. /**
  43394. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43395. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43396. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43397. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43398. * @param name Define the name of the camera in the scene
  43399. * @param position Define the start position of the camera in the scene
  43400. * @param scene Define the scene the camera belongs to
  43401. */
  43402. constructor(name: string, position: Vector3, scene: Scene);
  43403. /**
  43404. * Gets the current object class name.
  43405. * @return the class name
  43406. */
  43407. getClassName(): string;
  43408. }
  43409. }
  43410. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43411. import { Matrix } from "babylonjs/Maths/math.vector";
  43412. /**
  43413. * This represents all the required metrics to create a VR camera.
  43414. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43415. */
  43416. export class VRCameraMetrics {
  43417. /**
  43418. * Define the horizontal resolution off the screen.
  43419. */
  43420. hResolution: number;
  43421. /**
  43422. * Define the vertical resolution off the screen.
  43423. */
  43424. vResolution: number;
  43425. /**
  43426. * Define the horizontal screen size.
  43427. */
  43428. hScreenSize: number;
  43429. /**
  43430. * Define the vertical screen size.
  43431. */
  43432. vScreenSize: number;
  43433. /**
  43434. * Define the vertical screen center position.
  43435. */
  43436. vScreenCenter: number;
  43437. /**
  43438. * Define the distance of the eyes to the screen.
  43439. */
  43440. eyeToScreenDistance: number;
  43441. /**
  43442. * Define the distance between both lenses
  43443. */
  43444. lensSeparationDistance: number;
  43445. /**
  43446. * Define the distance between both viewer's eyes.
  43447. */
  43448. interpupillaryDistance: number;
  43449. /**
  43450. * Define the distortion factor of the VR postprocess.
  43451. * Please, touch with care.
  43452. */
  43453. distortionK: number[];
  43454. /**
  43455. * Define the chromatic aberration correction factors for the VR post process.
  43456. */
  43457. chromaAbCorrection: number[];
  43458. /**
  43459. * Define the scale factor of the post process.
  43460. * The smaller the better but the slower.
  43461. */
  43462. postProcessScaleFactor: number;
  43463. /**
  43464. * Define an offset for the lens center.
  43465. */
  43466. lensCenterOffset: number;
  43467. /**
  43468. * Define if the current vr camera should compensate the distortion of the lense or not.
  43469. */
  43470. compensateDistortion: boolean;
  43471. /**
  43472. * Defines if multiview should be enabled when rendering (Default: false)
  43473. */
  43474. multiviewEnabled: boolean;
  43475. /**
  43476. * Gets the rendering aspect ratio based on the provided resolutions.
  43477. */
  43478. get aspectRatio(): number;
  43479. /**
  43480. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43481. */
  43482. get aspectRatioFov(): number;
  43483. /**
  43484. * @hidden
  43485. */
  43486. get leftHMatrix(): Matrix;
  43487. /**
  43488. * @hidden
  43489. */
  43490. get rightHMatrix(): Matrix;
  43491. /**
  43492. * @hidden
  43493. */
  43494. get leftPreViewMatrix(): Matrix;
  43495. /**
  43496. * @hidden
  43497. */
  43498. get rightPreViewMatrix(): Matrix;
  43499. /**
  43500. * Get the default VRMetrics based on the most generic setup.
  43501. * @returns the default vr metrics
  43502. */
  43503. static GetDefault(): VRCameraMetrics;
  43504. }
  43505. }
  43506. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43507. /** @hidden */
  43508. export var vrDistortionCorrectionPixelShader: {
  43509. name: string;
  43510. shader: string;
  43511. };
  43512. }
  43513. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43514. import { Camera } from "babylonjs/Cameras/camera";
  43515. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43516. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43517. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43518. /**
  43519. * VRDistortionCorrectionPostProcess used for mobile VR
  43520. */
  43521. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43522. private _isRightEye;
  43523. private _distortionFactors;
  43524. private _postProcessScaleFactor;
  43525. private _lensCenterOffset;
  43526. private _scaleIn;
  43527. private _scaleFactor;
  43528. private _lensCenter;
  43529. /**
  43530. * Initializes the VRDistortionCorrectionPostProcess
  43531. * @param name The name of the effect.
  43532. * @param camera The camera to apply the render pass to.
  43533. * @param isRightEye If this is for the right eye distortion
  43534. * @param vrMetrics All the required metrics for the VR camera
  43535. */
  43536. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43537. }
  43538. }
  43539. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43540. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43541. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43542. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43543. import { Scene } from "babylonjs/scene";
  43544. import { Vector3 } from "babylonjs/Maths/math.vector";
  43545. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43546. import "babylonjs/Cameras/RigModes/vrRigMode";
  43547. /**
  43548. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43549. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43550. */
  43551. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43552. /**
  43553. * Creates a new VRDeviceOrientationArcRotateCamera
  43554. * @param name defines camera name
  43555. * @param alpha defines the camera rotation along the logitudinal axis
  43556. * @param beta defines the camera rotation along the latitudinal axis
  43557. * @param radius defines the camera distance from its target
  43558. * @param target defines the camera target
  43559. * @param scene defines the scene the camera belongs to
  43560. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43561. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43562. */
  43563. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43564. /**
  43565. * Gets camera class name
  43566. * @returns VRDeviceOrientationArcRotateCamera
  43567. */
  43568. getClassName(): string;
  43569. }
  43570. }
  43571. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43572. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43573. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43574. import { Scene } from "babylonjs/scene";
  43575. import { Vector3 } from "babylonjs/Maths/math.vector";
  43576. import "babylonjs/Cameras/RigModes/vrRigMode";
  43577. /**
  43578. * Camera used to simulate VR rendering (based on FreeCamera)
  43579. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43580. */
  43581. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43582. /**
  43583. * Creates a new VRDeviceOrientationFreeCamera
  43584. * @param name defines camera name
  43585. * @param position defines the start position of the camera
  43586. * @param scene defines the scene the camera belongs to
  43587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43589. */
  43590. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43591. /**
  43592. * Gets camera class name
  43593. * @returns VRDeviceOrientationFreeCamera
  43594. */
  43595. getClassName(): string;
  43596. }
  43597. }
  43598. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43599. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43600. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43601. import { Scene } from "babylonjs/scene";
  43602. import { Vector3 } from "babylonjs/Maths/math.vector";
  43603. import "babylonjs/Gamepads/gamepadSceneComponent";
  43604. /**
  43605. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43606. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43607. */
  43608. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43609. /**
  43610. * Creates a new VRDeviceOrientationGamepadCamera
  43611. * @param name defines camera name
  43612. * @param position defines the start position of the camera
  43613. * @param scene defines the scene the camera belongs to
  43614. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43615. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43616. */
  43617. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43618. /**
  43619. * Gets camera class name
  43620. * @returns VRDeviceOrientationGamepadCamera
  43621. */
  43622. getClassName(): string;
  43623. }
  43624. }
  43625. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43626. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43627. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43628. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43629. /** @hidden */
  43630. export var imageProcessingPixelShader: {
  43631. name: string;
  43632. shader: string;
  43633. };
  43634. }
  43635. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43636. import { Nullable } from "babylonjs/types";
  43637. import { Color4 } from "babylonjs/Maths/math.color";
  43638. import { Camera } from "babylonjs/Cameras/camera";
  43639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43640. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43641. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43642. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43643. import { Engine } from "babylonjs/Engines/engine";
  43644. import "babylonjs/Shaders/imageProcessing.fragment";
  43645. import "babylonjs/Shaders/postprocess.vertex";
  43646. /**
  43647. * ImageProcessingPostProcess
  43648. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43649. */
  43650. export class ImageProcessingPostProcess extends PostProcess {
  43651. /**
  43652. * Default configuration related to image processing available in the PBR Material.
  43653. */
  43654. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43655. /**
  43656. * Gets the image processing configuration used either in this material.
  43657. */
  43658. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43659. /**
  43660. * Sets the Default image processing configuration used either in the this material.
  43661. *
  43662. * If sets to null, the scene one is in use.
  43663. */
  43664. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43665. /**
  43666. * Keep track of the image processing observer to allow dispose and replace.
  43667. */
  43668. private _imageProcessingObserver;
  43669. /**
  43670. * Attaches a new image processing configuration to the PBR Material.
  43671. * @param configuration
  43672. */
  43673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43674. /**
  43675. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43676. */
  43677. get colorCurves(): Nullable<ColorCurves>;
  43678. /**
  43679. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43680. */
  43681. set colorCurves(value: Nullable<ColorCurves>);
  43682. /**
  43683. * Gets wether the color curves effect is enabled.
  43684. */
  43685. get colorCurvesEnabled(): boolean;
  43686. /**
  43687. * Sets wether the color curves effect is enabled.
  43688. */
  43689. set colorCurvesEnabled(value: boolean);
  43690. /**
  43691. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43692. */
  43693. get colorGradingTexture(): Nullable<BaseTexture>;
  43694. /**
  43695. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43696. */
  43697. set colorGradingTexture(value: Nullable<BaseTexture>);
  43698. /**
  43699. * Gets wether the color grading effect is enabled.
  43700. */
  43701. get colorGradingEnabled(): boolean;
  43702. /**
  43703. * Gets wether the color grading effect is enabled.
  43704. */
  43705. set colorGradingEnabled(value: boolean);
  43706. /**
  43707. * Gets exposure used in the effect.
  43708. */
  43709. get exposure(): number;
  43710. /**
  43711. * Sets exposure used in the effect.
  43712. */
  43713. set exposure(value: number);
  43714. /**
  43715. * Gets wether tonemapping is enabled or not.
  43716. */
  43717. get toneMappingEnabled(): boolean;
  43718. /**
  43719. * Sets wether tonemapping is enabled or not
  43720. */
  43721. set toneMappingEnabled(value: boolean);
  43722. /**
  43723. * Gets the type of tone mapping effect.
  43724. */
  43725. get toneMappingType(): number;
  43726. /**
  43727. * Sets the type of tone mapping effect.
  43728. */
  43729. set toneMappingType(value: number);
  43730. /**
  43731. * Gets contrast used in the effect.
  43732. */
  43733. get contrast(): number;
  43734. /**
  43735. * Sets contrast used in the effect.
  43736. */
  43737. set contrast(value: number);
  43738. /**
  43739. * Gets Vignette stretch size.
  43740. */
  43741. get vignetteStretch(): number;
  43742. /**
  43743. * Sets Vignette stretch size.
  43744. */
  43745. set vignetteStretch(value: number);
  43746. /**
  43747. * Gets Vignette centre X Offset.
  43748. */
  43749. get vignetteCentreX(): number;
  43750. /**
  43751. * Sets Vignette centre X Offset.
  43752. */
  43753. set vignetteCentreX(value: number);
  43754. /**
  43755. * Gets Vignette centre Y Offset.
  43756. */
  43757. get vignetteCentreY(): number;
  43758. /**
  43759. * Sets Vignette centre Y Offset.
  43760. */
  43761. set vignetteCentreY(value: number);
  43762. /**
  43763. * Gets Vignette weight or intensity of the vignette effect.
  43764. */
  43765. get vignetteWeight(): number;
  43766. /**
  43767. * Sets Vignette weight or intensity of the vignette effect.
  43768. */
  43769. set vignetteWeight(value: number);
  43770. /**
  43771. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43772. * if vignetteEnabled is set to true.
  43773. */
  43774. get vignetteColor(): Color4;
  43775. /**
  43776. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43777. * if vignetteEnabled is set to true.
  43778. */
  43779. set vignetteColor(value: Color4);
  43780. /**
  43781. * Gets Camera field of view used by the Vignette effect.
  43782. */
  43783. get vignetteCameraFov(): number;
  43784. /**
  43785. * Sets Camera field of view used by the Vignette effect.
  43786. */
  43787. set vignetteCameraFov(value: number);
  43788. /**
  43789. * Gets the vignette blend mode allowing different kind of effect.
  43790. */
  43791. get vignetteBlendMode(): number;
  43792. /**
  43793. * Sets the vignette blend mode allowing different kind of effect.
  43794. */
  43795. set vignetteBlendMode(value: number);
  43796. /**
  43797. * Gets wether the vignette effect is enabled.
  43798. */
  43799. get vignetteEnabled(): boolean;
  43800. /**
  43801. * Sets wether the vignette effect is enabled.
  43802. */
  43803. set vignetteEnabled(value: boolean);
  43804. private _fromLinearSpace;
  43805. /**
  43806. * Gets wether the input of the processing is in Gamma or Linear Space.
  43807. */
  43808. get fromLinearSpace(): boolean;
  43809. /**
  43810. * Sets wether the input of the processing is in Gamma or Linear Space.
  43811. */
  43812. set fromLinearSpace(value: boolean);
  43813. /**
  43814. * Defines cache preventing GC.
  43815. */
  43816. private _defines;
  43817. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43818. /**
  43819. * "ImageProcessingPostProcess"
  43820. * @returns "ImageProcessingPostProcess"
  43821. */
  43822. getClassName(): string;
  43823. protected _updateParameters(): void;
  43824. dispose(camera?: Camera): void;
  43825. }
  43826. }
  43827. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43828. import { Scene } from "babylonjs/scene";
  43829. import { Color3 } from "babylonjs/Maths/math.color";
  43830. import { Mesh } from "babylonjs/Meshes/mesh";
  43831. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43832. import { Nullable } from "babylonjs/types";
  43833. /**
  43834. * Class containing static functions to help procedurally build meshes
  43835. */
  43836. export class GroundBuilder {
  43837. /**
  43838. * Creates a ground mesh
  43839. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43840. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43842. * @param name defines the name of the mesh
  43843. * @param options defines the options used to create the mesh
  43844. * @param scene defines the hosting scene
  43845. * @returns the ground mesh
  43846. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43847. */
  43848. static CreateGround(name: string, options: {
  43849. width?: number;
  43850. height?: number;
  43851. subdivisions?: number;
  43852. subdivisionsX?: number;
  43853. subdivisionsY?: number;
  43854. updatable?: boolean;
  43855. }, scene: any): Mesh;
  43856. /**
  43857. * Creates a tiled ground mesh
  43858. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43859. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43860. * * 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
  43861. * * 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
  43862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43863. * @param name defines the name of the mesh
  43864. * @param options defines the options used to create the mesh
  43865. * @param scene defines the hosting scene
  43866. * @returns the tiled ground mesh
  43867. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43868. */
  43869. static CreateTiledGround(name: string, options: {
  43870. xmin: number;
  43871. zmin: number;
  43872. xmax: number;
  43873. zmax: number;
  43874. subdivisions?: {
  43875. w: number;
  43876. h: number;
  43877. };
  43878. precision?: {
  43879. w: number;
  43880. h: number;
  43881. };
  43882. updatable?: boolean;
  43883. }, scene?: Nullable<Scene>): Mesh;
  43884. /**
  43885. * Creates a ground mesh from a height map
  43886. * * The parameter `url` sets the URL of the height map image resource.
  43887. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43888. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43889. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43890. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43891. * * 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.
  43892. * * 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).
  43893. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43895. * @param name defines the name of the mesh
  43896. * @param url defines the url to the height map
  43897. * @param options defines the options used to create the mesh
  43898. * @param scene defines the hosting scene
  43899. * @returns the ground mesh
  43900. * @see https://doc.babylonjs.com/babylon101/height_map
  43901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43902. */
  43903. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43904. width?: number;
  43905. height?: number;
  43906. subdivisions?: number;
  43907. minHeight?: number;
  43908. maxHeight?: number;
  43909. colorFilter?: Color3;
  43910. alphaFilter?: number;
  43911. updatable?: boolean;
  43912. onReady?: (mesh: GroundMesh) => void;
  43913. }, scene?: Nullable<Scene>): GroundMesh;
  43914. }
  43915. }
  43916. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43917. import { Vector4 } from "babylonjs/Maths/math.vector";
  43918. import { Mesh } from "babylonjs/Meshes/mesh";
  43919. /**
  43920. * Class containing static functions to help procedurally build meshes
  43921. */
  43922. export class TorusBuilder {
  43923. /**
  43924. * Creates a torus mesh
  43925. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43926. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43927. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43931. * @param name defines the name of the mesh
  43932. * @param options defines the options used to create the mesh
  43933. * @param scene defines the hosting scene
  43934. * @returns the torus mesh
  43935. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43936. */
  43937. static CreateTorus(name: string, options: {
  43938. diameter?: number;
  43939. thickness?: number;
  43940. tessellation?: number;
  43941. updatable?: boolean;
  43942. sideOrientation?: number;
  43943. frontUVs?: Vector4;
  43944. backUVs?: Vector4;
  43945. }, scene: any): Mesh;
  43946. }
  43947. }
  43948. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43949. import { Vector4 } from "babylonjs/Maths/math.vector";
  43950. import { Color4 } from "babylonjs/Maths/math.color";
  43951. import { Mesh } from "babylonjs/Meshes/mesh";
  43952. /**
  43953. * Class containing static functions to help procedurally build meshes
  43954. */
  43955. export class CylinderBuilder {
  43956. /**
  43957. * Creates a cylinder or a cone mesh
  43958. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43959. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43960. * * 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.
  43961. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43962. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43963. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43964. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43965. * * 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).
  43966. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43967. * * 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).
  43968. * * 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
  43969. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43970. * * 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
  43971. * * 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.
  43972. * * If `enclose` is false, a ring surface is one element.
  43973. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43974. * * 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
  43975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43978. * @param name defines the name of the mesh
  43979. * @param options defines the options used to create the mesh
  43980. * @param scene defines the hosting scene
  43981. * @returns the cylinder mesh
  43982. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43983. */
  43984. static CreateCylinder(name: string, options: {
  43985. height?: number;
  43986. diameterTop?: number;
  43987. diameterBottom?: number;
  43988. diameter?: number;
  43989. tessellation?: number;
  43990. subdivisions?: number;
  43991. arc?: number;
  43992. faceColors?: Color4[];
  43993. faceUV?: Vector4[];
  43994. updatable?: boolean;
  43995. hasRings?: boolean;
  43996. enclose?: boolean;
  43997. cap?: number;
  43998. sideOrientation?: number;
  43999. frontUVs?: Vector4;
  44000. backUVs?: Vector4;
  44001. }, scene: any): Mesh;
  44002. }
  44003. }
  44004. declare module "babylonjs/XR/webXRTypes" {
  44005. import { Nullable } from "babylonjs/types";
  44006. import { IDisposable } from "babylonjs/scene";
  44007. /**
  44008. * States of the webXR experience
  44009. */
  44010. export enum WebXRState {
  44011. /**
  44012. * Transitioning to being in XR mode
  44013. */
  44014. ENTERING_XR = 0,
  44015. /**
  44016. * Transitioning to non XR mode
  44017. */
  44018. EXITING_XR = 1,
  44019. /**
  44020. * In XR mode and presenting
  44021. */
  44022. IN_XR = 2,
  44023. /**
  44024. * Not entered XR mode
  44025. */
  44026. NOT_IN_XR = 3
  44027. }
  44028. /**
  44029. * Abstraction of the XR render target
  44030. */
  44031. export interface WebXRRenderTarget extends IDisposable {
  44032. /**
  44033. * xrpresent context of the canvas which can be used to display/mirror xr content
  44034. */
  44035. canvasContext: WebGLRenderingContext;
  44036. /**
  44037. * xr layer for the canvas
  44038. */
  44039. xrLayer: Nullable<XRWebGLLayer>;
  44040. /**
  44041. * Initializes the xr layer for the session
  44042. * @param xrSession xr session
  44043. * @returns a promise that will resolve once the XR Layer has been created
  44044. */
  44045. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44046. }
  44047. }
  44048. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44049. import { Nullable } from "babylonjs/types";
  44050. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44051. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44052. /**
  44053. * COnfiguration object for WebXR output canvas
  44054. */
  44055. export class WebXRManagedOutputCanvasOptions {
  44056. /**
  44057. * An optional canvas in case you wish to create it yourself and provide it here.
  44058. * If not provided, a new canvas will be created
  44059. */
  44060. canvasElement?: HTMLCanvasElement;
  44061. /**
  44062. * Options for this XR Layer output
  44063. */
  44064. canvasOptions?: XRWebGLLayerOptions;
  44065. /**
  44066. * CSS styling for a newly created canvas (if not provided)
  44067. */
  44068. newCanvasCssStyle?: string;
  44069. /**
  44070. * Get the default values of the configuration object
  44071. * @returns default values of this configuration object
  44072. */
  44073. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44074. }
  44075. /**
  44076. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44077. */
  44078. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44079. private _options;
  44080. private _canvas;
  44081. private _engine;
  44082. /**
  44083. * Rendering context of the canvas which can be used to display/mirror xr content
  44084. */
  44085. canvasContext: WebGLRenderingContext;
  44086. /**
  44087. * xr layer for the canvas
  44088. */
  44089. xrLayer: Nullable<XRWebGLLayer>;
  44090. /**
  44091. * Initializes the canvas to be added/removed upon entering/exiting xr
  44092. * @param _xrSessionManager The XR Session manager
  44093. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44094. */
  44095. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44096. /**
  44097. * Disposes of the object
  44098. */
  44099. dispose(): void;
  44100. /**
  44101. * Initializes the xr layer for the session
  44102. * @param xrSession xr session
  44103. * @returns a promise that will resolve once the XR Layer has been created
  44104. */
  44105. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44106. private _addCanvas;
  44107. private _removeCanvas;
  44108. private _setManagedOutputCanvas;
  44109. }
  44110. }
  44111. declare module "babylonjs/XR/webXRSessionManager" {
  44112. import { Observable } from "babylonjs/Misc/observable";
  44113. import { Nullable } from "babylonjs/types";
  44114. import { IDisposable, Scene } from "babylonjs/scene";
  44115. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44116. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44117. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44118. /**
  44119. * Manages an XRSession to work with Babylon's engine
  44120. * @see https://doc.babylonjs.com/how_to/webxr
  44121. */
  44122. export class WebXRSessionManager implements IDisposable {
  44123. /** The scene which the session should be created for */
  44124. scene: Scene;
  44125. private _referenceSpace;
  44126. private _rttProvider;
  44127. private _sessionEnded;
  44128. private _xrNavigator;
  44129. private baseLayer;
  44130. /**
  44131. * The base reference space from which the session started. good if you want to reset your
  44132. * reference space
  44133. */
  44134. baseReferenceSpace: XRReferenceSpace;
  44135. /**
  44136. * Current XR frame
  44137. */
  44138. currentFrame: Nullable<XRFrame>;
  44139. /** WebXR timestamp updated every frame */
  44140. currentTimestamp: number;
  44141. /**
  44142. * Used just in case of a failure to initialize an immersive session.
  44143. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44144. */
  44145. defaultHeightCompensation: number;
  44146. /**
  44147. * Fires every time a new xrFrame arrives which can be used to update the camera
  44148. */
  44149. onXRFrameObservable: Observable<XRFrame>;
  44150. /**
  44151. * Fires when the reference space changed
  44152. */
  44153. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44154. /**
  44155. * Fires when the xr session is ended either by the device or manually done
  44156. */
  44157. onXRSessionEnded: Observable<any>;
  44158. /**
  44159. * Fires when the xr session is ended either by the device or manually done
  44160. */
  44161. onXRSessionInit: Observable<XRSession>;
  44162. /**
  44163. * Underlying xr session
  44164. */
  44165. session: XRSession;
  44166. /**
  44167. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44168. * or get the offset the player is currently at.
  44169. */
  44170. viewerReferenceSpace: XRReferenceSpace;
  44171. /**
  44172. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44173. * @param scene The scene which the session should be created for
  44174. */
  44175. constructor(
  44176. /** The scene which the session should be created for */
  44177. scene: Scene);
  44178. /**
  44179. * The current reference space used in this session. This reference space can constantly change!
  44180. * It is mainly used to offset the camera's position.
  44181. */
  44182. get referenceSpace(): XRReferenceSpace;
  44183. /**
  44184. * Set a new reference space and triggers the observable
  44185. */
  44186. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44187. /**
  44188. * Disposes of the session manager
  44189. */
  44190. dispose(): void;
  44191. /**
  44192. * Stops the xrSession and restores the render loop
  44193. * @returns Promise which resolves after it exits XR
  44194. */
  44195. exitXRAsync(): Promise<void>;
  44196. /**
  44197. * Gets the correct render target texture to be rendered this frame for this eye
  44198. * @param eye the eye for which to get the render target
  44199. * @returns the render target for the specified eye
  44200. */
  44201. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44202. /**
  44203. * Creates a WebXRRenderTarget object for the XR session
  44204. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44205. * @param options optional options to provide when creating a new render target
  44206. * @returns a WebXR render target to which the session can render
  44207. */
  44208. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44209. /**
  44210. * Initializes the manager
  44211. * After initialization enterXR can be called to start an XR session
  44212. * @returns Promise which resolves after it is initialized
  44213. */
  44214. initializeAsync(): Promise<void>;
  44215. /**
  44216. * Initializes an xr session
  44217. * @param xrSessionMode mode to initialize
  44218. * @param xrSessionInit defines optional and required values to pass to the session builder
  44219. * @returns a promise which will resolve once the session has been initialized
  44220. */
  44221. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44222. /**
  44223. * Checks if a session would be supported for the creation options specified
  44224. * @param sessionMode session mode to check if supported eg. immersive-vr
  44225. * @returns A Promise that resolves to true if supported and false if not
  44226. */
  44227. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44228. /**
  44229. * Resets the reference space to the one started the session
  44230. */
  44231. resetReferenceSpace(): void;
  44232. /**
  44233. * Starts rendering to the xr layer
  44234. */
  44235. runXRRenderLoop(): void;
  44236. /**
  44237. * Sets the reference space on the xr session
  44238. * @param referenceSpaceType space to set
  44239. * @returns a promise that will resolve once the reference space has been set
  44240. */
  44241. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44242. /**
  44243. * Updates the render state of the session
  44244. * @param state state to set
  44245. * @returns a promise that resolves once the render state has been updated
  44246. */
  44247. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44248. /**
  44249. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44250. * @param sessionMode defines the session to test
  44251. * @returns a promise with boolean as final value
  44252. */
  44253. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44254. private _createRenderTargetTexture;
  44255. }
  44256. }
  44257. declare module "babylonjs/XR/webXRCamera" {
  44258. import { Scene } from "babylonjs/scene";
  44259. import { Camera } from "babylonjs/Cameras/camera";
  44260. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44261. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44262. /**
  44263. * WebXR Camera which holds the views for the xrSession
  44264. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44265. */
  44266. export class WebXRCamera extends FreeCamera {
  44267. private _xrSessionManager;
  44268. private _firstFrame;
  44269. private _referenceQuaternion;
  44270. private _referencedPosition;
  44271. private _xrInvPositionCache;
  44272. private _xrInvQuaternionCache;
  44273. /**
  44274. * Should position compensation execute on first frame.
  44275. * This is used when copying the position from a native (non XR) camera
  44276. */
  44277. compensateOnFirstFrame: boolean;
  44278. /**
  44279. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44280. * @param name the name of the camera
  44281. * @param scene the scene to add the camera to
  44282. * @param _xrSessionManager a constructed xr session manager
  44283. */
  44284. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44285. /**
  44286. * Return the user's height, unrelated to the current ground.
  44287. * This will be the y position of this camera, when ground level is 0.
  44288. */
  44289. get realWorldHeight(): number;
  44290. /** @hidden */
  44291. _updateForDualEyeDebugging(): void;
  44292. /**
  44293. * Sets this camera's transformation based on a non-vr camera
  44294. * @param otherCamera the non-vr camera to copy the transformation from
  44295. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44296. */
  44297. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44298. /**
  44299. * Gets the current instance class name ("WebXRCamera").
  44300. * @returns the class name
  44301. */
  44302. getClassName(): string;
  44303. private _updateFromXRSession;
  44304. private _updateNumberOfRigCameras;
  44305. private _updateReferenceSpace;
  44306. private _updateReferenceSpaceOffset;
  44307. }
  44308. }
  44309. declare module "babylonjs/XR/webXRFeaturesManager" {
  44310. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44311. import { IDisposable } from "babylonjs/scene";
  44312. /**
  44313. * Defining the interface required for a (webxr) feature
  44314. */
  44315. export interface IWebXRFeature extends IDisposable {
  44316. /**
  44317. * Is this feature attached
  44318. */
  44319. attached: boolean;
  44320. /**
  44321. * Should auto-attach be disabled?
  44322. */
  44323. disableAutoAttach: boolean;
  44324. /**
  44325. * Attach the feature to the session
  44326. * Will usually be called by the features manager
  44327. *
  44328. * @param force should attachment be forced (even when already attached)
  44329. * @returns true if successful.
  44330. */
  44331. attach(force?: boolean): boolean;
  44332. /**
  44333. * Detach the feature from the session
  44334. * Will usually be called by the features manager
  44335. *
  44336. * @returns true if successful.
  44337. */
  44338. detach(): boolean;
  44339. }
  44340. /**
  44341. * A list of the currently available features without referencing them
  44342. */
  44343. export class WebXRFeatureName {
  44344. /**
  44345. * The name of the anchor system feature
  44346. */
  44347. static ANCHOR_SYSTEM: string;
  44348. /**
  44349. * The name of the background remover feature
  44350. */
  44351. static BACKGROUND_REMOVER: string;
  44352. /**
  44353. * The name of the hit test feature
  44354. */
  44355. static HIT_TEST: string;
  44356. /**
  44357. * physics impostors for xr controllers feature
  44358. */
  44359. static PHYSICS_CONTROLLERS: string;
  44360. /**
  44361. * The name of the plane detection feature
  44362. */
  44363. static PLANE_DETECTION: string;
  44364. /**
  44365. * The name of the pointer selection feature
  44366. */
  44367. static POINTER_SELECTION: string;
  44368. /**
  44369. * The name of the teleportation feature
  44370. */
  44371. static TELEPORTATION: string;
  44372. }
  44373. /**
  44374. * Defining the constructor of a feature. Used to register the modules.
  44375. */
  44376. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44377. /**
  44378. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44379. * It is mainly used in AR sessions.
  44380. *
  44381. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44382. */
  44383. export class WebXRFeaturesManager implements IDisposable {
  44384. private _xrSessionManager;
  44385. private static readonly _AvailableFeatures;
  44386. private _features;
  44387. /**
  44388. * constructs a new features manages.
  44389. *
  44390. * @param _xrSessionManager an instance of WebXRSessionManager
  44391. */
  44392. constructor(_xrSessionManager: WebXRSessionManager);
  44393. /**
  44394. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44395. * Mainly used internally.
  44396. *
  44397. * @param featureName the name of the feature to register
  44398. * @param constructorFunction the function used to construct the module
  44399. * @param version the (babylon) version of the module
  44400. * @param stable is that a stable version of this module
  44401. */
  44402. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44403. /**
  44404. * Returns a constructor of a specific feature.
  44405. *
  44406. * @param featureName the name of the feature to construct
  44407. * @param version the version of the feature to load
  44408. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44409. * @param options optional options provided to the module.
  44410. * @returns a function that, when called, will return a new instance of this feature
  44411. */
  44412. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44413. /**
  44414. * Can be used to return the list of features currently registered
  44415. *
  44416. * @returns an Array of available features
  44417. */
  44418. static GetAvailableFeatures(): string[];
  44419. /**
  44420. * Gets the versions available for a specific feature
  44421. * @param featureName the name of the feature
  44422. * @returns an array with the available versions
  44423. */
  44424. static GetAvailableVersions(featureName: string): string[];
  44425. /**
  44426. * Return the latest unstable version of this feature
  44427. * @param featureName the name of the feature to search
  44428. * @returns the version number. if not found will return -1
  44429. */
  44430. static GetLatestVersionOfFeature(featureName: string): number;
  44431. /**
  44432. * Return the latest stable version of this feature
  44433. * @param featureName the name of the feature to search
  44434. * @returns the version number. if not found will return -1
  44435. */
  44436. static GetStableVersionOfFeature(featureName: string): number;
  44437. /**
  44438. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44439. * Can be used during a session to start a feature
  44440. * @param featureName the name of feature to attach
  44441. */
  44442. attachFeature(featureName: string): void;
  44443. /**
  44444. * Can be used inside a session or when the session ends to detach a specific feature
  44445. * @param featureName the name of the feature to detach
  44446. */
  44447. detachFeature(featureName: string): void;
  44448. /**
  44449. * Used to disable an already-enabled feature
  44450. * The feature will be disposed and will be recreated once enabled.
  44451. * @param featureName the feature to disable
  44452. * @returns true if disable was successful
  44453. */
  44454. disableFeature(featureName: string | {
  44455. Name: string;
  44456. }): boolean;
  44457. /**
  44458. * dispose this features manager
  44459. */
  44460. dispose(): void;
  44461. /**
  44462. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  44463. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  44464. *
  44465. * @param featureName the name of the feature to load or the class of the feature
  44466. * @param version optional version to load. if not provided the latest version will be enabled
  44467. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44468. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44469. * @returns a new constructed feature or throws an error if feature not found.
  44470. */
  44471. enableFeature(featureName: string | {
  44472. Name: string;
  44473. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44474. /**
  44475. * get the implementation of an enabled feature.
  44476. * @param featureName the name of the feature to load
  44477. * @returns the feature class, if found
  44478. */
  44479. getEnabledFeature(featureName: string): IWebXRFeature;
  44480. /**
  44481. * Get the list of enabled features
  44482. * @returns an array of enabled features
  44483. */
  44484. getEnabledFeatures(): string[];
  44485. }
  44486. }
  44487. declare module "babylonjs/XR/webXRExperienceHelper" {
  44488. import { Observable } from "babylonjs/Misc/observable";
  44489. import { IDisposable, Scene } from "babylonjs/scene";
  44490. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44491. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44492. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44493. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44494. /**
  44495. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44496. * @see https://doc.babylonjs.com/how_to/webxr
  44497. */
  44498. export class WebXRExperienceHelper implements IDisposable {
  44499. private scene;
  44500. private _nonVRCamera;
  44501. private _originalSceneAutoClear;
  44502. private _supported;
  44503. /**
  44504. * Camera used to render xr content
  44505. */
  44506. camera: WebXRCamera;
  44507. /** A features manager for this xr session */
  44508. featuresManager: WebXRFeaturesManager;
  44509. /**
  44510. * Observers registered here will be triggered after the camera's initial transformation is set
  44511. * This can be used to set a different ground level or an extra rotation.
  44512. *
  44513. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44514. * to the position set after this observable is done executing.
  44515. */
  44516. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44517. /**
  44518. * Fires when the state of the experience helper has changed
  44519. */
  44520. onStateChangedObservable: Observable<WebXRState>;
  44521. /** Session manager used to keep track of xr session */
  44522. sessionManager: WebXRSessionManager;
  44523. /**
  44524. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44525. */
  44526. state: WebXRState;
  44527. /**
  44528. * Creates a WebXRExperienceHelper
  44529. * @param scene The scene the helper should be created in
  44530. */
  44531. private constructor();
  44532. /**
  44533. * Creates the experience helper
  44534. * @param scene the scene to attach the experience helper to
  44535. * @returns a promise for the experience helper
  44536. */
  44537. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44538. /**
  44539. * Disposes of the experience helper
  44540. */
  44541. dispose(): void;
  44542. /**
  44543. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44544. * @param sessionMode options for the XR session
  44545. * @param referenceSpaceType frame of reference of the XR session
  44546. * @param renderTarget the output canvas that will be used to enter XR mode
  44547. * @returns promise that resolves after xr mode has entered
  44548. */
  44549. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44550. /**
  44551. * Exits XR mode and returns the scene to its original state
  44552. * @returns promise that resolves after xr mode has exited
  44553. */
  44554. exitXRAsync(): Promise<void>;
  44555. private _nonXRToXRCamera;
  44556. private _setState;
  44557. }
  44558. }
  44559. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44560. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44561. import { Observable } from "babylonjs/Misc/observable";
  44562. import { IDisposable } from "babylonjs/scene";
  44563. /**
  44564. * X-Y values for axes in WebXR
  44565. */
  44566. export interface IWebXRMotionControllerAxesValue {
  44567. /**
  44568. * The value of the x axis
  44569. */
  44570. x: number;
  44571. /**
  44572. * The value of the y-axis
  44573. */
  44574. y: number;
  44575. }
  44576. /**
  44577. * changed / previous values for the values of this component
  44578. */
  44579. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44580. /**
  44581. * current (this frame) value
  44582. */
  44583. current: T;
  44584. /**
  44585. * previous (last change) value
  44586. */
  44587. previous: T;
  44588. }
  44589. /**
  44590. * Represents changes in the component between current frame and last values recorded
  44591. */
  44592. export interface IWebXRMotionControllerComponentChanges {
  44593. /**
  44594. * will be populated with previous and current values if axes changed
  44595. */
  44596. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44597. /**
  44598. * will be populated with previous and current values if pressed changed
  44599. */
  44600. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44601. /**
  44602. * will be populated with previous and current values if touched changed
  44603. */
  44604. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44605. /**
  44606. * will be populated with previous and current values if value changed
  44607. */
  44608. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44609. }
  44610. /**
  44611. * This class represents a single component (for example button or thumbstick) of a motion controller
  44612. */
  44613. export class WebXRControllerComponent implements IDisposable {
  44614. /**
  44615. * the id of this component
  44616. */
  44617. id: string;
  44618. /**
  44619. * the type of the component
  44620. */
  44621. type: MotionControllerComponentType;
  44622. private _buttonIndex;
  44623. private _axesIndices;
  44624. private _axes;
  44625. private _changes;
  44626. private _currentValue;
  44627. private _hasChanges;
  44628. private _pressed;
  44629. private _touched;
  44630. /**
  44631. * button component type
  44632. */
  44633. static BUTTON_TYPE: MotionControllerComponentType;
  44634. /**
  44635. * squeeze component type
  44636. */
  44637. static SQUEEZE_TYPE: MotionControllerComponentType;
  44638. /**
  44639. * Thumbstick component type
  44640. */
  44641. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44642. /**
  44643. * Touchpad component type
  44644. */
  44645. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44646. /**
  44647. * trigger component type
  44648. */
  44649. static TRIGGER_TYPE: MotionControllerComponentType;
  44650. /**
  44651. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44652. * the axes data changes
  44653. */
  44654. onAxisValueChangedObservable: Observable<{
  44655. x: number;
  44656. y: number;
  44657. }>;
  44658. /**
  44659. * Observers registered here will be triggered when the state of a button changes
  44660. * State change is either pressed / touched / value
  44661. */
  44662. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44663. /**
  44664. * Creates a new component for a motion controller.
  44665. * It is created by the motion controller itself
  44666. *
  44667. * @param id the id of this component
  44668. * @param type the type of the component
  44669. * @param _buttonIndex index in the buttons array of the gamepad
  44670. * @param _axesIndices indices of the values in the axes array of the gamepad
  44671. */
  44672. constructor(
  44673. /**
  44674. * the id of this component
  44675. */
  44676. id: string,
  44677. /**
  44678. * the type of the component
  44679. */
  44680. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44681. /**
  44682. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44683. */
  44684. get axes(): IWebXRMotionControllerAxesValue;
  44685. /**
  44686. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44687. */
  44688. get changes(): IWebXRMotionControllerComponentChanges;
  44689. /**
  44690. * Return whether or not the component changed the last frame
  44691. */
  44692. get hasChanges(): boolean;
  44693. /**
  44694. * is the button currently pressed
  44695. */
  44696. get pressed(): boolean;
  44697. /**
  44698. * is the button currently touched
  44699. */
  44700. get touched(): boolean;
  44701. /**
  44702. * Get the current value of this component
  44703. */
  44704. get value(): number;
  44705. /**
  44706. * Dispose this component
  44707. */
  44708. dispose(): void;
  44709. /**
  44710. * Are there axes correlating to this component
  44711. * @return true is axes data is available
  44712. */
  44713. isAxes(): boolean;
  44714. /**
  44715. * Is this component a button (hence - pressable)
  44716. * @returns true if can be pressed
  44717. */
  44718. isButton(): boolean;
  44719. /**
  44720. * update this component using the gamepad object it is in. Called on every frame
  44721. * @param nativeController the native gamepad controller object
  44722. */
  44723. update(nativeController: IMinimalMotionControllerObject): void;
  44724. }
  44725. }
  44726. declare module "babylonjs/Loading/sceneLoader" {
  44727. import { Observable } from "babylonjs/Misc/observable";
  44728. import { Nullable } from "babylonjs/types";
  44729. import { Scene } from "babylonjs/scene";
  44730. import { Engine } from "babylonjs/Engines/engine";
  44731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44732. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44733. import { AssetContainer } from "babylonjs/assetContainer";
  44734. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44735. import { Skeleton } from "babylonjs/Bones/skeleton";
  44736. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44737. import { WebRequest } from "babylonjs/Misc/webRequest";
  44738. /**
  44739. * Class used to represent data loading progression
  44740. */
  44741. export class SceneLoaderProgressEvent {
  44742. /** defines if data length to load can be evaluated */
  44743. readonly lengthComputable: boolean;
  44744. /** defines the loaded data length */
  44745. readonly loaded: number;
  44746. /** defines the data length to load */
  44747. readonly total: number;
  44748. /**
  44749. * Create a new progress event
  44750. * @param lengthComputable defines if data length to load can be evaluated
  44751. * @param loaded defines the loaded data length
  44752. * @param total defines the data length to load
  44753. */
  44754. constructor(
  44755. /** defines if data length to load can be evaluated */
  44756. lengthComputable: boolean,
  44757. /** defines the loaded data length */
  44758. loaded: number,
  44759. /** defines the data length to load */
  44760. total: number);
  44761. /**
  44762. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44763. * @param event defines the source event
  44764. * @returns a new SceneLoaderProgressEvent
  44765. */
  44766. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44767. }
  44768. /**
  44769. * Interface used by SceneLoader plugins to define supported file extensions
  44770. */
  44771. export interface ISceneLoaderPluginExtensions {
  44772. /**
  44773. * Defines the list of supported extensions
  44774. */
  44775. [extension: string]: {
  44776. isBinary: boolean;
  44777. };
  44778. }
  44779. /**
  44780. * Interface used by SceneLoader plugin factory
  44781. */
  44782. export interface ISceneLoaderPluginFactory {
  44783. /**
  44784. * Defines the name of the factory
  44785. */
  44786. name: string;
  44787. /**
  44788. * Function called to create a new plugin
  44789. * @return the new plugin
  44790. */
  44791. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44792. /**
  44793. * The callback that returns true if the data can be directly loaded.
  44794. * @param data string containing the file data
  44795. * @returns if the data can be loaded directly
  44796. */
  44797. canDirectLoad?(data: string): boolean;
  44798. }
  44799. /**
  44800. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44801. */
  44802. export interface ISceneLoaderPluginBase {
  44803. /**
  44804. * The friendly name of this plugin.
  44805. */
  44806. name: string;
  44807. /**
  44808. * The file extensions supported by this plugin.
  44809. */
  44810. extensions: string | ISceneLoaderPluginExtensions;
  44811. /**
  44812. * The callback called when loading from a url.
  44813. * @param scene scene loading this url
  44814. * @param url url to load
  44815. * @param onSuccess callback called when the file successfully loads
  44816. * @param onProgress callback called while file is loading (if the server supports this mode)
  44817. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44818. * @param onError callback called when the file fails to load
  44819. * @returns a file request object
  44820. */
  44821. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44822. /**
  44823. * The callback called when loading from a file object.
  44824. * @param scene scene loading this file
  44825. * @param file defines the file to load
  44826. * @param onSuccess defines the callback to call when data is loaded
  44827. * @param onProgress defines the callback to call during loading process
  44828. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44829. * @param onError defines the callback to call when an error occurs
  44830. * @returns a file request object
  44831. */
  44832. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44833. /**
  44834. * The callback that returns true if the data can be directly loaded.
  44835. * @param data string containing the file data
  44836. * @returns if the data can be loaded directly
  44837. */
  44838. canDirectLoad?(data: string): boolean;
  44839. /**
  44840. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44841. * @param scene scene loading this data
  44842. * @param data string containing the data
  44843. * @returns data to pass to the plugin
  44844. */
  44845. directLoad?(scene: Scene, data: string): any;
  44846. /**
  44847. * The callback that allows custom handling of the root url based on the response url.
  44848. * @param rootUrl the original root url
  44849. * @param responseURL the response url if available
  44850. * @returns the new root url
  44851. */
  44852. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44853. }
  44854. /**
  44855. * Interface used to define a SceneLoader plugin
  44856. */
  44857. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44858. /**
  44859. * Import meshes into a scene.
  44860. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44861. * @param scene The scene to import into
  44862. * @param data The data to import
  44863. * @param rootUrl The root url for scene and resources
  44864. * @param meshes The meshes array to import into
  44865. * @param particleSystems The particle systems array to import into
  44866. * @param skeletons The skeletons array to import into
  44867. * @param onError The callback when import fails
  44868. * @returns True if successful or false otherwise
  44869. */
  44870. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44871. /**
  44872. * Load into a scene.
  44873. * @param scene The scene to load into
  44874. * @param data The data to import
  44875. * @param rootUrl The root url for scene and resources
  44876. * @param onError The callback when import fails
  44877. * @returns True if successful or false otherwise
  44878. */
  44879. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44880. /**
  44881. * Load into an asset container.
  44882. * @param scene The scene to load into
  44883. * @param data The data to import
  44884. * @param rootUrl The root url for scene and resources
  44885. * @param onError The callback when import fails
  44886. * @returns The loaded asset container
  44887. */
  44888. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44889. }
  44890. /**
  44891. * Interface used to define an async SceneLoader plugin
  44892. */
  44893. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44894. /**
  44895. * Import meshes into a scene.
  44896. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44897. * @param scene The scene to import into
  44898. * @param data The data to import
  44899. * @param rootUrl The root url for scene and resources
  44900. * @param onProgress The callback when the load progresses
  44901. * @param fileName Defines the name of the file to load
  44902. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44903. */
  44904. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44905. meshes: AbstractMesh[];
  44906. particleSystems: IParticleSystem[];
  44907. skeletons: Skeleton[];
  44908. animationGroups: AnimationGroup[];
  44909. }>;
  44910. /**
  44911. * Load into a scene.
  44912. * @param scene The scene to load into
  44913. * @param data The data to import
  44914. * @param rootUrl The root url for scene and resources
  44915. * @param onProgress The callback when the load progresses
  44916. * @param fileName Defines the name of the file to load
  44917. * @returns Nothing
  44918. */
  44919. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44920. /**
  44921. * Load into an asset container.
  44922. * @param scene The scene to load into
  44923. * @param data The data to import
  44924. * @param rootUrl The root url for scene and resources
  44925. * @param onProgress The callback when the load progresses
  44926. * @param fileName Defines the name of the file to load
  44927. * @returns The loaded asset container
  44928. */
  44929. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44930. }
  44931. /**
  44932. * Mode that determines how to handle old animation groups before loading new ones.
  44933. */
  44934. export enum SceneLoaderAnimationGroupLoadingMode {
  44935. /**
  44936. * Reset all old animations to initial state then dispose them.
  44937. */
  44938. Clean = 0,
  44939. /**
  44940. * Stop all old animations.
  44941. */
  44942. Stop = 1,
  44943. /**
  44944. * Restart old animations from first frame.
  44945. */
  44946. Sync = 2,
  44947. /**
  44948. * Old animations remains untouched.
  44949. */
  44950. NoSync = 3
  44951. }
  44952. /**
  44953. * Class used to load scene from various file formats using registered plugins
  44954. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44955. */
  44956. export class SceneLoader {
  44957. /**
  44958. * No logging while loading
  44959. */
  44960. static readonly NO_LOGGING: number;
  44961. /**
  44962. * Minimal logging while loading
  44963. */
  44964. static readonly MINIMAL_LOGGING: number;
  44965. /**
  44966. * Summary logging while loading
  44967. */
  44968. static readonly SUMMARY_LOGGING: number;
  44969. /**
  44970. * Detailled logging while loading
  44971. */
  44972. static readonly DETAILED_LOGGING: number;
  44973. /**
  44974. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44975. */
  44976. static get ForceFullSceneLoadingForIncremental(): boolean;
  44977. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44978. /**
  44979. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44980. */
  44981. static get ShowLoadingScreen(): boolean;
  44982. static set ShowLoadingScreen(value: boolean);
  44983. /**
  44984. * Defines the current logging level (while loading the scene)
  44985. * @ignorenaming
  44986. */
  44987. static get loggingLevel(): number;
  44988. static set loggingLevel(value: number);
  44989. /**
  44990. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44991. */
  44992. static get CleanBoneMatrixWeights(): boolean;
  44993. static set CleanBoneMatrixWeights(value: boolean);
  44994. /**
  44995. * Event raised when a plugin is used to load a scene
  44996. */
  44997. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44998. private static _registeredPlugins;
  44999. private static _getDefaultPlugin;
  45000. private static _getPluginForExtension;
  45001. private static _getPluginForDirectLoad;
  45002. private static _getPluginForFilename;
  45003. private static _getDirectLoad;
  45004. private static _loadData;
  45005. private static _getFileInfo;
  45006. /**
  45007. * Gets a plugin that can load the given extension
  45008. * @param extension defines the extension to load
  45009. * @returns a plugin or null if none works
  45010. */
  45011. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45012. /**
  45013. * Gets a boolean indicating that the given extension can be loaded
  45014. * @param extension defines the extension to load
  45015. * @returns true if the extension is supported
  45016. */
  45017. static IsPluginForExtensionAvailable(extension: string): boolean;
  45018. /**
  45019. * Adds a new plugin to the list of registered plugins
  45020. * @param plugin defines the plugin to add
  45021. */
  45022. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45023. /**
  45024. * Import meshes into a scene
  45025. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45026. * @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)
  45027. * @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)
  45028. * @param scene the instance of BABYLON.Scene to append to
  45029. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45030. * @param onProgress a callback with a progress event for each file being loaded
  45031. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45032. * @param pluginExtension the extension used to determine the plugin
  45033. * @returns The loaded plugin
  45034. */
  45035. 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>;
  45036. /**
  45037. * Import meshes into a scene
  45038. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45039. * @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)
  45040. * @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)
  45041. * @param scene the instance of BABYLON.Scene to append to
  45042. * @param onProgress a callback with a progress event for each file being loaded
  45043. * @param pluginExtension the extension used to determine the plugin
  45044. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45045. */
  45046. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45047. meshes: AbstractMesh[];
  45048. particleSystems: IParticleSystem[];
  45049. skeletons: Skeleton[];
  45050. animationGroups: AnimationGroup[];
  45051. }>;
  45052. /**
  45053. * Load a scene
  45054. * @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)
  45055. * @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)
  45056. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45057. * @param onSuccess a callback with the scene when import succeeds
  45058. * @param onProgress a callback with a progress event for each file being loaded
  45059. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45060. * @param pluginExtension the extension used to determine the plugin
  45061. * @returns The loaded plugin
  45062. */
  45063. 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>;
  45064. /**
  45065. * Load a scene
  45066. * @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)
  45067. * @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)
  45068. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45069. * @param onProgress a callback with a progress event for each file being loaded
  45070. * @param pluginExtension the extension used to determine the plugin
  45071. * @returns The loaded scene
  45072. */
  45073. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45074. /**
  45075. * Append a scene
  45076. * @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)
  45077. * @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)
  45078. * @param scene is the instance of BABYLON.Scene to append to
  45079. * @param onSuccess a callback with the scene when import succeeds
  45080. * @param onProgress a callback with a progress event for each file being loaded
  45081. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45082. * @param pluginExtension the extension used to determine the plugin
  45083. * @returns The loaded plugin
  45084. */
  45085. 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>;
  45086. /**
  45087. * Append a scene
  45088. * @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)
  45089. * @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)
  45090. * @param scene is the instance of BABYLON.Scene to append to
  45091. * @param onProgress a callback with a progress event for each file being loaded
  45092. * @param pluginExtension the extension used to determine the plugin
  45093. * @returns The given scene
  45094. */
  45095. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45096. /**
  45097. * Load a scene into an asset container
  45098. * @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)
  45099. * @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)
  45100. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45101. * @param onSuccess a callback with the scene when import succeeds
  45102. * @param onProgress a callback with a progress event for each file being loaded
  45103. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45104. * @param pluginExtension the extension used to determine the plugin
  45105. * @returns The loaded plugin
  45106. */
  45107. 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>;
  45108. /**
  45109. * Load a scene into an asset container
  45110. * @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)
  45111. * @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)
  45112. * @param scene is the instance of Scene to append to
  45113. * @param onProgress a callback with a progress event for each file being loaded
  45114. * @param pluginExtension the extension used to determine the plugin
  45115. * @returns The loaded asset container
  45116. */
  45117. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45118. /**
  45119. * Import animations from a file into a scene
  45120. * @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)
  45121. * @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)
  45122. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45123. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45124. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45125. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45126. * @param onSuccess a callback with the scene when import succeeds
  45127. * @param onProgress a callback with a progress event for each file being loaded
  45128. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45129. */
  45130. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  45131. /**
  45132. * Import animations from a file into a scene
  45133. * @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)
  45134. * @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)
  45135. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45136. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45137. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45138. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45139. * @param onSuccess a callback with the scene when import succeeds
  45140. * @param onProgress a callback with a progress event for each file being loaded
  45141. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45142. * @returns the updated scene with imported animations
  45143. */
  45144. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  45145. }
  45146. }
  45147. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45148. import { IDisposable, Scene } from "babylonjs/scene";
  45149. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45150. import { Observable } from "babylonjs/Misc/observable";
  45151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45152. import { Nullable } from "babylonjs/types";
  45153. /**
  45154. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45155. */
  45156. export type MotionControllerHandness = "none" | "left" | "right";
  45157. /**
  45158. * The type of components available in motion controllers.
  45159. * This is not the name of the component.
  45160. */
  45161. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45162. /**
  45163. * The state of a controller component
  45164. */
  45165. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45166. /**
  45167. * The schema of motion controller layout.
  45168. * No object will be initialized using this interface
  45169. * This is used just to define the profile.
  45170. */
  45171. export interface IMotionControllerLayout {
  45172. /**
  45173. * Path to load the assets. Usually relative to the base path
  45174. */
  45175. assetPath: string;
  45176. /**
  45177. * Available components (unsorted)
  45178. */
  45179. components: {
  45180. /**
  45181. * A map of component Ids
  45182. */
  45183. [componentId: string]: {
  45184. /**
  45185. * The type of input the component outputs
  45186. */
  45187. type: MotionControllerComponentType;
  45188. /**
  45189. * The indices of this component in the gamepad object
  45190. */
  45191. gamepadIndices: {
  45192. /**
  45193. * Index of button
  45194. */
  45195. button?: number;
  45196. /**
  45197. * If available, index of x-axis
  45198. */
  45199. xAxis?: number;
  45200. /**
  45201. * If available, index of y-axis
  45202. */
  45203. yAxis?: number;
  45204. };
  45205. /**
  45206. * The mesh's root node name
  45207. */
  45208. rootNodeName: string;
  45209. /**
  45210. * Animation definitions for this model
  45211. */
  45212. visualResponses: {
  45213. [stateKey: string]: {
  45214. /**
  45215. * What property will be animated
  45216. */
  45217. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45218. /**
  45219. * What states influence this visual response
  45220. */
  45221. states: MotionControllerComponentStateType[];
  45222. /**
  45223. * Type of animation - movement or visibility
  45224. */
  45225. valueNodeProperty: "transform" | "visibility";
  45226. /**
  45227. * Base node name to move. Its position will be calculated according to the min and max nodes
  45228. */
  45229. valueNodeName?: string;
  45230. /**
  45231. * Minimum movement node
  45232. */
  45233. minNodeName?: string;
  45234. /**
  45235. * Max movement node
  45236. */
  45237. maxNodeName?: string;
  45238. };
  45239. };
  45240. /**
  45241. * If touch enabled, what is the name of node to display user feedback
  45242. */
  45243. touchPointNodeName?: string;
  45244. };
  45245. };
  45246. /**
  45247. * Is it xr standard mapping or not
  45248. */
  45249. gamepadMapping: "" | "xr-standard";
  45250. /**
  45251. * Base root node of this entire model
  45252. */
  45253. rootNodeName: string;
  45254. /**
  45255. * Defines the main button component id
  45256. */
  45257. selectComponentId: string;
  45258. }
  45259. /**
  45260. * A definition for the layout map in the input profile
  45261. */
  45262. export interface IMotionControllerLayoutMap {
  45263. /**
  45264. * Layouts with handness type as a key
  45265. */
  45266. [handness: string]: IMotionControllerLayout;
  45267. }
  45268. /**
  45269. * The XR Input profile schema
  45270. * Profiles can be found here:
  45271. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45272. */
  45273. export interface IMotionControllerProfile {
  45274. /**
  45275. * fallback profiles for this profileId
  45276. */
  45277. fallbackProfileIds: string[];
  45278. /**
  45279. * The layout map, with handness as key
  45280. */
  45281. layouts: IMotionControllerLayoutMap;
  45282. /**
  45283. * The id of this profile
  45284. * correlates to the profile(s) in the xrInput.profiles array
  45285. */
  45286. profileId: string;
  45287. }
  45288. /**
  45289. * A helper-interface for the 3 meshes needed for controller button animation
  45290. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45291. */
  45292. export interface IMotionControllerButtonMeshMap {
  45293. /**
  45294. * the mesh that defines the pressed value mesh position.
  45295. * This is used to find the max-position of this button
  45296. */
  45297. pressedMesh: AbstractMesh;
  45298. /**
  45299. * the mesh that defines the unpressed value mesh position.
  45300. * This is used to find the min (or initial) position of this button
  45301. */
  45302. unpressedMesh: AbstractMesh;
  45303. /**
  45304. * The mesh that will be changed when value changes
  45305. */
  45306. valueMesh: AbstractMesh;
  45307. }
  45308. /**
  45309. * A helper-interface for the 3 meshes needed for controller axis animation.
  45310. * This will be expanded when touchpad animations are fully supported
  45311. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45312. */
  45313. export interface IMotionControllerMeshMap {
  45314. /**
  45315. * the mesh that defines the maximum value mesh position.
  45316. */
  45317. maxMesh?: AbstractMesh;
  45318. /**
  45319. * the mesh that defines the minimum value mesh position.
  45320. */
  45321. minMesh?: AbstractMesh;
  45322. /**
  45323. * The mesh that will be changed when axis value changes
  45324. */
  45325. valueMesh: AbstractMesh;
  45326. }
  45327. /**
  45328. * The elements needed for change-detection of the gamepad objects in motion controllers
  45329. */
  45330. export interface IMinimalMotionControllerObject {
  45331. /**
  45332. * Available axes of this controller
  45333. */
  45334. axes: number[];
  45335. /**
  45336. * An array of available buttons
  45337. */
  45338. buttons: Array<{
  45339. /**
  45340. * Value of the button/trigger
  45341. */
  45342. value: number;
  45343. /**
  45344. * If the button/trigger is currently touched
  45345. */
  45346. touched: boolean;
  45347. /**
  45348. * If the button/trigger is currently pressed
  45349. */
  45350. pressed: boolean;
  45351. }>;
  45352. }
  45353. /**
  45354. * An Abstract Motion controller
  45355. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45356. * Each component has an observable to check for changes in value and state
  45357. */
  45358. export abstract class WebXRAbstractMotionController implements IDisposable {
  45359. protected scene: Scene;
  45360. protected layout: IMotionControllerLayout;
  45361. /**
  45362. * The gamepad object correlating to this controller
  45363. */
  45364. gamepadObject: IMinimalMotionControllerObject;
  45365. /**
  45366. * handness (left/right/none) of this controller
  45367. */
  45368. handness: MotionControllerHandness;
  45369. private _initComponent;
  45370. private _modelReady;
  45371. /**
  45372. * A map of components (WebXRControllerComponent) in this motion controller
  45373. * Components have a ComponentType and can also have both button and axis definitions
  45374. */
  45375. readonly components: {
  45376. [id: string]: WebXRControllerComponent;
  45377. };
  45378. /**
  45379. * Disable the model's animation. Can be set at any time.
  45380. */
  45381. disableAnimation: boolean;
  45382. /**
  45383. * Observers registered here will be triggered when the model of this controller is done loading
  45384. */
  45385. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45386. /**
  45387. * The profile id of this motion controller
  45388. */
  45389. abstract profileId: string;
  45390. /**
  45391. * The root mesh of the model. It is null if the model was not yet initialized
  45392. */
  45393. rootMesh: Nullable<AbstractMesh>;
  45394. /**
  45395. * constructs a new abstract motion controller
  45396. * @param scene the scene to which the model of the controller will be added
  45397. * @param layout The profile layout to load
  45398. * @param gamepadObject The gamepad object correlating to this controller
  45399. * @param handness handness (left/right/none) of this controller
  45400. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45401. */
  45402. constructor(scene: Scene, layout: IMotionControllerLayout,
  45403. /**
  45404. * The gamepad object correlating to this controller
  45405. */
  45406. gamepadObject: IMinimalMotionControllerObject,
  45407. /**
  45408. * handness (left/right/none) of this controller
  45409. */
  45410. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45411. /**
  45412. * Dispose this controller, the model mesh and all its components
  45413. */
  45414. dispose(): void;
  45415. /**
  45416. * Returns all components of specific type
  45417. * @param type the type to search for
  45418. * @return an array of components with this type
  45419. */
  45420. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45421. /**
  45422. * get a component based an its component id as defined in layout.components
  45423. * @param id the id of the component
  45424. * @returns the component correlates to the id or undefined if not found
  45425. */
  45426. getComponent(id: string): WebXRControllerComponent;
  45427. /**
  45428. * Get the list of components available in this motion controller
  45429. * @returns an array of strings correlating to available components
  45430. */
  45431. getComponentIds(): string[];
  45432. /**
  45433. * Get the first component of specific type
  45434. * @param type type of component to find
  45435. * @return a controller component or null if not found
  45436. */
  45437. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45438. /**
  45439. * Get the main (Select) component of this controller as defined in the layout
  45440. * @returns the main component of this controller
  45441. */
  45442. getMainComponent(): WebXRControllerComponent;
  45443. /**
  45444. * Loads the model correlating to this controller
  45445. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45446. * @returns A promise fulfilled with the result of the model loading
  45447. */
  45448. loadModel(): Promise<boolean>;
  45449. /**
  45450. * Update this model using the current XRFrame
  45451. * @param xrFrame the current xr frame to use and update the model
  45452. */
  45453. updateFromXRFrame(xrFrame: XRFrame): void;
  45454. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45455. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45456. /**
  45457. * Moves the axis on the controller mesh based on its current state
  45458. * @param axis the index of the axis
  45459. * @param axisValue the value of the axis which determines the meshes new position
  45460. * @hidden
  45461. */
  45462. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45463. /**
  45464. * Update the model itself with the current frame data
  45465. * @param xrFrame the frame to use for updating the model mesh
  45466. */
  45467. protected updateModel(xrFrame: XRFrame): void;
  45468. /**
  45469. * Get the filename and path for this controller's model
  45470. * @returns a map of filename and path
  45471. */
  45472. protected abstract _getFilenameAndPath(): {
  45473. filename: string;
  45474. path: string;
  45475. };
  45476. /**
  45477. * This function is called before the mesh is loaded. It checks for loading constraints.
  45478. * For example, this function can check if the GLB loader is available
  45479. * If this function returns false, the generic controller will be loaded instead
  45480. * @returns Is the client ready to load the mesh
  45481. */
  45482. protected abstract _getModelLoadingConstraints(): boolean;
  45483. /**
  45484. * This function will be called after the model was successfully loaded and can be used
  45485. * for mesh transformations before it is available for the user
  45486. * @param meshes the loaded meshes
  45487. */
  45488. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45489. /**
  45490. * Set the root mesh for this controller. Important for the WebXR controller class
  45491. * @param meshes the loaded meshes
  45492. */
  45493. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45494. /**
  45495. * A function executed each frame that updates the mesh (if needed)
  45496. * @param xrFrame the current xrFrame
  45497. */
  45498. protected abstract _updateModel(xrFrame: XRFrame): void;
  45499. private _getGenericFilenameAndPath;
  45500. private _getGenericParentMesh;
  45501. }
  45502. }
  45503. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45504. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45506. import { Scene } from "babylonjs/scene";
  45507. /**
  45508. * A generic trigger-only motion controller for WebXR
  45509. */
  45510. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45511. /**
  45512. * Static version of the profile id of this controller
  45513. */
  45514. static ProfileId: string;
  45515. profileId: string;
  45516. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45517. protected _getFilenameAndPath(): {
  45518. filename: string;
  45519. path: string;
  45520. };
  45521. protected _getModelLoadingConstraints(): boolean;
  45522. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45523. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45524. protected _updateModel(): void;
  45525. }
  45526. }
  45527. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45528. import { Vector4 } from "babylonjs/Maths/math.vector";
  45529. import { Mesh } from "babylonjs/Meshes/mesh";
  45530. import { Scene } from "babylonjs/scene";
  45531. import { Nullable } from "babylonjs/types";
  45532. /**
  45533. * Class containing static functions to help procedurally build meshes
  45534. */
  45535. export class SphereBuilder {
  45536. /**
  45537. * Creates a sphere mesh
  45538. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45539. * * 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`)
  45540. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45541. * * 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
  45542. * * 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)
  45543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45546. * @param name defines the name of the mesh
  45547. * @param options defines the options used to create the mesh
  45548. * @param scene defines the hosting scene
  45549. * @returns the sphere mesh
  45550. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45551. */
  45552. static CreateSphere(name: string, options: {
  45553. segments?: number;
  45554. diameter?: number;
  45555. diameterX?: number;
  45556. diameterY?: number;
  45557. diameterZ?: number;
  45558. arc?: number;
  45559. slice?: number;
  45560. sideOrientation?: number;
  45561. frontUVs?: Vector4;
  45562. backUVs?: Vector4;
  45563. updatable?: boolean;
  45564. }, scene?: Nullable<Scene>): Mesh;
  45565. }
  45566. }
  45567. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45569. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45570. import { Scene } from "babylonjs/scene";
  45571. /**
  45572. * A profiled motion controller has its profile loaded from an online repository.
  45573. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45574. */
  45575. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45576. private _repositoryUrl;
  45577. private _buttonMeshMapping;
  45578. private _touchDots;
  45579. /**
  45580. * The profile ID of this controller. Will be populated when the controller initializes.
  45581. */
  45582. profileId: string;
  45583. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45584. dispose(): void;
  45585. protected _getFilenameAndPath(): {
  45586. filename: string;
  45587. path: string;
  45588. };
  45589. protected _getModelLoadingConstraints(): boolean;
  45590. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45591. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45592. protected _updateModel(_xrFrame: XRFrame): void;
  45593. }
  45594. }
  45595. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45596. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45597. import { Scene } from "babylonjs/scene";
  45598. /**
  45599. * A construction function type to create a new controller based on an xrInput object
  45600. */
  45601. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45602. /**
  45603. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45604. *
  45605. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45606. * it should be replaced with auto-loaded controllers.
  45607. *
  45608. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45609. */
  45610. export class WebXRMotionControllerManager {
  45611. private static _AvailableControllers;
  45612. private static _Fallbacks;
  45613. private static _ProfileLoadingPromises;
  45614. private static _ProfilesList;
  45615. /**
  45616. * The base URL of the online controller repository. Can be changed at any time.
  45617. */
  45618. static BaseRepositoryUrl: string;
  45619. /**
  45620. * Which repository gets priority - local or online
  45621. */
  45622. static PrioritizeOnlineRepository: boolean;
  45623. /**
  45624. * Use the online repository, or use only locally-defined controllers
  45625. */
  45626. static UseOnlineRepository: boolean;
  45627. /**
  45628. * Clear the cache used for profile loading and reload when requested again
  45629. */
  45630. static ClearProfilesCache(): void;
  45631. /**
  45632. * Register the default fallbacks.
  45633. * This function is called automatically when this file is imported.
  45634. */
  45635. static DefaultFallbacks(): void;
  45636. /**
  45637. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45638. * @param profileId the profile to which a fallback needs to be found
  45639. * @return an array with corresponding fallback profiles
  45640. */
  45641. static FindFallbackWithProfileId(profileId: string): string[];
  45642. /**
  45643. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45644. * The order of search:
  45645. *
  45646. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45647. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45648. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45649. * 4) return the generic trigger controller if none were found
  45650. *
  45651. * @param xrInput the xrInput to which a new controller is initialized
  45652. * @param scene the scene to which the model will be added
  45653. * @param forceProfile force a certain profile for this controller
  45654. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45655. */
  45656. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45657. /**
  45658. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45659. *
  45660. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45661. *
  45662. * @param type the profile type to register
  45663. * @param constructFunction the function to be called when loading this profile
  45664. */
  45665. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45666. /**
  45667. * Register a fallback to a specific profile.
  45668. * @param profileId the profileId that will receive the fallbacks
  45669. * @param fallbacks A list of fallback profiles
  45670. */
  45671. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45672. /**
  45673. * Will update the list of profiles available in the repository
  45674. * @return a promise that resolves to a map of profiles available online
  45675. */
  45676. static UpdateProfilesList(): Promise<{
  45677. [profile: string]: string;
  45678. }>;
  45679. private static _LoadProfileFromRepository;
  45680. private static _LoadProfilesFromAvailableControllers;
  45681. }
  45682. }
  45683. declare module "babylonjs/XR/webXRInputSource" {
  45684. import { Observable } from "babylonjs/Misc/observable";
  45685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45686. import { Ray } from "babylonjs/Culling/ray";
  45687. import { Scene } from "babylonjs/scene";
  45688. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45689. /**
  45690. * Configuration options for the WebXR controller creation
  45691. */
  45692. export interface IWebXRControllerOptions {
  45693. /**
  45694. * Should the controller mesh be animated when a user interacts with it
  45695. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45696. */
  45697. disableMotionControllerAnimation?: boolean;
  45698. /**
  45699. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45700. */
  45701. doNotLoadControllerMesh?: boolean;
  45702. /**
  45703. * Force a specific controller type for this controller.
  45704. * This can be used when creating your own profile or when testing different controllers
  45705. */
  45706. forceControllerProfile?: string;
  45707. }
  45708. /**
  45709. * Represents an XR controller
  45710. */
  45711. export class WebXRInputSource {
  45712. private _scene;
  45713. /** The underlying input source for the controller */
  45714. inputSource: XRInputSource;
  45715. private _options;
  45716. private _tmpQuaternion;
  45717. private _tmpVector;
  45718. private _uniqueId;
  45719. /**
  45720. * 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
  45721. */
  45722. grip?: AbstractMesh;
  45723. /**
  45724. * If available, this is the gamepad object related to this controller.
  45725. * Using this object it is possible to get click events and trackpad changes of the
  45726. * webxr controller that is currently being used.
  45727. */
  45728. motionController?: WebXRAbstractMotionController;
  45729. /**
  45730. * Event that fires when the controller is removed/disposed.
  45731. * The object provided as event data is this controller, after associated assets were disposed.
  45732. * uniqueId is still available.
  45733. */
  45734. onDisposeObservable: Observable<WebXRInputSource>;
  45735. /**
  45736. * Will be triggered when the mesh associated with the motion controller is done loading.
  45737. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45738. * A shortened version of controller -> motion controller -> on mesh loaded.
  45739. */
  45740. onMeshLoadedObservable: Observable<AbstractMesh>;
  45741. /**
  45742. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45743. */
  45744. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45745. /**
  45746. * Pointer which can be used to select objects or attach a visible laser to
  45747. */
  45748. pointer: AbstractMesh;
  45749. /**
  45750. * Creates the controller
  45751. * @see https://doc.babylonjs.com/how_to/webxr
  45752. * @param _scene the scene which the controller should be associated to
  45753. * @param inputSource the underlying input source for the controller
  45754. * @param _options options for this controller creation
  45755. */
  45756. constructor(_scene: Scene,
  45757. /** The underlying input source for the controller */
  45758. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45759. /**
  45760. * Get this controllers unique id
  45761. */
  45762. get uniqueId(): string;
  45763. /**
  45764. * Disposes of the object
  45765. */
  45766. dispose(): void;
  45767. /**
  45768. * Gets a world space ray coming from the pointer or grip
  45769. * @param result the resulting ray
  45770. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45771. */
  45772. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45773. /**
  45774. * Updates the controller pose based on the given XRFrame
  45775. * @param xrFrame xr frame to update the pose with
  45776. * @param referenceSpace reference space to use
  45777. */
  45778. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45779. }
  45780. }
  45781. declare module "babylonjs/XR/webXRInput" {
  45782. import { Observable } from "babylonjs/Misc/observable";
  45783. import { IDisposable } from "babylonjs/scene";
  45784. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45785. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45786. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45787. /**
  45788. * The schema for initialization options of the XR Input class
  45789. */
  45790. export interface IWebXRInputOptions {
  45791. /**
  45792. * If set to true no model will be automatically loaded
  45793. */
  45794. doNotLoadControllerMeshes?: boolean;
  45795. /**
  45796. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45797. * If not found, the xr input profile data will be used.
  45798. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45799. */
  45800. forceInputProfile?: string;
  45801. /**
  45802. * Do not send a request to the controller repository to load the profile.
  45803. *
  45804. * Instead, use the controllers available in babylon itself.
  45805. */
  45806. disableOnlineControllerRepository?: boolean;
  45807. /**
  45808. * A custom URL for the controllers repository
  45809. */
  45810. customControllersRepositoryURL?: string;
  45811. /**
  45812. * Should the controller model's components not move according to the user input
  45813. */
  45814. disableControllerAnimation?: boolean;
  45815. }
  45816. /**
  45817. * XR input used to track XR inputs such as controllers/rays
  45818. */
  45819. export class WebXRInput implements IDisposable {
  45820. /**
  45821. * the xr session manager for this session
  45822. */
  45823. xrSessionManager: WebXRSessionManager;
  45824. /**
  45825. * the WebXR camera for this session. Mainly used for teleportation
  45826. */
  45827. xrCamera: WebXRCamera;
  45828. private readonly options;
  45829. /**
  45830. * XR controllers being tracked
  45831. */
  45832. controllers: Array<WebXRInputSource>;
  45833. private _frameObserver;
  45834. private _sessionEndedObserver;
  45835. private _sessionInitObserver;
  45836. /**
  45837. * Event when a controller has been connected/added
  45838. */
  45839. onControllerAddedObservable: Observable<WebXRInputSource>;
  45840. /**
  45841. * Event when a controller has been removed/disconnected
  45842. */
  45843. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45844. /**
  45845. * Initializes the WebXRInput
  45846. * @param xrSessionManager the xr session manager for this session
  45847. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45848. * @param options = initialization options for this xr input
  45849. */
  45850. constructor(
  45851. /**
  45852. * the xr session manager for this session
  45853. */
  45854. xrSessionManager: WebXRSessionManager,
  45855. /**
  45856. * the WebXR camera for this session. Mainly used for teleportation
  45857. */
  45858. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45859. private _onInputSourcesChange;
  45860. private _addAndRemoveControllers;
  45861. /**
  45862. * Disposes of the object
  45863. */
  45864. dispose(): void;
  45865. }
  45866. }
  45867. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45868. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45869. import { Observable, EventState } from "babylonjs/Misc/observable";
  45870. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45871. /**
  45872. * This is the base class for all WebXR features.
  45873. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45874. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45875. */
  45876. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45877. protected _xrSessionManager: WebXRSessionManager;
  45878. private _attached;
  45879. private _removeOnDetach;
  45880. /**
  45881. * Should auto-attach be disabled?
  45882. */
  45883. disableAutoAttach: boolean;
  45884. /**
  45885. * Construct a new (abstract) WebXR feature
  45886. * @param _xrSessionManager the xr session manager for this feature
  45887. */
  45888. constructor(_xrSessionManager: WebXRSessionManager);
  45889. /**
  45890. * Is this feature attached
  45891. */
  45892. get attached(): boolean;
  45893. /**
  45894. * attach this feature
  45895. *
  45896. * @param force should attachment be forced (even when already attached)
  45897. * @returns true if successful, false is failed or already attached
  45898. */
  45899. attach(force?: boolean): boolean;
  45900. /**
  45901. * detach this feature.
  45902. *
  45903. * @returns true if successful, false if failed or already detached
  45904. */
  45905. detach(): boolean;
  45906. /**
  45907. * Dispose this feature and all of the resources attached
  45908. */
  45909. dispose(): void;
  45910. /**
  45911. * This is used to register callbacks that will automatically be removed when detach is called.
  45912. * @param observable the observable to which the observer will be attached
  45913. * @param callback the callback to register
  45914. */
  45915. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45916. /**
  45917. * Code in this function will be executed on each xrFrame received from the browser.
  45918. * This function will not execute after the feature is detached.
  45919. * @param _xrFrame the current frame
  45920. */
  45921. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45922. }
  45923. }
  45924. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45925. import { IDisposable, Scene } from "babylonjs/scene";
  45926. import { Nullable } from "babylonjs/types";
  45927. import { Observable } from "babylonjs/Misc/observable";
  45928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45929. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45930. import { Camera } from "babylonjs/Cameras/camera";
  45931. /**
  45932. * Renders a layer on top of an existing scene
  45933. */
  45934. export class UtilityLayerRenderer implements IDisposable {
  45935. /** the original scene that will be rendered on top of */
  45936. originalScene: Scene;
  45937. private _pointerCaptures;
  45938. private _lastPointerEvents;
  45939. private static _DefaultUtilityLayer;
  45940. private static _DefaultKeepDepthUtilityLayer;
  45941. private _sharedGizmoLight;
  45942. private _renderCamera;
  45943. /**
  45944. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45945. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  45946. * @returns the camera that is used when rendering the utility layer
  45947. */
  45948. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45949. /**
  45950. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45951. * @param cam the camera that should be used when rendering the utility layer
  45952. */
  45953. setRenderCamera(cam: Nullable<Camera>): void;
  45954. /**
  45955. * @hidden
  45956. * Light which used by gizmos to get light shading
  45957. */
  45958. _getSharedGizmoLight(): HemisphericLight;
  45959. /**
  45960. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45961. */
  45962. pickUtilitySceneFirst: boolean;
  45963. /**
  45964. * 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)
  45965. */
  45966. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45967. /**
  45968. * 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)
  45969. */
  45970. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45971. /**
  45972. * The scene that is rendered on top of the original scene
  45973. */
  45974. utilityLayerScene: Scene;
  45975. /**
  45976. * If the utility layer should automatically be rendered on top of existing scene
  45977. */
  45978. shouldRender: boolean;
  45979. /**
  45980. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45981. */
  45982. onlyCheckPointerDownEvents: boolean;
  45983. /**
  45984. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45985. */
  45986. processAllEvents: boolean;
  45987. /**
  45988. * Observable raised when the pointer move from the utility layer scene to the main scene
  45989. */
  45990. onPointerOutObservable: Observable<number>;
  45991. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45992. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45993. private _afterRenderObserver;
  45994. private _sceneDisposeObserver;
  45995. private _originalPointerObserver;
  45996. /**
  45997. * Instantiates a UtilityLayerRenderer
  45998. * @param originalScene the original scene that will be rendered on top of
  45999. * @param handleEvents boolean indicating if the utility layer should handle events
  46000. */
  46001. constructor(
  46002. /** the original scene that will be rendered on top of */
  46003. originalScene: Scene, handleEvents?: boolean);
  46004. private _notifyObservers;
  46005. /**
  46006. * Renders the utility layers scene on top of the original scene
  46007. */
  46008. render(): void;
  46009. /**
  46010. * Disposes of the renderer
  46011. */
  46012. dispose(): void;
  46013. private _updateCamera;
  46014. }
  46015. }
  46016. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46017. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46019. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46020. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46021. import { Scene } from "babylonjs/scene";
  46022. import { Nullable } from "babylonjs/types";
  46023. import { Color3 } from "babylonjs/Maths/math.color";
  46024. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46025. /**
  46026. * Options interface for the pointer selection module
  46027. */
  46028. export interface IWebXRControllerPointerSelectionOptions {
  46029. /**
  46030. * if provided, this scene will be used to render meshes.
  46031. */
  46032. customUtilityLayerScene?: Scene;
  46033. /**
  46034. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  46035. * If not disabled, the last picked point will be used to execute a pointer up event
  46036. * If disabled, pointer up event will be triggered right after the pointer down event.
  46037. * Used in screen and gaze target ray mode only
  46038. */
  46039. disablePointerUpOnTouchOut: boolean;
  46040. /**
  46041. * For gaze mode (time to select instead of press)
  46042. */
  46043. forceGazeMode: boolean;
  46044. /**
  46045. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  46046. * to start a new countdown to the pointer down event.
  46047. * Defaults to 1.
  46048. */
  46049. gazeModePointerMovedFactor?: number;
  46050. /**
  46051. * Different button type to use instead of the main component
  46052. */
  46053. overrideButtonId?: string;
  46054. /**
  46055. * use this rendering group id for the meshes (optional)
  46056. */
  46057. renderingGroupId?: number;
  46058. /**
  46059. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46060. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46061. * 3000 means 3 seconds between pointing at something and selecting it
  46062. */
  46063. timeToSelect?: number;
  46064. /**
  46065. * Should meshes created here be added to a utility layer or the main scene
  46066. */
  46067. useUtilityLayer?: boolean;
  46068. /**
  46069. * the xr input to use with this pointer selection
  46070. */
  46071. xrInput: WebXRInput;
  46072. }
  46073. /**
  46074. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46075. */
  46076. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46077. private readonly _options;
  46078. private static _idCounter;
  46079. private _attachController;
  46080. private _controllers;
  46081. private _scene;
  46082. private _tmpVectorForPickCompare;
  46083. /**
  46084. * The module's name
  46085. */
  46086. static readonly Name: string;
  46087. /**
  46088. * The (Babylon) version of this module.
  46089. * This is an integer representing the implementation version.
  46090. * This number does not correspond to the WebXR specs version
  46091. */
  46092. static readonly Version: number;
  46093. /**
  46094. * Disable lighting on the laser pointer (so it will always be visible)
  46095. */
  46096. disablePointerLighting: boolean;
  46097. /**
  46098. * Disable lighting on the selection mesh (so it will always be visible)
  46099. */
  46100. disableSelectionMeshLighting: boolean;
  46101. /**
  46102. * Should the laser pointer be displayed
  46103. */
  46104. displayLaserPointer: boolean;
  46105. /**
  46106. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46107. */
  46108. displaySelectionMesh: boolean;
  46109. /**
  46110. * This color will be set to the laser pointer when selection is triggered
  46111. */
  46112. laserPointerPickedColor: Color3;
  46113. /**
  46114. * Default color of the laser pointer
  46115. */
  46116. lasterPointerDefaultColor: Color3;
  46117. /**
  46118. * default color of the selection ring
  46119. */
  46120. selectionMeshDefaultColor: Color3;
  46121. /**
  46122. * This color will be applied to the selection ring when selection is triggered
  46123. */
  46124. selectionMeshPickedColor: Color3;
  46125. /**
  46126. * constructs a new background remover module
  46127. * @param _xrSessionManager the session manager for this module
  46128. * @param _options read-only options to be used in this module
  46129. */
  46130. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46131. /**
  46132. * attach this feature
  46133. * Will usually be called by the features manager
  46134. *
  46135. * @returns true if successful.
  46136. */
  46137. attach(): boolean;
  46138. /**
  46139. * detach this feature.
  46140. * Will usually be called by the features manager
  46141. *
  46142. * @returns true if successful.
  46143. */
  46144. detach(): boolean;
  46145. /**
  46146. * Will get the mesh under a specific pointer.
  46147. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46148. * @param controllerId the controllerId to check
  46149. * @returns The mesh under pointer or null if no mesh is under the pointer
  46150. */
  46151. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46152. /**
  46153. * Get the xr controller that correlates to the pointer id in the pointer event
  46154. *
  46155. * @param id the pointer id to search for
  46156. * @returns the controller that correlates to this id or null if not found
  46157. */
  46158. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46159. protected _onXRFrame(_xrFrame: XRFrame): void;
  46160. private _attachGazeMode;
  46161. private _attachScreenRayMode;
  46162. private _attachTrackedPointerRayMode;
  46163. private _convertNormalToDirectionOfRay;
  46164. private _detachController;
  46165. private _generateNewMeshPair;
  46166. private _pickingMoved;
  46167. private _updatePointerDistance;
  46168. }
  46169. }
  46170. declare module "babylonjs/XR/webXREnterExitUI" {
  46171. import { Nullable } from "babylonjs/types";
  46172. import { Observable } from "babylonjs/Misc/observable";
  46173. import { IDisposable, Scene } from "babylonjs/scene";
  46174. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46175. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46176. /**
  46177. * Button which can be used to enter a different mode of XR
  46178. */
  46179. export class WebXREnterExitUIButton {
  46180. /** button element */
  46181. element: HTMLElement;
  46182. /** XR initialization options for the button */
  46183. sessionMode: XRSessionMode;
  46184. /** Reference space type */
  46185. referenceSpaceType: XRReferenceSpaceType;
  46186. /**
  46187. * Creates a WebXREnterExitUIButton
  46188. * @param element button element
  46189. * @param sessionMode XR initialization session mode
  46190. * @param referenceSpaceType the type of reference space to be used
  46191. */
  46192. constructor(
  46193. /** button element */
  46194. element: HTMLElement,
  46195. /** XR initialization options for the button */
  46196. sessionMode: XRSessionMode,
  46197. /** Reference space type */
  46198. referenceSpaceType: XRReferenceSpaceType);
  46199. /**
  46200. * Extendable function which can be used to update the button's visuals when the state changes
  46201. * @param activeButton the current active button in the UI
  46202. */
  46203. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46204. }
  46205. /**
  46206. * Options to create the webXR UI
  46207. */
  46208. export class WebXREnterExitUIOptions {
  46209. /**
  46210. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46211. */
  46212. customButtons?: Array<WebXREnterExitUIButton>;
  46213. /**
  46214. * A reference space type to use when creating the default button.
  46215. * Default is local-floor
  46216. */
  46217. referenceSpaceType?: XRReferenceSpaceType;
  46218. /**
  46219. * Context to enter xr with
  46220. */
  46221. renderTarget?: Nullable<WebXRRenderTarget>;
  46222. /**
  46223. * A session mode to use when creating the default button.
  46224. * Default is immersive-vr
  46225. */
  46226. sessionMode?: XRSessionMode;
  46227. }
  46228. /**
  46229. * UI to allow the user to enter/exit XR mode
  46230. */
  46231. export class WebXREnterExitUI implements IDisposable {
  46232. private scene;
  46233. /** version of the options passed to this UI */
  46234. options: WebXREnterExitUIOptions;
  46235. private _activeButton;
  46236. private _buttons;
  46237. private _overlay;
  46238. /**
  46239. * Fired every time the active button is changed.
  46240. *
  46241. * When xr is entered via a button that launches xr that button will be the callback parameter
  46242. *
  46243. * When exiting xr the callback parameter will be null)
  46244. */
  46245. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46246. /**
  46247. *
  46248. * @param scene babylon scene object to use
  46249. * @param options (read-only) version of the options passed to this UI
  46250. */
  46251. private constructor();
  46252. /**
  46253. * Creates UI to allow the user to enter/exit XR mode
  46254. * @param scene the scene to add the ui to
  46255. * @param helper the xr experience helper to enter/exit xr with
  46256. * @param options options to configure the UI
  46257. * @returns the created ui
  46258. */
  46259. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46260. /**
  46261. * Disposes of the XR UI component
  46262. */
  46263. dispose(): void;
  46264. private _updateButtons;
  46265. }
  46266. }
  46267. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46268. import { Vector3 } from "babylonjs/Maths/math.vector";
  46269. import { Color4 } from "babylonjs/Maths/math.color";
  46270. import { Nullable } from "babylonjs/types";
  46271. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46272. import { Scene } from "babylonjs/scene";
  46273. /**
  46274. * Class containing static functions to help procedurally build meshes
  46275. */
  46276. export class LinesBuilder {
  46277. /**
  46278. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46279. * * 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
  46280. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46281. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46282. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46283. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46284. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46285. * * 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
  46286. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46289. * @param name defines the name of the new line system
  46290. * @param options defines the options used to create the line system
  46291. * @param scene defines the hosting scene
  46292. * @returns a new line system mesh
  46293. */
  46294. static CreateLineSystem(name: string, options: {
  46295. lines: Vector3[][];
  46296. updatable?: boolean;
  46297. instance?: Nullable<LinesMesh>;
  46298. colors?: Nullable<Color4[][]>;
  46299. useVertexAlpha?: boolean;
  46300. }, scene: Nullable<Scene>): LinesMesh;
  46301. /**
  46302. * Creates a line mesh
  46303. * 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
  46304. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46305. * * The parameter `points` is an array successive Vector3
  46306. * * 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
  46307. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46308. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46309. * * When updating an instance, remember that only point positions can change, not the number of points
  46310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46312. * @param name defines the name of the new line system
  46313. * @param options defines the options used to create the line system
  46314. * @param scene defines the hosting scene
  46315. * @returns a new line mesh
  46316. */
  46317. static CreateLines(name: string, options: {
  46318. points: Vector3[];
  46319. updatable?: boolean;
  46320. instance?: Nullable<LinesMesh>;
  46321. colors?: Color4[];
  46322. useVertexAlpha?: boolean;
  46323. }, scene?: Nullable<Scene>): LinesMesh;
  46324. /**
  46325. * Creates a dashed line mesh
  46326. * * 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
  46327. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46328. * * The parameter `points` is an array successive Vector3
  46329. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46330. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46331. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46332. * * 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
  46333. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46334. * * When updating an instance, remember that only point positions can change, not the number of points
  46335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46336. * @param name defines the name of the mesh
  46337. * @param options defines the options used to create the mesh
  46338. * @param scene defines the hosting scene
  46339. * @returns the dashed line mesh
  46340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46341. */
  46342. static CreateDashedLines(name: string, options: {
  46343. points: Vector3[];
  46344. dashSize?: number;
  46345. gapSize?: number;
  46346. dashNb?: number;
  46347. updatable?: boolean;
  46348. instance?: LinesMesh;
  46349. useVertexAlpha?: boolean;
  46350. }, scene?: Nullable<Scene>): LinesMesh;
  46351. }
  46352. }
  46353. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46354. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46355. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46356. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46358. import { Vector3 } from "babylonjs/Maths/math.vector";
  46359. import { Material } from "babylonjs/Materials/material";
  46360. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46361. import { Scene } from "babylonjs/scene";
  46362. /**
  46363. * The options container for the teleportation module
  46364. */
  46365. export interface IWebXRTeleportationOptions {
  46366. /**
  46367. * if provided, this scene will be used to render meshes.
  46368. */
  46369. customUtilityLayerScene?: Scene;
  46370. /**
  46371. * Values to configure the default target mesh
  46372. */
  46373. defaultTargetMeshOptions?: {
  46374. /**
  46375. * Fill color of the teleportation area
  46376. */
  46377. teleportationFillColor?: string;
  46378. /**
  46379. * Border color for the teleportation area
  46380. */
  46381. teleportationBorderColor?: string;
  46382. /**
  46383. * Disable the mesh's animation sequence
  46384. */
  46385. disableAnimation?: boolean;
  46386. /**
  46387. * Disable lighting on the material or the ring and arrow
  46388. */
  46389. disableLighting?: boolean;
  46390. /**
  46391. * Override the default material of the torus and arrow
  46392. */
  46393. torusArrowMaterial?: Material;
  46394. };
  46395. /**
  46396. * A list of meshes to use as floor meshes.
  46397. * Meshes can be added and removed after initializing the feature using the
  46398. * addFloorMesh and removeFloorMesh functions
  46399. * If empty, rotation will still work
  46400. */
  46401. floorMeshes?: AbstractMesh[];
  46402. /**
  46403. * use this rendering group id for the meshes (optional)
  46404. */
  46405. renderingGroupId?: number;
  46406. /**
  46407. * Should teleportation move only to snap points
  46408. */
  46409. snapPointsOnly?: boolean;
  46410. /**
  46411. * An array of points to which the teleportation will snap to.
  46412. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46413. */
  46414. snapPositions?: Vector3[];
  46415. /**
  46416. * How close should the teleportation ray be in order to snap to position.
  46417. * Default to 0.8 units (meters)
  46418. */
  46419. snapToPositionRadius?: number;
  46420. /**
  46421. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46422. * If you want to support rotation, make sure your mesh has a direction indicator.
  46423. *
  46424. * When left untouched, the default mesh will be initialized.
  46425. */
  46426. teleportationTargetMesh?: AbstractMesh;
  46427. /**
  46428. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46429. */
  46430. timeToTeleport?: number;
  46431. /**
  46432. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46433. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46434. */
  46435. useMainComponentOnly?: boolean;
  46436. /**
  46437. * Should meshes created here be added to a utility layer or the main scene
  46438. */
  46439. useUtilityLayer?: boolean;
  46440. /**
  46441. * Babylon XR Input class for controller
  46442. */
  46443. xrInput: WebXRInput;
  46444. }
  46445. /**
  46446. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46447. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46448. * the input of the attached controllers.
  46449. */
  46450. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46451. private _options;
  46452. private _controllers;
  46453. private _currentTeleportationControllerId;
  46454. private _floorMeshes;
  46455. private _quadraticBezierCurve;
  46456. private _selectionFeature;
  46457. private _snapToPositions;
  46458. private _snappedToPoint;
  46459. private _teleportationRingMaterial?;
  46460. private _tmpRay;
  46461. private _tmpVector;
  46462. /**
  46463. * The module's name
  46464. */
  46465. static readonly Name: string;
  46466. /**
  46467. * The (Babylon) version of this module.
  46468. * This is an integer representing the implementation version.
  46469. * This number does not correspond to the webxr specs version
  46470. */
  46471. static readonly Version: number;
  46472. /**
  46473. * Is movement backwards enabled
  46474. */
  46475. backwardsMovementEnabled: boolean;
  46476. /**
  46477. * Distance to travel when moving backwards
  46478. */
  46479. backwardsTeleportationDistance: number;
  46480. /**
  46481. * The distance from the user to the inspection point in the direction of the controller
  46482. * A higher number will allow the user to move further
  46483. * defaults to 5 (meters, in xr units)
  46484. */
  46485. parabolicCheckRadius: number;
  46486. /**
  46487. * Should the module support parabolic ray on top of direct ray
  46488. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46489. * Very helpful when moving between floors / different heights
  46490. */
  46491. parabolicRayEnabled: boolean;
  46492. /**
  46493. * How much rotation should be applied when rotating right and left
  46494. */
  46495. rotationAngle: number;
  46496. /**
  46497. * Is rotation enabled when moving forward?
  46498. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46499. */
  46500. rotationEnabled: boolean;
  46501. /**
  46502. * constructs a new anchor system
  46503. * @param _xrSessionManager an instance of WebXRSessionManager
  46504. * @param _options configuration object for this feature
  46505. */
  46506. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46507. /**
  46508. * Get the snapPointsOnly flag
  46509. */
  46510. get snapPointsOnly(): boolean;
  46511. /**
  46512. * Sets the snapPointsOnly flag
  46513. * @param snapToPoints should teleportation be exclusively to snap points
  46514. */
  46515. set snapPointsOnly(snapToPoints: boolean);
  46516. /**
  46517. * Add a new mesh to the floor meshes array
  46518. * @param mesh the mesh to use as floor mesh
  46519. */
  46520. addFloorMesh(mesh: AbstractMesh): void;
  46521. /**
  46522. * Add a new snap-to point to fix teleportation to this position
  46523. * @param newSnapPoint The new Snap-To point
  46524. */
  46525. addSnapPoint(newSnapPoint: Vector3): void;
  46526. attach(): boolean;
  46527. detach(): boolean;
  46528. dispose(): void;
  46529. /**
  46530. * Remove a mesh from the floor meshes array
  46531. * @param mesh the mesh to remove
  46532. */
  46533. removeFloorMesh(mesh: AbstractMesh): void;
  46534. /**
  46535. * Remove a mesh from the floor meshes array using its name
  46536. * @param name the mesh name to remove
  46537. */
  46538. removeFloorMeshByName(name: string): void;
  46539. /**
  46540. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  46541. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46542. * @returns was the point found and removed or not
  46543. */
  46544. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46545. /**
  46546. * This function sets a selection feature that will be disabled when
  46547. * the forward ray is shown and will be reattached when hidden.
  46548. * This is used to remove the selection rays when moving.
  46549. * @param selectionFeature the feature to disable when forward movement is enabled
  46550. */
  46551. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46552. protected _onXRFrame(_xrFrame: XRFrame): void;
  46553. private _attachController;
  46554. private _createDefaultTargetMesh;
  46555. private _detachController;
  46556. private _findClosestSnapPointWithRadius;
  46557. private _setTargetMeshPosition;
  46558. private _setTargetMeshVisibility;
  46559. private _showParabolicPath;
  46560. private _teleportForward;
  46561. }
  46562. }
  46563. declare module "babylonjs/XR/webXRDefaultExperience" {
  46564. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46565. import { Scene } from "babylonjs/scene";
  46566. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46567. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46568. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46569. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46571. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46572. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46573. /**
  46574. * Options for the default xr helper
  46575. */
  46576. export class WebXRDefaultExperienceOptions {
  46577. /**
  46578. * Enable or disable default UI to enter XR
  46579. */
  46580. disableDefaultUI?: boolean;
  46581. /**
  46582. * Should teleportation not initialize. defaults to false.
  46583. */
  46584. disableTeleportation?: boolean;
  46585. /**
  46586. * Floor meshes that will be used for teleport
  46587. */
  46588. floorMeshes?: Array<AbstractMesh>;
  46589. /**
  46590. * If set to true, the first frame will not be used to reset position
  46591. * The first frame is mainly used when copying transformation from the old camera
  46592. * Mainly used in AR
  46593. */
  46594. ignoreNativeCameraTransformation?: boolean;
  46595. /**
  46596. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46597. */
  46598. inputOptions?: IWebXRInputOptions;
  46599. /**
  46600. * optional configuration for the output canvas
  46601. */
  46602. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46603. /**
  46604. * optional UI options. This can be used among other to change session mode and reference space type
  46605. */
  46606. uiOptions?: WebXREnterExitUIOptions;
  46607. /**
  46608. * When loading teleportation and pointer select, use stable versions instead of latest.
  46609. */
  46610. useStablePlugins?: boolean;
  46611. }
  46612. /**
  46613. * Default experience which provides a similar setup to the previous webVRExperience
  46614. */
  46615. export class WebXRDefaultExperience {
  46616. /**
  46617. * Base experience
  46618. */
  46619. baseExperience: WebXRExperienceHelper;
  46620. /**
  46621. * Enables ui for entering/exiting xr
  46622. */
  46623. enterExitUI: WebXREnterExitUI;
  46624. /**
  46625. * Input experience extension
  46626. */
  46627. input: WebXRInput;
  46628. /**
  46629. * Enables laser pointer and selection
  46630. */
  46631. pointerSelection: WebXRControllerPointerSelection;
  46632. /**
  46633. * Default target xr should render to
  46634. */
  46635. renderTarget: WebXRRenderTarget;
  46636. /**
  46637. * Enables teleportation
  46638. */
  46639. teleportation: WebXRMotionControllerTeleportation;
  46640. private constructor();
  46641. /**
  46642. * Creates the default xr experience
  46643. * @param scene scene
  46644. * @param options options for basic configuration
  46645. * @returns resulting WebXRDefaultExperience
  46646. */
  46647. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46648. /**
  46649. * DIsposes of the experience helper
  46650. */
  46651. dispose(): void;
  46652. }
  46653. }
  46654. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46655. import { Observable } from "babylonjs/Misc/observable";
  46656. import { Nullable } from "babylonjs/types";
  46657. import { Camera } from "babylonjs/Cameras/camera";
  46658. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46659. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46660. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46661. import { Scene } from "babylonjs/scene";
  46662. import { Vector3 } from "babylonjs/Maths/math.vector";
  46663. import { Color3 } from "babylonjs/Maths/math.color";
  46664. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46666. import { Mesh } from "babylonjs/Meshes/mesh";
  46667. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46668. import { EasingFunction } from "babylonjs/Animations/easing";
  46669. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46670. import "babylonjs/Meshes/Builders/groundBuilder";
  46671. import "babylonjs/Meshes/Builders/torusBuilder";
  46672. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46673. import "babylonjs/Gamepads/gamepadSceneComponent";
  46674. import "babylonjs/Animations/animatable";
  46675. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46676. /**
  46677. * Options to modify the vr teleportation behavior.
  46678. */
  46679. export interface VRTeleportationOptions {
  46680. /**
  46681. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46682. */
  46683. floorMeshName?: string;
  46684. /**
  46685. * A list of meshes to be used as the teleportation floor. (default: empty)
  46686. */
  46687. floorMeshes?: Mesh[];
  46688. /**
  46689. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46690. */
  46691. teleportationMode?: number;
  46692. /**
  46693. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46694. */
  46695. teleportationTime?: number;
  46696. /**
  46697. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46698. */
  46699. teleportationSpeed?: number;
  46700. /**
  46701. * The easing function used in the animation or null for Linear. (default CircleEase)
  46702. */
  46703. easingFunction?: EasingFunction;
  46704. }
  46705. /**
  46706. * Options to modify the vr experience helper's behavior.
  46707. */
  46708. export interface VRExperienceHelperOptions extends WebVROptions {
  46709. /**
  46710. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46711. */
  46712. createDeviceOrientationCamera?: boolean;
  46713. /**
  46714. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46715. */
  46716. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46717. /**
  46718. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46719. */
  46720. laserToggle?: boolean;
  46721. /**
  46722. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46723. */
  46724. floorMeshes?: Mesh[];
  46725. /**
  46726. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46727. */
  46728. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46729. /**
  46730. * Defines if WebXR should be used instead of WebVR (if available)
  46731. */
  46732. useXR?: boolean;
  46733. }
  46734. /**
  46735. * Event containing information after VR has been entered
  46736. */
  46737. export class OnAfterEnteringVRObservableEvent {
  46738. /**
  46739. * If entering vr was successful
  46740. */
  46741. success: boolean;
  46742. }
  46743. /**
  46744. * Helps to quickly add VR support to an existing scene.
  46745. * See http://doc.babylonjs.com/how_to/webvr_helper
  46746. */
  46747. export class VRExperienceHelper {
  46748. /** Options to modify the vr experience helper's behavior. */
  46749. webVROptions: VRExperienceHelperOptions;
  46750. private _scene;
  46751. private _position;
  46752. private _btnVR;
  46753. private _btnVRDisplayed;
  46754. private _webVRsupported;
  46755. private _webVRready;
  46756. private _webVRrequesting;
  46757. private _webVRpresenting;
  46758. private _hasEnteredVR;
  46759. private _fullscreenVRpresenting;
  46760. private _inputElement;
  46761. private _webVRCamera;
  46762. private _vrDeviceOrientationCamera;
  46763. private _deviceOrientationCamera;
  46764. private _existingCamera;
  46765. private _onKeyDown;
  46766. private _onVrDisplayPresentChange;
  46767. private _onVRDisplayChanged;
  46768. private _onVRRequestPresentStart;
  46769. private _onVRRequestPresentComplete;
  46770. /**
  46771. * 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)
  46772. */
  46773. enableGazeEvenWhenNoPointerLock: boolean;
  46774. /**
  46775. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46776. */
  46777. exitVROnDoubleTap: boolean;
  46778. /**
  46779. * Observable raised right before entering VR.
  46780. */
  46781. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46782. /**
  46783. * Observable raised when entering VR has completed.
  46784. */
  46785. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46786. /**
  46787. * Observable raised when exiting VR.
  46788. */
  46789. onExitingVRObservable: Observable<VRExperienceHelper>;
  46790. /**
  46791. * Observable raised when controller mesh is loaded.
  46792. */
  46793. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46794. /** Return this.onEnteringVRObservable
  46795. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46796. */
  46797. get onEnteringVR(): Observable<VRExperienceHelper>;
  46798. /** Return this.onExitingVRObservable
  46799. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46800. */
  46801. get onExitingVR(): Observable<VRExperienceHelper>;
  46802. /** Return this.onControllerMeshLoadedObservable
  46803. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46804. */
  46805. get onControllerMeshLoaded(): Observable<WebVRController>;
  46806. private _rayLength;
  46807. private _useCustomVRButton;
  46808. private _teleportationRequested;
  46809. private _teleportActive;
  46810. private _floorMeshName;
  46811. private _floorMeshesCollection;
  46812. private _teleportationMode;
  46813. private _teleportationTime;
  46814. private _teleportationSpeed;
  46815. private _teleportationEasing;
  46816. private _rotationAllowed;
  46817. private _teleportBackwardsVector;
  46818. private _teleportationTarget;
  46819. private _isDefaultTeleportationTarget;
  46820. private _postProcessMove;
  46821. private _teleportationFillColor;
  46822. private _teleportationBorderColor;
  46823. private _rotationAngle;
  46824. private _haloCenter;
  46825. private _cameraGazer;
  46826. private _padSensibilityUp;
  46827. private _padSensibilityDown;
  46828. private _leftController;
  46829. private _rightController;
  46830. private _gazeColor;
  46831. private _laserColor;
  46832. private _pickedLaserColor;
  46833. private _pickedGazeColor;
  46834. /**
  46835. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46836. */
  46837. onNewMeshSelected: Observable<AbstractMesh>;
  46838. /**
  46839. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46840. * This observable will provide the mesh and the controller used to select the mesh
  46841. */
  46842. onMeshSelectedWithController: Observable<{
  46843. mesh: AbstractMesh;
  46844. controller: WebVRController;
  46845. }>;
  46846. /**
  46847. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46848. */
  46849. onNewMeshPicked: Observable<PickingInfo>;
  46850. private _circleEase;
  46851. /**
  46852. * Observable raised before camera teleportation
  46853. */
  46854. onBeforeCameraTeleport: Observable<Vector3>;
  46855. /**
  46856. * Observable raised after camera teleportation
  46857. */
  46858. onAfterCameraTeleport: Observable<Vector3>;
  46859. /**
  46860. * Observable raised when current selected mesh gets unselected
  46861. */
  46862. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46863. private _raySelectionPredicate;
  46864. /**
  46865. * To be optionaly changed by user to define custom ray selection
  46866. */
  46867. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46868. /**
  46869. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46870. */
  46871. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46872. /**
  46873. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46874. */
  46875. teleportationEnabled: boolean;
  46876. private _defaultHeight;
  46877. private _teleportationInitialized;
  46878. private _interactionsEnabled;
  46879. private _interactionsRequested;
  46880. private _displayGaze;
  46881. private _displayLaserPointer;
  46882. /**
  46883. * The mesh used to display where the user is going to teleport.
  46884. */
  46885. get teleportationTarget(): Mesh;
  46886. /**
  46887. * Sets the mesh to be used to display where the user is going to teleport.
  46888. */
  46889. set teleportationTarget(value: Mesh);
  46890. /**
  46891. * 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
  46892. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46893. * See http://doc.babylonjs.com/resources/baking_transformations
  46894. */
  46895. get gazeTrackerMesh(): Mesh;
  46896. set gazeTrackerMesh(value: Mesh);
  46897. /**
  46898. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46899. */
  46900. updateGazeTrackerScale: boolean;
  46901. /**
  46902. * If the gaze trackers color should be updated when selecting meshes
  46903. */
  46904. updateGazeTrackerColor: boolean;
  46905. /**
  46906. * If the controller laser color should be updated when selecting meshes
  46907. */
  46908. updateControllerLaserColor: boolean;
  46909. /**
  46910. * The gaze tracking mesh corresponding to the left controller
  46911. */
  46912. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46913. /**
  46914. * The gaze tracking mesh corresponding to the right controller
  46915. */
  46916. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46917. /**
  46918. * If the ray of the gaze should be displayed.
  46919. */
  46920. get displayGaze(): boolean;
  46921. /**
  46922. * Sets if the ray of the gaze should be displayed.
  46923. */
  46924. set displayGaze(value: boolean);
  46925. /**
  46926. * If the ray of the LaserPointer should be displayed.
  46927. */
  46928. get displayLaserPointer(): boolean;
  46929. /**
  46930. * Sets if the ray of the LaserPointer should be displayed.
  46931. */
  46932. set displayLaserPointer(value: boolean);
  46933. /**
  46934. * The deviceOrientationCamera used as the camera when not in VR.
  46935. */
  46936. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46937. /**
  46938. * Based on the current WebVR support, returns the current VR camera used.
  46939. */
  46940. get currentVRCamera(): Nullable<Camera>;
  46941. /**
  46942. * The webVRCamera which is used when in VR.
  46943. */
  46944. get webVRCamera(): WebVRFreeCamera;
  46945. /**
  46946. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46947. */
  46948. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46949. /**
  46950. * The html button that is used to trigger entering into VR.
  46951. */
  46952. get vrButton(): Nullable<HTMLButtonElement>;
  46953. private get _teleportationRequestInitiated();
  46954. /**
  46955. * Defines whether or not Pointer lock should be requested when switching to
  46956. * full screen.
  46957. */
  46958. requestPointerLockOnFullScreen: boolean;
  46959. /**
  46960. * If asking to force XR, this will be populated with the default xr experience
  46961. */
  46962. xr: WebXRDefaultExperience;
  46963. /**
  46964. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46965. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46966. */
  46967. xrTestDone: boolean;
  46968. /**
  46969. * Instantiates a VRExperienceHelper.
  46970. * Helps to quickly add VR support to an existing scene.
  46971. * @param scene The scene the VRExperienceHelper belongs to.
  46972. * @param webVROptions Options to modify the vr experience helper's behavior.
  46973. */
  46974. constructor(scene: Scene,
  46975. /** Options to modify the vr experience helper's behavior. */
  46976. webVROptions?: VRExperienceHelperOptions);
  46977. private completeVRInit;
  46978. private _onDefaultMeshLoaded;
  46979. private _onResize;
  46980. private _onFullscreenChange;
  46981. /**
  46982. * Gets a value indicating if we are currently in VR mode.
  46983. */
  46984. get isInVRMode(): boolean;
  46985. private onVrDisplayPresentChange;
  46986. private onVRDisplayChanged;
  46987. private moveButtonToBottomRight;
  46988. private displayVRButton;
  46989. private updateButtonVisibility;
  46990. private _cachedAngularSensibility;
  46991. /**
  46992. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46993. * Otherwise, will use the fullscreen API.
  46994. */
  46995. enterVR(): void;
  46996. /**
  46997. * Attempt to exit VR, or fullscreen.
  46998. */
  46999. exitVR(): void;
  47000. /**
  47001. * The position of the vr experience helper.
  47002. */
  47003. get position(): Vector3;
  47004. /**
  47005. * Sets the position of the vr experience helper.
  47006. */
  47007. set position(value: Vector3);
  47008. /**
  47009. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47010. */
  47011. enableInteractions(): void;
  47012. private get _noControllerIsActive();
  47013. private beforeRender;
  47014. private _isTeleportationFloor;
  47015. /**
  47016. * Adds a floor mesh to be used for teleportation.
  47017. * @param floorMesh the mesh to be used for teleportation.
  47018. */
  47019. addFloorMesh(floorMesh: Mesh): void;
  47020. /**
  47021. * Removes a floor mesh from being used for teleportation.
  47022. * @param floorMesh the mesh to be removed.
  47023. */
  47024. removeFloorMesh(floorMesh: Mesh): void;
  47025. /**
  47026. * Enables interactions and teleportation using the VR controllers and gaze.
  47027. * @param vrTeleportationOptions options to modify teleportation behavior.
  47028. */
  47029. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47030. private _onNewGamepadConnected;
  47031. private _tryEnableInteractionOnController;
  47032. private _onNewGamepadDisconnected;
  47033. private _enableInteractionOnController;
  47034. private _checkTeleportWithRay;
  47035. private _checkRotate;
  47036. private _checkTeleportBackwards;
  47037. private _enableTeleportationOnController;
  47038. private _createTeleportationCircles;
  47039. private _displayTeleportationTarget;
  47040. private _hideTeleportationTarget;
  47041. private _rotateCamera;
  47042. private _moveTeleportationSelectorTo;
  47043. private _workingVector;
  47044. private _workingQuaternion;
  47045. private _workingMatrix;
  47046. /**
  47047. * Time Constant Teleportation Mode
  47048. */
  47049. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47050. /**
  47051. * Speed Constant Teleportation Mode
  47052. */
  47053. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47054. /**
  47055. * Teleports the users feet to the desired location
  47056. * @param location The location where the user's feet should be placed
  47057. */
  47058. teleportCamera(location: Vector3): void;
  47059. private _convertNormalToDirectionOfRay;
  47060. private _castRayAndSelectObject;
  47061. private _notifySelectedMeshUnselected;
  47062. /**
  47063. * Permanently set new colors for the laser pointer
  47064. * @param color the new laser color
  47065. * @param pickedColor the new laser color when picked mesh detected
  47066. */
  47067. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47068. /**
  47069. * Set lighting enabled / disabled on the laser pointer of both controllers
  47070. * @param enabled should the lighting be enabled on the laser pointer
  47071. */
  47072. setLaserLightingState(enabled?: boolean): void;
  47073. /**
  47074. * Permanently set new colors for the gaze pointer
  47075. * @param color the new gaze color
  47076. * @param pickedColor the new gaze color when picked mesh detected
  47077. */
  47078. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47079. /**
  47080. * Sets the color of the laser ray from the vr controllers.
  47081. * @param color new color for the ray.
  47082. */
  47083. changeLaserColor(color: Color3): void;
  47084. /**
  47085. * Sets the color of the ray from the vr headsets gaze.
  47086. * @param color new color for the ray.
  47087. */
  47088. changeGazeColor(color: Color3): void;
  47089. /**
  47090. * Exits VR and disposes of the vr experience helper
  47091. */
  47092. dispose(): void;
  47093. /**
  47094. * Gets the name of the VRExperienceHelper class
  47095. * @returns "VRExperienceHelper"
  47096. */
  47097. getClassName(): string;
  47098. }
  47099. }
  47100. declare module "babylonjs/Cameras/VR/index" {
  47101. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47102. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47103. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47104. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47105. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47106. export * from "babylonjs/Cameras/VR/webVRCamera";
  47107. }
  47108. declare module "babylonjs/Cameras/RigModes/index" {
  47109. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47110. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47111. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47112. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47113. }
  47114. declare module "babylonjs/Cameras/index" {
  47115. export * from "babylonjs/Cameras/Inputs/index";
  47116. export * from "babylonjs/Cameras/cameraInputsManager";
  47117. export * from "babylonjs/Cameras/camera";
  47118. export * from "babylonjs/Cameras/targetCamera";
  47119. export * from "babylonjs/Cameras/freeCamera";
  47120. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47121. export * from "babylonjs/Cameras/touchCamera";
  47122. export * from "babylonjs/Cameras/arcRotateCamera";
  47123. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47124. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47125. export * from "babylonjs/Cameras/flyCamera";
  47126. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47127. export * from "babylonjs/Cameras/followCamera";
  47128. export * from "babylonjs/Cameras/followCameraInputsManager";
  47129. export * from "babylonjs/Cameras/gamepadCamera";
  47130. export * from "babylonjs/Cameras/Stereoscopic/index";
  47131. export * from "babylonjs/Cameras/universalCamera";
  47132. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47133. export * from "babylonjs/Cameras/VR/index";
  47134. export * from "babylonjs/Cameras/RigModes/index";
  47135. }
  47136. declare module "babylonjs/Collisions/index" {
  47137. export * from "babylonjs/Collisions/collider";
  47138. export * from "babylonjs/Collisions/collisionCoordinator";
  47139. export * from "babylonjs/Collisions/pickingInfo";
  47140. export * from "babylonjs/Collisions/intersectionInfo";
  47141. export * from "babylonjs/Collisions/meshCollisionData";
  47142. }
  47143. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47144. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47145. import { Vector3 } from "babylonjs/Maths/math.vector";
  47146. import { Ray } from "babylonjs/Culling/ray";
  47147. import { Plane } from "babylonjs/Maths/math.plane";
  47148. /**
  47149. * Contains an array of blocks representing the octree
  47150. */
  47151. export interface IOctreeContainer<T> {
  47152. /**
  47153. * Blocks within the octree
  47154. */
  47155. blocks: Array<OctreeBlock<T>>;
  47156. }
  47157. /**
  47158. * Class used to store a cell in an octree
  47159. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47160. */
  47161. export class OctreeBlock<T> {
  47162. /**
  47163. * Gets the content of the current block
  47164. */
  47165. entries: T[];
  47166. /**
  47167. * Gets the list of block children
  47168. */
  47169. blocks: Array<OctreeBlock<T>>;
  47170. private _depth;
  47171. private _maxDepth;
  47172. private _capacity;
  47173. private _minPoint;
  47174. private _maxPoint;
  47175. private _boundingVectors;
  47176. private _creationFunc;
  47177. /**
  47178. * Creates a new block
  47179. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47180. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47181. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47182. * @param depth defines the current depth of this block in the octree
  47183. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47184. * @param creationFunc defines a callback to call when an element is added to the block
  47185. */
  47186. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47187. /**
  47188. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47189. */
  47190. get capacity(): number;
  47191. /**
  47192. * Gets the minimum vector (in world space) of the block's bounding box
  47193. */
  47194. get minPoint(): Vector3;
  47195. /**
  47196. * Gets the maximum vector (in world space) of the block's bounding box
  47197. */
  47198. get maxPoint(): Vector3;
  47199. /**
  47200. * Add a new element to this block
  47201. * @param entry defines the element to add
  47202. */
  47203. addEntry(entry: T): void;
  47204. /**
  47205. * Remove an element from this block
  47206. * @param entry defines the element to remove
  47207. */
  47208. removeEntry(entry: T): void;
  47209. /**
  47210. * Add an array of elements to this block
  47211. * @param entries defines the array of elements to add
  47212. */
  47213. addEntries(entries: T[]): void;
  47214. /**
  47215. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47216. * @param frustumPlanes defines the frustum planes to test
  47217. * @param selection defines the array to store current content if selection is positive
  47218. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47219. */
  47220. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47221. /**
  47222. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47223. * @param sphereCenter defines the bounding sphere center
  47224. * @param sphereRadius defines the bounding sphere radius
  47225. * @param selection defines the array to store current content if selection is positive
  47226. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47227. */
  47228. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47229. /**
  47230. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47231. * @param ray defines the ray to test with
  47232. * @param selection defines the array to store current content if selection is positive
  47233. */
  47234. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47235. /**
  47236. * Subdivide the content into child blocks (this block will then be empty)
  47237. */
  47238. createInnerBlocks(): void;
  47239. /**
  47240. * @hidden
  47241. */
  47242. 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;
  47243. }
  47244. }
  47245. declare module "babylonjs/Culling/Octrees/octree" {
  47246. import { SmartArray } from "babylonjs/Misc/smartArray";
  47247. import { Vector3 } from "babylonjs/Maths/math.vector";
  47248. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47250. import { Ray } from "babylonjs/Culling/ray";
  47251. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47252. import { Plane } from "babylonjs/Maths/math.plane";
  47253. /**
  47254. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47255. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47256. */
  47257. export class Octree<T> {
  47258. /** 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.) */
  47259. maxDepth: number;
  47260. /**
  47261. * Blocks within the octree containing objects
  47262. */
  47263. blocks: Array<OctreeBlock<T>>;
  47264. /**
  47265. * Content stored in the octree
  47266. */
  47267. dynamicContent: T[];
  47268. private _maxBlockCapacity;
  47269. private _selectionContent;
  47270. private _creationFunc;
  47271. /**
  47272. * Creates a octree
  47273. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47274. * @param creationFunc function to be used to instatiate the octree
  47275. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47276. * @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.)
  47277. */
  47278. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47279. /** 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.) */
  47280. maxDepth?: number);
  47281. /**
  47282. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47283. * @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);
  47284. * @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);
  47285. * @param entries meshes to be added to the octree blocks
  47286. */
  47287. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47288. /**
  47289. * Adds a mesh to the octree
  47290. * @param entry Mesh to add to the octree
  47291. */
  47292. addMesh(entry: T): void;
  47293. /**
  47294. * Remove an element from the octree
  47295. * @param entry defines the element to remove
  47296. */
  47297. removeMesh(entry: T): void;
  47298. /**
  47299. * Selects an array of meshes within the frustum
  47300. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47301. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47302. * @returns array of meshes within the frustum
  47303. */
  47304. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47305. /**
  47306. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47307. * @param sphereCenter defines the bounding sphere center
  47308. * @param sphereRadius defines the bounding sphere radius
  47309. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47310. * @returns an array of objects that intersect the sphere
  47311. */
  47312. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47313. /**
  47314. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47315. * @param ray defines the ray to test with
  47316. * @returns array of intersected objects
  47317. */
  47318. intersectsRay(ray: Ray): SmartArray<T>;
  47319. /**
  47320. * Adds a mesh into the octree block if it intersects the block
  47321. */
  47322. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47323. /**
  47324. * Adds a submesh into the octree block if it intersects the block
  47325. */
  47326. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47327. }
  47328. }
  47329. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47330. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47331. import { Scene } from "babylonjs/scene";
  47332. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47334. import { Ray } from "babylonjs/Culling/ray";
  47335. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47336. import { Collider } from "babylonjs/Collisions/collider";
  47337. module "babylonjs/scene" {
  47338. interface Scene {
  47339. /**
  47340. * @hidden
  47341. * Backing Filed
  47342. */
  47343. _selectionOctree: Octree<AbstractMesh>;
  47344. /**
  47345. * Gets the octree used to boost mesh selection (picking)
  47346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47347. */
  47348. selectionOctree: Octree<AbstractMesh>;
  47349. /**
  47350. * Creates or updates the octree used to boost selection (picking)
  47351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47352. * @param maxCapacity defines the maximum capacity per leaf
  47353. * @param maxDepth defines the maximum depth of the octree
  47354. * @returns an octree of AbstractMesh
  47355. */
  47356. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47357. }
  47358. }
  47359. module "babylonjs/Meshes/abstractMesh" {
  47360. interface AbstractMesh {
  47361. /**
  47362. * @hidden
  47363. * Backing Field
  47364. */
  47365. _submeshesOctree: Octree<SubMesh>;
  47366. /**
  47367. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47368. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47369. * @param maxCapacity defines the maximum size of each block (64 by default)
  47370. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47371. * @returns the new octree
  47372. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47374. */
  47375. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47376. }
  47377. }
  47378. /**
  47379. * Defines the octree scene component responsible to manage any octrees
  47380. * in a given scene.
  47381. */
  47382. export class OctreeSceneComponent {
  47383. /**
  47384. * The component name help to identify the component in the list of scene components.
  47385. */
  47386. readonly name: string;
  47387. /**
  47388. * The scene the component belongs to.
  47389. */
  47390. scene: Scene;
  47391. /**
  47392. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47393. */
  47394. readonly checksIsEnabled: boolean;
  47395. /**
  47396. * Creates a new instance of the component for the given scene
  47397. * @param scene Defines the scene to register the component in
  47398. */
  47399. constructor(scene: Scene);
  47400. /**
  47401. * Registers the component in a given scene
  47402. */
  47403. register(): void;
  47404. /**
  47405. * Return the list of active meshes
  47406. * @returns the list of active meshes
  47407. */
  47408. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47409. /**
  47410. * Return the list of active sub meshes
  47411. * @param mesh The mesh to get the candidates sub meshes from
  47412. * @returns the list of active sub meshes
  47413. */
  47414. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47415. private _tempRay;
  47416. /**
  47417. * Return the list of sub meshes intersecting with a given local ray
  47418. * @param mesh defines the mesh to find the submesh for
  47419. * @param localRay defines the ray in local space
  47420. * @returns the list of intersecting sub meshes
  47421. */
  47422. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47423. /**
  47424. * Return the list of sub meshes colliding with a collider
  47425. * @param mesh defines the mesh to find the submesh for
  47426. * @param collider defines the collider to evaluate the collision against
  47427. * @returns the list of colliding sub meshes
  47428. */
  47429. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47430. /**
  47431. * Rebuilds the elements related to this component in case of
  47432. * context lost for instance.
  47433. */
  47434. rebuild(): void;
  47435. /**
  47436. * Disposes the component and the associated ressources.
  47437. */
  47438. dispose(): void;
  47439. }
  47440. }
  47441. declare module "babylonjs/Culling/Octrees/index" {
  47442. export * from "babylonjs/Culling/Octrees/octree";
  47443. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47444. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47445. }
  47446. declare module "babylonjs/Culling/index" {
  47447. export * from "babylonjs/Culling/boundingBox";
  47448. export * from "babylonjs/Culling/boundingInfo";
  47449. export * from "babylonjs/Culling/boundingSphere";
  47450. export * from "babylonjs/Culling/Octrees/index";
  47451. export * from "babylonjs/Culling/ray";
  47452. }
  47453. declare module "babylonjs/Gizmos/gizmo" {
  47454. import { Nullable } from "babylonjs/types";
  47455. import { IDisposable } from "babylonjs/scene";
  47456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47457. import { Mesh } from "babylonjs/Meshes/mesh";
  47458. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47459. /**
  47460. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47461. */
  47462. export class Gizmo implements IDisposable {
  47463. /** The utility layer the gizmo will be added to */
  47464. gizmoLayer: UtilityLayerRenderer;
  47465. /**
  47466. * The root mesh of the gizmo
  47467. */
  47468. _rootMesh: Mesh;
  47469. private _attachedMesh;
  47470. /**
  47471. * Ratio for the scale of the gizmo (Default: 1)
  47472. */
  47473. scaleRatio: number;
  47474. /**
  47475. * If a custom mesh has been set (Default: false)
  47476. */
  47477. protected _customMeshSet: boolean;
  47478. /**
  47479. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47480. * * When set, interactions will be enabled
  47481. */
  47482. get attachedMesh(): Nullable<AbstractMesh>;
  47483. set attachedMesh(value: Nullable<AbstractMesh>);
  47484. /**
  47485. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47486. * @param mesh The mesh to replace the default mesh of the gizmo
  47487. */
  47488. setCustomMesh(mesh: Mesh): void;
  47489. /**
  47490. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47491. */
  47492. updateGizmoRotationToMatchAttachedMesh: boolean;
  47493. /**
  47494. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47495. */
  47496. updateGizmoPositionToMatchAttachedMesh: boolean;
  47497. /**
  47498. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47499. */
  47500. updateScale: boolean;
  47501. protected _interactionsEnabled: boolean;
  47502. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47503. private _beforeRenderObserver;
  47504. private _tempVector;
  47505. /**
  47506. * Creates a gizmo
  47507. * @param gizmoLayer The utility layer the gizmo will be added to
  47508. */
  47509. constructor(
  47510. /** The utility layer the gizmo will be added to */
  47511. gizmoLayer?: UtilityLayerRenderer);
  47512. /**
  47513. * Updates the gizmo to match the attached mesh's position/rotation
  47514. */
  47515. protected _update(): void;
  47516. /**
  47517. * Disposes of the gizmo
  47518. */
  47519. dispose(): void;
  47520. }
  47521. }
  47522. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47523. import { Observable } from "babylonjs/Misc/observable";
  47524. import { Nullable } from "babylonjs/types";
  47525. import { Vector3 } from "babylonjs/Maths/math.vector";
  47526. import { Color3 } from "babylonjs/Maths/math.color";
  47527. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47529. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47530. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47531. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47532. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47533. import { Scene } from "babylonjs/scene";
  47534. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47535. /**
  47536. * Single plane drag gizmo
  47537. */
  47538. export class PlaneDragGizmo extends Gizmo {
  47539. /**
  47540. * Drag behavior responsible for the gizmos dragging interactions
  47541. */
  47542. dragBehavior: PointerDragBehavior;
  47543. private _pointerObserver;
  47544. /**
  47545. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47546. */
  47547. snapDistance: number;
  47548. /**
  47549. * Event that fires each time the gizmo snaps to a new location.
  47550. * * snapDistance is the the change in distance
  47551. */
  47552. onSnapObservable: Observable<{
  47553. snapDistance: number;
  47554. }>;
  47555. private _plane;
  47556. private _coloredMaterial;
  47557. private _hoverMaterial;
  47558. private _isEnabled;
  47559. private _parent;
  47560. /** @hidden */
  47561. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47562. /** @hidden */
  47563. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47564. /**
  47565. * Creates a PlaneDragGizmo
  47566. * @param gizmoLayer The utility layer the gizmo will be added to
  47567. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47568. * @param color The color of the gizmo
  47569. */
  47570. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47571. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47572. /**
  47573. * If the gizmo is enabled
  47574. */
  47575. set isEnabled(value: boolean);
  47576. get isEnabled(): boolean;
  47577. /**
  47578. * Disposes of the gizmo
  47579. */
  47580. dispose(): void;
  47581. }
  47582. }
  47583. declare module "babylonjs/Gizmos/positionGizmo" {
  47584. import { Observable } from "babylonjs/Misc/observable";
  47585. import { Nullable } from "babylonjs/types";
  47586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47587. import { Mesh } from "babylonjs/Meshes/mesh";
  47588. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47589. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47590. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47591. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47592. /**
  47593. * Gizmo that enables dragging a mesh along 3 axis
  47594. */
  47595. export class PositionGizmo extends Gizmo {
  47596. /**
  47597. * Internal gizmo used for interactions on the x axis
  47598. */
  47599. xGizmo: AxisDragGizmo;
  47600. /**
  47601. * Internal gizmo used for interactions on the y axis
  47602. */
  47603. yGizmo: AxisDragGizmo;
  47604. /**
  47605. * Internal gizmo used for interactions on the z axis
  47606. */
  47607. zGizmo: AxisDragGizmo;
  47608. /**
  47609. * Internal gizmo used for interactions on the yz plane
  47610. */
  47611. xPlaneGizmo: PlaneDragGizmo;
  47612. /**
  47613. * Internal gizmo used for interactions on the xz plane
  47614. */
  47615. yPlaneGizmo: PlaneDragGizmo;
  47616. /**
  47617. * Internal gizmo used for interactions on the xy plane
  47618. */
  47619. zPlaneGizmo: PlaneDragGizmo;
  47620. /**
  47621. * private variables
  47622. */
  47623. private _meshAttached;
  47624. private _updateGizmoRotationToMatchAttachedMesh;
  47625. private _snapDistance;
  47626. private _scaleRatio;
  47627. /** Fires an event when any of it's sub gizmos are dragged */
  47628. onDragStartObservable: Observable<unknown>;
  47629. /** Fires an event when any of it's sub gizmos are released from dragging */
  47630. onDragEndObservable: Observable<unknown>;
  47631. /**
  47632. * If set to true, planar drag is enabled
  47633. */
  47634. private _planarGizmoEnabled;
  47635. get attachedMesh(): Nullable<AbstractMesh>;
  47636. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47637. /**
  47638. * Creates a PositionGizmo
  47639. * @param gizmoLayer The utility layer the gizmo will be added to
  47640. */
  47641. constructor(gizmoLayer?: UtilityLayerRenderer);
  47642. /**
  47643. * If the planar drag gizmo is enabled
  47644. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47645. */
  47646. set planarGizmoEnabled(value: boolean);
  47647. get planarGizmoEnabled(): boolean;
  47648. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47649. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47650. /**
  47651. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47652. */
  47653. set snapDistance(value: number);
  47654. get snapDistance(): number;
  47655. /**
  47656. * Ratio for the scale of the gizmo (Default: 1)
  47657. */
  47658. set scaleRatio(value: number);
  47659. get scaleRatio(): number;
  47660. /**
  47661. * Disposes of the gizmo
  47662. */
  47663. dispose(): void;
  47664. /**
  47665. * CustomMeshes are not supported by this gizmo
  47666. * @param mesh The mesh to replace the default mesh of the gizmo
  47667. */
  47668. setCustomMesh(mesh: Mesh): void;
  47669. }
  47670. }
  47671. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47672. import { Observable } from "babylonjs/Misc/observable";
  47673. import { Nullable } from "babylonjs/types";
  47674. import { Vector3 } from "babylonjs/Maths/math.vector";
  47675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47677. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47678. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47679. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47680. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47681. import { Scene } from "babylonjs/scene";
  47682. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47683. import { Color3 } from "babylonjs/Maths/math.color";
  47684. /**
  47685. * Single axis drag gizmo
  47686. */
  47687. export class AxisDragGizmo extends Gizmo {
  47688. /**
  47689. * Drag behavior responsible for the gizmos dragging interactions
  47690. */
  47691. dragBehavior: PointerDragBehavior;
  47692. private _pointerObserver;
  47693. /**
  47694. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47695. */
  47696. snapDistance: number;
  47697. /**
  47698. * Event that fires each time the gizmo snaps to a new location.
  47699. * * snapDistance is the the change in distance
  47700. */
  47701. onSnapObservable: Observable<{
  47702. snapDistance: number;
  47703. }>;
  47704. private _isEnabled;
  47705. private _parent;
  47706. private _arrow;
  47707. private _coloredMaterial;
  47708. private _hoverMaterial;
  47709. /** @hidden */
  47710. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47711. /** @hidden */
  47712. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47713. /**
  47714. * Creates an AxisDragGizmo
  47715. * @param gizmoLayer The utility layer the gizmo will be added to
  47716. * @param dragAxis The axis which the gizmo will be able to drag on
  47717. * @param color The color of the gizmo
  47718. */
  47719. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47720. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47721. /**
  47722. * If the gizmo is enabled
  47723. */
  47724. set isEnabled(value: boolean);
  47725. get isEnabled(): boolean;
  47726. /**
  47727. * Disposes of the gizmo
  47728. */
  47729. dispose(): void;
  47730. }
  47731. }
  47732. declare module "babylonjs/Debug/axesViewer" {
  47733. import { Vector3 } from "babylonjs/Maths/math.vector";
  47734. import { Nullable } from "babylonjs/types";
  47735. import { Scene } from "babylonjs/scene";
  47736. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47737. /**
  47738. * The Axes viewer will show 3 axes in a specific point in space
  47739. */
  47740. export class AxesViewer {
  47741. private _xAxis;
  47742. private _yAxis;
  47743. private _zAxis;
  47744. private _scaleLinesFactor;
  47745. private _instanced;
  47746. /**
  47747. * Gets the hosting scene
  47748. */
  47749. scene: Scene;
  47750. /**
  47751. * Gets or sets a number used to scale line length
  47752. */
  47753. scaleLines: number;
  47754. /** Gets the node hierarchy used to render x-axis */
  47755. get xAxis(): TransformNode;
  47756. /** Gets the node hierarchy used to render y-axis */
  47757. get yAxis(): TransformNode;
  47758. /** Gets the node hierarchy used to render z-axis */
  47759. get zAxis(): TransformNode;
  47760. /**
  47761. * Creates a new AxesViewer
  47762. * @param scene defines the hosting scene
  47763. * @param scaleLines defines a number used to scale line length (1 by default)
  47764. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47765. * @param xAxis defines the node hierarchy used to render the x-axis
  47766. * @param yAxis defines the node hierarchy used to render the y-axis
  47767. * @param zAxis defines the node hierarchy used to render the z-axis
  47768. */
  47769. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47770. /**
  47771. * Force the viewer to update
  47772. * @param position defines the position of the viewer
  47773. * @param xaxis defines the x axis of the viewer
  47774. * @param yaxis defines the y axis of the viewer
  47775. * @param zaxis defines the z axis of the viewer
  47776. */
  47777. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47778. /**
  47779. * Creates an instance of this axes viewer.
  47780. * @returns a new axes viewer with instanced meshes
  47781. */
  47782. createInstance(): AxesViewer;
  47783. /** Releases resources */
  47784. dispose(): void;
  47785. private static _SetRenderingGroupId;
  47786. }
  47787. }
  47788. declare module "babylonjs/Debug/boneAxesViewer" {
  47789. import { Nullable } from "babylonjs/types";
  47790. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47791. import { Vector3 } from "babylonjs/Maths/math.vector";
  47792. import { Mesh } from "babylonjs/Meshes/mesh";
  47793. import { Bone } from "babylonjs/Bones/bone";
  47794. import { Scene } from "babylonjs/scene";
  47795. /**
  47796. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47797. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47798. */
  47799. export class BoneAxesViewer extends AxesViewer {
  47800. /**
  47801. * Gets or sets the target mesh where to display the axes viewer
  47802. */
  47803. mesh: Nullable<Mesh>;
  47804. /**
  47805. * Gets or sets the target bone where to display the axes viewer
  47806. */
  47807. bone: Nullable<Bone>;
  47808. /** Gets current position */
  47809. pos: Vector3;
  47810. /** Gets direction of X axis */
  47811. xaxis: Vector3;
  47812. /** Gets direction of Y axis */
  47813. yaxis: Vector3;
  47814. /** Gets direction of Z axis */
  47815. zaxis: Vector3;
  47816. /**
  47817. * Creates a new BoneAxesViewer
  47818. * @param scene defines the hosting scene
  47819. * @param bone defines the target bone
  47820. * @param mesh defines the target mesh
  47821. * @param scaleLines defines a scaling factor for line length (1 by default)
  47822. */
  47823. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47824. /**
  47825. * Force the viewer to update
  47826. */
  47827. update(): void;
  47828. /** Releases resources */
  47829. dispose(): void;
  47830. }
  47831. }
  47832. declare module "babylonjs/Debug/debugLayer" {
  47833. import { Scene } from "babylonjs/scene";
  47834. /**
  47835. * Interface used to define scene explorer extensibility option
  47836. */
  47837. export interface IExplorerExtensibilityOption {
  47838. /**
  47839. * Define the option label
  47840. */
  47841. label: string;
  47842. /**
  47843. * Defines the action to execute on click
  47844. */
  47845. action: (entity: any) => void;
  47846. }
  47847. /**
  47848. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47849. */
  47850. export interface IExplorerExtensibilityGroup {
  47851. /**
  47852. * Defines a predicate to test if a given type mut be extended
  47853. */
  47854. predicate: (entity: any) => boolean;
  47855. /**
  47856. * Gets the list of options added to a type
  47857. */
  47858. entries: IExplorerExtensibilityOption[];
  47859. }
  47860. /**
  47861. * Interface used to define the options to use to create the Inspector
  47862. */
  47863. export interface IInspectorOptions {
  47864. /**
  47865. * Display in overlay mode (default: false)
  47866. */
  47867. overlay?: boolean;
  47868. /**
  47869. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47870. */
  47871. globalRoot?: HTMLElement;
  47872. /**
  47873. * Display the Scene explorer
  47874. */
  47875. showExplorer?: boolean;
  47876. /**
  47877. * Display the property inspector
  47878. */
  47879. showInspector?: boolean;
  47880. /**
  47881. * Display in embed mode (both panes on the right)
  47882. */
  47883. embedMode?: boolean;
  47884. /**
  47885. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47886. */
  47887. handleResize?: boolean;
  47888. /**
  47889. * Allow the panes to popup (default: true)
  47890. */
  47891. enablePopup?: boolean;
  47892. /**
  47893. * Allow the panes to be closed by users (default: true)
  47894. */
  47895. enableClose?: boolean;
  47896. /**
  47897. * Optional list of extensibility entries
  47898. */
  47899. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47900. /**
  47901. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47902. */
  47903. inspectorURL?: string;
  47904. /**
  47905. * Optional initial tab (default to DebugLayerTab.Properties)
  47906. */
  47907. initialTab?: DebugLayerTab;
  47908. }
  47909. module "babylonjs/scene" {
  47910. interface Scene {
  47911. /**
  47912. * @hidden
  47913. * Backing field
  47914. */
  47915. _debugLayer: DebugLayer;
  47916. /**
  47917. * Gets the debug layer (aka Inspector) associated with the scene
  47918. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47919. */
  47920. debugLayer: DebugLayer;
  47921. }
  47922. }
  47923. /**
  47924. * Enum of inspector action tab
  47925. */
  47926. export enum DebugLayerTab {
  47927. /**
  47928. * Properties tag (default)
  47929. */
  47930. Properties = 0,
  47931. /**
  47932. * Debug tab
  47933. */
  47934. Debug = 1,
  47935. /**
  47936. * Statistics tab
  47937. */
  47938. Statistics = 2,
  47939. /**
  47940. * Tools tab
  47941. */
  47942. Tools = 3,
  47943. /**
  47944. * Settings tab
  47945. */
  47946. Settings = 4
  47947. }
  47948. /**
  47949. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47950. * what is happening in your scene
  47951. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47952. */
  47953. export class DebugLayer {
  47954. /**
  47955. * Define the url to get the inspector script from.
  47956. * By default it uses the babylonjs CDN.
  47957. * @ignoreNaming
  47958. */
  47959. static InspectorURL: string;
  47960. private _scene;
  47961. private BJSINSPECTOR;
  47962. private _onPropertyChangedObservable?;
  47963. /**
  47964. * Observable triggered when a property is changed through the inspector.
  47965. */
  47966. get onPropertyChangedObservable(): any;
  47967. /**
  47968. * Instantiates a new debug layer.
  47969. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47970. * what is happening in your scene
  47971. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47972. * @param scene Defines the scene to inspect
  47973. */
  47974. constructor(scene: Scene);
  47975. /** Creates the inspector window. */
  47976. private _createInspector;
  47977. /**
  47978. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47979. * @param entity defines the entity to select
  47980. * @param lineContainerTitle defines the specific block to highlight
  47981. */
  47982. select(entity: any, lineContainerTitle?: string): void;
  47983. /** Get the inspector from bundle or global */
  47984. private _getGlobalInspector;
  47985. /**
  47986. * Get if the inspector is visible or not.
  47987. * @returns true if visible otherwise, false
  47988. */
  47989. isVisible(): boolean;
  47990. /**
  47991. * Hide the inspector and close its window.
  47992. */
  47993. hide(): void;
  47994. /**
  47995. * Launch the debugLayer.
  47996. * @param config Define the configuration of the inspector
  47997. * @return a promise fulfilled when the debug layer is visible
  47998. */
  47999. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48000. }
  48001. }
  48002. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48003. import { Nullable } from "babylonjs/types";
  48004. import { Scene } from "babylonjs/scene";
  48005. import { Vector4 } from "babylonjs/Maths/math.vector";
  48006. import { Color4 } from "babylonjs/Maths/math.color";
  48007. import { Mesh } from "babylonjs/Meshes/mesh";
  48008. /**
  48009. * Class containing static functions to help procedurally build meshes
  48010. */
  48011. export class BoxBuilder {
  48012. /**
  48013. * Creates a box mesh
  48014. * * The parameter `size` sets the size (float) of each box side (default 1)
  48015. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48016. * * 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)
  48017. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48021. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48022. * @param name defines the name of the mesh
  48023. * @param options defines the options used to create the mesh
  48024. * @param scene defines the hosting scene
  48025. * @returns the box mesh
  48026. */
  48027. static CreateBox(name: string, options: {
  48028. size?: number;
  48029. width?: number;
  48030. height?: number;
  48031. depth?: number;
  48032. faceUV?: Vector4[];
  48033. faceColors?: Color4[];
  48034. sideOrientation?: number;
  48035. frontUVs?: Vector4;
  48036. backUVs?: Vector4;
  48037. wrap?: boolean;
  48038. topBaseAt?: number;
  48039. bottomBaseAt?: number;
  48040. updatable?: boolean;
  48041. }, scene?: Nullable<Scene>): Mesh;
  48042. }
  48043. }
  48044. declare module "babylonjs/Debug/physicsViewer" {
  48045. import { Nullable } from "babylonjs/types";
  48046. import { Scene } from "babylonjs/scene";
  48047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48048. import { Mesh } from "babylonjs/Meshes/mesh";
  48049. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48050. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48051. /**
  48052. * Used to show the physics impostor around the specific mesh
  48053. */
  48054. export class PhysicsViewer {
  48055. /** @hidden */
  48056. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48057. /** @hidden */
  48058. protected _meshes: Array<Nullable<AbstractMesh>>;
  48059. /** @hidden */
  48060. protected _scene: Nullable<Scene>;
  48061. /** @hidden */
  48062. protected _numMeshes: number;
  48063. /** @hidden */
  48064. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48065. private _renderFunction;
  48066. private _utilityLayer;
  48067. private _debugBoxMesh;
  48068. private _debugSphereMesh;
  48069. private _debugCylinderMesh;
  48070. private _debugMaterial;
  48071. private _debugMeshMeshes;
  48072. /**
  48073. * Creates a new PhysicsViewer
  48074. * @param scene defines the hosting scene
  48075. */
  48076. constructor(scene: Scene);
  48077. /** @hidden */
  48078. protected _updateDebugMeshes(): void;
  48079. /**
  48080. * Renders a specified physic impostor
  48081. * @param impostor defines the impostor to render
  48082. * @param targetMesh defines the mesh represented by the impostor
  48083. * @returns the new debug mesh used to render the impostor
  48084. */
  48085. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48086. /**
  48087. * Hides a specified physic impostor
  48088. * @param impostor defines the impostor to hide
  48089. */
  48090. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48091. private _getDebugMaterial;
  48092. private _getDebugBoxMesh;
  48093. private _getDebugSphereMesh;
  48094. private _getDebugCylinderMesh;
  48095. private _getDebugMeshMesh;
  48096. private _getDebugMesh;
  48097. /** Releases all resources */
  48098. dispose(): void;
  48099. }
  48100. }
  48101. declare module "babylonjs/Debug/rayHelper" {
  48102. import { Nullable } from "babylonjs/types";
  48103. import { Ray } from "babylonjs/Culling/ray";
  48104. import { Vector3 } from "babylonjs/Maths/math.vector";
  48105. import { Color3 } from "babylonjs/Maths/math.color";
  48106. import { Scene } from "babylonjs/scene";
  48107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48108. import "babylonjs/Meshes/Builders/linesBuilder";
  48109. /**
  48110. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48111. * in order to better appreciate the issue one might have.
  48112. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48113. */
  48114. export class RayHelper {
  48115. /**
  48116. * Defines the ray we are currently tryin to visualize.
  48117. */
  48118. ray: Nullable<Ray>;
  48119. private _renderPoints;
  48120. private _renderLine;
  48121. private _renderFunction;
  48122. private _scene;
  48123. private _updateToMeshFunction;
  48124. private _attachedToMesh;
  48125. private _meshSpaceDirection;
  48126. private _meshSpaceOrigin;
  48127. /**
  48128. * Helper function to create a colored helper in a scene in one line.
  48129. * @param ray Defines the ray we are currently tryin to visualize
  48130. * @param scene Defines the scene the ray is used in
  48131. * @param color Defines the color we want to see the ray in
  48132. * @returns The newly created ray helper.
  48133. */
  48134. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48135. /**
  48136. * Instantiate a new ray helper.
  48137. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48138. * in order to better appreciate the issue one might have.
  48139. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48140. * @param ray Defines the ray we are currently tryin to visualize
  48141. */
  48142. constructor(ray: Ray);
  48143. /**
  48144. * Shows the ray we are willing to debug.
  48145. * @param scene Defines the scene the ray needs to be rendered in
  48146. * @param color Defines the color the ray needs to be rendered in
  48147. */
  48148. show(scene: Scene, color?: Color3): void;
  48149. /**
  48150. * Hides the ray we are debugging.
  48151. */
  48152. hide(): void;
  48153. private _render;
  48154. /**
  48155. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48156. * @param mesh Defines the mesh we want the helper attached to
  48157. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48158. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48159. * @param length Defines the length of the ray
  48160. */
  48161. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48162. /**
  48163. * Detach the ray helper from the mesh it has previously been attached to.
  48164. */
  48165. detachFromMesh(): void;
  48166. private _updateToMesh;
  48167. /**
  48168. * Dispose the helper and release its associated resources.
  48169. */
  48170. dispose(): void;
  48171. }
  48172. }
  48173. declare module "babylonjs/Debug/skeletonViewer" {
  48174. import { Color3 } from "babylonjs/Maths/math.color";
  48175. import { Scene } from "babylonjs/scene";
  48176. import { Nullable } from "babylonjs/types";
  48177. import { Skeleton } from "babylonjs/Bones/skeleton";
  48178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48179. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48180. /**
  48181. * Class used to render a debug view of a given skeleton
  48182. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48183. */
  48184. export class SkeletonViewer {
  48185. /** defines the skeleton to render */
  48186. skeleton: Skeleton;
  48187. /** defines the mesh attached to the skeleton */
  48188. mesh: AbstractMesh;
  48189. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48190. autoUpdateBonesMatrices: boolean;
  48191. /** defines the rendering group id to use with the viewer */
  48192. renderingGroupId: number;
  48193. /** Gets or sets the color used to render the skeleton */
  48194. color: Color3;
  48195. private _scene;
  48196. private _debugLines;
  48197. private _debugMesh;
  48198. private _isEnabled;
  48199. private _renderFunction;
  48200. private _utilityLayer;
  48201. /**
  48202. * Returns the mesh used to render the bones
  48203. */
  48204. get debugMesh(): Nullable<LinesMesh>;
  48205. /**
  48206. * Creates a new SkeletonViewer
  48207. * @param skeleton defines the skeleton to render
  48208. * @param mesh defines the mesh attached to the skeleton
  48209. * @param scene defines the hosting scene
  48210. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48211. * @param renderingGroupId defines the rendering group id to use with the viewer
  48212. */
  48213. constructor(
  48214. /** defines the skeleton to render */
  48215. skeleton: Skeleton,
  48216. /** defines the mesh attached to the skeleton */
  48217. mesh: AbstractMesh, scene: Scene,
  48218. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48219. autoUpdateBonesMatrices?: boolean,
  48220. /** defines the rendering group id to use with the viewer */
  48221. renderingGroupId?: number);
  48222. /** Gets or sets a boolean indicating if the viewer is enabled */
  48223. set isEnabled(value: boolean);
  48224. get isEnabled(): boolean;
  48225. private _getBonePosition;
  48226. private _getLinesForBonesWithLength;
  48227. private _getLinesForBonesNoLength;
  48228. /** Update the viewer to sync with current skeleton state */
  48229. update(): void;
  48230. /** Release associated resources */
  48231. dispose(): void;
  48232. }
  48233. }
  48234. declare module "babylonjs/Debug/index" {
  48235. export * from "babylonjs/Debug/axesViewer";
  48236. export * from "babylonjs/Debug/boneAxesViewer";
  48237. export * from "babylonjs/Debug/debugLayer";
  48238. export * from "babylonjs/Debug/physicsViewer";
  48239. export * from "babylonjs/Debug/rayHelper";
  48240. export * from "babylonjs/Debug/skeletonViewer";
  48241. }
  48242. declare module "babylonjs/Engines/nullEngine" {
  48243. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48244. import { Engine } from "babylonjs/Engines/engine";
  48245. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48246. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48247. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48248. import { Effect } from "babylonjs/Materials/effect";
  48249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48250. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48251. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48252. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48253. /**
  48254. * Options to create the null engine
  48255. */
  48256. export class NullEngineOptions {
  48257. /**
  48258. * Render width (Default: 512)
  48259. */
  48260. renderWidth: number;
  48261. /**
  48262. * Render height (Default: 256)
  48263. */
  48264. renderHeight: number;
  48265. /**
  48266. * Texture size (Default: 512)
  48267. */
  48268. textureSize: number;
  48269. /**
  48270. * If delta time between frames should be constant
  48271. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48272. */
  48273. deterministicLockstep: boolean;
  48274. /**
  48275. * Maximum about of steps between frames (Default: 4)
  48276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48277. */
  48278. lockstepMaxSteps: number;
  48279. }
  48280. /**
  48281. * The null engine class provides support for headless version of babylon.js.
  48282. * This can be used in server side scenario or for testing purposes
  48283. */
  48284. export class NullEngine extends Engine {
  48285. private _options;
  48286. /**
  48287. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48288. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48289. * @returns true if engine is in deterministic lock step mode
  48290. */
  48291. isDeterministicLockStep(): boolean;
  48292. /**
  48293. * Gets the max steps when engine is running in deterministic lock step
  48294. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48295. * @returns the max steps
  48296. */
  48297. getLockstepMaxSteps(): number;
  48298. /**
  48299. * Gets the current hardware scaling level.
  48300. * By default the hardware scaling level is computed from the window device ratio.
  48301. * 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.
  48302. * @returns a number indicating the current hardware scaling level
  48303. */
  48304. getHardwareScalingLevel(): number;
  48305. constructor(options?: NullEngineOptions);
  48306. /**
  48307. * Creates a vertex buffer
  48308. * @param vertices the data for the vertex buffer
  48309. * @returns the new WebGL static buffer
  48310. */
  48311. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48312. /**
  48313. * Creates a new index buffer
  48314. * @param indices defines the content of the index buffer
  48315. * @param updatable defines if the index buffer must be updatable
  48316. * @returns a new webGL buffer
  48317. */
  48318. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48319. /**
  48320. * Clear the current render buffer or the current render target (if any is set up)
  48321. * @param color defines the color to use
  48322. * @param backBuffer defines if the back buffer must be cleared
  48323. * @param depth defines if the depth buffer must be cleared
  48324. * @param stencil defines if the stencil buffer must be cleared
  48325. */
  48326. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48327. /**
  48328. * Gets the current render width
  48329. * @param useScreen defines if screen size must be used (or the current render target if any)
  48330. * @returns a number defining the current render width
  48331. */
  48332. getRenderWidth(useScreen?: boolean): number;
  48333. /**
  48334. * Gets the current render height
  48335. * @param useScreen defines if screen size must be used (or the current render target if any)
  48336. * @returns a number defining the current render height
  48337. */
  48338. getRenderHeight(useScreen?: boolean): number;
  48339. /**
  48340. * Set the WebGL's viewport
  48341. * @param viewport defines the viewport element to be used
  48342. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48343. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48344. */
  48345. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48346. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48347. /**
  48348. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48349. * @param pipelineContext defines the pipeline context to use
  48350. * @param uniformsNames defines the list of uniform names
  48351. * @returns an array of webGL uniform locations
  48352. */
  48353. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48354. /**
  48355. * Gets the lsit of active attributes for a given webGL program
  48356. * @param pipelineContext defines the pipeline context to use
  48357. * @param attributesNames defines the list of attribute names to get
  48358. * @returns an array of indices indicating the offset of each attribute
  48359. */
  48360. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48361. /**
  48362. * Binds an effect to the webGL context
  48363. * @param effect defines the effect to bind
  48364. */
  48365. bindSamplers(effect: Effect): void;
  48366. /**
  48367. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48368. * @param effect defines the effect to activate
  48369. */
  48370. enableEffect(effect: Effect): void;
  48371. /**
  48372. * Set various states to the webGL context
  48373. * @param culling defines backface culling state
  48374. * @param zOffset defines the value to apply to zOffset (0 by default)
  48375. * @param force defines if states must be applied even if cache is up to date
  48376. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48377. */
  48378. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48379. /**
  48380. * Set the value of an uniform to an array of int32
  48381. * @param uniform defines the webGL uniform location where to store the value
  48382. * @param array defines the array of int32 to store
  48383. */
  48384. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48385. /**
  48386. * Set the value of an uniform to an array of int32 (stored as vec2)
  48387. * @param uniform defines the webGL uniform location where to store the value
  48388. * @param array defines the array of int32 to store
  48389. */
  48390. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48391. /**
  48392. * Set the value of an uniform to an array of int32 (stored as vec3)
  48393. * @param uniform defines the webGL uniform location where to store the value
  48394. * @param array defines the array of int32 to store
  48395. */
  48396. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48397. /**
  48398. * Set the value of an uniform to an array of int32 (stored as vec4)
  48399. * @param uniform defines the webGL uniform location where to store the value
  48400. * @param array defines the array of int32 to store
  48401. */
  48402. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48403. /**
  48404. * Set the value of an uniform to an array of float32
  48405. * @param uniform defines the webGL uniform location where to store the value
  48406. * @param array defines the array of float32 to store
  48407. */
  48408. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48409. /**
  48410. * Set the value of an uniform to an array of float32 (stored as vec2)
  48411. * @param uniform defines the webGL uniform location where to store the value
  48412. * @param array defines the array of float32 to store
  48413. */
  48414. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48415. /**
  48416. * Set the value of an uniform to an array of float32 (stored as vec3)
  48417. * @param uniform defines the webGL uniform location where to store the value
  48418. * @param array defines the array of float32 to store
  48419. */
  48420. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48421. /**
  48422. * Set the value of an uniform to an array of float32 (stored as vec4)
  48423. * @param uniform defines the webGL uniform location where to store the value
  48424. * @param array defines the array of float32 to store
  48425. */
  48426. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48427. /**
  48428. * Set the value of an uniform to an array of number
  48429. * @param uniform defines the webGL uniform location where to store the value
  48430. * @param array defines the array of number to store
  48431. */
  48432. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48433. /**
  48434. * Set the value of an uniform to an array of number (stored as vec2)
  48435. * @param uniform defines the webGL uniform location where to store the value
  48436. * @param array defines the array of number to store
  48437. */
  48438. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48439. /**
  48440. * Set the value of an uniform to an array of number (stored as vec3)
  48441. * @param uniform defines the webGL uniform location where to store the value
  48442. * @param array defines the array of number to store
  48443. */
  48444. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48445. /**
  48446. * Set the value of an uniform to an array of number (stored as vec4)
  48447. * @param uniform defines the webGL uniform location where to store the value
  48448. * @param array defines the array of number to store
  48449. */
  48450. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48451. /**
  48452. * Set the value of an uniform to an array of float32 (stored as matrices)
  48453. * @param uniform defines the webGL uniform location where to store the value
  48454. * @param matrices defines the array of float32 to store
  48455. */
  48456. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48457. /**
  48458. * Set the value of an uniform to a matrix (3x3)
  48459. * @param uniform defines the webGL uniform location where to store the value
  48460. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48461. */
  48462. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48463. /**
  48464. * Set the value of an uniform to a matrix (2x2)
  48465. * @param uniform defines the webGL uniform location where to store the value
  48466. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48467. */
  48468. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48469. /**
  48470. * Set the value of an uniform to a number (float)
  48471. * @param uniform defines the webGL uniform location where to store the value
  48472. * @param value defines the float number to store
  48473. */
  48474. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48475. /**
  48476. * Set the value of an uniform to a vec2
  48477. * @param uniform defines the webGL uniform location where to store the value
  48478. * @param x defines the 1st component of the value
  48479. * @param y defines the 2nd component of the value
  48480. */
  48481. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48482. /**
  48483. * Set the value of an uniform to a vec3
  48484. * @param uniform defines the webGL uniform location where to store the value
  48485. * @param x defines the 1st component of the value
  48486. * @param y defines the 2nd component of the value
  48487. * @param z defines the 3rd component of the value
  48488. */
  48489. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48490. /**
  48491. * Set the value of an uniform to a boolean
  48492. * @param uniform defines the webGL uniform location where to store the value
  48493. * @param bool defines the boolean to store
  48494. */
  48495. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48496. /**
  48497. * Set the value of an uniform to a vec4
  48498. * @param uniform defines the webGL uniform location where to store the value
  48499. * @param x defines the 1st component of the value
  48500. * @param y defines the 2nd component of the value
  48501. * @param z defines the 3rd component of the value
  48502. * @param w defines the 4th component of the value
  48503. */
  48504. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48505. /**
  48506. * Sets the current alpha mode
  48507. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48508. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48509. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48510. */
  48511. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48512. /**
  48513. * Bind webGl buffers directly to the webGL context
  48514. * @param vertexBuffers defines the vertex buffer to bind
  48515. * @param indexBuffer defines the index buffer to bind
  48516. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48517. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48518. * @param effect defines the effect associated with the vertex buffer
  48519. */
  48520. bindBuffers(vertexBuffers: {
  48521. [key: string]: VertexBuffer;
  48522. }, indexBuffer: DataBuffer, effect: Effect): void;
  48523. /**
  48524. * Force the entire cache to be cleared
  48525. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48526. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48527. */
  48528. wipeCaches(bruteForce?: boolean): void;
  48529. /**
  48530. * Send a draw order
  48531. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48532. * @param indexStart defines the starting index
  48533. * @param indexCount defines the number of index to draw
  48534. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48535. */
  48536. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48537. /**
  48538. * Draw a list of indexed primitives
  48539. * @param fillMode defines the primitive to use
  48540. * @param indexStart defines the starting index
  48541. * @param indexCount defines the number of index to draw
  48542. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48543. */
  48544. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48545. /**
  48546. * Draw a list of unindexed primitives
  48547. * @param fillMode defines the primitive to use
  48548. * @param verticesStart defines the index of first vertex to draw
  48549. * @param verticesCount defines the count of vertices to draw
  48550. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48551. */
  48552. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48553. /** @hidden */
  48554. _createTexture(): WebGLTexture;
  48555. /** @hidden */
  48556. _releaseTexture(texture: InternalTexture): void;
  48557. /**
  48558. * Usually called from Texture.ts.
  48559. * Passed information to create a WebGLTexture
  48560. * @param urlArg defines a value which contains one of the following:
  48561. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48562. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48563. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48564. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48565. * @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)
  48566. * @param scene needed for loading to the correct scene
  48567. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48568. * @param onLoad optional callback to be called upon successful completion
  48569. * @param onError optional callback to be called upon failure
  48570. * @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
  48571. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48572. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48573. * @param forcedExtension defines the extension to use to pick the right loader
  48574. * @param mimeType defines an optional mime type
  48575. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48576. */
  48577. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  48578. /**
  48579. * Creates a new render target texture
  48580. * @param size defines the size of the texture
  48581. * @param options defines the options used to create the texture
  48582. * @returns a new render target texture stored in an InternalTexture
  48583. */
  48584. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48585. /**
  48586. * Update the sampling mode of a given texture
  48587. * @param samplingMode defines the required sampling mode
  48588. * @param texture defines the texture to update
  48589. */
  48590. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48591. /**
  48592. * Binds the frame buffer to the specified texture.
  48593. * @param texture The texture to render to or null for the default canvas
  48594. * @param faceIndex The face of the texture to render to in case of cube texture
  48595. * @param requiredWidth The width of the target to render to
  48596. * @param requiredHeight The height of the target to render to
  48597. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48598. * @param lodLevel defines le lod level to bind to the frame buffer
  48599. */
  48600. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48601. /**
  48602. * Unbind the current render target texture from the webGL context
  48603. * @param texture defines the render target texture to unbind
  48604. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48605. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48606. */
  48607. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48608. /**
  48609. * Creates a dynamic vertex buffer
  48610. * @param vertices the data for the dynamic vertex buffer
  48611. * @returns the new WebGL dynamic buffer
  48612. */
  48613. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48614. /**
  48615. * Update the content of a dynamic texture
  48616. * @param texture defines the texture to update
  48617. * @param canvas defines the canvas containing the source
  48618. * @param invertY defines if data must be stored with Y axis inverted
  48619. * @param premulAlpha defines if alpha is stored as premultiplied
  48620. * @param format defines the format of the data
  48621. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48622. */
  48623. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48624. /**
  48625. * Gets a boolean indicating if all created effects are ready
  48626. * @returns true if all effects are ready
  48627. */
  48628. areAllEffectsReady(): boolean;
  48629. /**
  48630. * @hidden
  48631. * Get the current error code of the webGL context
  48632. * @returns the error code
  48633. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48634. */
  48635. getError(): number;
  48636. /** @hidden */
  48637. _getUnpackAlignement(): number;
  48638. /** @hidden */
  48639. _unpackFlipY(value: boolean): void;
  48640. /**
  48641. * Update a dynamic index buffer
  48642. * @param indexBuffer defines the target index buffer
  48643. * @param indices defines the data to update
  48644. * @param offset defines the offset in the target index buffer where update should start
  48645. */
  48646. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48647. /**
  48648. * Updates a dynamic vertex buffer.
  48649. * @param vertexBuffer the vertex buffer to update
  48650. * @param vertices the data used to update the vertex buffer
  48651. * @param byteOffset the byte offset of the data (optional)
  48652. * @param byteLength the byte length of the data (optional)
  48653. */
  48654. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48655. /** @hidden */
  48656. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48657. /** @hidden */
  48658. _bindTexture(channel: number, texture: InternalTexture): void;
  48659. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48660. /**
  48661. * 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
  48662. */
  48663. releaseEffects(): void;
  48664. displayLoadingUI(): void;
  48665. hideLoadingUI(): void;
  48666. /** @hidden */
  48667. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48668. /** @hidden */
  48669. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48670. /** @hidden */
  48671. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48672. /** @hidden */
  48673. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48674. }
  48675. }
  48676. declare module "babylonjs/Instrumentation/timeToken" {
  48677. import { Nullable } from "babylonjs/types";
  48678. /**
  48679. * @hidden
  48680. **/
  48681. export class _TimeToken {
  48682. _startTimeQuery: Nullable<WebGLQuery>;
  48683. _endTimeQuery: Nullable<WebGLQuery>;
  48684. _timeElapsedQuery: Nullable<WebGLQuery>;
  48685. _timeElapsedQueryEnded: boolean;
  48686. }
  48687. }
  48688. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48689. import { Nullable, int } from "babylonjs/types";
  48690. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48691. /** @hidden */
  48692. export class _OcclusionDataStorage {
  48693. /** @hidden */
  48694. occlusionInternalRetryCounter: number;
  48695. /** @hidden */
  48696. isOcclusionQueryInProgress: boolean;
  48697. /** @hidden */
  48698. isOccluded: boolean;
  48699. /** @hidden */
  48700. occlusionRetryCount: number;
  48701. /** @hidden */
  48702. occlusionType: number;
  48703. /** @hidden */
  48704. occlusionQueryAlgorithmType: number;
  48705. }
  48706. module "babylonjs/Engines/engine" {
  48707. interface Engine {
  48708. /**
  48709. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48710. * @return the new query
  48711. */
  48712. createQuery(): WebGLQuery;
  48713. /**
  48714. * Delete and release a webGL query
  48715. * @param query defines the query to delete
  48716. * @return the current engine
  48717. */
  48718. deleteQuery(query: WebGLQuery): Engine;
  48719. /**
  48720. * Check if a given query has resolved and got its value
  48721. * @param query defines the query to check
  48722. * @returns true if the query got its value
  48723. */
  48724. isQueryResultAvailable(query: WebGLQuery): boolean;
  48725. /**
  48726. * Gets the value of a given query
  48727. * @param query defines the query to check
  48728. * @returns the value of the query
  48729. */
  48730. getQueryResult(query: WebGLQuery): number;
  48731. /**
  48732. * Initiates an occlusion query
  48733. * @param algorithmType defines the algorithm to use
  48734. * @param query defines the query to use
  48735. * @returns the current engine
  48736. * @see http://doc.babylonjs.com/features/occlusionquery
  48737. */
  48738. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48739. /**
  48740. * Ends an occlusion query
  48741. * @see http://doc.babylonjs.com/features/occlusionquery
  48742. * @param algorithmType defines the algorithm to use
  48743. * @returns the current engine
  48744. */
  48745. endOcclusionQuery(algorithmType: number): Engine;
  48746. /**
  48747. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48748. * Please note that only one query can be issued at a time
  48749. * @returns a time token used to track the time span
  48750. */
  48751. startTimeQuery(): Nullable<_TimeToken>;
  48752. /**
  48753. * Ends a time query
  48754. * @param token defines the token used to measure the time span
  48755. * @returns the time spent (in ns)
  48756. */
  48757. endTimeQuery(token: _TimeToken): int;
  48758. /** @hidden */
  48759. _currentNonTimestampToken: Nullable<_TimeToken>;
  48760. /** @hidden */
  48761. _createTimeQuery(): WebGLQuery;
  48762. /** @hidden */
  48763. _deleteTimeQuery(query: WebGLQuery): void;
  48764. /** @hidden */
  48765. _getGlAlgorithmType(algorithmType: number): number;
  48766. /** @hidden */
  48767. _getTimeQueryResult(query: WebGLQuery): any;
  48768. /** @hidden */
  48769. _getTimeQueryAvailability(query: WebGLQuery): any;
  48770. }
  48771. }
  48772. module "babylonjs/Meshes/abstractMesh" {
  48773. interface AbstractMesh {
  48774. /**
  48775. * Backing filed
  48776. * @hidden
  48777. */
  48778. __occlusionDataStorage: _OcclusionDataStorage;
  48779. /**
  48780. * Access property
  48781. * @hidden
  48782. */
  48783. _occlusionDataStorage: _OcclusionDataStorage;
  48784. /**
  48785. * 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.
  48786. * The default value is -1 which means don't break the query and wait till the result
  48787. * @see http://doc.babylonjs.com/features/occlusionquery
  48788. */
  48789. occlusionRetryCount: number;
  48790. /**
  48791. * 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:
  48792. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48793. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48794. * * 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.
  48795. * @see http://doc.babylonjs.com/features/occlusionquery
  48796. */
  48797. occlusionType: number;
  48798. /**
  48799. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48800. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48801. * * 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.
  48802. * @see http://doc.babylonjs.com/features/occlusionquery
  48803. */
  48804. occlusionQueryAlgorithmType: number;
  48805. /**
  48806. * 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
  48807. * @see http://doc.babylonjs.com/features/occlusionquery
  48808. */
  48809. isOccluded: boolean;
  48810. /**
  48811. * Flag to check the progress status of the query
  48812. * @see http://doc.babylonjs.com/features/occlusionquery
  48813. */
  48814. isOcclusionQueryInProgress: boolean;
  48815. }
  48816. }
  48817. }
  48818. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48819. import { Nullable } from "babylonjs/types";
  48820. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48821. /** @hidden */
  48822. export var _forceTransformFeedbackToBundle: boolean;
  48823. module "babylonjs/Engines/engine" {
  48824. interface Engine {
  48825. /**
  48826. * Creates a webGL transform feedback object
  48827. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48828. * @returns the webGL transform feedback object
  48829. */
  48830. createTransformFeedback(): WebGLTransformFeedback;
  48831. /**
  48832. * Delete a webGL transform feedback object
  48833. * @param value defines the webGL transform feedback object to delete
  48834. */
  48835. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48836. /**
  48837. * Bind a webGL transform feedback object to the webgl context
  48838. * @param value defines the webGL transform feedback object to bind
  48839. */
  48840. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48841. /**
  48842. * Begins a transform feedback operation
  48843. * @param usePoints defines if points or triangles must be used
  48844. */
  48845. beginTransformFeedback(usePoints: boolean): void;
  48846. /**
  48847. * Ends a transform feedback operation
  48848. */
  48849. endTransformFeedback(): void;
  48850. /**
  48851. * Specify the varyings to use with transform feedback
  48852. * @param program defines the associated webGL program
  48853. * @param value defines the list of strings representing the varying names
  48854. */
  48855. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48856. /**
  48857. * Bind a webGL buffer for a transform feedback operation
  48858. * @param value defines the webGL buffer to bind
  48859. */
  48860. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48861. }
  48862. }
  48863. }
  48864. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48865. import { Scene } from "babylonjs/scene";
  48866. import { Engine } from "babylonjs/Engines/engine";
  48867. import { Texture } from "babylonjs/Materials/Textures/texture";
  48868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48869. import "babylonjs/Engines/Extensions/engine.multiRender";
  48870. /**
  48871. * Creation options of the multi render target texture.
  48872. */
  48873. export interface IMultiRenderTargetOptions {
  48874. /**
  48875. * Define if the texture needs to create mip maps after render.
  48876. */
  48877. generateMipMaps?: boolean;
  48878. /**
  48879. * Define the types of all the draw buffers we want to create
  48880. */
  48881. types?: number[];
  48882. /**
  48883. * Define the sampling modes of all the draw buffers we want to create
  48884. */
  48885. samplingModes?: number[];
  48886. /**
  48887. * Define if a depth buffer is required
  48888. */
  48889. generateDepthBuffer?: boolean;
  48890. /**
  48891. * Define if a stencil buffer is required
  48892. */
  48893. generateStencilBuffer?: boolean;
  48894. /**
  48895. * Define if a depth texture is required instead of a depth buffer
  48896. */
  48897. generateDepthTexture?: boolean;
  48898. /**
  48899. * Define the number of desired draw buffers
  48900. */
  48901. textureCount?: number;
  48902. /**
  48903. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48904. */
  48905. doNotChangeAspectRatio?: boolean;
  48906. /**
  48907. * Define the default type of the buffers we are creating
  48908. */
  48909. defaultType?: number;
  48910. }
  48911. /**
  48912. * A multi render target, like a render target provides the ability to render to a texture.
  48913. * Unlike the render target, it can render to several draw buffers in one draw.
  48914. * This is specially interesting in deferred rendering or for any effects requiring more than
  48915. * just one color from a single pass.
  48916. */
  48917. export class MultiRenderTarget extends RenderTargetTexture {
  48918. private _internalTextures;
  48919. private _textures;
  48920. private _multiRenderTargetOptions;
  48921. /**
  48922. * Get if draw buffers are currently supported by the used hardware and browser.
  48923. */
  48924. get isSupported(): boolean;
  48925. /**
  48926. * Get the list of textures generated by the multi render target.
  48927. */
  48928. get textures(): Texture[];
  48929. /**
  48930. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48931. */
  48932. get depthTexture(): Texture;
  48933. /**
  48934. * Set the wrapping mode on U of all the textures we are rendering to.
  48935. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48936. */
  48937. set wrapU(wrap: number);
  48938. /**
  48939. * Set the wrapping mode on V of all the textures we are rendering to.
  48940. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48941. */
  48942. set wrapV(wrap: number);
  48943. /**
  48944. * Instantiate a new multi render target texture.
  48945. * A multi render target, like a render target provides the ability to render to a texture.
  48946. * Unlike the render target, it can render to several draw buffers in one draw.
  48947. * This is specially interesting in deferred rendering or for any effects requiring more than
  48948. * just one color from a single pass.
  48949. * @param name Define the name of the texture
  48950. * @param size Define the size of the buffers to render to
  48951. * @param count Define the number of target we are rendering into
  48952. * @param scene Define the scene the texture belongs to
  48953. * @param options Define the options used to create the multi render target
  48954. */
  48955. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48956. /** @hidden */
  48957. _rebuild(): void;
  48958. private _createInternalTextures;
  48959. private _createTextures;
  48960. /**
  48961. * Define the number of samples used if MSAA is enabled.
  48962. */
  48963. get samples(): number;
  48964. set samples(value: number);
  48965. /**
  48966. * Resize all the textures in the multi render target.
  48967. * Be carrefull as it will recreate all the data in the new texture.
  48968. * @param size Define the new size
  48969. */
  48970. resize(size: any): void;
  48971. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48972. /**
  48973. * Dispose the render targets and their associated resources
  48974. */
  48975. dispose(): void;
  48976. /**
  48977. * Release all the underlying texture used as draw buffers.
  48978. */
  48979. releaseInternalTextures(): void;
  48980. }
  48981. }
  48982. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48983. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48984. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48985. import { Nullable } from "babylonjs/types";
  48986. module "babylonjs/Engines/thinEngine" {
  48987. interface ThinEngine {
  48988. /**
  48989. * Unbind a list of render target textures from the webGL context
  48990. * This is used only when drawBuffer extension or webGL2 are active
  48991. * @param textures defines the render target textures to unbind
  48992. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48993. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48994. */
  48995. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48996. /**
  48997. * Create a multi render target texture
  48998. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48999. * @param size defines the size of the texture
  49000. * @param options defines the creation options
  49001. * @returns the cube texture as an InternalTexture
  49002. */
  49003. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49004. /**
  49005. * Update the sample count for a given multiple render target texture
  49006. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49007. * @param textures defines the textures to update
  49008. * @param samples defines the sample count to set
  49009. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49010. */
  49011. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49012. }
  49013. }
  49014. }
  49015. declare module "babylonjs/Engines/Extensions/engine.views" {
  49016. import { Camera } from "babylonjs/Cameras/camera";
  49017. import { Nullable } from "babylonjs/types";
  49018. /**
  49019. * Class used to define an additional view for the engine
  49020. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49021. */
  49022. export class EngineView {
  49023. /** Defines the canvas where to render the view */
  49024. target: HTMLCanvasElement;
  49025. /** Defines an optional camera used to render the view (will use active camera else) */
  49026. camera?: Camera;
  49027. }
  49028. module "babylonjs/Engines/engine" {
  49029. interface Engine {
  49030. /**
  49031. * Gets or sets the HTML element to use for attaching events
  49032. */
  49033. inputElement: Nullable<HTMLElement>;
  49034. /**
  49035. * Gets the current engine view
  49036. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49037. */
  49038. activeView: Nullable<EngineView>;
  49039. /** Gets or sets the list of views */
  49040. views: EngineView[];
  49041. /**
  49042. * Register a new child canvas
  49043. * @param canvas defines the canvas to register
  49044. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49045. * @returns the associated view
  49046. */
  49047. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49048. /**
  49049. * Remove a registered child canvas
  49050. * @param canvas defines the canvas to remove
  49051. * @returns the current engine
  49052. */
  49053. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49054. }
  49055. }
  49056. }
  49057. declare module "babylonjs/Engines/Extensions/index" {
  49058. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49059. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49060. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49061. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49062. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49063. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49064. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49065. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49066. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49067. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49068. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49069. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49070. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49071. export * from "babylonjs/Engines/Extensions/engine.views";
  49072. }
  49073. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49074. import { Nullable } from "babylonjs/types";
  49075. /**
  49076. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49077. */
  49078. export interface CubeMapInfo {
  49079. /**
  49080. * The pixel array for the front face.
  49081. * This is stored in format, left to right, up to down format.
  49082. */
  49083. front: Nullable<ArrayBufferView>;
  49084. /**
  49085. * The pixel array for the back face.
  49086. * This is stored in format, left to right, up to down format.
  49087. */
  49088. back: Nullable<ArrayBufferView>;
  49089. /**
  49090. * The pixel array for the left face.
  49091. * This is stored in format, left to right, up to down format.
  49092. */
  49093. left: Nullable<ArrayBufferView>;
  49094. /**
  49095. * The pixel array for the right face.
  49096. * This is stored in format, left to right, up to down format.
  49097. */
  49098. right: Nullable<ArrayBufferView>;
  49099. /**
  49100. * The pixel array for the up face.
  49101. * This is stored in format, left to right, up to down format.
  49102. */
  49103. up: Nullable<ArrayBufferView>;
  49104. /**
  49105. * The pixel array for the down face.
  49106. * This is stored in format, left to right, up to down format.
  49107. */
  49108. down: Nullable<ArrayBufferView>;
  49109. /**
  49110. * The size of the cubemap stored.
  49111. *
  49112. * Each faces will be size * size pixels.
  49113. */
  49114. size: number;
  49115. /**
  49116. * The format of the texture.
  49117. *
  49118. * RGBA, RGB.
  49119. */
  49120. format: number;
  49121. /**
  49122. * The type of the texture data.
  49123. *
  49124. * UNSIGNED_INT, FLOAT.
  49125. */
  49126. type: number;
  49127. /**
  49128. * Specifies whether the texture is in gamma space.
  49129. */
  49130. gammaSpace: boolean;
  49131. }
  49132. /**
  49133. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49134. */
  49135. export class PanoramaToCubeMapTools {
  49136. private static FACE_FRONT;
  49137. private static FACE_BACK;
  49138. private static FACE_RIGHT;
  49139. private static FACE_LEFT;
  49140. private static FACE_DOWN;
  49141. private static FACE_UP;
  49142. /**
  49143. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49144. *
  49145. * @param float32Array The source data.
  49146. * @param inputWidth The width of the input panorama.
  49147. * @param inputHeight The height of the input panorama.
  49148. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49149. * @return The cubemap data
  49150. */
  49151. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49152. private static CreateCubemapTexture;
  49153. private static CalcProjectionSpherical;
  49154. }
  49155. }
  49156. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49157. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49159. import { Nullable } from "babylonjs/types";
  49160. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49161. /**
  49162. * Helper class dealing with the extraction of spherical polynomial dataArray
  49163. * from a cube map.
  49164. */
  49165. export class CubeMapToSphericalPolynomialTools {
  49166. private static FileFaces;
  49167. /**
  49168. * Converts a texture to the according Spherical Polynomial data.
  49169. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49170. *
  49171. * @param texture The texture to extract the information from.
  49172. * @return The Spherical Polynomial data.
  49173. */
  49174. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49175. /**
  49176. * Converts a cubemap to the according Spherical Polynomial data.
  49177. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49178. *
  49179. * @param cubeInfo The Cube map to extract the information from.
  49180. * @return The Spherical Polynomial data.
  49181. */
  49182. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49183. }
  49184. }
  49185. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49186. import { Nullable } from "babylonjs/types";
  49187. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49188. module "babylonjs/Materials/Textures/baseTexture" {
  49189. interface BaseTexture {
  49190. /**
  49191. * Get the polynomial representation of the texture data.
  49192. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49193. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49194. */
  49195. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49196. }
  49197. }
  49198. }
  49199. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49201. /** @hidden */
  49202. export var rgbdEncodePixelShader: {
  49203. name: string;
  49204. shader: string;
  49205. };
  49206. }
  49207. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49209. /** @hidden */
  49210. export var rgbdDecodePixelShader: {
  49211. name: string;
  49212. shader: string;
  49213. };
  49214. }
  49215. declare module "babylonjs/Misc/environmentTextureTools" {
  49216. import { Nullable } from "babylonjs/types";
  49217. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49218. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49219. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49220. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49221. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49222. import "babylonjs/Shaders/rgbdEncode.fragment";
  49223. import "babylonjs/Shaders/rgbdDecode.fragment";
  49224. /**
  49225. * Raw texture data and descriptor sufficient for WebGL texture upload
  49226. */
  49227. export interface EnvironmentTextureInfo {
  49228. /**
  49229. * Version of the environment map
  49230. */
  49231. version: number;
  49232. /**
  49233. * Width of image
  49234. */
  49235. width: number;
  49236. /**
  49237. * Irradiance information stored in the file.
  49238. */
  49239. irradiance: any;
  49240. /**
  49241. * Specular information stored in the file.
  49242. */
  49243. specular: any;
  49244. }
  49245. /**
  49246. * Defines One Image in the file. It requires only the position in the file
  49247. * as well as the length.
  49248. */
  49249. interface BufferImageData {
  49250. /**
  49251. * Length of the image data.
  49252. */
  49253. length: number;
  49254. /**
  49255. * Position of the data from the null terminator delimiting the end of the JSON.
  49256. */
  49257. position: number;
  49258. }
  49259. /**
  49260. * Defines the specular data enclosed in the file.
  49261. * This corresponds to the version 1 of the data.
  49262. */
  49263. export interface EnvironmentTextureSpecularInfoV1 {
  49264. /**
  49265. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49266. */
  49267. specularDataPosition?: number;
  49268. /**
  49269. * This contains all the images data needed to reconstruct the cubemap.
  49270. */
  49271. mipmaps: Array<BufferImageData>;
  49272. /**
  49273. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49274. */
  49275. lodGenerationScale: number;
  49276. }
  49277. /**
  49278. * Sets of helpers addressing the serialization and deserialization of environment texture
  49279. * stored in a BabylonJS env file.
  49280. * Those files are usually stored as .env files.
  49281. */
  49282. export class EnvironmentTextureTools {
  49283. /**
  49284. * Magic number identifying the env file.
  49285. */
  49286. private static _MagicBytes;
  49287. /**
  49288. * Gets the environment info from an env file.
  49289. * @param data The array buffer containing the .env bytes.
  49290. * @returns the environment file info (the json header) if successfully parsed.
  49291. */
  49292. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49293. /**
  49294. * Creates an environment texture from a loaded cube texture.
  49295. * @param texture defines the cube texture to convert in env file
  49296. * @return a promise containing the environment data if succesfull.
  49297. */
  49298. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49299. /**
  49300. * Creates a JSON representation of the spherical data.
  49301. * @param texture defines the texture containing the polynomials
  49302. * @return the JSON representation of the spherical info
  49303. */
  49304. private static _CreateEnvTextureIrradiance;
  49305. /**
  49306. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49307. * @param data the image data
  49308. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49309. * @return the views described by info providing access to the underlying buffer
  49310. */
  49311. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49312. /**
  49313. * Uploads the texture info contained in the env file to the GPU.
  49314. * @param texture defines the internal texture to upload to
  49315. * @param data defines the data to load
  49316. * @param info defines the texture info retrieved through the GetEnvInfo method
  49317. * @returns a promise
  49318. */
  49319. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49320. private static _OnImageReadyAsync;
  49321. /**
  49322. * Uploads the levels of image data to the GPU.
  49323. * @param texture defines the internal texture to upload to
  49324. * @param imageData defines the array buffer views of image data [mipmap][face]
  49325. * @returns a promise
  49326. */
  49327. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49328. /**
  49329. * Uploads spherical polynomials information to the texture.
  49330. * @param texture defines the texture we are trying to upload the information to
  49331. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49332. */
  49333. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49334. /** @hidden */
  49335. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49336. }
  49337. }
  49338. declare module "babylonjs/Maths/math.vertexFormat" {
  49339. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49340. /**
  49341. * Contains position and normal vectors for a vertex
  49342. */
  49343. export class PositionNormalVertex {
  49344. /** the position of the vertex (defaut: 0,0,0) */
  49345. position: Vector3;
  49346. /** the normal of the vertex (defaut: 0,1,0) */
  49347. normal: Vector3;
  49348. /**
  49349. * Creates a PositionNormalVertex
  49350. * @param position the position of the vertex (defaut: 0,0,0)
  49351. * @param normal the normal of the vertex (defaut: 0,1,0)
  49352. */
  49353. constructor(
  49354. /** the position of the vertex (defaut: 0,0,0) */
  49355. position?: Vector3,
  49356. /** the normal of the vertex (defaut: 0,1,0) */
  49357. normal?: Vector3);
  49358. /**
  49359. * Clones the PositionNormalVertex
  49360. * @returns the cloned PositionNormalVertex
  49361. */
  49362. clone(): PositionNormalVertex;
  49363. }
  49364. /**
  49365. * Contains position, normal and uv vectors for a vertex
  49366. */
  49367. export class PositionNormalTextureVertex {
  49368. /** the position of the vertex (defaut: 0,0,0) */
  49369. position: Vector3;
  49370. /** the normal of the vertex (defaut: 0,1,0) */
  49371. normal: Vector3;
  49372. /** the uv of the vertex (default: 0,0) */
  49373. uv: Vector2;
  49374. /**
  49375. * Creates a PositionNormalTextureVertex
  49376. * @param position the position of the vertex (defaut: 0,0,0)
  49377. * @param normal the normal of the vertex (defaut: 0,1,0)
  49378. * @param uv the uv of the vertex (default: 0,0)
  49379. */
  49380. constructor(
  49381. /** the position of the vertex (defaut: 0,0,0) */
  49382. position?: Vector3,
  49383. /** the normal of the vertex (defaut: 0,1,0) */
  49384. normal?: Vector3,
  49385. /** the uv of the vertex (default: 0,0) */
  49386. uv?: Vector2);
  49387. /**
  49388. * Clones the PositionNormalTextureVertex
  49389. * @returns the cloned PositionNormalTextureVertex
  49390. */
  49391. clone(): PositionNormalTextureVertex;
  49392. }
  49393. }
  49394. declare module "babylonjs/Maths/math" {
  49395. export * from "babylonjs/Maths/math.axis";
  49396. export * from "babylonjs/Maths/math.color";
  49397. export * from "babylonjs/Maths/math.constants";
  49398. export * from "babylonjs/Maths/math.frustum";
  49399. export * from "babylonjs/Maths/math.path";
  49400. export * from "babylonjs/Maths/math.plane";
  49401. export * from "babylonjs/Maths/math.size";
  49402. export * from "babylonjs/Maths/math.vector";
  49403. export * from "babylonjs/Maths/math.vertexFormat";
  49404. export * from "babylonjs/Maths/math.viewport";
  49405. }
  49406. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49407. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49408. /** @hidden */
  49409. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49410. private _genericAttributeLocation;
  49411. private _varyingLocationCount;
  49412. private _varyingLocationMap;
  49413. private _replacements;
  49414. private _textureCount;
  49415. private _uniforms;
  49416. lineProcessor(line: string): string;
  49417. attributeProcessor(attribute: string): string;
  49418. varyingProcessor(varying: string, isFragment: boolean): string;
  49419. uniformProcessor(uniform: string): string;
  49420. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49421. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49422. }
  49423. }
  49424. declare module "babylonjs/Engines/nativeEngine" {
  49425. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49426. import { Engine } from "babylonjs/Engines/engine";
  49427. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49430. import { Effect } from "babylonjs/Materials/effect";
  49431. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49432. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49433. import { IColor4Like } from "babylonjs/Maths/math.like";
  49434. import { Scene } from "babylonjs/scene";
  49435. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49436. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49437. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49438. /**
  49439. * Container for accessors for natively-stored mesh data buffers.
  49440. */
  49441. class NativeDataBuffer extends DataBuffer {
  49442. /**
  49443. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49444. */
  49445. nativeIndexBuffer?: any;
  49446. /**
  49447. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49448. */
  49449. nativeVertexBuffer?: any;
  49450. }
  49451. /** @hidden */
  49452. class NativeTexture extends InternalTexture {
  49453. getInternalTexture(): InternalTexture;
  49454. getViewCount(): number;
  49455. }
  49456. /** @hidden */
  49457. export class NativeEngine extends Engine {
  49458. private readonly _native;
  49459. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49460. private readonly INVALID_HANDLE;
  49461. getHardwareScalingLevel(): number;
  49462. constructor();
  49463. /**
  49464. * Can be used to override the current requestAnimationFrame requester.
  49465. * @hidden
  49466. */
  49467. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49468. /**
  49469. * Override default engine behavior.
  49470. * @param color
  49471. * @param backBuffer
  49472. * @param depth
  49473. * @param stencil
  49474. */
  49475. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49476. /**
  49477. * Gets host document
  49478. * @returns the host document object
  49479. */
  49480. getHostDocument(): Nullable<Document>;
  49481. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49482. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49483. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49484. recordVertexArrayObject(vertexBuffers: {
  49485. [key: string]: VertexBuffer;
  49486. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49487. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49488. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49489. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49490. /**
  49491. * Draw a list of indexed primitives
  49492. * @param fillMode defines the primitive to use
  49493. * @param indexStart defines the starting index
  49494. * @param indexCount defines the number of index to draw
  49495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49496. */
  49497. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49498. /**
  49499. * Draw a list of unindexed primitives
  49500. * @param fillMode defines the primitive to use
  49501. * @param verticesStart defines the index of first vertex to draw
  49502. * @param verticesCount defines the count of vertices to draw
  49503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49504. */
  49505. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49506. createPipelineContext(): IPipelineContext;
  49507. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49508. /** @hidden */
  49509. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49510. /** @hidden */
  49511. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49512. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49513. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49514. protected _setProgram(program: WebGLProgram): void;
  49515. _releaseEffect(effect: Effect): void;
  49516. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49517. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49518. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49519. bindSamplers(effect: Effect): void;
  49520. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49521. getRenderWidth(useScreen?: boolean): number;
  49522. getRenderHeight(useScreen?: boolean): number;
  49523. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49524. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49525. /**
  49526. * Set the z offset to apply to current rendering
  49527. * @param value defines the offset to apply
  49528. */
  49529. setZOffset(value: number): void;
  49530. /**
  49531. * Gets the current value of the zOffset
  49532. * @returns the current zOffset state
  49533. */
  49534. getZOffset(): number;
  49535. /**
  49536. * Enable or disable depth buffering
  49537. * @param enable defines the state to set
  49538. */
  49539. setDepthBuffer(enable: boolean): void;
  49540. /**
  49541. * Gets a boolean indicating if depth writing is enabled
  49542. * @returns the current depth writing state
  49543. */
  49544. getDepthWrite(): boolean;
  49545. /**
  49546. * Enable or disable depth writing
  49547. * @param enable defines the state to set
  49548. */
  49549. setDepthWrite(enable: boolean): void;
  49550. /**
  49551. * Enable or disable color writing
  49552. * @param enable defines the state to set
  49553. */
  49554. setColorWrite(enable: boolean): void;
  49555. /**
  49556. * Gets a boolean indicating if color writing is enabled
  49557. * @returns the current color writing state
  49558. */
  49559. getColorWrite(): boolean;
  49560. /**
  49561. * Sets alpha constants used by some alpha blending modes
  49562. * @param r defines the red component
  49563. * @param g defines the green component
  49564. * @param b defines the blue component
  49565. * @param a defines the alpha component
  49566. */
  49567. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49568. /**
  49569. * Sets the current alpha mode
  49570. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49571. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49573. */
  49574. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49575. /**
  49576. * Gets the current alpha mode
  49577. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49578. * @returns the current alpha mode
  49579. */
  49580. getAlphaMode(): number;
  49581. setInt(uniform: WebGLUniformLocation, int: number): void;
  49582. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49583. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49584. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49585. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49586. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49587. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49588. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49589. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49590. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49591. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49592. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49593. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49594. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49595. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49596. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49597. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49598. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49599. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49600. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49601. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49602. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49603. wipeCaches(bruteForce?: boolean): void;
  49604. _createTexture(): WebGLTexture;
  49605. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49606. /**
  49607. * Usually called from Texture.ts.
  49608. * Passed information to create a WebGLTexture
  49609. * @param urlArg defines a value which contains one of the following:
  49610. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49611. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49612. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49613. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49614. * @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)
  49615. * @param scene needed for loading to the correct scene
  49616. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49617. * @param onLoad optional callback to be called upon successful completion
  49618. * @param onError optional callback to be called upon failure
  49619. * @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
  49620. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49621. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49622. * @param forcedExtension defines the extension to use to pick the right loader
  49623. * @param mimeType defines an optional mime type
  49624. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49625. */
  49626. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  49627. /**
  49628. * Creates a cube texture
  49629. * @param rootUrl defines the url where the files to load is located
  49630. * @param scene defines the current scene
  49631. * @param files defines the list of files to load (1 per face)
  49632. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49633. * @param onLoad defines an optional callback raised when the texture is loaded
  49634. * @param onError defines an optional callback raised if there is an issue to load the texture
  49635. * @param format defines the format of the data
  49636. * @param forcedExtension defines the extension to use to pick the right loader
  49637. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49638. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49639. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49640. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49641. * @returns the cube texture as an InternalTexture
  49642. */
  49643. 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;
  49644. private _getSamplingFilter;
  49645. private static _GetNativeTextureFormat;
  49646. createRenderTargetTexture(size: number | {
  49647. width: number;
  49648. height: number;
  49649. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49650. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49651. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49652. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49653. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49654. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49655. /**
  49656. * Updates a dynamic vertex buffer.
  49657. * @param vertexBuffer the vertex buffer to update
  49658. * @param data the data used to update the vertex buffer
  49659. * @param byteOffset the byte offset of the data (optional)
  49660. * @param byteLength the byte length of the data (optional)
  49661. */
  49662. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49663. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49664. private _updateAnisotropicLevel;
  49665. private _getAddressMode;
  49666. /** @hidden */
  49667. _bindTexture(channel: number, texture: InternalTexture): void;
  49668. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49669. releaseEffects(): void;
  49670. /** @hidden */
  49671. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49672. /** @hidden */
  49673. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49674. /** @hidden */
  49675. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49676. /** @hidden */
  49677. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49678. }
  49679. }
  49680. declare module "babylonjs/Engines/index" {
  49681. export * from "babylonjs/Engines/constants";
  49682. export * from "babylonjs/Engines/engineCapabilities";
  49683. export * from "babylonjs/Engines/instancingAttributeInfo";
  49684. export * from "babylonjs/Engines/thinEngine";
  49685. export * from "babylonjs/Engines/engine";
  49686. export * from "babylonjs/Engines/engineStore";
  49687. export * from "babylonjs/Engines/nullEngine";
  49688. export * from "babylonjs/Engines/Extensions/index";
  49689. export * from "babylonjs/Engines/IPipelineContext";
  49690. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49691. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49692. export * from "babylonjs/Engines/nativeEngine";
  49693. }
  49694. declare module "babylonjs/Events/clipboardEvents" {
  49695. /**
  49696. * Gather the list of clipboard event types as constants.
  49697. */
  49698. export class ClipboardEventTypes {
  49699. /**
  49700. * The clipboard event is fired when a copy command is active (pressed).
  49701. */
  49702. static readonly COPY: number;
  49703. /**
  49704. * The clipboard event is fired when a cut command is active (pressed).
  49705. */
  49706. static readonly CUT: number;
  49707. /**
  49708. * The clipboard event is fired when a paste command is active (pressed).
  49709. */
  49710. static readonly PASTE: number;
  49711. }
  49712. /**
  49713. * This class is used to store clipboard related info for the onClipboardObservable event.
  49714. */
  49715. export class ClipboardInfo {
  49716. /**
  49717. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49718. */
  49719. type: number;
  49720. /**
  49721. * Defines the related dom event
  49722. */
  49723. event: ClipboardEvent;
  49724. /**
  49725. *Creates an instance of ClipboardInfo.
  49726. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49727. * @param event Defines the related dom event
  49728. */
  49729. constructor(
  49730. /**
  49731. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49732. */
  49733. type: number,
  49734. /**
  49735. * Defines the related dom event
  49736. */
  49737. event: ClipboardEvent);
  49738. /**
  49739. * Get the clipboard event's type from the keycode.
  49740. * @param keyCode Defines the keyCode for the current keyboard event.
  49741. * @return {number}
  49742. */
  49743. static GetTypeFromCharacter(keyCode: number): number;
  49744. }
  49745. }
  49746. declare module "babylonjs/Events/index" {
  49747. export * from "babylonjs/Events/keyboardEvents";
  49748. export * from "babylonjs/Events/pointerEvents";
  49749. export * from "babylonjs/Events/clipboardEvents";
  49750. }
  49751. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49752. import { Scene } from "babylonjs/scene";
  49753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49754. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49755. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49756. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49757. /**
  49758. * Google Daydream controller
  49759. */
  49760. export class DaydreamController extends WebVRController {
  49761. /**
  49762. * Base Url for the controller model.
  49763. */
  49764. static MODEL_BASE_URL: string;
  49765. /**
  49766. * File name for the controller model.
  49767. */
  49768. static MODEL_FILENAME: string;
  49769. /**
  49770. * Gamepad Id prefix used to identify Daydream Controller.
  49771. */
  49772. static readonly GAMEPAD_ID_PREFIX: string;
  49773. /**
  49774. * Creates a new DaydreamController from a gamepad
  49775. * @param vrGamepad the gamepad that the controller should be created from
  49776. */
  49777. constructor(vrGamepad: any);
  49778. /**
  49779. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49780. * @param scene scene in which to add meshes
  49781. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49782. */
  49783. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49784. /**
  49785. * Called once for each button that changed state since the last frame
  49786. * @param buttonIdx Which button index changed
  49787. * @param state New state of the button
  49788. * @param changes Which properties on the state changed since last frame
  49789. */
  49790. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49791. }
  49792. }
  49793. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49794. import { Scene } from "babylonjs/scene";
  49795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49796. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49797. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49798. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49799. /**
  49800. * Gear VR Controller
  49801. */
  49802. export class GearVRController extends WebVRController {
  49803. /**
  49804. * Base Url for the controller model.
  49805. */
  49806. static MODEL_BASE_URL: string;
  49807. /**
  49808. * File name for the controller model.
  49809. */
  49810. static MODEL_FILENAME: string;
  49811. /**
  49812. * Gamepad Id prefix used to identify this controller.
  49813. */
  49814. static readonly GAMEPAD_ID_PREFIX: string;
  49815. private readonly _buttonIndexToObservableNameMap;
  49816. /**
  49817. * Creates a new GearVRController from a gamepad
  49818. * @param vrGamepad the gamepad that the controller should be created from
  49819. */
  49820. constructor(vrGamepad: any);
  49821. /**
  49822. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49823. * @param scene scene in which to add meshes
  49824. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49825. */
  49826. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49827. /**
  49828. * Called once for each button that changed state since the last frame
  49829. * @param buttonIdx Which button index changed
  49830. * @param state New state of the button
  49831. * @param changes Which properties on the state changed since last frame
  49832. */
  49833. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49834. }
  49835. }
  49836. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49837. import { Scene } from "babylonjs/scene";
  49838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49839. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49840. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49841. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49842. /**
  49843. * Generic Controller
  49844. */
  49845. export class GenericController extends WebVRController {
  49846. /**
  49847. * Base Url for the controller model.
  49848. */
  49849. static readonly MODEL_BASE_URL: string;
  49850. /**
  49851. * File name for the controller model.
  49852. */
  49853. static readonly MODEL_FILENAME: string;
  49854. /**
  49855. * Creates a new GenericController from a gamepad
  49856. * @param vrGamepad the gamepad that the controller should be created from
  49857. */
  49858. constructor(vrGamepad: any);
  49859. /**
  49860. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49861. * @param scene scene in which to add meshes
  49862. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49863. */
  49864. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49865. /**
  49866. * Called once for each button that changed state since the last frame
  49867. * @param buttonIdx Which button index changed
  49868. * @param state New state of the button
  49869. * @param changes Which properties on the state changed since last frame
  49870. */
  49871. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49872. }
  49873. }
  49874. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49875. import { Observable } from "babylonjs/Misc/observable";
  49876. import { Scene } from "babylonjs/scene";
  49877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49878. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49879. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49880. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49881. /**
  49882. * Oculus Touch Controller
  49883. */
  49884. export class OculusTouchController extends WebVRController {
  49885. /**
  49886. * Base Url for the controller model.
  49887. */
  49888. static MODEL_BASE_URL: string;
  49889. /**
  49890. * File name for the left controller model.
  49891. */
  49892. static MODEL_LEFT_FILENAME: string;
  49893. /**
  49894. * File name for the right controller model.
  49895. */
  49896. static MODEL_RIGHT_FILENAME: string;
  49897. /**
  49898. * Base Url for the Quest controller model.
  49899. */
  49900. static QUEST_MODEL_BASE_URL: string;
  49901. /**
  49902. * @hidden
  49903. * If the controllers are running on a device that needs the updated Quest controller models
  49904. */
  49905. static _IsQuest: boolean;
  49906. /**
  49907. * Fired when the secondary trigger on this controller is modified
  49908. */
  49909. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49910. /**
  49911. * Fired when the thumb rest on this controller is modified
  49912. */
  49913. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49914. /**
  49915. * Creates a new OculusTouchController from a gamepad
  49916. * @param vrGamepad the gamepad that the controller should be created from
  49917. */
  49918. constructor(vrGamepad: any);
  49919. /**
  49920. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49921. * @param scene scene in which to add meshes
  49922. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49923. */
  49924. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49925. /**
  49926. * Fired when the A button on this controller is modified
  49927. */
  49928. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49929. /**
  49930. * Fired when the B button on this controller is modified
  49931. */
  49932. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49933. /**
  49934. * Fired when the X button on this controller is modified
  49935. */
  49936. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49937. /**
  49938. * Fired when the Y button on this controller is modified
  49939. */
  49940. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49941. /**
  49942. * Called once for each button that changed state since the last frame
  49943. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49944. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49945. * 2) secondary trigger (same)
  49946. * 3) A (right) X (left), touch, pressed = value
  49947. * 4) B / Y
  49948. * 5) thumb rest
  49949. * @param buttonIdx Which button index changed
  49950. * @param state New state of the button
  49951. * @param changes Which properties on the state changed since last frame
  49952. */
  49953. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49954. }
  49955. }
  49956. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49957. import { Scene } from "babylonjs/scene";
  49958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49959. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49960. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49961. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49962. import { Observable } from "babylonjs/Misc/observable";
  49963. /**
  49964. * Vive Controller
  49965. */
  49966. export class ViveController extends WebVRController {
  49967. /**
  49968. * Base Url for the controller model.
  49969. */
  49970. static MODEL_BASE_URL: string;
  49971. /**
  49972. * File name for the controller model.
  49973. */
  49974. static MODEL_FILENAME: string;
  49975. /**
  49976. * Creates a new ViveController from a gamepad
  49977. * @param vrGamepad the gamepad that the controller should be created from
  49978. */
  49979. constructor(vrGamepad: any);
  49980. /**
  49981. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49982. * @param scene scene in which to add meshes
  49983. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49984. */
  49985. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49986. /**
  49987. * Fired when the left button on this controller is modified
  49988. */
  49989. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49990. /**
  49991. * Fired when the right button on this controller is modified
  49992. */
  49993. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49994. /**
  49995. * Fired when the menu button on this controller is modified
  49996. */
  49997. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49998. /**
  49999. * Called once for each button that changed state since the last frame
  50000. * Vive mapping:
  50001. * 0: touchpad
  50002. * 1: trigger
  50003. * 2: left AND right buttons
  50004. * 3: menu button
  50005. * @param buttonIdx Which button index changed
  50006. * @param state New state of the button
  50007. * @param changes Which properties on the state changed since last frame
  50008. */
  50009. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50010. }
  50011. }
  50012. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50013. import { Observable } from "babylonjs/Misc/observable";
  50014. import { Scene } from "babylonjs/scene";
  50015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50016. import { Ray } from "babylonjs/Culling/ray";
  50017. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50018. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50019. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50020. /**
  50021. * Defines the WindowsMotionController object that the state of the windows motion controller
  50022. */
  50023. export class WindowsMotionController extends WebVRController {
  50024. /**
  50025. * The base url used to load the left and right controller models
  50026. */
  50027. static MODEL_BASE_URL: string;
  50028. /**
  50029. * The name of the left controller model file
  50030. */
  50031. static MODEL_LEFT_FILENAME: string;
  50032. /**
  50033. * The name of the right controller model file
  50034. */
  50035. static MODEL_RIGHT_FILENAME: string;
  50036. /**
  50037. * The controller name prefix for this controller type
  50038. */
  50039. static readonly GAMEPAD_ID_PREFIX: string;
  50040. /**
  50041. * The controller id pattern for this controller type
  50042. */
  50043. private static readonly GAMEPAD_ID_PATTERN;
  50044. private _loadedMeshInfo;
  50045. protected readonly _mapping: {
  50046. buttons: string[];
  50047. buttonMeshNames: {
  50048. 'trigger': string;
  50049. 'menu': string;
  50050. 'grip': string;
  50051. 'thumbstick': string;
  50052. 'trackpad': string;
  50053. };
  50054. buttonObservableNames: {
  50055. 'trigger': string;
  50056. 'menu': string;
  50057. 'grip': string;
  50058. 'thumbstick': string;
  50059. 'trackpad': string;
  50060. };
  50061. axisMeshNames: string[];
  50062. pointingPoseMeshName: string;
  50063. };
  50064. /**
  50065. * Fired when the trackpad on this controller is clicked
  50066. */
  50067. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50068. /**
  50069. * Fired when the trackpad on this controller is modified
  50070. */
  50071. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50072. /**
  50073. * The current x and y values of this controller's trackpad
  50074. */
  50075. trackpad: StickValues;
  50076. /**
  50077. * Creates a new WindowsMotionController from a gamepad
  50078. * @param vrGamepad the gamepad that the controller should be created from
  50079. */
  50080. constructor(vrGamepad: any);
  50081. /**
  50082. * Fired when the trigger on this controller is modified
  50083. */
  50084. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50085. /**
  50086. * Fired when the menu button on this controller is modified
  50087. */
  50088. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50089. /**
  50090. * Fired when the grip button on this controller is modified
  50091. */
  50092. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50093. /**
  50094. * Fired when the thumbstick button on this controller is modified
  50095. */
  50096. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50097. /**
  50098. * Fired when the touchpad button on this controller is modified
  50099. */
  50100. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50101. /**
  50102. * Fired when the touchpad values on this controller are modified
  50103. */
  50104. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50105. protected _updateTrackpad(): void;
  50106. /**
  50107. * Called once per frame by the engine.
  50108. */
  50109. update(): void;
  50110. /**
  50111. * Called once for each button that changed state since the last frame
  50112. * @param buttonIdx Which button index changed
  50113. * @param state New state of the button
  50114. * @param changes Which properties on the state changed since last frame
  50115. */
  50116. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50117. /**
  50118. * Moves the buttons on the controller mesh based on their current state
  50119. * @param buttonName the name of the button to move
  50120. * @param buttonValue the value of the button which determines the buttons new position
  50121. */
  50122. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50123. /**
  50124. * Moves the axis on the controller mesh based on its current state
  50125. * @param axis the index of the axis
  50126. * @param axisValue the value of the axis which determines the meshes new position
  50127. * @hidden
  50128. */
  50129. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50130. /**
  50131. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50132. * @param scene scene in which to add meshes
  50133. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50134. */
  50135. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50136. /**
  50137. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50138. * can be transformed by button presses and axes values, based on this._mapping.
  50139. *
  50140. * @param scene scene in which the meshes exist
  50141. * @param meshes list of meshes that make up the controller model to process
  50142. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50143. */
  50144. private processModel;
  50145. private createMeshInfo;
  50146. /**
  50147. * Gets the ray of the controller in the direction the controller is pointing
  50148. * @param length the length the resulting ray should be
  50149. * @returns a ray in the direction the controller is pointing
  50150. */
  50151. getForwardRay(length?: number): Ray;
  50152. /**
  50153. * Disposes of the controller
  50154. */
  50155. dispose(): void;
  50156. }
  50157. /**
  50158. * This class represents a new windows motion controller in XR.
  50159. */
  50160. export class XRWindowsMotionController extends WindowsMotionController {
  50161. /**
  50162. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50163. */
  50164. protected readonly _mapping: {
  50165. buttons: string[];
  50166. buttonMeshNames: {
  50167. 'trigger': string;
  50168. 'menu': string;
  50169. 'grip': string;
  50170. 'thumbstick': string;
  50171. 'trackpad': string;
  50172. };
  50173. buttonObservableNames: {
  50174. 'trigger': string;
  50175. 'menu': string;
  50176. 'grip': string;
  50177. 'thumbstick': string;
  50178. 'trackpad': string;
  50179. };
  50180. axisMeshNames: string[];
  50181. pointingPoseMeshName: string;
  50182. };
  50183. /**
  50184. * Construct a new XR-Based windows motion controller
  50185. *
  50186. * @param gamepadInfo the gamepad object from the browser
  50187. */
  50188. constructor(gamepadInfo: any);
  50189. /**
  50190. * holds the thumbstick values (X,Y)
  50191. */
  50192. thumbstickValues: StickValues;
  50193. /**
  50194. * Fired when the thumbstick on this controller is clicked
  50195. */
  50196. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50197. /**
  50198. * Fired when the thumbstick on this controller is modified
  50199. */
  50200. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50201. /**
  50202. * Fired when the touchpad button on this controller is modified
  50203. */
  50204. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50205. /**
  50206. * Fired when the touchpad values on this controller are modified
  50207. */
  50208. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50209. /**
  50210. * Fired when the thumbstick button on this controller is modified
  50211. * here to prevent breaking changes
  50212. */
  50213. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50214. /**
  50215. * updating the thumbstick(!) and not the trackpad.
  50216. * This is named this way due to the difference between WebVR and XR and to avoid
  50217. * changing the parent class.
  50218. */
  50219. protected _updateTrackpad(): void;
  50220. /**
  50221. * Disposes the class with joy
  50222. */
  50223. dispose(): void;
  50224. }
  50225. }
  50226. declare module "babylonjs/Gamepads/Controllers/index" {
  50227. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50228. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50229. export * from "babylonjs/Gamepads/Controllers/genericController";
  50230. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50231. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50232. export * from "babylonjs/Gamepads/Controllers/viveController";
  50233. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50234. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50235. }
  50236. declare module "babylonjs/Gamepads/index" {
  50237. export * from "babylonjs/Gamepads/Controllers/index";
  50238. export * from "babylonjs/Gamepads/gamepad";
  50239. export * from "babylonjs/Gamepads/gamepadManager";
  50240. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50241. export * from "babylonjs/Gamepads/xboxGamepad";
  50242. export * from "babylonjs/Gamepads/dualShockGamepad";
  50243. }
  50244. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50245. import { Scene } from "babylonjs/scene";
  50246. import { Vector4 } from "babylonjs/Maths/math.vector";
  50247. import { Color4 } from "babylonjs/Maths/math.color";
  50248. import { Mesh } from "babylonjs/Meshes/mesh";
  50249. import { Nullable } from "babylonjs/types";
  50250. /**
  50251. * Class containing static functions to help procedurally build meshes
  50252. */
  50253. export class PolyhedronBuilder {
  50254. /**
  50255. * Creates a polyhedron mesh
  50256. * * 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
  50257. * * The parameter `size` (positive float, default 1) sets the polygon size
  50258. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50259. * * 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`
  50260. * * 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
  50261. * * 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)`)
  50262. * * 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
  50263. * * 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
  50264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50267. * @param name defines the name of the mesh
  50268. * @param options defines the options used to create the mesh
  50269. * @param scene defines the hosting scene
  50270. * @returns the polyhedron mesh
  50271. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50272. */
  50273. static CreatePolyhedron(name: string, options: {
  50274. type?: number;
  50275. size?: number;
  50276. sizeX?: number;
  50277. sizeY?: number;
  50278. sizeZ?: number;
  50279. custom?: any;
  50280. faceUV?: Vector4[];
  50281. faceColors?: Color4[];
  50282. flat?: boolean;
  50283. updatable?: boolean;
  50284. sideOrientation?: number;
  50285. frontUVs?: Vector4;
  50286. backUVs?: Vector4;
  50287. }, scene?: Nullable<Scene>): Mesh;
  50288. }
  50289. }
  50290. declare module "babylonjs/Gizmos/scaleGizmo" {
  50291. import { Observable } from "babylonjs/Misc/observable";
  50292. import { Nullable } from "babylonjs/types";
  50293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50294. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50295. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50296. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50297. /**
  50298. * Gizmo that enables scaling a mesh along 3 axis
  50299. */
  50300. export class ScaleGizmo extends Gizmo {
  50301. /**
  50302. * Internal gizmo used for interactions on the x axis
  50303. */
  50304. xGizmo: AxisScaleGizmo;
  50305. /**
  50306. * Internal gizmo used for interactions on the y axis
  50307. */
  50308. yGizmo: AxisScaleGizmo;
  50309. /**
  50310. * Internal gizmo used for interactions on the z axis
  50311. */
  50312. zGizmo: AxisScaleGizmo;
  50313. /**
  50314. * Internal gizmo used to scale all axis equally
  50315. */
  50316. uniformScaleGizmo: AxisScaleGizmo;
  50317. private _meshAttached;
  50318. private _updateGizmoRotationToMatchAttachedMesh;
  50319. private _snapDistance;
  50320. private _scaleRatio;
  50321. private _uniformScalingMesh;
  50322. private _octahedron;
  50323. private _sensitivity;
  50324. /** Fires an event when any of it's sub gizmos are dragged */
  50325. onDragStartObservable: Observable<unknown>;
  50326. /** Fires an event when any of it's sub gizmos are released from dragging */
  50327. onDragEndObservable: Observable<unknown>;
  50328. get attachedMesh(): Nullable<AbstractMesh>;
  50329. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50330. /**
  50331. * Creates a ScaleGizmo
  50332. * @param gizmoLayer The utility layer the gizmo will be added to
  50333. */
  50334. constructor(gizmoLayer?: UtilityLayerRenderer);
  50335. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50336. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50337. /**
  50338. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50339. */
  50340. set snapDistance(value: number);
  50341. get snapDistance(): number;
  50342. /**
  50343. * Ratio for the scale of the gizmo (Default: 1)
  50344. */
  50345. set scaleRatio(value: number);
  50346. get scaleRatio(): number;
  50347. /**
  50348. * Sensitivity factor for dragging (Default: 1)
  50349. */
  50350. set sensitivity(value: number);
  50351. get sensitivity(): number;
  50352. /**
  50353. * Disposes of the gizmo
  50354. */
  50355. dispose(): void;
  50356. }
  50357. }
  50358. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50359. import { Observable } from "babylonjs/Misc/observable";
  50360. import { Nullable } from "babylonjs/types";
  50361. import { Vector3 } from "babylonjs/Maths/math.vector";
  50362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50363. import { Mesh } from "babylonjs/Meshes/mesh";
  50364. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50365. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50366. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50367. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50368. import { Color3 } from "babylonjs/Maths/math.color";
  50369. /**
  50370. * Single axis scale gizmo
  50371. */
  50372. export class AxisScaleGizmo extends Gizmo {
  50373. /**
  50374. * Drag behavior responsible for the gizmos dragging interactions
  50375. */
  50376. dragBehavior: PointerDragBehavior;
  50377. private _pointerObserver;
  50378. /**
  50379. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50380. */
  50381. snapDistance: number;
  50382. /**
  50383. * Event that fires each time the gizmo snaps to a new location.
  50384. * * snapDistance is the the change in distance
  50385. */
  50386. onSnapObservable: Observable<{
  50387. snapDistance: number;
  50388. }>;
  50389. /**
  50390. * If the scaling operation should be done on all axis (default: false)
  50391. */
  50392. uniformScaling: boolean;
  50393. /**
  50394. * Custom sensitivity value for the drag strength
  50395. */
  50396. sensitivity: number;
  50397. private _isEnabled;
  50398. private _parent;
  50399. private _arrow;
  50400. private _coloredMaterial;
  50401. private _hoverMaterial;
  50402. /**
  50403. * Creates an AxisScaleGizmo
  50404. * @param gizmoLayer The utility layer the gizmo will be added to
  50405. * @param dragAxis The axis which the gizmo will be able to scale on
  50406. * @param color The color of the gizmo
  50407. */
  50408. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50409. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50410. /**
  50411. * If the gizmo is enabled
  50412. */
  50413. set isEnabled(value: boolean);
  50414. get isEnabled(): boolean;
  50415. /**
  50416. * Disposes of the gizmo
  50417. */
  50418. dispose(): void;
  50419. /**
  50420. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50421. * @param mesh The mesh to replace the default mesh of the gizmo
  50422. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50423. */
  50424. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50425. }
  50426. }
  50427. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50428. import { Observable } from "babylonjs/Misc/observable";
  50429. import { Nullable } from "babylonjs/types";
  50430. import { Vector3 } from "babylonjs/Maths/math.vector";
  50431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50432. import { Mesh } from "babylonjs/Meshes/mesh";
  50433. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50434. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50435. import { Color3 } from "babylonjs/Maths/math.color";
  50436. import "babylonjs/Meshes/Builders/boxBuilder";
  50437. /**
  50438. * Bounding box gizmo
  50439. */
  50440. export class BoundingBoxGizmo extends Gizmo {
  50441. private _lineBoundingBox;
  50442. private _rotateSpheresParent;
  50443. private _scaleBoxesParent;
  50444. private _boundingDimensions;
  50445. private _renderObserver;
  50446. private _pointerObserver;
  50447. private _scaleDragSpeed;
  50448. private _tmpQuaternion;
  50449. private _tmpVector;
  50450. private _tmpRotationMatrix;
  50451. /**
  50452. * 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)
  50453. */
  50454. ignoreChildren: boolean;
  50455. /**
  50456. * 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)
  50457. */
  50458. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50459. /**
  50460. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50461. */
  50462. rotationSphereSize: number;
  50463. /**
  50464. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50465. */
  50466. scaleBoxSize: number;
  50467. /**
  50468. * 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)
  50469. */
  50470. fixedDragMeshScreenSize: boolean;
  50471. /**
  50472. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50473. */
  50474. fixedDragMeshScreenSizeDistanceFactor: number;
  50475. /**
  50476. * Fired when a rotation sphere or scale box is dragged
  50477. */
  50478. onDragStartObservable: Observable<{}>;
  50479. /**
  50480. * Fired when a scale box is dragged
  50481. */
  50482. onScaleBoxDragObservable: Observable<{}>;
  50483. /**
  50484. * Fired when a scale box drag is ended
  50485. */
  50486. onScaleBoxDragEndObservable: Observable<{}>;
  50487. /**
  50488. * Fired when a rotation sphere is dragged
  50489. */
  50490. onRotationSphereDragObservable: Observable<{}>;
  50491. /**
  50492. * Fired when a rotation sphere drag is ended
  50493. */
  50494. onRotationSphereDragEndObservable: Observable<{}>;
  50495. /**
  50496. * 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)
  50497. */
  50498. scalePivot: Nullable<Vector3>;
  50499. /**
  50500. * Mesh used as a pivot to rotate the attached mesh
  50501. */
  50502. private _anchorMesh;
  50503. private _existingMeshScale;
  50504. private _dragMesh;
  50505. private pointerDragBehavior;
  50506. private coloredMaterial;
  50507. private hoverColoredMaterial;
  50508. /**
  50509. * Sets the color of the bounding box gizmo
  50510. * @param color the color to set
  50511. */
  50512. setColor(color: Color3): void;
  50513. /**
  50514. * Creates an BoundingBoxGizmo
  50515. * @param gizmoLayer The utility layer the gizmo will be added to
  50516. * @param color The color of the gizmo
  50517. */
  50518. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50519. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50520. private _selectNode;
  50521. /**
  50522. * Updates the bounding box information for the Gizmo
  50523. */
  50524. updateBoundingBox(): void;
  50525. private _updateRotationSpheres;
  50526. private _updateScaleBoxes;
  50527. /**
  50528. * Enables rotation on the specified axis and disables rotation on the others
  50529. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50530. */
  50531. setEnabledRotationAxis(axis: string): void;
  50532. /**
  50533. * Enables/disables scaling
  50534. * @param enable if scaling should be enabled
  50535. */
  50536. setEnabledScaling(enable: boolean): void;
  50537. private _updateDummy;
  50538. /**
  50539. * Enables a pointer drag behavior on the bounding box of the gizmo
  50540. */
  50541. enableDragBehavior(): void;
  50542. /**
  50543. * Disposes of the gizmo
  50544. */
  50545. dispose(): void;
  50546. /**
  50547. * 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)
  50548. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50549. * @returns the bounding box mesh with the passed in mesh as a child
  50550. */
  50551. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50552. /**
  50553. * CustomMeshes are not supported by this gizmo
  50554. * @param mesh The mesh to replace the default mesh of the gizmo
  50555. */
  50556. setCustomMesh(mesh: Mesh): void;
  50557. }
  50558. }
  50559. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50560. import { Observable } from "babylonjs/Misc/observable";
  50561. import { Nullable } from "babylonjs/types";
  50562. import { Vector3 } from "babylonjs/Maths/math.vector";
  50563. import { Color3 } from "babylonjs/Maths/math.color";
  50564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50565. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50566. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50567. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50568. import "babylonjs/Meshes/Builders/linesBuilder";
  50569. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50570. /**
  50571. * Single plane rotation gizmo
  50572. */
  50573. export class PlaneRotationGizmo extends Gizmo {
  50574. /**
  50575. * Drag behavior responsible for the gizmos dragging interactions
  50576. */
  50577. dragBehavior: PointerDragBehavior;
  50578. private _pointerObserver;
  50579. /**
  50580. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50581. */
  50582. snapDistance: number;
  50583. /**
  50584. * Event that fires each time the gizmo snaps to a new location.
  50585. * * snapDistance is the the change in distance
  50586. */
  50587. onSnapObservable: Observable<{
  50588. snapDistance: number;
  50589. }>;
  50590. private _isEnabled;
  50591. private _parent;
  50592. /**
  50593. * Creates a PlaneRotationGizmo
  50594. * @param gizmoLayer The utility layer the gizmo will be added to
  50595. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50596. * @param color The color of the gizmo
  50597. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50598. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50599. */
  50600. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50601. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50602. /**
  50603. * If the gizmo is enabled
  50604. */
  50605. set isEnabled(value: boolean);
  50606. get isEnabled(): boolean;
  50607. /**
  50608. * Disposes of the gizmo
  50609. */
  50610. dispose(): void;
  50611. }
  50612. }
  50613. declare module "babylonjs/Gizmos/rotationGizmo" {
  50614. import { Observable } from "babylonjs/Misc/observable";
  50615. import { Nullable } from "babylonjs/types";
  50616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50617. import { Mesh } from "babylonjs/Meshes/mesh";
  50618. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50619. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50620. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50621. /**
  50622. * Gizmo that enables rotating a mesh along 3 axis
  50623. */
  50624. export class RotationGizmo extends Gizmo {
  50625. /**
  50626. * Internal gizmo used for interactions on the x axis
  50627. */
  50628. xGizmo: PlaneRotationGizmo;
  50629. /**
  50630. * Internal gizmo used for interactions on the y axis
  50631. */
  50632. yGizmo: PlaneRotationGizmo;
  50633. /**
  50634. * Internal gizmo used for interactions on the z axis
  50635. */
  50636. zGizmo: PlaneRotationGizmo;
  50637. /** Fires an event when any of it's sub gizmos are dragged */
  50638. onDragStartObservable: Observable<unknown>;
  50639. /** Fires an event when any of it's sub gizmos are released from dragging */
  50640. onDragEndObservable: Observable<unknown>;
  50641. private _meshAttached;
  50642. get attachedMesh(): Nullable<AbstractMesh>;
  50643. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50644. /**
  50645. * Creates a RotationGizmo
  50646. * @param gizmoLayer The utility layer the gizmo will be added to
  50647. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50648. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50649. */
  50650. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50651. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50652. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50653. /**
  50654. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50655. */
  50656. set snapDistance(value: number);
  50657. get snapDistance(): number;
  50658. /**
  50659. * Ratio for the scale of the gizmo (Default: 1)
  50660. */
  50661. set scaleRatio(value: number);
  50662. get scaleRatio(): number;
  50663. /**
  50664. * Disposes of the gizmo
  50665. */
  50666. dispose(): void;
  50667. /**
  50668. * CustomMeshes are not supported by this gizmo
  50669. * @param mesh The mesh to replace the default mesh of the gizmo
  50670. */
  50671. setCustomMesh(mesh: Mesh): void;
  50672. }
  50673. }
  50674. declare module "babylonjs/Gizmos/gizmoManager" {
  50675. import { Observable } from "babylonjs/Misc/observable";
  50676. import { Nullable } from "babylonjs/types";
  50677. import { Scene, IDisposable } from "babylonjs/scene";
  50678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50679. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50680. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50681. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50682. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50683. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50684. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50685. /**
  50686. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50687. */
  50688. export class GizmoManager implements IDisposable {
  50689. private scene;
  50690. /**
  50691. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50692. */
  50693. gizmos: {
  50694. positionGizmo: Nullable<PositionGizmo>;
  50695. rotationGizmo: Nullable<RotationGizmo>;
  50696. scaleGizmo: Nullable<ScaleGizmo>;
  50697. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50698. };
  50699. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50700. clearGizmoOnEmptyPointerEvent: boolean;
  50701. /** Fires an event when the manager is attached to a mesh */
  50702. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50703. private _gizmosEnabled;
  50704. private _pointerObserver;
  50705. private _attachedMesh;
  50706. private _boundingBoxColor;
  50707. private _defaultUtilityLayer;
  50708. private _defaultKeepDepthUtilityLayer;
  50709. /**
  50710. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50711. */
  50712. boundingBoxDragBehavior: SixDofDragBehavior;
  50713. /**
  50714. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50715. */
  50716. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50717. /**
  50718. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50719. */
  50720. usePointerToAttachGizmos: boolean;
  50721. /**
  50722. * Utility layer that the bounding box gizmo belongs to
  50723. */
  50724. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50725. /**
  50726. * Utility layer that all gizmos besides bounding box belong to
  50727. */
  50728. get utilityLayer(): UtilityLayerRenderer;
  50729. /**
  50730. * Instatiates a gizmo manager
  50731. * @param scene the scene to overlay the gizmos on top of
  50732. */
  50733. constructor(scene: Scene);
  50734. /**
  50735. * Attaches a set of gizmos to the specified mesh
  50736. * @param mesh The mesh the gizmo's should be attached to
  50737. */
  50738. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50739. /**
  50740. * If the position gizmo is enabled
  50741. */
  50742. set positionGizmoEnabled(value: boolean);
  50743. get positionGizmoEnabled(): boolean;
  50744. /**
  50745. * If the rotation gizmo is enabled
  50746. */
  50747. set rotationGizmoEnabled(value: boolean);
  50748. get rotationGizmoEnabled(): boolean;
  50749. /**
  50750. * If the scale gizmo is enabled
  50751. */
  50752. set scaleGizmoEnabled(value: boolean);
  50753. get scaleGizmoEnabled(): boolean;
  50754. /**
  50755. * If the boundingBox gizmo is enabled
  50756. */
  50757. set boundingBoxGizmoEnabled(value: boolean);
  50758. get boundingBoxGizmoEnabled(): boolean;
  50759. /**
  50760. * Disposes of the gizmo manager
  50761. */
  50762. dispose(): void;
  50763. }
  50764. }
  50765. declare module "babylonjs/Lights/directionalLight" {
  50766. import { Camera } from "babylonjs/Cameras/camera";
  50767. import { Scene } from "babylonjs/scene";
  50768. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50770. import { Light } from "babylonjs/Lights/light";
  50771. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50772. import { Effect } from "babylonjs/Materials/effect";
  50773. /**
  50774. * A directional light is defined by a direction (what a surprise!).
  50775. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50776. * 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.
  50777. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50778. */
  50779. export class DirectionalLight extends ShadowLight {
  50780. private _shadowFrustumSize;
  50781. /**
  50782. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50783. */
  50784. get shadowFrustumSize(): number;
  50785. /**
  50786. * Specifies a fix frustum size for the shadow generation.
  50787. */
  50788. set shadowFrustumSize(value: number);
  50789. private _shadowOrthoScale;
  50790. /**
  50791. * Gets the shadow projection scale against the optimal computed one.
  50792. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50793. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50794. */
  50795. get shadowOrthoScale(): number;
  50796. /**
  50797. * Sets the shadow projection scale against the optimal computed one.
  50798. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50799. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50800. */
  50801. set shadowOrthoScale(value: number);
  50802. /**
  50803. * Automatically compute the projection matrix to best fit (including all the casters)
  50804. * on each frame.
  50805. */
  50806. autoUpdateExtends: boolean;
  50807. /**
  50808. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50809. * on each frame. autoUpdateExtends must be set to true for this to work
  50810. */
  50811. autoCalcShadowZBounds: boolean;
  50812. private _orthoLeft;
  50813. private _orthoRight;
  50814. private _orthoTop;
  50815. private _orthoBottom;
  50816. /**
  50817. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50818. * The directional light is emitted from everywhere in the given direction.
  50819. * It can cast shadows.
  50820. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50821. * @param name The friendly name of the light
  50822. * @param direction The direction of the light
  50823. * @param scene The scene the light belongs to
  50824. */
  50825. constructor(name: string, direction: Vector3, scene: Scene);
  50826. /**
  50827. * Returns the string "DirectionalLight".
  50828. * @return The class name
  50829. */
  50830. getClassName(): string;
  50831. /**
  50832. * Returns the integer 1.
  50833. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50834. */
  50835. getTypeID(): number;
  50836. /**
  50837. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50838. * Returns the DirectionalLight Shadow projection matrix.
  50839. */
  50840. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50841. /**
  50842. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50843. * Returns the DirectionalLight Shadow projection matrix.
  50844. */
  50845. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50846. /**
  50847. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50848. * Returns the DirectionalLight Shadow projection matrix.
  50849. */
  50850. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50851. protected _buildUniformLayout(): void;
  50852. /**
  50853. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50854. * @param effect The effect to update
  50855. * @param lightIndex The index of the light in the effect to update
  50856. * @returns The directional light
  50857. */
  50858. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50859. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50860. /**
  50861. * Gets the minZ used for shadow according to both the scene and the light.
  50862. *
  50863. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50864. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50865. * @param activeCamera The camera we are returning the min for
  50866. * @returns the depth min z
  50867. */
  50868. getDepthMinZ(activeCamera: Camera): number;
  50869. /**
  50870. * Gets the maxZ used for shadow according to both the scene and the light.
  50871. *
  50872. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50873. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50874. * @param activeCamera The camera we are returning the max for
  50875. * @returns the depth max z
  50876. */
  50877. getDepthMaxZ(activeCamera: Camera): number;
  50878. /**
  50879. * Prepares the list of defines specific to the light type.
  50880. * @param defines the list of defines
  50881. * @param lightIndex defines the index of the light for the effect
  50882. */
  50883. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50884. }
  50885. }
  50886. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50887. import { Mesh } from "babylonjs/Meshes/mesh";
  50888. /**
  50889. * Class containing static functions to help procedurally build meshes
  50890. */
  50891. export class HemisphereBuilder {
  50892. /**
  50893. * Creates a hemisphere mesh
  50894. * @param name defines the name of the mesh
  50895. * @param options defines the options used to create the mesh
  50896. * @param scene defines the hosting scene
  50897. * @returns the hemisphere mesh
  50898. */
  50899. static CreateHemisphere(name: string, options: {
  50900. segments?: number;
  50901. diameter?: number;
  50902. sideOrientation?: number;
  50903. }, scene: any): Mesh;
  50904. }
  50905. }
  50906. declare module "babylonjs/Lights/spotLight" {
  50907. import { Nullable } from "babylonjs/types";
  50908. import { Scene } from "babylonjs/scene";
  50909. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50911. import { Effect } from "babylonjs/Materials/effect";
  50912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50913. import { Light } from "babylonjs/Lights/light";
  50914. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50915. /**
  50916. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50917. * These values define a cone of light starting from the position, emitting toward the direction.
  50918. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50919. * and the exponent defines the speed of the decay of the light with distance (reach).
  50920. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50921. */
  50922. export class SpotLight extends ShadowLight {
  50923. private _angle;
  50924. private _innerAngle;
  50925. private _cosHalfAngle;
  50926. private _lightAngleScale;
  50927. private _lightAngleOffset;
  50928. /**
  50929. * Gets the cone angle of the spot light in Radians.
  50930. */
  50931. get angle(): number;
  50932. /**
  50933. * Sets the cone angle of the spot light in Radians.
  50934. */
  50935. set angle(value: number);
  50936. /**
  50937. * Only used in gltf falloff mode, this defines the angle where
  50938. * the directional falloff will start before cutting at angle which could be seen
  50939. * as outer angle.
  50940. */
  50941. get innerAngle(): number;
  50942. /**
  50943. * Only used in gltf falloff mode, this defines the angle where
  50944. * the directional falloff will start before cutting at angle which could be seen
  50945. * as outer angle.
  50946. */
  50947. set innerAngle(value: number);
  50948. private _shadowAngleScale;
  50949. /**
  50950. * Allows scaling the angle of the light for shadow generation only.
  50951. */
  50952. get shadowAngleScale(): number;
  50953. /**
  50954. * Allows scaling the angle of the light for shadow generation only.
  50955. */
  50956. set shadowAngleScale(value: number);
  50957. /**
  50958. * The light decay speed with the distance from the emission spot.
  50959. */
  50960. exponent: number;
  50961. private _projectionTextureMatrix;
  50962. /**
  50963. * Allows reading the projecton texture
  50964. */
  50965. get projectionTextureMatrix(): Matrix;
  50966. protected _projectionTextureLightNear: number;
  50967. /**
  50968. * Gets the near clip of the Spotlight for texture projection.
  50969. */
  50970. get projectionTextureLightNear(): number;
  50971. /**
  50972. * Sets the near clip of the Spotlight for texture projection.
  50973. */
  50974. set projectionTextureLightNear(value: number);
  50975. protected _projectionTextureLightFar: number;
  50976. /**
  50977. * Gets the far clip of the Spotlight for texture projection.
  50978. */
  50979. get projectionTextureLightFar(): number;
  50980. /**
  50981. * Sets the far clip of the Spotlight for texture projection.
  50982. */
  50983. set projectionTextureLightFar(value: number);
  50984. protected _projectionTextureUpDirection: Vector3;
  50985. /**
  50986. * Gets the Up vector of the Spotlight for texture projection.
  50987. */
  50988. get projectionTextureUpDirection(): Vector3;
  50989. /**
  50990. * Sets the Up vector of the Spotlight for texture projection.
  50991. */
  50992. set projectionTextureUpDirection(value: Vector3);
  50993. private _projectionTexture;
  50994. /**
  50995. * Gets the projection texture of the light.
  50996. */
  50997. get projectionTexture(): Nullable<BaseTexture>;
  50998. /**
  50999. * Sets the projection texture of the light.
  51000. */
  51001. set projectionTexture(value: Nullable<BaseTexture>);
  51002. private _projectionTextureViewLightDirty;
  51003. private _projectionTextureProjectionLightDirty;
  51004. private _projectionTextureDirty;
  51005. private _projectionTextureViewTargetVector;
  51006. private _projectionTextureViewLightMatrix;
  51007. private _projectionTextureProjectionLightMatrix;
  51008. private _projectionTextureScalingMatrix;
  51009. /**
  51010. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51011. * It can cast shadows.
  51012. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51013. * @param name The light friendly name
  51014. * @param position The position of the spot light in the scene
  51015. * @param direction The direction of the light in the scene
  51016. * @param angle The cone angle of the light in Radians
  51017. * @param exponent The light decay speed with the distance from the emission spot
  51018. * @param scene The scene the lights belongs to
  51019. */
  51020. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51021. /**
  51022. * Returns the string "SpotLight".
  51023. * @returns the class name
  51024. */
  51025. getClassName(): string;
  51026. /**
  51027. * Returns the integer 2.
  51028. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51029. */
  51030. getTypeID(): number;
  51031. /**
  51032. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51033. */
  51034. protected _setDirection(value: Vector3): void;
  51035. /**
  51036. * Overrides the position setter to recompute the projection texture view light Matrix.
  51037. */
  51038. protected _setPosition(value: Vector3): void;
  51039. /**
  51040. * 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.
  51041. * Returns the SpotLight.
  51042. */
  51043. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51044. protected _computeProjectionTextureViewLightMatrix(): void;
  51045. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51046. /**
  51047. * Main function for light texture projection matrix computing.
  51048. */
  51049. protected _computeProjectionTextureMatrix(): void;
  51050. protected _buildUniformLayout(): void;
  51051. private _computeAngleValues;
  51052. /**
  51053. * Sets the passed Effect "effect" with the Light textures.
  51054. * @param effect The effect to update
  51055. * @param lightIndex The index of the light in the effect to update
  51056. * @returns The light
  51057. */
  51058. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51059. /**
  51060. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51061. * @param effect The effect to update
  51062. * @param lightIndex The index of the light in the effect to update
  51063. * @returns The spot light
  51064. */
  51065. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51066. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51067. /**
  51068. * Disposes the light and the associated resources.
  51069. */
  51070. dispose(): void;
  51071. /**
  51072. * Prepares the list of defines specific to the light type.
  51073. * @param defines the list of defines
  51074. * @param lightIndex defines the index of the light for the effect
  51075. */
  51076. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51077. }
  51078. }
  51079. declare module "babylonjs/Gizmos/lightGizmo" {
  51080. import { Nullable } from "babylonjs/types";
  51081. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51082. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51083. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51084. import { Light } from "babylonjs/Lights/light";
  51085. /**
  51086. * Gizmo that enables viewing a light
  51087. */
  51088. export class LightGizmo extends Gizmo {
  51089. private _lightMesh;
  51090. private _material;
  51091. private _cachedPosition;
  51092. private _cachedForward;
  51093. private _attachedMeshParent;
  51094. /**
  51095. * Creates a LightGizmo
  51096. * @param gizmoLayer The utility layer the gizmo will be added to
  51097. */
  51098. constructor(gizmoLayer?: UtilityLayerRenderer);
  51099. private _light;
  51100. /**
  51101. * The light that the gizmo is attached to
  51102. */
  51103. set light(light: Nullable<Light>);
  51104. get light(): Nullable<Light>;
  51105. /**
  51106. * Gets the material used to render the light gizmo
  51107. */
  51108. get material(): StandardMaterial;
  51109. /**
  51110. * @hidden
  51111. * Updates the gizmo to match the attached mesh's position/rotation
  51112. */
  51113. protected _update(): void;
  51114. private static _Scale;
  51115. /**
  51116. * Creates the lines for a light mesh
  51117. */
  51118. private static _CreateLightLines;
  51119. /**
  51120. * Disposes of the light gizmo
  51121. */
  51122. dispose(): void;
  51123. private static _CreateHemisphericLightMesh;
  51124. private static _CreatePointLightMesh;
  51125. private static _CreateSpotLightMesh;
  51126. private static _CreateDirectionalLightMesh;
  51127. }
  51128. }
  51129. declare module "babylonjs/Gizmos/index" {
  51130. export * from "babylonjs/Gizmos/axisDragGizmo";
  51131. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51132. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51133. export * from "babylonjs/Gizmos/gizmo";
  51134. export * from "babylonjs/Gizmos/gizmoManager";
  51135. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51136. export * from "babylonjs/Gizmos/positionGizmo";
  51137. export * from "babylonjs/Gizmos/rotationGizmo";
  51138. export * from "babylonjs/Gizmos/scaleGizmo";
  51139. export * from "babylonjs/Gizmos/lightGizmo";
  51140. export * from "babylonjs/Gizmos/planeDragGizmo";
  51141. }
  51142. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51143. /** @hidden */
  51144. export var backgroundFragmentDeclaration: {
  51145. name: string;
  51146. shader: string;
  51147. };
  51148. }
  51149. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51150. /** @hidden */
  51151. export var backgroundUboDeclaration: {
  51152. name: string;
  51153. shader: string;
  51154. };
  51155. }
  51156. declare module "babylonjs/Shaders/background.fragment" {
  51157. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51158. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51159. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51160. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51161. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51162. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51163. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51164. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51165. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51166. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51167. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51168. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51169. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51170. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51171. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51172. /** @hidden */
  51173. export var backgroundPixelShader: {
  51174. name: string;
  51175. shader: string;
  51176. };
  51177. }
  51178. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51179. /** @hidden */
  51180. export var backgroundVertexDeclaration: {
  51181. name: string;
  51182. shader: string;
  51183. };
  51184. }
  51185. declare module "babylonjs/Shaders/background.vertex" {
  51186. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51187. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51188. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51189. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51190. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51191. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51192. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51193. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51194. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51195. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51196. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51197. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51198. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51199. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51200. /** @hidden */
  51201. export var backgroundVertexShader: {
  51202. name: string;
  51203. shader: string;
  51204. };
  51205. }
  51206. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51207. import { Nullable, int, float } from "babylonjs/types";
  51208. import { Scene } from "babylonjs/scene";
  51209. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51212. import { Mesh } from "babylonjs/Meshes/mesh";
  51213. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51214. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51215. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51217. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51218. import { Color3 } from "babylonjs/Maths/math.color";
  51219. import "babylonjs/Shaders/background.fragment";
  51220. import "babylonjs/Shaders/background.vertex";
  51221. /**
  51222. * Background material used to create an efficient environement around your scene.
  51223. */
  51224. export class BackgroundMaterial extends PushMaterial {
  51225. /**
  51226. * Standard reflectance value at parallel view angle.
  51227. */
  51228. static StandardReflectance0: number;
  51229. /**
  51230. * Standard reflectance value at grazing angle.
  51231. */
  51232. static StandardReflectance90: number;
  51233. protected _primaryColor: Color3;
  51234. /**
  51235. * Key light Color (multiply against the environement texture)
  51236. */
  51237. primaryColor: Color3;
  51238. protected __perceptualColor: Nullable<Color3>;
  51239. /**
  51240. * Experimental Internal Use Only.
  51241. *
  51242. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51243. * This acts as a helper to set the primary color to a more "human friendly" value.
  51244. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51245. * output color as close as possible from the chosen value.
  51246. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51247. * part of lighting setup.)
  51248. */
  51249. get _perceptualColor(): Nullable<Color3>;
  51250. set _perceptualColor(value: Nullable<Color3>);
  51251. protected _primaryColorShadowLevel: float;
  51252. /**
  51253. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51254. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51255. */
  51256. get primaryColorShadowLevel(): float;
  51257. set primaryColorShadowLevel(value: float);
  51258. protected _primaryColorHighlightLevel: float;
  51259. /**
  51260. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51261. * The primary color is used at the level chosen to define what the white area would look.
  51262. */
  51263. get primaryColorHighlightLevel(): float;
  51264. set primaryColorHighlightLevel(value: float);
  51265. protected _reflectionTexture: Nullable<BaseTexture>;
  51266. /**
  51267. * Reflection Texture used in the material.
  51268. * Should be author in a specific way for the best result (refer to the documentation).
  51269. */
  51270. reflectionTexture: Nullable<BaseTexture>;
  51271. protected _reflectionBlur: float;
  51272. /**
  51273. * Reflection Texture level of blur.
  51274. *
  51275. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51276. * texture twice.
  51277. */
  51278. reflectionBlur: float;
  51279. protected _diffuseTexture: Nullable<BaseTexture>;
  51280. /**
  51281. * Diffuse Texture used in the material.
  51282. * Should be author in a specific way for the best result (refer to the documentation).
  51283. */
  51284. diffuseTexture: Nullable<BaseTexture>;
  51285. protected _shadowLights: Nullable<IShadowLight[]>;
  51286. /**
  51287. * Specify the list of lights casting shadow on the material.
  51288. * All scene shadow lights will be included if null.
  51289. */
  51290. shadowLights: Nullable<IShadowLight[]>;
  51291. protected _shadowLevel: float;
  51292. /**
  51293. * Helps adjusting the shadow to a softer level if required.
  51294. * 0 means black shadows and 1 means no shadows.
  51295. */
  51296. shadowLevel: float;
  51297. protected _sceneCenter: Vector3;
  51298. /**
  51299. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51300. * It is usually zero but might be interesting to modify according to your setup.
  51301. */
  51302. sceneCenter: Vector3;
  51303. protected _opacityFresnel: boolean;
  51304. /**
  51305. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51306. * This helps ensuring a nice transition when the camera goes under the ground.
  51307. */
  51308. opacityFresnel: boolean;
  51309. protected _reflectionFresnel: boolean;
  51310. /**
  51311. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51312. * This helps adding a mirror texture on the ground.
  51313. */
  51314. reflectionFresnel: boolean;
  51315. protected _reflectionFalloffDistance: number;
  51316. /**
  51317. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51318. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51319. */
  51320. reflectionFalloffDistance: number;
  51321. protected _reflectionAmount: number;
  51322. /**
  51323. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51324. */
  51325. reflectionAmount: number;
  51326. protected _reflectionReflectance0: number;
  51327. /**
  51328. * This specifies the weight of the reflection at grazing angle.
  51329. */
  51330. reflectionReflectance0: number;
  51331. protected _reflectionReflectance90: number;
  51332. /**
  51333. * This specifies the weight of the reflection at a perpendicular point of view.
  51334. */
  51335. reflectionReflectance90: number;
  51336. /**
  51337. * Sets the reflection reflectance fresnel values according to the default standard
  51338. * empirically know to work well :-)
  51339. */
  51340. set reflectionStandardFresnelWeight(value: number);
  51341. protected _useRGBColor: boolean;
  51342. /**
  51343. * Helps to directly use the maps channels instead of their level.
  51344. */
  51345. useRGBColor: boolean;
  51346. protected _enableNoise: boolean;
  51347. /**
  51348. * This helps reducing the banding effect that could occur on the background.
  51349. */
  51350. enableNoise: boolean;
  51351. /**
  51352. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51353. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51354. * Recommended to be keep at 1.0 except for special cases.
  51355. */
  51356. get fovMultiplier(): number;
  51357. set fovMultiplier(value: number);
  51358. private _fovMultiplier;
  51359. /**
  51360. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51361. */
  51362. useEquirectangularFOV: boolean;
  51363. private _maxSimultaneousLights;
  51364. /**
  51365. * Number of Simultaneous lights allowed on the material.
  51366. */
  51367. maxSimultaneousLights: int;
  51368. /**
  51369. * Default configuration related to image processing available in the Background Material.
  51370. */
  51371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51372. /**
  51373. * Keep track of the image processing observer to allow dispose and replace.
  51374. */
  51375. private _imageProcessingObserver;
  51376. /**
  51377. * Attaches a new image processing configuration to the PBR Material.
  51378. * @param configuration (if null the scene configuration will be use)
  51379. */
  51380. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51381. /**
  51382. * Gets the image processing configuration used either in this material.
  51383. */
  51384. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51385. /**
  51386. * Sets the Default image processing configuration used either in the this material.
  51387. *
  51388. * If sets to null, the scene one is in use.
  51389. */
  51390. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51391. /**
  51392. * Gets wether the color curves effect is enabled.
  51393. */
  51394. get cameraColorCurvesEnabled(): boolean;
  51395. /**
  51396. * Sets wether the color curves effect is enabled.
  51397. */
  51398. set cameraColorCurvesEnabled(value: boolean);
  51399. /**
  51400. * Gets wether the color grading effect is enabled.
  51401. */
  51402. get cameraColorGradingEnabled(): boolean;
  51403. /**
  51404. * Gets wether the color grading effect is enabled.
  51405. */
  51406. set cameraColorGradingEnabled(value: boolean);
  51407. /**
  51408. * Gets wether tonemapping is enabled or not.
  51409. */
  51410. get cameraToneMappingEnabled(): boolean;
  51411. /**
  51412. * Sets wether tonemapping is enabled or not
  51413. */
  51414. set cameraToneMappingEnabled(value: boolean);
  51415. /**
  51416. * The camera exposure used on this material.
  51417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51418. * This corresponds to a photographic exposure.
  51419. */
  51420. get cameraExposure(): float;
  51421. /**
  51422. * The camera exposure used on this material.
  51423. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51424. * This corresponds to a photographic exposure.
  51425. */
  51426. set cameraExposure(value: float);
  51427. /**
  51428. * Gets The camera contrast used on this material.
  51429. */
  51430. get cameraContrast(): float;
  51431. /**
  51432. * Sets The camera contrast used on this material.
  51433. */
  51434. set cameraContrast(value: float);
  51435. /**
  51436. * Gets the Color Grading 2D Lookup Texture.
  51437. */
  51438. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51439. /**
  51440. * Sets the Color Grading 2D Lookup Texture.
  51441. */
  51442. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51443. /**
  51444. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51445. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51446. * 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;
  51447. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51448. */
  51449. get cameraColorCurves(): Nullable<ColorCurves>;
  51450. /**
  51451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51453. * 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;
  51454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51455. */
  51456. set cameraColorCurves(value: Nullable<ColorCurves>);
  51457. /**
  51458. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51459. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51460. */
  51461. switchToBGR: boolean;
  51462. private _renderTargets;
  51463. private _reflectionControls;
  51464. private _white;
  51465. private _primaryShadowColor;
  51466. private _primaryHighlightColor;
  51467. /**
  51468. * Instantiates a Background Material in the given scene
  51469. * @param name The friendly name of the material
  51470. * @param scene The scene to add the material to
  51471. */
  51472. constructor(name: string, scene: Scene);
  51473. /**
  51474. * Gets a boolean indicating that current material needs to register RTT
  51475. */
  51476. get hasRenderTargetTextures(): boolean;
  51477. /**
  51478. * The entire material has been created in order to prevent overdraw.
  51479. * @returns false
  51480. */
  51481. needAlphaTesting(): boolean;
  51482. /**
  51483. * The entire material has been created in order to prevent overdraw.
  51484. * @returns true if blending is enable
  51485. */
  51486. needAlphaBlending(): boolean;
  51487. /**
  51488. * Checks wether the material is ready to be rendered for a given mesh.
  51489. * @param mesh The mesh to render
  51490. * @param subMesh The submesh to check against
  51491. * @param useInstances Specify wether or not the material is used with instances
  51492. * @returns true if all the dependencies are ready (Textures, Effects...)
  51493. */
  51494. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51495. /**
  51496. * Compute the primary color according to the chosen perceptual color.
  51497. */
  51498. private _computePrimaryColorFromPerceptualColor;
  51499. /**
  51500. * Compute the highlights and shadow colors according to their chosen levels.
  51501. */
  51502. private _computePrimaryColors;
  51503. /**
  51504. * Build the uniform buffer used in the material.
  51505. */
  51506. buildUniformLayout(): void;
  51507. /**
  51508. * Unbind the material.
  51509. */
  51510. unbind(): void;
  51511. /**
  51512. * Bind only the world matrix to the material.
  51513. * @param world The world matrix to bind.
  51514. */
  51515. bindOnlyWorldMatrix(world: Matrix): void;
  51516. /**
  51517. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51518. * @param world The world matrix to bind.
  51519. * @param subMesh The submesh to bind for.
  51520. */
  51521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51522. /**
  51523. * Checks to see if a texture is used in the material.
  51524. * @param texture - Base texture to use.
  51525. * @returns - Boolean specifying if a texture is used in the material.
  51526. */
  51527. hasTexture(texture: BaseTexture): boolean;
  51528. /**
  51529. * Dispose the material.
  51530. * @param forceDisposeEffect Force disposal of the associated effect.
  51531. * @param forceDisposeTextures Force disposal of the associated textures.
  51532. */
  51533. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51534. /**
  51535. * Clones the material.
  51536. * @param name The cloned name.
  51537. * @returns The cloned material.
  51538. */
  51539. clone(name: string): BackgroundMaterial;
  51540. /**
  51541. * Serializes the current material to its JSON representation.
  51542. * @returns The JSON representation.
  51543. */
  51544. serialize(): any;
  51545. /**
  51546. * Gets the class name of the material
  51547. * @returns "BackgroundMaterial"
  51548. */
  51549. getClassName(): string;
  51550. /**
  51551. * Parse a JSON input to create back a background material.
  51552. * @param source The JSON data to parse
  51553. * @param scene The scene to create the parsed material in
  51554. * @param rootUrl The root url of the assets the material depends upon
  51555. * @returns the instantiated BackgroundMaterial.
  51556. */
  51557. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51558. }
  51559. }
  51560. declare module "babylonjs/Helpers/environmentHelper" {
  51561. import { Observable } from "babylonjs/Misc/observable";
  51562. import { Nullable } from "babylonjs/types";
  51563. import { Scene } from "babylonjs/scene";
  51564. import { Vector3 } from "babylonjs/Maths/math.vector";
  51565. import { Color3 } from "babylonjs/Maths/math.color";
  51566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51567. import { Mesh } from "babylonjs/Meshes/mesh";
  51568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51569. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51570. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51571. import "babylonjs/Meshes/Builders/planeBuilder";
  51572. import "babylonjs/Meshes/Builders/boxBuilder";
  51573. /**
  51574. * Represents the different options available during the creation of
  51575. * a Environment helper.
  51576. *
  51577. * This can control the default ground, skybox and image processing setup of your scene.
  51578. */
  51579. export interface IEnvironmentHelperOptions {
  51580. /**
  51581. * Specifies whether or not to create a ground.
  51582. * True by default.
  51583. */
  51584. createGround: boolean;
  51585. /**
  51586. * Specifies the ground size.
  51587. * 15 by default.
  51588. */
  51589. groundSize: number;
  51590. /**
  51591. * The texture used on the ground for the main color.
  51592. * Comes from the BabylonJS CDN by default.
  51593. *
  51594. * Remarks: Can be either a texture or a url.
  51595. */
  51596. groundTexture: string | BaseTexture;
  51597. /**
  51598. * The color mixed in the ground texture by default.
  51599. * BabylonJS clearColor by default.
  51600. */
  51601. groundColor: Color3;
  51602. /**
  51603. * Specifies the ground opacity.
  51604. * 1 by default.
  51605. */
  51606. groundOpacity: number;
  51607. /**
  51608. * Enables the ground to receive shadows.
  51609. * True by default.
  51610. */
  51611. enableGroundShadow: boolean;
  51612. /**
  51613. * Helps preventing the shadow to be fully black on the ground.
  51614. * 0.5 by default.
  51615. */
  51616. groundShadowLevel: number;
  51617. /**
  51618. * Creates a mirror texture attach to the ground.
  51619. * false by default.
  51620. */
  51621. enableGroundMirror: boolean;
  51622. /**
  51623. * Specifies the ground mirror size ratio.
  51624. * 0.3 by default as the default kernel is 64.
  51625. */
  51626. groundMirrorSizeRatio: number;
  51627. /**
  51628. * Specifies the ground mirror blur kernel size.
  51629. * 64 by default.
  51630. */
  51631. groundMirrorBlurKernel: number;
  51632. /**
  51633. * Specifies the ground mirror visibility amount.
  51634. * 1 by default
  51635. */
  51636. groundMirrorAmount: number;
  51637. /**
  51638. * Specifies the ground mirror reflectance weight.
  51639. * This uses the standard weight of the background material to setup the fresnel effect
  51640. * of the mirror.
  51641. * 1 by default.
  51642. */
  51643. groundMirrorFresnelWeight: number;
  51644. /**
  51645. * Specifies the ground mirror Falloff distance.
  51646. * This can helps reducing the size of the reflection.
  51647. * 0 by Default.
  51648. */
  51649. groundMirrorFallOffDistance: number;
  51650. /**
  51651. * Specifies the ground mirror texture type.
  51652. * Unsigned Int by Default.
  51653. */
  51654. groundMirrorTextureType: number;
  51655. /**
  51656. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51657. * the shown objects.
  51658. */
  51659. groundYBias: number;
  51660. /**
  51661. * Specifies whether or not to create a skybox.
  51662. * True by default.
  51663. */
  51664. createSkybox: boolean;
  51665. /**
  51666. * Specifies the skybox size.
  51667. * 20 by default.
  51668. */
  51669. skyboxSize: number;
  51670. /**
  51671. * The texture used on the skybox for the main color.
  51672. * Comes from the BabylonJS CDN by default.
  51673. *
  51674. * Remarks: Can be either a texture or a url.
  51675. */
  51676. skyboxTexture: string | BaseTexture;
  51677. /**
  51678. * The color mixed in the skybox texture by default.
  51679. * BabylonJS clearColor by default.
  51680. */
  51681. skyboxColor: Color3;
  51682. /**
  51683. * The background rotation around the Y axis of the scene.
  51684. * This helps aligning the key lights of your scene with the background.
  51685. * 0 by default.
  51686. */
  51687. backgroundYRotation: number;
  51688. /**
  51689. * Compute automatically the size of the elements to best fit with the scene.
  51690. */
  51691. sizeAuto: boolean;
  51692. /**
  51693. * Default position of the rootMesh if autoSize is not true.
  51694. */
  51695. rootPosition: Vector3;
  51696. /**
  51697. * Sets up the image processing in the scene.
  51698. * true by default.
  51699. */
  51700. setupImageProcessing: boolean;
  51701. /**
  51702. * The texture used as your environment texture in the scene.
  51703. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51704. *
  51705. * Remarks: Can be either a texture or a url.
  51706. */
  51707. environmentTexture: string | BaseTexture;
  51708. /**
  51709. * The value of the exposure to apply to the scene.
  51710. * 0.6 by default if setupImageProcessing is true.
  51711. */
  51712. cameraExposure: number;
  51713. /**
  51714. * The value of the contrast to apply to the scene.
  51715. * 1.6 by default if setupImageProcessing is true.
  51716. */
  51717. cameraContrast: number;
  51718. /**
  51719. * Specifies whether or not tonemapping should be enabled in the scene.
  51720. * true by default if setupImageProcessing is true.
  51721. */
  51722. toneMappingEnabled: boolean;
  51723. }
  51724. /**
  51725. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51726. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51727. * It also helps with the default setup of your imageProcessing configuration.
  51728. */
  51729. export class EnvironmentHelper {
  51730. /**
  51731. * Default ground texture URL.
  51732. */
  51733. private static _groundTextureCDNUrl;
  51734. /**
  51735. * Default skybox texture URL.
  51736. */
  51737. private static _skyboxTextureCDNUrl;
  51738. /**
  51739. * Default environment texture URL.
  51740. */
  51741. private static _environmentTextureCDNUrl;
  51742. /**
  51743. * Creates the default options for the helper.
  51744. */
  51745. private static _getDefaultOptions;
  51746. private _rootMesh;
  51747. /**
  51748. * Gets the root mesh created by the helper.
  51749. */
  51750. get rootMesh(): Mesh;
  51751. private _skybox;
  51752. /**
  51753. * Gets the skybox created by the helper.
  51754. */
  51755. get skybox(): Nullable<Mesh>;
  51756. private _skyboxTexture;
  51757. /**
  51758. * Gets the skybox texture created by the helper.
  51759. */
  51760. get skyboxTexture(): Nullable<BaseTexture>;
  51761. private _skyboxMaterial;
  51762. /**
  51763. * Gets the skybox material created by the helper.
  51764. */
  51765. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51766. private _ground;
  51767. /**
  51768. * Gets the ground mesh created by the helper.
  51769. */
  51770. get ground(): Nullable<Mesh>;
  51771. private _groundTexture;
  51772. /**
  51773. * Gets the ground texture created by the helper.
  51774. */
  51775. get groundTexture(): Nullable<BaseTexture>;
  51776. private _groundMirror;
  51777. /**
  51778. * Gets the ground mirror created by the helper.
  51779. */
  51780. get groundMirror(): Nullable<MirrorTexture>;
  51781. /**
  51782. * Gets the ground mirror render list to helps pushing the meshes
  51783. * you wish in the ground reflection.
  51784. */
  51785. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51786. private _groundMaterial;
  51787. /**
  51788. * Gets the ground material created by the helper.
  51789. */
  51790. get groundMaterial(): Nullable<BackgroundMaterial>;
  51791. /**
  51792. * Stores the creation options.
  51793. */
  51794. private readonly _scene;
  51795. private _options;
  51796. /**
  51797. * This observable will be notified with any error during the creation of the environment,
  51798. * mainly texture creation errors.
  51799. */
  51800. onErrorObservable: Observable<{
  51801. message?: string;
  51802. exception?: any;
  51803. }>;
  51804. /**
  51805. * constructor
  51806. * @param options Defines the options we want to customize the helper
  51807. * @param scene The scene to add the material to
  51808. */
  51809. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51810. /**
  51811. * Updates the background according to the new options
  51812. * @param options
  51813. */
  51814. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51815. /**
  51816. * Sets the primary color of all the available elements.
  51817. * @param color the main color to affect to the ground and the background
  51818. */
  51819. setMainColor(color: Color3): void;
  51820. /**
  51821. * Setup the image processing according to the specified options.
  51822. */
  51823. private _setupImageProcessing;
  51824. /**
  51825. * Setup the environment texture according to the specified options.
  51826. */
  51827. private _setupEnvironmentTexture;
  51828. /**
  51829. * Setup the background according to the specified options.
  51830. */
  51831. private _setupBackground;
  51832. /**
  51833. * Get the scene sizes according to the setup.
  51834. */
  51835. private _getSceneSize;
  51836. /**
  51837. * Setup the ground according to the specified options.
  51838. */
  51839. private _setupGround;
  51840. /**
  51841. * Setup the ground material according to the specified options.
  51842. */
  51843. private _setupGroundMaterial;
  51844. /**
  51845. * Setup the ground diffuse texture according to the specified options.
  51846. */
  51847. private _setupGroundDiffuseTexture;
  51848. /**
  51849. * Setup the ground mirror texture according to the specified options.
  51850. */
  51851. private _setupGroundMirrorTexture;
  51852. /**
  51853. * Setup the ground to receive the mirror texture.
  51854. */
  51855. private _setupMirrorInGroundMaterial;
  51856. /**
  51857. * Setup the skybox according to the specified options.
  51858. */
  51859. private _setupSkybox;
  51860. /**
  51861. * Setup the skybox material according to the specified options.
  51862. */
  51863. private _setupSkyboxMaterial;
  51864. /**
  51865. * Setup the skybox reflection texture according to the specified options.
  51866. */
  51867. private _setupSkyboxReflectionTexture;
  51868. private _errorHandler;
  51869. /**
  51870. * Dispose all the elements created by the Helper.
  51871. */
  51872. dispose(): void;
  51873. }
  51874. }
  51875. declare module "babylonjs/Helpers/photoDome" {
  51876. import { Observable } from "babylonjs/Misc/observable";
  51877. import { Nullable } from "babylonjs/types";
  51878. import { Scene } from "babylonjs/scene";
  51879. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51880. import { Mesh } from "babylonjs/Meshes/mesh";
  51881. import { Texture } from "babylonjs/Materials/Textures/texture";
  51882. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51883. import "babylonjs/Meshes/Builders/sphereBuilder";
  51884. /**
  51885. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51886. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51887. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51888. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51889. */
  51890. export class PhotoDome extends TransformNode {
  51891. /**
  51892. * Define the image as a Monoscopic panoramic 360 image.
  51893. */
  51894. static readonly MODE_MONOSCOPIC: number;
  51895. /**
  51896. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51897. */
  51898. static readonly MODE_TOPBOTTOM: number;
  51899. /**
  51900. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51901. */
  51902. static readonly MODE_SIDEBYSIDE: number;
  51903. private _useDirectMapping;
  51904. /**
  51905. * The texture being displayed on the sphere
  51906. */
  51907. protected _photoTexture: Texture;
  51908. /**
  51909. * Gets or sets the texture being displayed on the sphere
  51910. */
  51911. get photoTexture(): Texture;
  51912. set photoTexture(value: Texture);
  51913. /**
  51914. * Observable raised when an error occured while loading the 360 image
  51915. */
  51916. onLoadErrorObservable: Observable<string>;
  51917. /**
  51918. * The skybox material
  51919. */
  51920. protected _material: BackgroundMaterial;
  51921. /**
  51922. * The surface used for the skybox
  51923. */
  51924. protected _mesh: Mesh;
  51925. /**
  51926. * Gets the mesh used for the skybox.
  51927. */
  51928. get mesh(): Mesh;
  51929. /**
  51930. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51931. * Also see the options.resolution property.
  51932. */
  51933. get fovMultiplier(): number;
  51934. set fovMultiplier(value: number);
  51935. private _imageMode;
  51936. /**
  51937. * Gets or set the current video mode for the video. It can be:
  51938. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51939. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51940. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51941. */
  51942. get imageMode(): number;
  51943. set imageMode(value: number);
  51944. /**
  51945. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51946. * @param name Element's name, child elements will append suffixes for their own names.
  51947. * @param urlsOfPhoto defines the url of the photo to display
  51948. * @param options defines an object containing optional or exposed sub element properties
  51949. * @param onError defines a callback called when an error occured while loading the texture
  51950. */
  51951. constructor(name: string, urlOfPhoto: string, options: {
  51952. resolution?: number;
  51953. size?: number;
  51954. useDirectMapping?: boolean;
  51955. faceForward?: boolean;
  51956. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51957. private _onBeforeCameraRenderObserver;
  51958. private _changeImageMode;
  51959. /**
  51960. * Releases resources associated with this node.
  51961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51963. */
  51964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51965. }
  51966. }
  51967. declare module "babylonjs/Misc/rgbdTextureTools" {
  51968. import "babylonjs/Shaders/rgbdDecode.fragment";
  51969. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51970. import { Texture } from "babylonjs/Materials/Textures/texture";
  51971. /**
  51972. * Class used to host RGBD texture specific utilities
  51973. */
  51974. export class RGBDTextureTools {
  51975. /**
  51976. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51977. * @param texture the texture to expand.
  51978. */
  51979. static ExpandRGBDTexture(texture: Texture): void;
  51980. }
  51981. }
  51982. declare module "babylonjs/Misc/brdfTextureTools" {
  51983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51984. import { Scene } from "babylonjs/scene";
  51985. /**
  51986. * Class used to host texture specific utilities
  51987. */
  51988. export class BRDFTextureTools {
  51989. /**
  51990. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51991. * @param scene defines the hosting scene
  51992. * @returns the environment BRDF texture
  51993. */
  51994. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51995. private static _environmentBRDFBase64Texture;
  51996. }
  51997. }
  51998. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51999. import { Nullable } from "babylonjs/types";
  52000. import { Color3 } from "babylonjs/Maths/math.color";
  52001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52002. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52003. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52004. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52005. import { Engine } from "babylonjs/Engines/engine";
  52006. import { Scene } from "babylonjs/scene";
  52007. /**
  52008. * @hidden
  52009. */
  52010. export interface IMaterialClearCoatDefines {
  52011. CLEARCOAT: boolean;
  52012. CLEARCOAT_DEFAULTIOR: boolean;
  52013. CLEARCOAT_TEXTURE: boolean;
  52014. CLEARCOAT_TEXTUREDIRECTUV: number;
  52015. CLEARCOAT_BUMP: boolean;
  52016. CLEARCOAT_BUMPDIRECTUV: number;
  52017. CLEARCOAT_TINT: boolean;
  52018. CLEARCOAT_TINT_TEXTURE: boolean;
  52019. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52020. /** @hidden */
  52021. _areTexturesDirty: boolean;
  52022. }
  52023. /**
  52024. * Define the code related to the clear coat parameters of the pbr material.
  52025. */
  52026. export class PBRClearCoatConfiguration {
  52027. /**
  52028. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52029. * The default fits with a polyurethane material.
  52030. */
  52031. private static readonly _DefaultIndexOfRefraction;
  52032. private _isEnabled;
  52033. /**
  52034. * Defines if the clear coat is enabled in the material.
  52035. */
  52036. isEnabled: boolean;
  52037. /**
  52038. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52039. */
  52040. intensity: number;
  52041. /**
  52042. * Defines the clear coat layer roughness.
  52043. */
  52044. roughness: number;
  52045. private _indexOfRefraction;
  52046. /**
  52047. * Defines the index of refraction of the clear coat.
  52048. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52049. * The default fits with a polyurethane material.
  52050. * Changing the default value is more performance intensive.
  52051. */
  52052. indexOfRefraction: number;
  52053. private _texture;
  52054. /**
  52055. * Stores the clear coat values in a texture.
  52056. */
  52057. texture: Nullable<BaseTexture>;
  52058. private _bumpTexture;
  52059. /**
  52060. * Define the clear coat specific bump texture.
  52061. */
  52062. bumpTexture: Nullable<BaseTexture>;
  52063. private _isTintEnabled;
  52064. /**
  52065. * Defines if the clear coat tint is enabled in the material.
  52066. */
  52067. isTintEnabled: boolean;
  52068. /**
  52069. * Defines the clear coat tint of the material.
  52070. * This is only use if tint is enabled
  52071. */
  52072. tintColor: Color3;
  52073. /**
  52074. * Defines the distance at which the tint color should be found in the
  52075. * clear coat media.
  52076. * This is only use if tint is enabled
  52077. */
  52078. tintColorAtDistance: number;
  52079. /**
  52080. * Defines the clear coat layer thickness.
  52081. * This is only use if tint is enabled
  52082. */
  52083. tintThickness: number;
  52084. private _tintTexture;
  52085. /**
  52086. * Stores the clear tint values in a texture.
  52087. * rgb is tint
  52088. * a is a thickness factor
  52089. */
  52090. tintTexture: Nullable<BaseTexture>;
  52091. /** @hidden */
  52092. private _internalMarkAllSubMeshesAsTexturesDirty;
  52093. /** @hidden */
  52094. _markAllSubMeshesAsTexturesDirty(): void;
  52095. /**
  52096. * Instantiate a new istance of clear coat configuration.
  52097. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52098. */
  52099. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52100. /**
  52101. * Gets wehter the submesh is ready to be used or not.
  52102. * @param defines the list of "defines" to update.
  52103. * @param scene defines the scene the material belongs to.
  52104. * @param engine defines the engine the material belongs to.
  52105. * @param disableBumpMap defines wether the material disables bump or not.
  52106. * @returns - boolean indicating that the submesh is ready or not.
  52107. */
  52108. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52109. /**
  52110. * Checks to see if a texture is used in the material.
  52111. * @param defines the list of "defines" to update.
  52112. * @param scene defines the scene to the material belongs to.
  52113. */
  52114. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52115. /**
  52116. * Binds the material data.
  52117. * @param uniformBuffer defines the Uniform buffer to fill in.
  52118. * @param scene defines the scene the material belongs to.
  52119. * @param engine defines the engine the material belongs to.
  52120. * @param disableBumpMap defines wether the material disables bump or not.
  52121. * @param isFrozen defines wether the material is frozen or not.
  52122. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52123. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52124. */
  52125. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52126. /**
  52127. * Checks to see if a texture is used in the material.
  52128. * @param texture - Base texture to use.
  52129. * @returns - Boolean specifying if a texture is used in the material.
  52130. */
  52131. hasTexture(texture: BaseTexture): boolean;
  52132. /**
  52133. * Returns an array of the actively used textures.
  52134. * @param activeTextures Array of BaseTextures
  52135. */
  52136. getActiveTextures(activeTextures: BaseTexture[]): void;
  52137. /**
  52138. * Returns the animatable textures.
  52139. * @param animatables Array of animatable textures.
  52140. */
  52141. getAnimatables(animatables: IAnimatable[]): void;
  52142. /**
  52143. * Disposes the resources of the material.
  52144. * @param forceDisposeTextures - Forces the disposal of all textures.
  52145. */
  52146. dispose(forceDisposeTextures?: boolean): void;
  52147. /**
  52148. * Get the current class name of the texture useful for serialization or dynamic coding.
  52149. * @returns "PBRClearCoatConfiguration"
  52150. */
  52151. getClassName(): string;
  52152. /**
  52153. * Add fallbacks to the effect fallbacks list.
  52154. * @param defines defines the Base texture to use.
  52155. * @param fallbacks defines the current fallback list.
  52156. * @param currentRank defines the current fallback rank.
  52157. * @returns the new fallback rank.
  52158. */
  52159. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52160. /**
  52161. * Add the required uniforms to the current list.
  52162. * @param uniforms defines the current uniform list.
  52163. */
  52164. static AddUniforms(uniforms: string[]): void;
  52165. /**
  52166. * Add the required samplers to the current list.
  52167. * @param samplers defines the current sampler list.
  52168. */
  52169. static AddSamplers(samplers: string[]): void;
  52170. /**
  52171. * Add the required uniforms to the current buffer.
  52172. * @param uniformBuffer defines the current uniform buffer.
  52173. */
  52174. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52175. /**
  52176. * Makes a duplicate of the current configuration into another one.
  52177. * @param clearCoatConfiguration define the config where to copy the info
  52178. */
  52179. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52180. /**
  52181. * Serializes this clear coat configuration.
  52182. * @returns - An object with the serialized config.
  52183. */
  52184. serialize(): any;
  52185. /**
  52186. * Parses a anisotropy Configuration from a serialized object.
  52187. * @param source - Serialized object.
  52188. * @param scene Defines the scene we are parsing for
  52189. * @param rootUrl Defines the rootUrl to load from
  52190. */
  52191. parse(source: any, scene: Scene, rootUrl: string): void;
  52192. }
  52193. }
  52194. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52195. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52197. import { Vector2 } from "babylonjs/Maths/math.vector";
  52198. import { Scene } from "babylonjs/scene";
  52199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52200. import { Nullable } from "babylonjs/types";
  52201. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52202. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52203. /**
  52204. * @hidden
  52205. */
  52206. export interface IMaterialAnisotropicDefines {
  52207. ANISOTROPIC: boolean;
  52208. ANISOTROPIC_TEXTURE: boolean;
  52209. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52210. MAINUV1: boolean;
  52211. _areTexturesDirty: boolean;
  52212. _needUVs: boolean;
  52213. }
  52214. /**
  52215. * Define the code related to the anisotropic parameters of the pbr material.
  52216. */
  52217. export class PBRAnisotropicConfiguration {
  52218. private _isEnabled;
  52219. /**
  52220. * Defines if the anisotropy is enabled in the material.
  52221. */
  52222. isEnabled: boolean;
  52223. /**
  52224. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52225. */
  52226. intensity: number;
  52227. /**
  52228. * Defines if the effect is along the tangents, bitangents or in between.
  52229. * By default, the effect is "strectching" the highlights along the tangents.
  52230. */
  52231. direction: Vector2;
  52232. private _texture;
  52233. /**
  52234. * Stores the anisotropy values in a texture.
  52235. * rg is direction (like normal from -1 to 1)
  52236. * b is a intensity
  52237. */
  52238. texture: Nullable<BaseTexture>;
  52239. /** @hidden */
  52240. private _internalMarkAllSubMeshesAsTexturesDirty;
  52241. /** @hidden */
  52242. _markAllSubMeshesAsTexturesDirty(): void;
  52243. /**
  52244. * Instantiate a new istance of anisotropy configuration.
  52245. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52246. */
  52247. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52248. /**
  52249. * Specifies that the submesh is ready to be used.
  52250. * @param defines the list of "defines" to update.
  52251. * @param scene defines the scene the material belongs to.
  52252. * @returns - boolean indicating that the submesh is ready or not.
  52253. */
  52254. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52255. /**
  52256. * Checks to see if a texture is used in the material.
  52257. * @param defines the list of "defines" to update.
  52258. * @param mesh the mesh we are preparing the defines for.
  52259. * @param scene defines the scene the material belongs to.
  52260. */
  52261. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52262. /**
  52263. * Binds the material data.
  52264. * @param uniformBuffer defines the Uniform buffer to fill in.
  52265. * @param scene defines the scene the material belongs to.
  52266. * @param isFrozen defines wether the material is frozen or not.
  52267. */
  52268. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52269. /**
  52270. * Checks to see if a texture is used in the material.
  52271. * @param texture - Base texture to use.
  52272. * @returns - Boolean specifying if a texture is used in the material.
  52273. */
  52274. hasTexture(texture: BaseTexture): boolean;
  52275. /**
  52276. * Returns an array of the actively used textures.
  52277. * @param activeTextures Array of BaseTextures
  52278. */
  52279. getActiveTextures(activeTextures: BaseTexture[]): void;
  52280. /**
  52281. * Returns the animatable textures.
  52282. * @param animatables Array of animatable textures.
  52283. */
  52284. getAnimatables(animatables: IAnimatable[]): void;
  52285. /**
  52286. * Disposes the resources of the material.
  52287. * @param forceDisposeTextures - Forces the disposal of all textures.
  52288. */
  52289. dispose(forceDisposeTextures?: boolean): void;
  52290. /**
  52291. * Get the current class name of the texture useful for serialization or dynamic coding.
  52292. * @returns "PBRAnisotropicConfiguration"
  52293. */
  52294. getClassName(): string;
  52295. /**
  52296. * Add fallbacks to the effect fallbacks list.
  52297. * @param defines defines the Base texture to use.
  52298. * @param fallbacks defines the current fallback list.
  52299. * @param currentRank defines the current fallback rank.
  52300. * @returns the new fallback rank.
  52301. */
  52302. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52303. /**
  52304. * Add the required uniforms to the current list.
  52305. * @param uniforms defines the current uniform list.
  52306. */
  52307. static AddUniforms(uniforms: string[]): void;
  52308. /**
  52309. * Add the required uniforms to the current buffer.
  52310. * @param uniformBuffer defines the current uniform buffer.
  52311. */
  52312. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52313. /**
  52314. * Add the required samplers to the current list.
  52315. * @param samplers defines the current sampler list.
  52316. */
  52317. static AddSamplers(samplers: string[]): void;
  52318. /**
  52319. * Makes a duplicate of the current configuration into another one.
  52320. * @param anisotropicConfiguration define the config where to copy the info
  52321. */
  52322. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52323. /**
  52324. * Serializes this anisotropy configuration.
  52325. * @returns - An object with the serialized config.
  52326. */
  52327. serialize(): any;
  52328. /**
  52329. * Parses a anisotropy Configuration from a serialized object.
  52330. * @param source - Serialized object.
  52331. * @param scene Defines the scene we are parsing for
  52332. * @param rootUrl Defines the rootUrl to load from
  52333. */
  52334. parse(source: any, scene: Scene, rootUrl: string): void;
  52335. }
  52336. }
  52337. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52338. import { Scene } from "babylonjs/scene";
  52339. /**
  52340. * @hidden
  52341. */
  52342. export interface IMaterialBRDFDefines {
  52343. BRDF_V_HEIGHT_CORRELATED: boolean;
  52344. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52345. SPHERICAL_HARMONICS: boolean;
  52346. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52347. /** @hidden */
  52348. _areMiscDirty: boolean;
  52349. }
  52350. /**
  52351. * Define the code related to the BRDF parameters of the pbr material.
  52352. */
  52353. export class PBRBRDFConfiguration {
  52354. /**
  52355. * Default value used for the energy conservation.
  52356. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52357. */
  52358. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52359. /**
  52360. * Default value used for the Smith Visibility Height Correlated mode.
  52361. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52362. */
  52363. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52364. /**
  52365. * Default value used for the IBL diffuse part.
  52366. * This can help switching back to the polynomials mode globally which is a tiny bit
  52367. * less GPU intensive at the drawback of a lower quality.
  52368. */
  52369. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52370. /**
  52371. * Default value used for activating energy conservation for the specular workflow.
  52372. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52373. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52374. */
  52375. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52376. private _useEnergyConservation;
  52377. /**
  52378. * Defines if the material uses energy conservation.
  52379. */
  52380. useEnergyConservation: boolean;
  52381. private _useSmithVisibilityHeightCorrelated;
  52382. /**
  52383. * LEGACY Mode set to false
  52384. * Defines if the material uses height smith correlated visibility term.
  52385. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52386. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52387. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52388. * Not relying on height correlated will also disable energy conservation.
  52389. */
  52390. useSmithVisibilityHeightCorrelated: boolean;
  52391. private _useSphericalHarmonics;
  52392. /**
  52393. * LEGACY Mode set to false
  52394. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52395. * diffuse part of the IBL.
  52396. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52397. * to the ground truth.
  52398. */
  52399. useSphericalHarmonics: boolean;
  52400. private _useSpecularGlossinessInputEnergyConservation;
  52401. /**
  52402. * Defines if the material uses energy conservation, when the specular workflow is active.
  52403. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52404. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52405. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52406. */
  52407. useSpecularGlossinessInputEnergyConservation: boolean;
  52408. /** @hidden */
  52409. private _internalMarkAllSubMeshesAsMiscDirty;
  52410. /** @hidden */
  52411. _markAllSubMeshesAsMiscDirty(): void;
  52412. /**
  52413. * Instantiate a new istance of clear coat configuration.
  52414. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52415. */
  52416. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52417. /**
  52418. * Checks to see if a texture is used in the material.
  52419. * @param defines the list of "defines" to update.
  52420. */
  52421. prepareDefines(defines: IMaterialBRDFDefines): void;
  52422. /**
  52423. * Get the current class name of the texture useful for serialization or dynamic coding.
  52424. * @returns "PBRClearCoatConfiguration"
  52425. */
  52426. getClassName(): string;
  52427. /**
  52428. * Makes a duplicate of the current configuration into another one.
  52429. * @param brdfConfiguration define the config where to copy the info
  52430. */
  52431. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52432. /**
  52433. * Serializes this BRDF configuration.
  52434. * @returns - An object with the serialized config.
  52435. */
  52436. serialize(): any;
  52437. /**
  52438. * Parses a anisotropy Configuration from a serialized object.
  52439. * @param source - Serialized object.
  52440. * @param scene Defines the scene we are parsing for
  52441. * @param rootUrl Defines the rootUrl to load from
  52442. */
  52443. parse(source: any, scene: Scene, rootUrl: string): void;
  52444. }
  52445. }
  52446. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52447. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52448. import { Color3 } from "babylonjs/Maths/math.color";
  52449. import { Scene } from "babylonjs/scene";
  52450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52451. import { Nullable } from "babylonjs/types";
  52452. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52453. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52454. /**
  52455. * @hidden
  52456. */
  52457. export interface IMaterialSheenDefines {
  52458. SHEEN: boolean;
  52459. SHEEN_TEXTURE: boolean;
  52460. SHEEN_TEXTUREDIRECTUV: number;
  52461. SHEEN_LINKWITHALBEDO: boolean;
  52462. /** @hidden */
  52463. _areTexturesDirty: boolean;
  52464. }
  52465. /**
  52466. * Define the code related to the Sheen parameters of the pbr material.
  52467. */
  52468. export class PBRSheenConfiguration {
  52469. private _isEnabled;
  52470. /**
  52471. * Defines if the material uses sheen.
  52472. */
  52473. isEnabled: boolean;
  52474. private _linkSheenWithAlbedo;
  52475. /**
  52476. * Defines if the sheen is linked to the sheen color.
  52477. */
  52478. linkSheenWithAlbedo: boolean;
  52479. /**
  52480. * Defines the sheen intensity.
  52481. */
  52482. intensity: number;
  52483. /**
  52484. * Defines the sheen color.
  52485. */
  52486. color: Color3;
  52487. private _texture;
  52488. /**
  52489. * Stores the sheen tint values in a texture.
  52490. * rgb is tint
  52491. * a is a intensity
  52492. */
  52493. texture: Nullable<BaseTexture>;
  52494. /** @hidden */
  52495. private _internalMarkAllSubMeshesAsTexturesDirty;
  52496. /** @hidden */
  52497. _markAllSubMeshesAsTexturesDirty(): void;
  52498. /**
  52499. * Instantiate a new istance of clear coat configuration.
  52500. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52501. */
  52502. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52503. /**
  52504. * Specifies that the submesh is ready to be used.
  52505. * @param defines the list of "defines" to update.
  52506. * @param scene defines the scene the material belongs to.
  52507. * @returns - boolean indicating that the submesh is ready or not.
  52508. */
  52509. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52510. /**
  52511. * Checks to see if a texture is used in the material.
  52512. * @param defines the list of "defines" to update.
  52513. * @param scene defines the scene the material belongs to.
  52514. */
  52515. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52516. /**
  52517. * Binds the material data.
  52518. * @param uniformBuffer defines the Uniform buffer to fill in.
  52519. * @param scene defines the scene the material belongs to.
  52520. * @param isFrozen defines wether the material is frozen or not.
  52521. */
  52522. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52523. /**
  52524. * Checks to see if a texture is used in the material.
  52525. * @param texture - Base texture to use.
  52526. * @returns - Boolean specifying if a texture is used in the material.
  52527. */
  52528. hasTexture(texture: BaseTexture): boolean;
  52529. /**
  52530. * Returns an array of the actively used textures.
  52531. * @param activeTextures Array of BaseTextures
  52532. */
  52533. getActiveTextures(activeTextures: BaseTexture[]): void;
  52534. /**
  52535. * Returns the animatable textures.
  52536. * @param animatables Array of animatable textures.
  52537. */
  52538. getAnimatables(animatables: IAnimatable[]): void;
  52539. /**
  52540. * Disposes the resources of the material.
  52541. * @param forceDisposeTextures - Forces the disposal of all textures.
  52542. */
  52543. dispose(forceDisposeTextures?: boolean): void;
  52544. /**
  52545. * Get the current class name of the texture useful for serialization or dynamic coding.
  52546. * @returns "PBRSheenConfiguration"
  52547. */
  52548. getClassName(): string;
  52549. /**
  52550. * Add fallbacks to the effect fallbacks list.
  52551. * @param defines defines the Base texture to use.
  52552. * @param fallbacks defines the current fallback list.
  52553. * @param currentRank defines the current fallback rank.
  52554. * @returns the new fallback rank.
  52555. */
  52556. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52557. /**
  52558. * Add the required uniforms to the current list.
  52559. * @param uniforms defines the current uniform list.
  52560. */
  52561. static AddUniforms(uniforms: string[]): void;
  52562. /**
  52563. * Add the required uniforms to the current buffer.
  52564. * @param uniformBuffer defines the current uniform buffer.
  52565. */
  52566. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52567. /**
  52568. * Add the required samplers to the current list.
  52569. * @param samplers defines the current sampler list.
  52570. */
  52571. static AddSamplers(samplers: string[]): void;
  52572. /**
  52573. * Makes a duplicate of the current configuration into another one.
  52574. * @param sheenConfiguration define the config where to copy the info
  52575. */
  52576. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52577. /**
  52578. * Serializes this BRDF configuration.
  52579. * @returns - An object with the serialized config.
  52580. */
  52581. serialize(): any;
  52582. /**
  52583. * Parses a anisotropy Configuration from a serialized object.
  52584. * @param source - Serialized object.
  52585. * @param scene Defines the scene we are parsing for
  52586. * @param rootUrl Defines the rootUrl to load from
  52587. */
  52588. parse(source: any, scene: Scene, rootUrl: string): void;
  52589. }
  52590. }
  52591. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52592. import { Nullable } from "babylonjs/types";
  52593. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52594. import { Color3 } from "babylonjs/Maths/math.color";
  52595. import { SmartArray } from "babylonjs/Misc/smartArray";
  52596. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52597. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52598. import { Effect } from "babylonjs/Materials/effect";
  52599. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52600. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52601. import { Engine } from "babylonjs/Engines/engine";
  52602. import { Scene } from "babylonjs/scene";
  52603. /**
  52604. * @hidden
  52605. */
  52606. export interface IMaterialSubSurfaceDefines {
  52607. SUBSURFACE: boolean;
  52608. SS_REFRACTION: boolean;
  52609. SS_TRANSLUCENCY: boolean;
  52610. SS_SCATERRING: boolean;
  52611. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52612. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52613. SS_REFRACTIONMAP_3D: boolean;
  52614. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52615. SS_LODINREFRACTIONALPHA: boolean;
  52616. SS_GAMMAREFRACTION: boolean;
  52617. SS_RGBDREFRACTION: boolean;
  52618. SS_LINEARSPECULARREFRACTION: boolean;
  52619. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52620. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52621. /** @hidden */
  52622. _areTexturesDirty: boolean;
  52623. }
  52624. /**
  52625. * Define the code related to the sub surface parameters of the pbr material.
  52626. */
  52627. export class PBRSubSurfaceConfiguration {
  52628. private _isRefractionEnabled;
  52629. /**
  52630. * Defines if the refraction is enabled in the material.
  52631. */
  52632. isRefractionEnabled: boolean;
  52633. private _isTranslucencyEnabled;
  52634. /**
  52635. * Defines if the translucency is enabled in the material.
  52636. */
  52637. isTranslucencyEnabled: boolean;
  52638. private _isScatteringEnabled;
  52639. /**
  52640. * Defines the refraction intensity of the material.
  52641. * The refraction when enabled replaces the Diffuse part of the material.
  52642. * The intensity helps transitionning between diffuse and refraction.
  52643. */
  52644. refractionIntensity: number;
  52645. /**
  52646. * Defines the translucency intensity of the material.
  52647. * When translucency has been enabled, this defines how much of the "translucency"
  52648. * is addded to the diffuse part of the material.
  52649. */
  52650. translucencyIntensity: number;
  52651. /**
  52652. * Defines the scattering intensity of the material.
  52653. * When scattering has been enabled, this defines how much of the "scattered light"
  52654. * is addded to the diffuse part of the material.
  52655. */
  52656. scatteringIntensity: number;
  52657. private _thicknessTexture;
  52658. /**
  52659. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52660. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52661. * 0 would mean minimumThickness
  52662. * 1 would mean maximumThickness
  52663. * The other channels might be use as a mask to vary the different effects intensity.
  52664. */
  52665. thicknessTexture: Nullable<BaseTexture>;
  52666. private _refractionTexture;
  52667. /**
  52668. * Defines the texture to use for refraction.
  52669. */
  52670. refractionTexture: Nullable<BaseTexture>;
  52671. private _indexOfRefraction;
  52672. /**
  52673. * Defines the index of refraction used in the material.
  52674. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52675. */
  52676. indexOfRefraction: number;
  52677. private _invertRefractionY;
  52678. /**
  52679. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52680. */
  52681. invertRefractionY: boolean;
  52682. private _linkRefractionWithTransparency;
  52683. /**
  52684. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52685. * Materials half opaque for instance using refraction could benefit from this control.
  52686. */
  52687. linkRefractionWithTransparency: boolean;
  52688. /**
  52689. * Defines the minimum thickness stored in the thickness map.
  52690. * If no thickness map is defined, this value will be used to simulate thickness.
  52691. */
  52692. minimumThickness: number;
  52693. /**
  52694. * Defines the maximum thickness stored in the thickness map.
  52695. */
  52696. maximumThickness: number;
  52697. /**
  52698. * Defines the volume tint of the material.
  52699. * This is used for both translucency and scattering.
  52700. */
  52701. tintColor: Color3;
  52702. /**
  52703. * Defines the distance at which the tint color should be found in the media.
  52704. * This is used for refraction only.
  52705. */
  52706. tintColorAtDistance: number;
  52707. /**
  52708. * Defines how far each channel transmit through the media.
  52709. * It is defined as a color to simplify it selection.
  52710. */
  52711. diffusionDistance: Color3;
  52712. private _useMaskFromThicknessTexture;
  52713. /**
  52714. * Stores the intensity of the different subsurface effects in the thickness texture.
  52715. * * the green channel is the translucency intensity.
  52716. * * the blue channel is the scattering intensity.
  52717. * * the alpha channel is the refraction intensity.
  52718. */
  52719. useMaskFromThicknessTexture: boolean;
  52720. /** @hidden */
  52721. private _internalMarkAllSubMeshesAsTexturesDirty;
  52722. /** @hidden */
  52723. _markAllSubMeshesAsTexturesDirty(): void;
  52724. /**
  52725. * Instantiate a new istance of sub surface configuration.
  52726. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52727. */
  52728. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52729. /**
  52730. * Gets wehter the submesh is ready to be used or not.
  52731. * @param defines the list of "defines" to update.
  52732. * @param scene defines the scene the material belongs to.
  52733. * @returns - boolean indicating that the submesh is ready or not.
  52734. */
  52735. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52736. /**
  52737. * Checks to see if a texture is used in the material.
  52738. * @param defines the list of "defines" to update.
  52739. * @param scene defines the scene to the material belongs to.
  52740. */
  52741. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52742. /**
  52743. * Binds the material data.
  52744. * @param uniformBuffer defines the Uniform buffer to fill in.
  52745. * @param scene defines the scene the material belongs to.
  52746. * @param engine defines the engine the material belongs to.
  52747. * @param isFrozen defines wether the material is frozen or not.
  52748. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52749. */
  52750. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52751. /**
  52752. * Unbinds the material from the mesh.
  52753. * @param activeEffect defines the effect that should be unbound from.
  52754. * @returns true if unbound, otherwise false
  52755. */
  52756. unbind(activeEffect: Effect): boolean;
  52757. /**
  52758. * Returns the texture used for refraction or null if none is used.
  52759. * @param scene defines the scene the material belongs to.
  52760. * @returns - Refraction texture if present. If no refraction texture and refraction
  52761. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52762. */
  52763. private _getRefractionTexture;
  52764. /**
  52765. * Returns true if alpha blending should be disabled.
  52766. */
  52767. get disableAlphaBlending(): boolean;
  52768. /**
  52769. * Fills the list of render target textures.
  52770. * @param renderTargets the list of render targets to update
  52771. */
  52772. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52773. /**
  52774. * Checks to see if a texture is used in the material.
  52775. * @param texture - Base texture to use.
  52776. * @returns - Boolean specifying if a texture is used in the material.
  52777. */
  52778. hasTexture(texture: BaseTexture): boolean;
  52779. /**
  52780. * Gets a boolean indicating that current material needs to register RTT
  52781. * @returns true if this uses a render target otherwise false.
  52782. */
  52783. hasRenderTargetTextures(): boolean;
  52784. /**
  52785. * Returns an array of the actively used textures.
  52786. * @param activeTextures Array of BaseTextures
  52787. */
  52788. getActiveTextures(activeTextures: BaseTexture[]): void;
  52789. /**
  52790. * Returns the animatable textures.
  52791. * @param animatables Array of animatable textures.
  52792. */
  52793. getAnimatables(animatables: IAnimatable[]): void;
  52794. /**
  52795. * Disposes the resources of the material.
  52796. * @param forceDisposeTextures - Forces the disposal of all textures.
  52797. */
  52798. dispose(forceDisposeTextures?: boolean): void;
  52799. /**
  52800. * Get the current class name of the texture useful for serialization or dynamic coding.
  52801. * @returns "PBRSubSurfaceConfiguration"
  52802. */
  52803. getClassName(): string;
  52804. /**
  52805. * Add fallbacks to the effect fallbacks list.
  52806. * @param defines defines the Base texture to use.
  52807. * @param fallbacks defines the current fallback list.
  52808. * @param currentRank defines the current fallback rank.
  52809. * @returns the new fallback rank.
  52810. */
  52811. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52812. /**
  52813. * Add the required uniforms to the current list.
  52814. * @param uniforms defines the current uniform list.
  52815. */
  52816. static AddUniforms(uniforms: string[]): void;
  52817. /**
  52818. * Add the required samplers to the current list.
  52819. * @param samplers defines the current sampler list.
  52820. */
  52821. static AddSamplers(samplers: string[]): void;
  52822. /**
  52823. * Add the required uniforms to the current buffer.
  52824. * @param uniformBuffer defines the current uniform buffer.
  52825. */
  52826. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52827. /**
  52828. * Makes a duplicate of the current configuration into another one.
  52829. * @param configuration define the config where to copy the info
  52830. */
  52831. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52832. /**
  52833. * Serializes this Sub Surface configuration.
  52834. * @returns - An object with the serialized config.
  52835. */
  52836. serialize(): any;
  52837. /**
  52838. * Parses a anisotropy Configuration from a serialized object.
  52839. * @param source - Serialized object.
  52840. * @param scene Defines the scene we are parsing for
  52841. * @param rootUrl Defines the rootUrl to load from
  52842. */
  52843. parse(source: any, scene: Scene, rootUrl: string): void;
  52844. }
  52845. }
  52846. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52847. /** @hidden */
  52848. export var pbrFragmentDeclaration: {
  52849. name: string;
  52850. shader: string;
  52851. };
  52852. }
  52853. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52854. /** @hidden */
  52855. export var pbrUboDeclaration: {
  52856. name: string;
  52857. shader: string;
  52858. };
  52859. }
  52860. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52861. /** @hidden */
  52862. export var pbrFragmentExtraDeclaration: {
  52863. name: string;
  52864. shader: string;
  52865. };
  52866. }
  52867. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52868. /** @hidden */
  52869. export var pbrFragmentSamplersDeclaration: {
  52870. name: string;
  52871. shader: string;
  52872. };
  52873. }
  52874. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52875. /** @hidden */
  52876. export var pbrHelperFunctions: {
  52877. name: string;
  52878. shader: string;
  52879. };
  52880. }
  52881. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52882. /** @hidden */
  52883. export var harmonicsFunctions: {
  52884. name: string;
  52885. shader: string;
  52886. };
  52887. }
  52888. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52889. /** @hidden */
  52890. export var pbrDirectLightingSetupFunctions: {
  52891. name: string;
  52892. shader: string;
  52893. };
  52894. }
  52895. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52896. /** @hidden */
  52897. export var pbrDirectLightingFalloffFunctions: {
  52898. name: string;
  52899. shader: string;
  52900. };
  52901. }
  52902. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52903. /** @hidden */
  52904. export var pbrBRDFFunctions: {
  52905. name: string;
  52906. shader: string;
  52907. };
  52908. }
  52909. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52910. /** @hidden */
  52911. export var pbrDirectLightingFunctions: {
  52912. name: string;
  52913. shader: string;
  52914. };
  52915. }
  52916. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52917. /** @hidden */
  52918. export var pbrIBLFunctions: {
  52919. name: string;
  52920. shader: string;
  52921. };
  52922. }
  52923. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52924. /** @hidden */
  52925. export var pbrDebug: {
  52926. name: string;
  52927. shader: string;
  52928. };
  52929. }
  52930. declare module "babylonjs/Shaders/pbr.fragment" {
  52931. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52932. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52933. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52934. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52935. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52936. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52937. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52938. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52939. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52940. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52941. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52942. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52943. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52944. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52945. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52946. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52947. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52948. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52949. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52950. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52951. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52952. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52953. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52954. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52955. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52956. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52957. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52958. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52959. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52960. /** @hidden */
  52961. export var pbrPixelShader: {
  52962. name: string;
  52963. shader: string;
  52964. };
  52965. }
  52966. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52967. /** @hidden */
  52968. export var pbrVertexDeclaration: {
  52969. name: string;
  52970. shader: string;
  52971. };
  52972. }
  52973. declare module "babylonjs/Shaders/pbr.vertex" {
  52974. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52975. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52976. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52977. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52978. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52979. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52980. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52981. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52982. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52983. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52984. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52985. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52987. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52989. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52990. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52991. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52992. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52993. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52994. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52995. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52996. /** @hidden */
  52997. export var pbrVertexShader: {
  52998. name: string;
  52999. shader: string;
  53000. };
  53001. }
  53002. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53003. import { Nullable } from "babylonjs/types";
  53004. import { Scene } from "babylonjs/scene";
  53005. import { Matrix } from "babylonjs/Maths/math.vector";
  53006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53008. import { Mesh } from "babylonjs/Meshes/mesh";
  53009. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53010. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53011. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53012. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53013. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53014. import { Color3 } from "babylonjs/Maths/math.color";
  53015. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53016. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53017. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53018. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53020. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53021. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53022. import "babylonjs/Shaders/pbr.fragment";
  53023. import "babylonjs/Shaders/pbr.vertex";
  53024. /**
  53025. * Manages the defines for the PBR Material.
  53026. * @hidden
  53027. */
  53028. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53029. PBR: boolean;
  53030. MAINUV1: boolean;
  53031. MAINUV2: boolean;
  53032. UV1: boolean;
  53033. UV2: boolean;
  53034. ALBEDO: boolean;
  53035. GAMMAALBEDO: boolean;
  53036. ALBEDODIRECTUV: number;
  53037. VERTEXCOLOR: boolean;
  53038. AMBIENT: boolean;
  53039. AMBIENTDIRECTUV: number;
  53040. AMBIENTINGRAYSCALE: boolean;
  53041. OPACITY: boolean;
  53042. VERTEXALPHA: boolean;
  53043. OPACITYDIRECTUV: number;
  53044. OPACITYRGB: boolean;
  53045. ALPHATEST: boolean;
  53046. DEPTHPREPASS: boolean;
  53047. ALPHABLEND: boolean;
  53048. ALPHAFROMALBEDO: boolean;
  53049. ALPHATESTVALUE: string;
  53050. SPECULAROVERALPHA: boolean;
  53051. RADIANCEOVERALPHA: boolean;
  53052. ALPHAFRESNEL: boolean;
  53053. LINEARALPHAFRESNEL: boolean;
  53054. PREMULTIPLYALPHA: boolean;
  53055. EMISSIVE: boolean;
  53056. EMISSIVEDIRECTUV: number;
  53057. REFLECTIVITY: boolean;
  53058. REFLECTIVITYDIRECTUV: number;
  53059. SPECULARTERM: boolean;
  53060. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53061. MICROSURFACEAUTOMATIC: boolean;
  53062. LODBASEDMICROSFURACE: boolean;
  53063. MICROSURFACEMAP: boolean;
  53064. MICROSURFACEMAPDIRECTUV: number;
  53065. METALLICWORKFLOW: boolean;
  53066. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53067. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53068. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53069. AOSTOREINMETALMAPRED: boolean;
  53070. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53071. ENVIRONMENTBRDF: boolean;
  53072. ENVIRONMENTBRDF_RGBD: boolean;
  53073. NORMAL: boolean;
  53074. TANGENT: boolean;
  53075. BUMP: boolean;
  53076. BUMPDIRECTUV: number;
  53077. OBJECTSPACE_NORMALMAP: boolean;
  53078. PARALLAX: boolean;
  53079. PARALLAXOCCLUSION: boolean;
  53080. NORMALXYSCALE: boolean;
  53081. LIGHTMAP: boolean;
  53082. LIGHTMAPDIRECTUV: number;
  53083. USELIGHTMAPASSHADOWMAP: boolean;
  53084. GAMMALIGHTMAP: boolean;
  53085. RGBDLIGHTMAP: boolean;
  53086. REFLECTION: boolean;
  53087. REFLECTIONMAP_3D: boolean;
  53088. REFLECTIONMAP_SPHERICAL: boolean;
  53089. REFLECTIONMAP_PLANAR: boolean;
  53090. REFLECTIONMAP_CUBIC: boolean;
  53091. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53092. REFLECTIONMAP_PROJECTION: boolean;
  53093. REFLECTIONMAP_SKYBOX: boolean;
  53094. REFLECTIONMAP_EXPLICIT: boolean;
  53095. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53096. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53097. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53098. INVERTCUBICMAP: boolean;
  53099. USESPHERICALFROMREFLECTIONMAP: boolean;
  53100. USEIRRADIANCEMAP: boolean;
  53101. SPHERICAL_HARMONICS: boolean;
  53102. USESPHERICALINVERTEX: boolean;
  53103. REFLECTIONMAP_OPPOSITEZ: boolean;
  53104. LODINREFLECTIONALPHA: boolean;
  53105. GAMMAREFLECTION: boolean;
  53106. RGBDREFLECTION: boolean;
  53107. LINEARSPECULARREFLECTION: boolean;
  53108. RADIANCEOCCLUSION: boolean;
  53109. HORIZONOCCLUSION: boolean;
  53110. INSTANCES: boolean;
  53111. NUM_BONE_INFLUENCERS: number;
  53112. BonesPerMesh: number;
  53113. BONETEXTURE: boolean;
  53114. NONUNIFORMSCALING: boolean;
  53115. MORPHTARGETS: boolean;
  53116. MORPHTARGETS_NORMAL: boolean;
  53117. MORPHTARGETS_TANGENT: boolean;
  53118. MORPHTARGETS_UV: boolean;
  53119. NUM_MORPH_INFLUENCERS: number;
  53120. IMAGEPROCESSING: boolean;
  53121. VIGNETTE: boolean;
  53122. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53123. VIGNETTEBLENDMODEOPAQUE: boolean;
  53124. TONEMAPPING: boolean;
  53125. TONEMAPPING_ACES: boolean;
  53126. CONTRAST: boolean;
  53127. COLORCURVES: boolean;
  53128. COLORGRADING: boolean;
  53129. COLORGRADING3D: boolean;
  53130. SAMPLER3DGREENDEPTH: boolean;
  53131. SAMPLER3DBGRMAP: boolean;
  53132. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53133. EXPOSURE: boolean;
  53134. MULTIVIEW: boolean;
  53135. USEPHYSICALLIGHTFALLOFF: boolean;
  53136. USEGLTFLIGHTFALLOFF: boolean;
  53137. TWOSIDEDLIGHTING: boolean;
  53138. SHADOWFLOAT: boolean;
  53139. CLIPPLANE: boolean;
  53140. CLIPPLANE2: boolean;
  53141. CLIPPLANE3: boolean;
  53142. CLIPPLANE4: boolean;
  53143. CLIPPLANE5: boolean;
  53144. CLIPPLANE6: boolean;
  53145. POINTSIZE: boolean;
  53146. FOG: boolean;
  53147. LOGARITHMICDEPTH: boolean;
  53148. FORCENORMALFORWARD: boolean;
  53149. SPECULARAA: boolean;
  53150. CLEARCOAT: boolean;
  53151. CLEARCOAT_DEFAULTIOR: boolean;
  53152. CLEARCOAT_TEXTURE: boolean;
  53153. CLEARCOAT_TEXTUREDIRECTUV: number;
  53154. CLEARCOAT_BUMP: boolean;
  53155. CLEARCOAT_BUMPDIRECTUV: number;
  53156. CLEARCOAT_TINT: boolean;
  53157. CLEARCOAT_TINT_TEXTURE: boolean;
  53158. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53159. ANISOTROPIC: boolean;
  53160. ANISOTROPIC_TEXTURE: boolean;
  53161. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53162. BRDF_V_HEIGHT_CORRELATED: boolean;
  53163. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53164. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53165. SHEEN: boolean;
  53166. SHEEN_TEXTURE: boolean;
  53167. SHEEN_TEXTUREDIRECTUV: number;
  53168. SHEEN_LINKWITHALBEDO: boolean;
  53169. SUBSURFACE: boolean;
  53170. SS_REFRACTION: boolean;
  53171. SS_TRANSLUCENCY: boolean;
  53172. SS_SCATERRING: boolean;
  53173. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53174. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53175. SS_REFRACTIONMAP_3D: boolean;
  53176. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53177. SS_LODINREFRACTIONALPHA: boolean;
  53178. SS_GAMMAREFRACTION: boolean;
  53179. SS_RGBDREFRACTION: boolean;
  53180. SS_LINEARSPECULARREFRACTION: boolean;
  53181. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53182. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53183. UNLIT: boolean;
  53184. DEBUGMODE: number;
  53185. /**
  53186. * Initializes the PBR Material defines.
  53187. */
  53188. constructor();
  53189. /**
  53190. * Resets the PBR Material defines.
  53191. */
  53192. reset(): void;
  53193. }
  53194. /**
  53195. * The Physically based material base class of BJS.
  53196. *
  53197. * This offers the main features of a standard PBR material.
  53198. * For more information, please refer to the documentation :
  53199. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53200. */
  53201. export abstract class PBRBaseMaterial extends PushMaterial {
  53202. /**
  53203. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53204. */
  53205. static readonly PBRMATERIAL_OPAQUE: number;
  53206. /**
  53207. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53208. */
  53209. static readonly PBRMATERIAL_ALPHATEST: number;
  53210. /**
  53211. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53212. */
  53213. static readonly PBRMATERIAL_ALPHABLEND: number;
  53214. /**
  53215. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53216. * They are also discarded below the alpha cutoff threshold to improve performances.
  53217. */
  53218. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53219. /**
  53220. * Defines the default value of how much AO map is occluding the analytical lights
  53221. * (point spot...).
  53222. */
  53223. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53224. /**
  53225. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53226. */
  53227. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53228. /**
  53229. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53230. * to enhance interoperability with other engines.
  53231. */
  53232. static readonly LIGHTFALLOFF_GLTF: number;
  53233. /**
  53234. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53235. * to enhance interoperability with other materials.
  53236. */
  53237. static readonly LIGHTFALLOFF_STANDARD: number;
  53238. /**
  53239. * Intensity of the direct lights e.g. the four lights available in your scene.
  53240. * This impacts both the direct diffuse and specular highlights.
  53241. */
  53242. protected _directIntensity: number;
  53243. /**
  53244. * Intensity of the emissive part of the material.
  53245. * This helps controlling the emissive effect without modifying the emissive color.
  53246. */
  53247. protected _emissiveIntensity: number;
  53248. /**
  53249. * Intensity of the environment e.g. how much the environment will light the object
  53250. * either through harmonics for rough material or through the refelction for shiny ones.
  53251. */
  53252. protected _environmentIntensity: number;
  53253. /**
  53254. * This is a special control allowing the reduction of the specular highlights coming from the
  53255. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53256. */
  53257. protected _specularIntensity: number;
  53258. /**
  53259. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53260. */
  53261. private _lightingInfos;
  53262. /**
  53263. * Debug Control allowing disabling the bump map on this material.
  53264. */
  53265. protected _disableBumpMap: boolean;
  53266. /**
  53267. * AKA Diffuse Texture in standard nomenclature.
  53268. */
  53269. protected _albedoTexture: Nullable<BaseTexture>;
  53270. /**
  53271. * AKA Occlusion Texture in other nomenclature.
  53272. */
  53273. protected _ambientTexture: Nullable<BaseTexture>;
  53274. /**
  53275. * AKA Occlusion Texture Intensity in other nomenclature.
  53276. */
  53277. protected _ambientTextureStrength: number;
  53278. /**
  53279. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53280. * 1 means it completely occludes it
  53281. * 0 mean it has no impact
  53282. */
  53283. protected _ambientTextureImpactOnAnalyticalLights: number;
  53284. /**
  53285. * Stores the alpha values in a texture.
  53286. */
  53287. protected _opacityTexture: Nullable<BaseTexture>;
  53288. /**
  53289. * Stores the reflection values in a texture.
  53290. */
  53291. protected _reflectionTexture: Nullable<BaseTexture>;
  53292. /**
  53293. * Stores the emissive values in a texture.
  53294. */
  53295. protected _emissiveTexture: Nullable<BaseTexture>;
  53296. /**
  53297. * AKA Specular texture in other nomenclature.
  53298. */
  53299. protected _reflectivityTexture: Nullable<BaseTexture>;
  53300. /**
  53301. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53302. */
  53303. protected _metallicTexture: Nullable<BaseTexture>;
  53304. /**
  53305. * Specifies the metallic scalar of the metallic/roughness workflow.
  53306. * Can also be used to scale the metalness values of the metallic texture.
  53307. */
  53308. protected _metallic: Nullable<number>;
  53309. /**
  53310. * Specifies the roughness scalar of the metallic/roughness workflow.
  53311. * Can also be used to scale the roughness values of the metallic texture.
  53312. */
  53313. protected _roughness: Nullable<number>;
  53314. /**
  53315. * Specifies the an F0 factor to help configuring the material F0.
  53316. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53317. * to 0.5 the previously hard coded value stays the same.
  53318. * Can also be used to scale the F0 values of the metallic texture.
  53319. */
  53320. protected _metallicF0Factor: number;
  53321. /**
  53322. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53323. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53324. * your expectation as it multiplies with the texture data.
  53325. */
  53326. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53327. /**
  53328. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53329. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53330. */
  53331. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53332. /**
  53333. * Stores surface normal data used to displace a mesh in a texture.
  53334. */
  53335. protected _bumpTexture: Nullable<BaseTexture>;
  53336. /**
  53337. * Stores the pre-calculated light information of a mesh in a texture.
  53338. */
  53339. protected _lightmapTexture: Nullable<BaseTexture>;
  53340. /**
  53341. * The color of a material in ambient lighting.
  53342. */
  53343. protected _ambientColor: Color3;
  53344. /**
  53345. * AKA Diffuse Color in other nomenclature.
  53346. */
  53347. protected _albedoColor: Color3;
  53348. /**
  53349. * AKA Specular Color in other nomenclature.
  53350. */
  53351. protected _reflectivityColor: Color3;
  53352. /**
  53353. * The color applied when light is reflected from a material.
  53354. */
  53355. protected _reflectionColor: Color3;
  53356. /**
  53357. * The color applied when light is emitted from a material.
  53358. */
  53359. protected _emissiveColor: Color3;
  53360. /**
  53361. * AKA Glossiness in other nomenclature.
  53362. */
  53363. protected _microSurface: number;
  53364. /**
  53365. * Specifies that the material will use the light map as a show map.
  53366. */
  53367. protected _useLightmapAsShadowmap: boolean;
  53368. /**
  53369. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53370. * makes the reflect vector face the model (under horizon).
  53371. */
  53372. protected _useHorizonOcclusion: boolean;
  53373. /**
  53374. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53375. * too much the area relying on ambient texture to define their ambient occlusion.
  53376. */
  53377. protected _useRadianceOcclusion: boolean;
  53378. /**
  53379. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53380. */
  53381. protected _useAlphaFromAlbedoTexture: boolean;
  53382. /**
  53383. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53384. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53385. */
  53386. protected _useSpecularOverAlpha: boolean;
  53387. /**
  53388. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53389. */
  53390. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53391. /**
  53392. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53393. */
  53394. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53395. /**
  53396. * Specifies if the metallic texture contains the roughness information in its green channel.
  53397. */
  53398. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53399. /**
  53400. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53401. */
  53402. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53403. /**
  53404. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53405. */
  53406. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53407. /**
  53408. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53409. */
  53410. protected _useAmbientInGrayScale: boolean;
  53411. /**
  53412. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53413. * The material will try to infer what glossiness each pixel should be.
  53414. */
  53415. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53416. /**
  53417. * Defines the falloff type used in this material.
  53418. * It by default is Physical.
  53419. */
  53420. protected _lightFalloff: number;
  53421. /**
  53422. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53423. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53424. */
  53425. protected _useRadianceOverAlpha: boolean;
  53426. /**
  53427. * Allows using an object space normal map (instead of tangent space).
  53428. */
  53429. protected _useObjectSpaceNormalMap: boolean;
  53430. /**
  53431. * Allows using the bump map in parallax mode.
  53432. */
  53433. protected _useParallax: boolean;
  53434. /**
  53435. * Allows using the bump map in parallax occlusion mode.
  53436. */
  53437. protected _useParallaxOcclusion: boolean;
  53438. /**
  53439. * Controls the scale bias of the parallax mode.
  53440. */
  53441. protected _parallaxScaleBias: number;
  53442. /**
  53443. * If sets to true, disables all the lights affecting the material.
  53444. */
  53445. protected _disableLighting: boolean;
  53446. /**
  53447. * Number of Simultaneous lights allowed on the material.
  53448. */
  53449. protected _maxSimultaneousLights: number;
  53450. /**
  53451. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53452. */
  53453. protected _invertNormalMapX: boolean;
  53454. /**
  53455. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53456. */
  53457. protected _invertNormalMapY: boolean;
  53458. /**
  53459. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53460. */
  53461. protected _twoSidedLighting: boolean;
  53462. /**
  53463. * Defines the alpha limits in alpha test mode.
  53464. */
  53465. protected _alphaCutOff: number;
  53466. /**
  53467. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53468. */
  53469. protected _forceAlphaTest: boolean;
  53470. /**
  53471. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53472. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53473. */
  53474. protected _useAlphaFresnel: boolean;
  53475. /**
  53476. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53477. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53478. */
  53479. protected _useLinearAlphaFresnel: boolean;
  53480. /**
  53481. * The transparency mode of the material.
  53482. */
  53483. protected _transparencyMode: Nullable<number>;
  53484. /**
  53485. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53486. * from cos thetav and roughness:
  53487. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53488. */
  53489. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53490. /**
  53491. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53492. */
  53493. protected _forceIrradianceInFragment: boolean;
  53494. /**
  53495. * Force normal to face away from face.
  53496. */
  53497. protected _forceNormalForward: boolean;
  53498. /**
  53499. * Enables specular anti aliasing in the PBR shader.
  53500. * It will both interacts on the Geometry for analytical and IBL lighting.
  53501. * It also prefilter the roughness map based on the bump values.
  53502. */
  53503. protected _enableSpecularAntiAliasing: boolean;
  53504. /**
  53505. * Default configuration related to image processing available in the PBR Material.
  53506. */
  53507. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53508. /**
  53509. * Keep track of the image processing observer to allow dispose and replace.
  53510. */
  53511. private _imageProcessingObserver;
  53512. /**
  53513. * Attaches a new image processing configuration to the PBR Material.
  53514. * @param configuration
  53515. */
  53516. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53517. /**
  53518. * Stores the available render targets.
  53519. */
  53520. private _renderTargets;
  53521. /**
  53522. * Sets the global ambient color for the material used in lighting calculations.
  53523. */
  53524. private _globalAmbientColor;
  53525. /**
  53526. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53527. */
  53528. private _useLogarithmicDepth;
  53529. /**
  53530. * If set to true, no lighting calculations will be applied.
  53531. */
  53532. private _unlit;
  53533. private _debugMode;
  53534. /**
  53535. * @hidden
  53536. * This is reserved for the inspector.
  53537. * Defines the material debug mode.
  53538. * It helps seeing only some components of the material while troubleshooting.
  53539. */
  53540. debugMode: number;
  53541. /**
  53542. * @hidden
  53543. * This is reserved for the inspector.
  53544. * Specify from where on screen the debug mode should start.
  53545. * The value goes from -1 (full screen) to 1 (not visible)
  53546. * It helps with side by side comparison against the final render
  53547. * This defaults to -1
  53548. */
  53549. private debugLimit;
  53550. /**
  53551. * @hidden
  53552. * This is reserved for the inspector.
  53553. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53554. * You can use the factor to better multiply the final value.
  53555. */
  53556. private debugFactor;
  53557. /**
  53558. * Defines the clear coat layer parameters for the material.
  53559. */
  53560. readonly clearCoat: PBRClearCoatConfiguration;
  53561. /**
  53562. * Defines the anisotropic parameters for the material.
  53563. */
  53564. readonly anisotropy: PBRAnisotropicConfiguration;
  53565. /**
  53566. * Defines the BRDF parameters for the material.
  53567. */
  53568. readonly brdf: PBRBRDFConfiguration;
  53569. /**
  53570. * Defines the Sheen parameters for the material.
  53571. */
  53572. readonly sheen: PBRSheenConfiguration;
  53573. /**
  53574. * Defines the SubSurface parameters for the material.
  53575. */
  53576. readonly subSurface: PBRSubSurfaceConfiguration;
  53577. /**
  53578. * Custom callback helping to override the default shader used in the material.
  53579. */
  53580. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53581. protected _rebuildInParallel: boolean;
  53582. /**
  53583. * Instantiates a new PBRMaterial instance.
  53584. *
  53585. * @param name The material name
  53586. * @param scene The scene the material will be use in.
  53587. */
  53588. constructor(name: string, scene: Scene);
  53589. /**
  53590. * Gets a boolean indicating that current material needs to register RTT
  53591. */
  53592. get hasRenderTargetTextures(): boolean;
  53593. /**
  53594. * Gets the name of the material class.
  53595. */
  53596. getClassName(): string;
  53597. /**
  53598. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53599. */
  53600. get useLogarithmicDepth(): boolean;
  53601. /**
  53602. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53603. */
  53604. set useLogarithmicDepth(value: boolean);
  53605. /**
  53606. * Gets the current transparency mode.
  53607. */
  53608. get transparencyMode(): Nullable<number>;
  53609. /**
  53610. * Sets the transparency mode of the material.
  53611. *
  53612. * | Value | Type | Description |
  53613. * | ----- | ----------------------------------- | ----------- |
  53614. * | 0 | OPAQUE | |
  53615. * | 1 | ALPHATEST | |
  53616. * | 2 | ALPHABLEND | |
  53617. * | 3 | ALPHATESTANDBLEND | |
  53618. *
  53619. */
  53620. set transparencyMode(value: Nullable<number>);
  53621. /**
  53622. * Returns true if alpha blending should be disabled.
  53623. */
  53624. private get _disableAlphaBlending();
  53625. /**
  53626. * Specifies whether or not this material should be rendered in alpha blend mode.
  53627. */
  53628. needAlphaBlending(): boolean;
  53629. /**
  53630. * Specifies if the mesh will require alpha blending.
  53631. * @param mesh - BJS mesh.
  53632. */
  53633. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53634. /**
  53635. * Specifies whether or not this material should be rendered in alpha test mode.
  53636. */
  53637. needAlphaTesting(): boolean;
  53638. /**
  53639. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53640. */
  53641. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53642. /**
  53643. * Gets the texture used for the alpha test.
  53644. */
  53645. getAlphaTestTexture(): Nullable<BaseTexture>;
  53646. /**
  53647. * Specifies that the submesh is ready to be used.
  53648. * @param mesh - BJS mesh.
  53649. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53650. * @param useInstances - Specifies that instances should be used.
  53651. * @returns - boolean indicating that the submesh is ready or not.
  53652. */
  53653. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53654. /**
  53655. * Specifies if the material uses metallic roughness workflow.
  53656. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53657. */
  53658. isMetallicWorkflow(): boolean;
  53659. private _prepareEffect;
  53660. private _prepareDefines;
  53661. /**
  53662. * Force shader compilation
  53663. */
  53664. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53665. /**
  53666. * Initializes the uniform buffer layout for the shader.
  53667. */
  53668. buildUniformLayout(): void;
  53669. /**
  53670. * Unbinds the material from the mesh
  53671. */
  53672. unbind(): void;
  53673. /**
  53674. * Binds the submesh data.
  53675. * @param world - The world matrix.
  53676. * @param mesh - The BJS mesh.
  53677. * @param subMesh - A submesh of the BJS mesh.
  53678. */
  53679. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53680. /**
  53681. * Returns the animatable textures.
  53682. * @returns - Array of animatable textures.
  53683. */
  53684. getAnimatables(): IAnimatable[];
  53685. /**
  53686. * Returns the texture used for reflections.
  53687. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53688. */
  53689. private _getReflectionTexture;
  53690. /**
  53691. * Returns an array of the actively used textures.
  53692. * @returns - Array of BaseTextures
  53693. */
  53694. getActiveTextures(): BaseTexture[];
  53695. /**
  53696. * Checks to see if a texture is used in the material.
  53697. * @param texture - Base texture to use.
  53698. * @returns - Boolean specifying if a texture is used in the material.
  53699. */
  53700. hasTexture(texture: BaseTexture): boolean;
  53701. /**
  53702. * Disposes the resources of the material.
  53703. * @param forceDisposeEffect - Forces the disposal of effects.
  53704. * @param forceDisposeTextures - Forces the disposal of all textures.
  53705. */
  53706. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53707. }
  53708. }
  53709. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53710. import { Nullable } from "babylonjs/types";
  53711. import { Scene } from "babylonjs/scene";
  53712. import { Color3 } from "babylonjs/Maths/math.color";
  53713. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53714. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53716. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53717. /**
  53718. * The Physically based material of BJS.
  53719. *
  53720. * This offers the main features of a standard PBR material.
  53721. * For more information, please refer to the documentation :
  53722. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53723. */
  53724. export class PBRMaterial extends PBRBaseMaterial {
  53725. /**
  53726. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53727. */
  53728. static readonly PBRMATERIAL_OPAQUE: number;
  53729. /**
  53730. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53731. */
  53732. static readonly PBRMATERIAL_ALPHATEST: number;
  53733. /**
  53734. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53735. */
  53736. static readonly PBRMATERIAL_ALPHABLEND: number;
  53737. /**
  53738. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53739. * They are also discarded below the alpha cutoff threshold to improve performances.
  53740. */
  53741. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53742. /**
  53743. * Defines the default value of how much AO map is occluding the analytical lights
  53744. * (point spot...).
  53745. */
  53746. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53747. /**
  53748. * Intensity of the direct lights e.g. the four lights available in your scene.
  53749. * This impacts both the direct diffuse and specular highlights.
  53750. */
  53751. directIntensity: number;
  53752. /**
  53753. * Intensity of the emissive part of the material.
  53754. * This helps controlling the emissive effect without modifying the emissive color.
  53755. */
  53756. emissiveIntensity: number;
  53757. /**
  53758. * Intensity of the environment e.g. how much the environment will light the object
  53759. * either through harmonics for rough material or through the refelction for shiny ones.
  53760. */
  53761. environmentIntensity: number;
  53762. /**
  53763. * This is a special control allowing the reduction of the specular highlights coming from the
  53764. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53765. */
  53766. specularIntensity: number;
  53767. /**
  53768. * Debug Control allowing disabling the bump map on this material.
  53769. */
  53770. disableBumpMap: boolean;
  53771. /**
  53772. * AKA Diffuse Texture in standard nomenclature.
  53773. */
  53774. albedoTexture: BaseTexture;
  53775. /**
  53776. * AKA Occlusion Texture in other nomenclature.
  53777. */
  53778. ambientTexture: BaseTexture;
  53779. /**
  53780. * AKA Occlusion Texture Intensity in other nomenclature.
  53781. */
  53782. ambientTextureStrength: number;
  53783. /**
  53784. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53785. * 1 means it completely occludes it
  53786. * 0 mean it has no impact
  53787. */
  53788. ambientTextureImpactOnAnalyticalLights: number;
  53789. /**
  53790. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53791. */
  53792. opacityTexture: BaseTexture;
  53793. /**
  53794. * Stores the reflection values in a texture.
  53795. */
  53796. reflectionTexture: Nullable<BaseTexture>;
  53797. /**
  53798. * Stores the emissive values in a texture.
  53799. */
  53800. emissiveTexture: BaseTexture;
  53801. /**
  53802. * AKA Specular texture in other nomenclature.
  53803. */
  53804. reflectivityTexture: BaseTexture;
  53805. /**
  53806. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53807. */
  53808. metallicTexture: BaseTexture;
  53809. /**
  53810. * Specifies the metallic scalar of the metallic/roughness workflow.
  53811. * Can also be used to scale the metalness values of the metallic texture.
  53812. */
  53813. metallic: Nullable<number>;
  53814. /**
  53815. * Specifies the roughness scalar of the metallic/roughness workflow.
  53816. * Can also be used to scale the roughness values of the metallic texture.
  53817. */
  53818. roughness: Nullable<number>;
  53819. /**
  53820. * Specifies the an F0 factor to help configuring the material F0.
  53821. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53822. * to 0.5 the previously hard coded value stays the same.
  53823. * Can also be used to scale the F0 values of the metallic texture.
  53824. */
  53825. metallicF0Factor: number;
  53826. /**
  53827. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53828. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53829. * your expectation as it multiplies with the texture data.
  53830. */
  53831. useMetallicF0FactorFromMetallicTexture: boolean;
  53832. /**
  53833. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53834. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53835. */
  53836. microSurfaceTexture: BaseTexture;
  53837. /**
  53838. * Stores surface normal data used to displace a mesh in a texture.
  53839. */
  53840. bumpTexture: BaseTexture;
  53841. /**
  53842. * Stores the pre-calculated light information of a mesh in a texture.
  53843. */
  53844. lightmapTexture: BaseTexture;
  53845. /**
  53846. * Stores the refracted light information in a texture.
  53847. */
  53848. get refractionTexture(): Nullable<BaseTexture>;
  53849. set refractionTexture(value: Nullable<BaseTexture>);
  53850. /**
  53851. * The color of a material in ambient lighting.
  53852. */
  53853. ambientColor: Color3;
  53854. /**
  53855. * AKA Diffuse Color in other nomenclature.
  53856. */
  53857. albedoColor: Color3;
  53858. /**
  53859. * AKA Specular Color in other nomenclature.
  53860. */
  53861. reflectivityColor: Color3;
  53862. /**
  53863. * The color reflected from the material.
  53864. */
  53865. reflectionColor: Color3;
  53866. /**
  53867. * The color emitted from the material.
  53868. */
  53869. emissiveColor: Color3;
  53870. /**
  53871. * AKA Glossiness in other nomenclature.
  53872. */
  53873. microSurface: number;
  53874. /**
  53875. * source material index of refraction (IOR)' / 'destination material IOR.
  53876. */
  53877. get indexOfRefraction(): number;
  53878. set indexOfRefraction(value: number);
  53879. /**
  53880. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53881. */
  53882. get invertRefractionY(): boolean;
  53883. set invertRefractionY(value: boolean);
  53884. /**
  53885. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53886. * Materials half opaque for instance using refraction could benefit from this control.
  53887. */
  53888. get linkRefractionWithTransparency(): boolean;
  53889. set linkRefractionWithTransparency(value: boolean);
  53890. /**
  53891. * If true, the light map contains occlusion information instead of lighting info.
  53892. */
  53893. useLightmapAsShadowmap: boolean;
  53894. /**
  53895. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53896. */
  53897. useAlphaFromAlbedoTexture: boolean;
  53898. /**
  53899. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53900. */
  53901. forceAlphaTest: boolean;
  53902. /**
  53903. * Defines the alpha limits in alpha test mode.
  53904. */
  53905. alphaCutOff: number;
  53906. /**
  53907. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53908. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53909. */
  53910. useSpecularOverAlpha: boolean;
  53911. /**
  53912. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53913. */
  53914. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53915. /**
  53916. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53917. */
  53918. useRoughnessFromMetallicTextureAlpha: boolean;
  53919. /**
  53920. * Specifies if the metallic texture contains the roughness information in its green channel.
  53921. */
  53922. useRoughnessFromMetallicTextureGreen: boolean;
  53923. /**
  53924. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53925. */
  53926. useMetallnessFromMetallicTextureBlue: boolean;
  53927. /**
  53928. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53929. */
  53930. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53931. /**
  53932. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53933. */
  53934. useAmbientInGrayScale: boolean;
  53935. /**
  53936. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53937. * The material will try to infer what glossiness each pixel should be.
  53938. */
  53939. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53940. /**
  53941. * BJS is using an harcoded light falloff based on a manually sets up range.
  53942. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53943. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53944. */
  53945. get usePhysicalLightFalloff(): boolean;
  53946. /**
  53947. * BJS is using an harcoded light falloff based on a manually sets up range.
  53948. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53949. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53950. */
  53951. set usePhysicalLightFalloff(value: boolean);
  53952. /**
  53953. * In order to support the falloff compatibility with gltf, a special mode has been added
  53954. * to reproduce the gltf light falloff.
  53955. */
  53956. get useGLTFLightFalloff(): boolean;
  53957. /**
  53958. * In order to support the falloff compatibility with gltf, a special mode has been added
  53959. * to reproduce the gltf light falloff.
  53960. */
  53961. set useGLTFLightFalloff(value: boolean);
  53962. /**
  53963. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53964. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53965. */
  53966. useRadianceOverAlpha: boolean;
  53967. /**
  53968. * Allows using an object space normal map (instead of tangent space).
  53969. */
  53970. useObjectSpaceNormalMap: boolean;
  53971. /**
  53972. * Allows using the bump map in parallax mode.
  53973. */
  53974. useParallax: boolean;
  53975. /**
  53976. * Allows using the bump map in parallax occlusion mode.
  53977. */
  53978. useParallaxOcclusion: boolean;
  53979. /**
  53980. * Controls the scale bias of the parallax mode.
  53981. */
  53982. parallaxScaleBias: number;
  53983. /**
  53984. * If sets to true, disables all the lights affecting the material.
  53985. */
  53986. disableLighting: boolean;
  53987. /**
  53988. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53989. */
  53990. forceIrradianceInFragment: boolean;
  53991. /**
  53992. * Number of Simultaneous lights allowed on the material.
  53993. */
  53994. maxSimultaneousLights: number;
  53995. /**
  53996. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53997. */
  53998. invertNormalMapX: boolean;
  53999. /**
  54000. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54001. */
  54002. invertNormalMapY: boolean;
  54003. /**
  54004. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54005. */
  54006. twoSidedLighting: boolean;
  54007. /**
  54008. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54009. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54010. */
  54011. useAlphaFresnel: boolean;
  54012. /**
  54013. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54014. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54015. */
  54016. useLinearAlphaFresnel: boolean;
  54017. /**
  54018. * Let user defines the brdf lookup texture used for IBL.
  54019. * A default 8bit version is embedded but you could point at :
  54020. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54021. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54022. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54023. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54024. */
  54025. environmentBRDFTexture: Nullable<BaseTexture>;
  54026. /**
  54027. * Force normal to face away from face.
  54028. */
  54029. forceNormalForward: boolean;
  54030. /**
  54031. * Enables specular anti aliasing in the PBR shader.
  54032. * It will both interacts on the Geometry for analytical and IBL lighting.
  54033. * It also prefilter the roughness map based on the bump values.
  54034. */
  54035. enableSpecularAntiAliasing: boolean;
  54036. /**
  54037. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54038. * makes the reflect vector face the model (under horizon).
  54039. */
  54040. useHorizonOcclusion: boolean;
  54041. /**
  54042. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54043. * too much the area relying on ambient texture to define their ambient occlusion.
  54044. */
  54045. useRadianceOcclusion: boolean;
  54046. /**
  54047. * If set to true, no lighting calculations will be applied.
  54048. */
  54049. unlit: boolean;
  54050. /**
  54051. * Gets the image processing configuration used either in this material.
  54052. */
  54053. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54054. /**
  54055. * Sets the Default image processing configuration used either in the this material.
  54056. *
  54057. * If sets to null, the scene one is in use.
  54058. */
  54059. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54060. /**
  54061. * Gets wether the color curves effect is enabled.
  54062. */
  54063. get cameraColorCurvesEnabled(): boolean;
  54064. /**
  54065. * Sets wether the color curves effect is enabled.
  54066. */
  54067. set cameraColorCurvesEnabled(value: boolean);
  54068. /**
  54069. * Gets wether the color grading effect is enabled.
  54070. */
  54071. get cameraColorGradingEnabled(): boolean;
  54072. /**
  54073. * Gets wether the color grading effect is enabled.
  54074. */
  54075. set cameraColorGradingEnabled(value: boolean);
  54076. /**
  54077. * Gets wether tonemapping is enabled or not.
  54078. */
  54079. get cameraToneMappingEnabled(): boolean;
  54080. /**
  54081. * Sets wether tonemapping is enabled or not
  54082. */
  54083. set cameraToneMappingEnabled(value: boolean);
  54084. /**
  54085. * The camera exposure used on this material.
  54086. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54087. * This corresponds to a photographic exposure.
  54088. */
  54089. get cameraExposure(): number;
  54090. /**
  54091. * The camera exposure used on this material.
  54092. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54093. * This corresponds to a photographic exposure.
  54094. */
  54095. set cameraExposure(value: number);
  54096. /**
  54097. * Gets The camera contrast used on this material.
  54098. */
  54099. get cameraContrast(): number;
  54100. /**
  54101. * Sets The camera contrast used on this material.
  54102. */
  54103. set cameraContrast(value: number);
  54104. /**
  54105. * Gets the Color Grading 2D Lookup Texture.
  54106. */
  54107. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54108. /**
  54109. * Sets the Color Grading 2D Lookup Texture.
  54110. */
  54111. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54112. /**
  54113. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54114. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54115. * 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;
  54116. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54117. */
  54118. get cameraColorCurves(): Nullable<ColorCurves>;
  54119. /**
  54120. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54121. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54122. * 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;
  54123. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54124. */
  54125. set cameraColorCurves(value: Nullable<ColorCurves>);
  54126. /**
  54127. * Instantiates a new PBRMaterial instance.
  54128. *
  54129. * @param name The material name
  54130. * @param scene The scene the material will be use in.
  54131. */
  54132. constructor(name: string, scene: Scene);
  54133. /**
  54134. * Returns the name of this material class.
  54135. */
  54136. getClassName(): string;
  54137. /**
  54138. * Makes a duplicate of the current material.
  54139. * @param name - name to use for the new material.
  54140. */
  54141. clone(name: string): PBRMaterial;
  54142. /**
  54143. * Serializes this PBR Material.
  54144. * @returns - An object with the serialized material.
  54145. */
  54146. serialize(): any;
  54147. /**
  54148. * Parses a PBR Material from a serialized object.
  54149. * @param source - Serialized object.
  54150. * @param scene - BJS scene instance.
  54151. * @param rootUrl - url for the scene object
  54152. * @returns - PBRMaterial
  54153. */
  54154. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54155. }
  54156. }
  54157. declare module "babylonjs/Misc/dds" {
  54158. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54159. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54160. import { Nullable } from "babylonjs/types";
  54161. import { Scene } from "babylonjs/scene";
  54162. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54163. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54164. /**
  54165. * Direct draw surface info
  54166. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54167. */
  54168. export interface DDSInfo {
  54169. /**
  54170. * Width of the texture
  54171. */
  54172. width: number;
  54173. /**
  54174. * Width of the texture
  54175. */
  54176. height: number;
  54177. /**
  54178. * Number of Mipmaps for the texture
  54179. * @see https://en.wikipedia.org/wiki/Mipmap
  54180. */
  54181. mipmapCount: number;
  54182. /**
  54183. * If the textures format is a known fourCC format
  54184. * @see https://www.fourcc.org/
  54185. */
  54186. isFourCC: boolean;
  54187. /**
  54188. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54189. */
  54190. isRGB: boolean;
  54191. /**
  54192. * If the texture is a lumincance format
  54193. */
  54194. isLuminance: boolean;
  54195. /**
  54196. * If this is a cube texture
  54197. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54198. */
  54199. isCube: boolean;
  54200. /**
  54201. * If the texture is a compressed format eg. FOURCC_DXT1
  54202. */
  54203. isCompressed: boolean;
  54204. /**
  54205. * The dxgiFormat of the texture
  54206. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54207. */
  54208. dxgiFormat: number;
  54209. /**
  54210. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54211. */
  54212. textureType: number;
  54213. /**
  54214. * Sphericle polynomial created for the dds texture
  54215. */
  54216. sphericalPolynomial?: SphericalPolynomial;
  54217. }
  54218. /**
  54219. * Class used to provide DDS decompression tools
  54220. */
  54221. export class DDSTools {
  54222. /**
  54223. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54224. */
  54225. static StoreLODInAlphaChannel: boolean;
  54226. /**
  54227. * Gets DDS information from an array buffer
  54228. * @param data defines the array buffer view to read data from
  54229. * @returns the DDS information
  54230. */
  54231. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54232. private static _FloatView;
  54233. private static _Int32View;
  54234. private static _ToHalfFloat;
  54235. private static _FromHalfFloat;
  54236. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54237. private static _GetHalfFloatRGBAArrayBuffer;
  54238. private static _GetFloatRGBAArrayBuffer;
  54239. private static _GetFloatAsUIntRGBAArrayBuffer;
  54240. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54241. private static _GetRGBAArrayBuffer;
  54242. private static _ExtractLongWordOrder;
  54243. private static _GetRGBArrayBuffer;
  54244. private static _GetLuminanceArrayBuffer;
  54245. /**
  54246. * Uploads DDS Levels to a Babylon Texture
  54247. * @hidden
  54248. */
  54249. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54250. }
  54251. module "babylonjs/Engines/thinEngine" {
  54252. interface ThinEngine {
  54253. /**
  54254. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54255. * @param rootUrl defines the url where the file to load is located
  54256. * @param scene defines the current scene
  54257. * @param lodScale defines scale to apply to the mip map selection
  54258. * @param lodOffset defines offset to apply to the mip map selection
  54259. * @param onLoad defines an optional callback raised when the texture is loaded
  54260. * @param onError defines an optional callback raised if there is an issue to load the texture
  54261. * @param format defines the format of the data
  54262. * @param forcedExtension defines the extension to use to pick the right loader
  54263. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54264. * @returns the cube texture as an InternalTexture
  54265. */
  54266. 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;
  54267. }
  54268. }
  54269. }
  54270. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54271. import { Nullable } from "babylonjs/types";
  54272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54273. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54274. /**
  54275. * Implementation of the DDS Texture Loader.
  54276. * @hidden
  54277. */
  54278. export class _DDSTextureLoader implements IInternalTextureLoader {
  54279. /**
  54280. * Defines wether the loader supports cascade loading the different faces.
  54281. */
  54282. readonly supportCascades: boolean;
  54283. /**
  54284. * This returns if the loader support the current file information.
  54285. * @param extension defines the file extension of the file being loaded
  54286. * @returns true if the loader can load the specified file
  54287. */
  54288. canLoad(extension: string): boolean;
  54289. /**
  54290. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54291. * @param data contains the texture data
  54292. * @param texture defines the BabylonJS internal texture
  54293. * @param createPolynomials will be true if polynomials have been requested
  54294. * @param onLoad defines the callback to trigger once the texture is ready
  54295. * @param onError defines the callback to trigger in case of error
  54296. */
  54297. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54298. /**
  54299. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54300. * @param data contains the texture data
  54301. * @param texture defines the BabylonJS internal texture
  54302. * @param callback defines the method to call once ready to upload
  54303. */
  54304. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54305. }
  54306. }
  54307. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54308. import { Nullable } from "babylonjs/types";
  54309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54310. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54311. /**
  54312. * Implementation of the ENV Texture Loader.
  54313. * @hidden
  54314. */
  54315. export class _ENVTextureLoader implements IInternalTextureLoader {
  54316. /**
  54317. * Defines wether the loader supports cascade loading the different faces.
  54318. */
  54319. readonly supportCascades: boolean;
  54320. /**
  54321. * This returns if the loader support the current file information.
  54322. * @param extension defines the file extension of the file being loaded
  54323. * @returns true if the loader can load the specified file
  54324. */
  54325. canLoad(extension: string): boolean;
  54326. /**
  54327. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54328. * @param data contains the texture data
  54329. * @param texture defines the BabylonJS internal texture
  54330. * @param createPolynomials will be true if polynomials have been requested
  54331. * @param onLoad defines the callback to trigger once the texture is ready
  54332. * @param onError defines the callback to trigger in case of error
  54333. */
  54334. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54335. /**
  54336. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54337. * @param data contains the texture data
  54338. * @param texture defines the BabylonJS internal texture
  54339. * @param callback defines the method to call once ready to upload
  54340. */
  54341. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54342. }
  54343. }
  54344. declare module "babylonjs/Misc/khronosTextureContainer" {
  54345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54346. /**
  54347. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54348. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54349. */
  54350. export class KhronosTextureContainer {
  54351. /** contents of the KTX container file */
  54352. data: ArrayBufferView;
  54353. private static HEADER_LEN;
  54354. private static COMPRESSED_2D;
  54355. private static COMPRESSED_3D;
  54356. private static TEX_2D;
  54357. private static TEX_3D;
  54358. /**
  54359. * Gets the openGL type
  54360. */
  54361. glType: number;
  54362. /**
  54363. * Gets the openGL type size
  54364. */
  54365. glTypeSize: number;
  54366. /**
  54367. * Gets the openGL format
  54368. */
  54369. glFormat: number;
  54370. /**
  54371. * Gets the openGL internal format
  54372. */
  54373. glInternalFormat: number;
  54374. /**
  54375. * Gets the base internal format
  54376. */
  54377. glBaseInternalFormat: number;
  54378. /**
  54379. * Gets image width in pixel
  54380. */
  54381. pixelWidth: number;
  54382. /**
  54383. * Gets image height in pixel
  54384. */
  54385. pixelHeight: number;
  54386. /**
  54387. * Gets image depth in pixels
  54388. */
  54389. pixelDepth: number;
  54390. /**
  54391. * Gets the number of array elements
  54392. */
  54393. numberOfArrayElements: number;
  54394. /**
  54395. * Gets the number of faces
  54396. */
  54397. numberOfFaces: number;
  54398. /**
  54399. * Gets the number of mipmap levels
  54400. */
  54401. numberOfMipmapLevels: number;
  54402. /**
  54403. * Gets the bytes of key value data
  54404. */
  54405. bytesOfKeyValueData: number;
  54406. /**
  54407. * Gets the load type
  54408. */
  54409. loadType: number;
  54410. /**
  54411. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54412. */
  54413. isInvalid: boolean;
  54414. /**
  54415. * Creates a new KhronosTextureContainer
  54416. * @param data contents of the KTX container file
  54417. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54418. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54419. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54420. */
  54421. constructor(
  54422. /** contents of the KTX container file */
  54423. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54424. /**
  54425. * Uploads KTX content to a Babylon Texture.
  54426. * It is assumed that the texture has already been created & is currently bound
  54427. * @hidden
  54428. */
  54429. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54430. private _upload2DCompressedLevels;
  54431. /**
  54432. * Checks if the given data starts with a KTX file identifier.
  54433. * @param data the data to check
  54434. * @returns true if the data is a KTX file or false otherwise
  54435. */
  54436. static IsValid(data: ArrayBufferView): boolean;
  54437. }
  54438. }
  54439. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54440. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54441. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54442. /**
  54443. * Class for loading KTX2 files
  54444. * !!! Experimental Extension Subject to Changes !!!
  54445. * @hidden
  54446. */
  54447. export class KhronosTextureContainer2 {
  54448. private static _ModulePromise;
  54449. private static _TranscodeFormat;
  54450. constructor(engine: ThinEngine);
  54451. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54452. private _determineTranscodeFormat;
  54453. /**
  54454. * Checks if the given data starts with a KTX2 file identifier.
  54455. * @param data the data to check
  54456. * @returns true if the data is a KTX2 file or false otherwise
  54457. */
  54458. static IsValid(data: ArrayBufferView): boolean;
  54459. }
  54460. }
  54461. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54462. import { Nullable } from "babylonjs/types";
  54463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54464. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54465. /**
  54466. * Implementation of the KTX Texture Loader.
  54467. * @hidden
  54468. */
  54469. export class _KTXTextureLoader implements IInternalTextureLoader {
  54470. /**
  54471. * Defines wether the loader supports cascade loading the different faces.
  54472. */
  54473. readonly supportCascades: boolean;
  54474. /**
  54475. * This returns if the loader support the current file information.
  54476. * @param extension defines the file extension of the file being loaded
  54477. * @returns true if the loader can load the specified file
  54478. */
  54479. canLoad(extension: string): boolean;
  54480. /**
  54481. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54482. * @param data contains the texture data
  54483. * @param texture defines the BabylonJS internal texture
  54484. * @param createPolynomials will be true if polynomials have been requested
  54485. * @param onLoad defines the callback to trigger once the texture is ready
  54486. * @param onError defines the callback to trigger in case of error
  54487. */
  54488. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54489. /**
  54490. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54491. * @param data contains the texture data
  54492. * @param texture defines the BabylonJS internal texture
  54493. * @param callback defines the method to call once ready to upload
  54494. */
  54495. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54496. }
  54497. }
  54498. declare module "babylonjs/Helpers/sceneHelpers" {
  54499. import { Nullable } from "babylonjs/types";
  54500. import { Mesh } from "babylonjs/Meshes/mesh";
  54501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54502. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54503. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54504. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54505. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54506. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54507. import "babylonjs/Meshes/Builders/boxBuilder";
  54508. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54509. /** @hidden */
  54510. export var _forceSceneHelpersToBundle: boolean;
  54511. module "babylonjs/scene" {
  54512. interface Scene {
  54513. /**
  54514. * Creates a default light for the scene.
  54515. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54516. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54517. */
  54518. createDefaultLight(replace?: boolean): void;
  54519. /**
  54520. * Creates a default camera for the scene.
  54521. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54522. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54523. * @param replace has default false, when true replaces the active camera in the scene
  54524. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54525. */
  54526. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54527. /**
  54528. * Creates a default camera and a default light.
  54529. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54530. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54531. * @param replace has the default false, when true replaces the active camera/light in the scene
  54532. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54533. */
  54534. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54535. /**
  54536. * Creates a new sky box
  54537. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54538. * @param environmentTexture defines the texture to use as environment texture
  54539. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54540. * @param scale defines the overall scale of the skybox
  54541. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54542. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54543. * @returns a new mesh holding the sky box
  54544. */
  54545. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54546. /**
  54547. * Creates a new environment
  54548. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54549. * @param options defines the options you can use to configure the environment
  54550. * @returns the new EnvironmentHelper
  54551. */
  54552. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54553. /**
  54554. * Creates a new VREXperienceHelper
  54555. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54556. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54557. * @returns a new VREXperienceHelper
  54558. */
  54559. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54560. /**
  54561. * Creates a new WebXRDefaultExperience
  54562. * @see http://doc.babylonjs.com/how_to/webxr
  54563. * @param options experience options
  54564. * @returns a promise for a new WebXRDefaultExperience
  54565. */
  54566. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54567. }
  54568. }
  54569. }
  54570. declare module "babylonjs/Helpers/videoDome" {
  54571. import { Scene } from "babylonjs/scene";
  54572. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54573. import { Mesh } from "babylonjs/Meshes/mesh";
  54574. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54575. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54576. import "babylonjs/Meshes/Builders/sphereBuilder";
  54577. /**
  54578. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54579. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54580. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54581. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54582. */
  54583. export class VideoDome extends TransformNode {
  54584. /**
  54585. * Define the video source as a Monoscopic panoramic 360 video.
  54586. */
  54587. static readonly MODE_MONOSCOPIC: number;
  54588. /**
  54589. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54590. */
  54591. static readonly MODE_TOPBOTTOM: number;
  54592. /**
  54593. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54594. */
  54595. static readonly MODE_SIDEBYSIDE: number;
  54596. private _halfDome;
  54597. private _useDirectMapping;
  54598. /**
  54599. * The video texture being displayed on the sphere
  54600. */
  54601. protected _videoTexture: VideoTexture;
  54602. /**
  54603. * Gets the video texture being displayed on the sphere
  54604. */
  54605. get videoTexture(): VideoTexture;
  54606. /**
  54607. * The skybox material
  54608. */
  54609. protected _material: BackgroundMaterial;
  54610. /**
  54611. * The surface used for the skybox
  54612. */
  54613. protected _mesh: Mesh;
  54614. /**
  54615. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54616. */
  54617. private _halfDomeMask;
  54618. /**
  54619. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54620. * Also see the options.resolution property.
  54621. */
  54622. get fovMultiplier(): number;
  54623. set fovMultiplier(value: number);
  54624. private _videoMode;
  54625. /**
  54626. * Gets or set the current video mode for the video. It can be:
  54627. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54628. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54629. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54630. */
  54631. get videoMode(): number;
  54632. set videoMode(value: number);
  54633. /**
  54634. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54635. *
  54636. */
  54637. get halfDome(): boolean;
  54638. /**
  54639. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54640. */
  54641. set halfDome(enabled: boolean);
  54642. /**
  54643. * Oberserver used in Stereoscopic VR Mode.
  54644. */
  54645. private _onBeforeCameraRenderObserver;
  54646. /**
  54647. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54648. * @param name Element's name, child elements will append suffixes for their own names.
  54649. * @param urlsOrVideo defines the url(s) or the video element to use
  54650. * @param options An object containing optional or exposed sub element properties
  54651. */
  54652. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54653. resolution?: number;
  54654. clickToPlay?: boolean;
  54655. autoPlay?: boolean;
  54656. loop?: boolean;
  54657. size?: number;
  54658. poster?: string;
  54659. faceForward?: boolean;
  54660. useDirectMapping?: boolean;
  54661. halfDomeMode?: boolean;
  54662. }, scene: Scene);
  54663. private _changeVideoMode;
  54664. /**
  54665. * Releases resources associated with this node.
  54666. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54667. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54668. */
  54669. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54670. }
  54671. }
  54672. declare module "babylonjs/Helpers/index" {
  54673. export * from "babylonjs/Helpers/environmentHelper";
  54674. export * from "babylonjs/Helpers/photoDome";
  54675. export * from "babylonjs/Helpers/sceneHelpers";
  54676. export * from "babylonjs/Helpers/videoDome";
  54677. }
  54678. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54679. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54680. import { IDisposable } from "babylonjs/scene";
  54681. import { Engine } from "babylonjs/Engines/engine";
  54682. /**
  54683. * This class can be used to get instrumentation data from a Babylon engine
  54684. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54685. */
  54686. export class EngineInstrumentation implements IDisposable {
  54687. /**
  54688. * Define the instrumented engine.
  54689. */
  54690. engine: Engine;
  54691. private _captureGPUFrameTime;
  54692. private _gpuFrameTimeToken;
  54693. private _gpuFrameTime;
  54694. private _captureShaderCompilationTime;
  54695. private _shaderCompilationTime;
  54696. private _onBeginFrameObserver;
  54697. private _onEndFrameObserver;
  54698. private _onBeforeShaderCompilationObserver;
  54699. private _onAfterShaderCompilationObserver;
  54700. /**
  54701. * Gets the perf counter used for GPU frame time
  54702. */
  54703. get gpuFrameTimeCounter(): PerfCounter;
  54704. /**
  54705. * Gets the GPU frame time capture status
  54706. */
  54707. get captureGPUFrameTime(): boolean;
  54708. /**
  54709. * Enable or disable the GPU frame time capture
  54710. */
  54711. set captureGPUFrameTime(value: boolean);
  54712. /**
  54713. * Gets the perf counter used for shader compilation time
  54714. */
  54715. get shaderCompilationTimeCounter(): PerfCounter;
  54716. /**
  54717. * Gets the shader compilation time capture status
  54718. */
  54719. get captureShaderCompilationTime(): boolean;
  54720. /**
  54721. * Enable or disable the shader compilation time capture
  54722. */
  54723. set captureShaderCompilationTime(value: boolean);
  54724. /**
  54725. * Instantiates a new engine instrumentation.
  54726. * This class can be used to get instrumentation data from a Babylon engine
  54727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54728. * @param engine Defines the engine to instrument
  54729. */
  54730. constructor(
  54731. /**
  54732. * Define the instrumented engine.
  54733. */
  54734. engine: Engine);
  54735. /**
  54736. * Dispose and release associated resources.
  54737. */
  54738. dispose(): void;
  54739. }
  54740. }
  54741. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54742. import { Scene, IDisposable } from "babylonjs/scene";
  54743. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54744. /**
  54745. * This class can be used to get instrumentation data from a Babylon engine
  54746. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54747. */
  54748. export class SceneInstrumentation implements IDisposable {
  54749. /**
  54750. * Defines the scene to instrument
  54751. */
  54752. scene: Scene;
  54753. private _captureActiveMeshesEvaluationTime;
  54754. private _activeMeshesEvaluationTime;
  54755. private _captureRenderTargetsRenderTime;
  54756. private _renderTargetsRenderTime;
  54757. private _captureFrameTime;
  54758. private _frameTime;
  54759. private _captureRenderTime;
  54760. private _renderTime;
  54761. private _captureInterFrameTime;
  54762. private _interFrameTime;
  54763. private _captureParticlesRenderTime;
  54764. private _particlesRenderTime;
  54765. private _captureSpritesRenderTime;
  54766. private _spritesRenderTime;
  54767. private _capturePhysicsTime;
  54768. private _physicsTime;
  54769. private _captureAnimationsTime;
  54770. private _animationsTime;
  54771. private _captureCameraRenderTime;
  54772. private _cameraRenderTime;
  54773. private _onBeforeActiveMeshesEvaluationObserver;
  54774. private _onAfterActiveMeshesEvaluationObserver;
  54775. private _onBeforeRenderTargetsRenderObserver;
  54776. private _onAfterRenderTargetsRenderObserver;
  54777. private _onAfterRenderObserver;
  54778. private _onBeforeDrawPhaseObserver;
  54779. private _onAfterDrawPhaseObserver;
  54780. private _onBeforeAnimationsObserver;
  54781. private _onBeforeParticlesRenderingObserver;
  54782. private _onAfterParticlesRenderingObserver;
  54783. private _onBeforeSpritesRenderingObserver;
  54784. private _onAfterSpritesRenderingObserver;
  54785. private _onBeforePhysicsObserver;
  54786. private _onAfterPhysicsObserver;
  54787. private _onAfterAnimationsObserver;
  54788. private _onBeforeCameraRenderObserver;
  54789. private _onAfterCameraRenderObserver;
  54790. /**
  54791. * Gets the perf counter used for active meshes evaluation time
  54792. */
  54793. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54794. /**
  54795. * Gets the active meshes evaluation time capture status
  54796. */
  54797. get captureActiveMeshesEvaluationTime(): boolean;
  54798. /**
  54799. * Enable or disable the active meshes evaluation time capture
  54800. */
  54801. set captureActiveMeshesEvaluationTime(value: boolean);
  54802. /**
  54803. * Gets the perf counter used for render targets render time
  54804. */
  54805. get renderTargetsRenderTimeCounter(): PerfCounter;
  54806. /**
  54807. * Gets the render targets render time capture status
  54808. */
  54809. get captureRenderTargetsRenderTime(): boolean;
  54810. /**
  54811. * Enable or disable the render targets render time capture
  54812. */
  54813. set captureRenderTargetsRenderTime(value: boolean);
  54814. /**
  54815. * Gets the perf counter used for particles render time
  54816. */
  54817. get particlesRenderTimeCounter(): PerfCounter;
  54818. /**
  54819. * Gets the particles render time capture status
  54820. */
  54821. get captureParticlesRenderTime(): boolean;
  54822. /**
  54823. * Enable or disable the particles render time capture
  54824. */
  54825. set captureParticlesRenderTime(value: boolean);
  54826. /**
  54827. * Gets the perf counter used for sprites render time
  54828. */
  54829. get spritesRenderTimeCounter(): PerfCounter;
  54830. /**
  54831. * Gets the sprites render time capture status
  54832. */
  54833. get captureSpritesRenderTime(): boolean;
  54834. /**
  54835. * Enable or disable the sprites render time capture
  54836. */
  54837. set captureSpritesRenderTime(value: boolean);
  54838. /**
  54839. * Gets the perf counter used for physics time
  54840. */
  54841. get physicsTimeCounter(): PerfCounter;
  54842. /**
  54843. * Gets the physics time capture status
  54844. */
  54845. get capturePhysicsTime(): boolean;
  54846. /**
  54847. * Enable or disable the physics time capture
  54848. */
  54849. set capturePhysicsTime(value: boolean);
  54850. /**
  54851. * Gets the perf counter used for animations time
  54852. */
  54853. get animationsTimeCounter(): PerfCounter;
  54854. /**
  54855. * Gets the animations time capture status
  54856. */
  54857. get captureAnimationsTime(): boolean;
  54858. /**
  54859. * Enable or disable the animations time capture
  54860. */
  54861. set captureAnimationsTime(value: boolean);
  54862. /**
  54863. * Gets the perf counter used for frame time capture
  54864. */
  54865. get frameTimeCounter(): PerfCounter;
  54866. /**
  54867. * Gets the frame time capture status
  54868. */
  54869. get captureFrameTime(): boolean;
  54870. /**
  54871. * Enable or disable the frame time capture
  54872. */
  54873. set captureFrameTime(value: boolean);
  54874. /**
  54875. * Gets the perf counter used for inter-frames time capture
  54876. */
  54877. get interFrameTimeCounter(): PerfCounter;
  54878. /**
  54879. * Gets the inter-frames time capture status
  54880. */
  54881. get captureInterFrameTime(): boolean;
  54882. /**
  54883. * Enable or disable the inter-frames time capture
  54884. */
  54885. set captureInterFrameTime(value: boolean);
  54886. /**
  54887. * Gets the perf counter used for render time capture
  54888. */
  54889. get renderTimeCounter(): PerfCounter;
  54890. /**
  54891. * Gets the render time capture status
  54892. */
  54893. get captureRenderTime(): boolean;
  54894. /**
  54895. * Enable or disable the render time capture
  54896. */
  54897. set captureRenderTime(value: boolean);
  54898. /**
  54899. * Gets the perf counter used for camera render time capture
  54900. */
  54901. get cameraRenderTimeCounter(): PerfCounter;
  54902. /**
  54903. * Gets the camera render time capture status
  54904. */
  54905. get captureCameraRenderTime(): boolean;
  54906. /**
  54907. * Enable or disable the camera render time capture
  54908. */
  54909. set captureCameraRenderTime(value: boolean);
  54910. /**
  54911. * Gets the perf counter used for draw calls
  54912. */
  54913. get drawCallsCounter(): PerfCounter;
  54914. /**
  54915. * Instantiates a new scene instrumentation.
  54916. * This class can be used to get instrumentation data from a Babylon engine
  54917. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54918. * @param scene Defines the scene to instrument
  54919. */
  54920. constructor(
  54921. /**
  54922. * Defines the scene to instrument
  54923. */
  54924. scene: Scene);
  54925. /**
  54926. * Dispose and release associated resources.
  54927. */
  54928. dispose(): void;
  54929. }
  54930. }
  54931. declare module "babylonjs/Instrumentation/index" {
  54932. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54933. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54934. export * from "babylonjs/Instrumentation/timeToken";
  54935. }
  54936. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54937. /** @hidden */
  54938. export var glowMapGenerationPixelShader: {
  54939. name: string;
  54940. shader: string;
  54941. };
  54942. }
  54943. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54944. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54947. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54948. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54949. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54950. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54951. /** @hidden */
  54952. export var glowMapGenerationVertexShader: {
  54953. name: string;
  54954. shader: string;
  54955. };
  54956. }
  54957. declare module "babylonjs/Layers/effectLayer" {
  54958. import { Observable } from "babylonjs/Misc/observable";
  54959. import { Nullable } from "babylonjs/types";
  54960. import { Camera } from "babylonjs/Cameras/camera";
  54961. import { Scene } from "babylonjs/scene";
  54962. import { ISize } from "babylonjs/Maths/math.size";
  54963. import { Color4 } from "babylonjs/Maths/math.color";
  54964. import { Engine } from "babylonjs/Engines/engine";
  54965. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54967. import { Mesh } from "babylonjs/Meshes/mesh";
  54968. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54970. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54971. import { Effect } from "babylonjs/Materials/effect";
  54972. import { Material } from "babylonjs/Materials/material";
  54973. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54974. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54975. /**
  54976. * Effect layer options. This helps customizing the behaviour
  54977. * of the effect layer.
  54978. */
  54979. export interface IEffectLayerOptions {
  54980. /**
  54981. * Multiplication factor apply to the canvas size to compute the render target size
  54982. * used to generated the objects (the smaller the faster).
  54983. */
  54984. mainTextureRatio: number;
  54985. /**
  54986. * Enforces a fixed size texture to ensure effect stability across devices.
  54987. */
  54988. mainTextureFixedSize?: number;
  54989. /**
  54990. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54991. */
  54992. alphaBlendingMode: number;
  54993. /**
  54994. * The camera attached to the layer.
  54995. */
  54996. camera: Nullable<Camera>;
  54997. /**
  54998. * The rendering group to draw the layer in.
  54999. */
  55000. renderingGroupId: number;
  55001. }
  55002. /**
  55003. * The effect layer Helps adding post process effect blended with the main pass.
  55004. *
  55005. * This can be for instance use to generate glow or higlight effects on the scene.
  55006. *
  55007. * The effect layer class can not be used directly and is intented to inherited from to be
  55008. * customized per effects.
  55009. */
  55010. export abstract class EffectLayer {
  55011. private _vertexBuffers;
  55012. private _indexBuffer;
  55013. private _cachedDefines;
  55014. private _effectLayerMapGenerationEffect;
  55015. private _effectLayerOptions;
  55016. private _mergeEffect;
  55017. protected _scene: Scene;
  55018. protected _engine: Engine;
  55019. protected _maxSize: number;
  55020. protected _mainTextureDesiredSize: ISize;
  55021. protected _mainTexture: RenderTargetTexture;
  55022. protected _shouldRender: boolean;
  55023. protected _postProcesses: PostProcess[];
  55024. protected _textures: BaseTexture[];
  55025. protected _emissiveTextureAndColor: {
  55026. texture: Nullable<BaseTexture>;
  55027. color: Color4;
  55028. };
  55029. /**
  55030. * The name of the layer
  55031. */
  55032. name: string;
  55033. /**
  55034. * The clear color of the texture used to generate the glow map.
  55035. */
  55036. neutralColor: Color4;
  55037. /**
  55038. * Specifies whether the highlight layer is enabled or not.
  55039. */
  55040. isEnabled: boolean;
  55041. /**
  55042. * Gets the camera attached to the layer.
  55043. */
  55044. get camera(): Nullable<Camera>;
  55045. /**
  55046. * Gets the rendering group id the layer should render in.
  55047. */
  55048. get renderingGroupId(): number;
  55049. set renderingGroupId(renderingGroupId: number);
  55050. /**
  55051. * An event triggered when the effect layer has been disposed.
  55052. */
  55053. onDisposeObservable: Observable<EffectLayer>;
  55054. /**
  55055. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55056. */
  55057. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55058. /**
  55059. * An event triggered when the generated texture is being merged in the scene.
  55060. */
  55061. onBeforeComposeObservable: Observable<EffectLayer>;
  55062. /**
  55063. * An event triggered when the mesh is rendered into the effect render target.
  55064. */
  55065. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55066. /**
  55067. * An event triggered after the mesh has been rendered into the effect render target.
  55068. */
  55069. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55070. /**
  55071. * An event triggered when the generated texture has been merged in the scene.
  55072. */
  55073. onAfterComposeObservable: Observable<EffectLayer>;
  55074. /**
  55075. * An event triggered when the efffect layer changes its size.
  55076. */
  55077. onSizeChangedObservable: Observable<EffectLayer>;
  55078. /** @hidden */
  55079. static _SceneComponentInitialization: (scene: Scene) => void;
  55080. /**
  55081. * Instantiates a new effect Layer and references it in the scene.
  55082. * @param name The name of the layer
  55083. * @param scene The scene to use the layer in
  55084. */
  55085. constructor(
  55086. /** The Friendly of the effect in the scene */
  55087. name: string, scene: Scene);
  55088. /**
  55089. * Get the effect name of the layer.
  55090. * @return The effect name
  55091. */
  55092. abstract getEffectName(): string;
  55093. /**
  55094. * Checks for the readiness of the element composing the layer.
  55095. * @param subMesh the mesh to check for
  55096. * @param useInstances specify whether or not to use instances to render the mesh
  55097. * @return true if ready otherwise, false
  55098. */
  55099. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55100. /**
  55101. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55102. * @returns true if the effect requires stencil during the main canvas render pass.
  55103. */
  55104. abstract needStencil(): boolean;
  55105. /**
  55106. * Create the merge effect. This is the shader use to blit the information back
  55107. * to the main canvas at the end of the scene rendering.
  55108. * @returns The effect containing the shader used to merge the effect on the main canvas
  55109. */
  55110. protected abstract _createMergeEffect(): Effect;
  55111. /**
  55112. * Creates the render target textures and post processes used in the effect layer.
  55113. */
  55114. protected abstract _createTextureAndPostProcesses(): void;
  55115. /**
  55116. * Implementation specific of rendering the generating effect on the main canvas.
  55117. * @param effect The effect used to render through
  55118. */
  55119. protected abstract _internalRender(effect: Effect): void;
  55120. /**
  55121. * Sets the required values for both the emissive texture and and the main color.
  55122. */
  55123. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55124. /**
  55125. * Free any resources and references associated to a mesh.
  55126. * Internal use
  55127. * @param mesh The mesh to free.
  55128. */
  55129. abstract _disposeMesh(mesh: Mesh): void;
  55130. /**
  55131. * Serializes this layer (Glow or Highlight for example)
  55132. * @returns a serialized layer object
  55133. */
  55134. abstract serialize?(): any;
  55135. /**
  55136. * Initializes the effect layer with the required options.
  55137. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55138. */
  55139. protected _init(options: Partial<IEffectLayerOptions>): void;
  55140. /**
  55141. * Generates the index buffer of the full screen quad blending to the main canvas.
  55142. */
  55143. private _generateIndexBuffer;
  55144. /**
  55145. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55146. */
  55147. private _generateVertexBuffer;
  55148. /**
  55149. * Sets the main texture desired size which is the closest power of two
  55150. * of the engine canvas size.
  55151. */
  55152. private _setMainTextureSize;
  55153. /**
  55154. * Creates the main texture for the effect layer.
  55155. */
  55156. protected _createMainTexture(): void;
  55157. /**
  55158. * Adds specific effects defines.
  55159. * @param defines The defines to add specifics to.
  55160. */
  55161. protected _addCustomEffectDefines(defines: string[]): void;
  55162. /**
  55163. * Checks for the readiness of the element composing the layer.
  55164. * @param subMesh the mesh to check for
  55165. * @param useInstances specify whether or not to use instances to render the mesh
  55166. * @param emissiveTexture the associated emissive texture used to generate the glow
  55167. * @return true if ready otherwise, false
  55168. */
  55169. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55170. /**
  55171. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55172. */
  55173. render(): void;
  55174. /**
  55175. * Determine if a given mesh will be used in the current effect.
  55176. * @param mesh mesh to test
  55177. * @returns true if the mesh will be used
  55178. */
  55179. hasMesh(mesh: AbstractMesh): boolean;
  55180. /**
  55181. * Returns true if the layer contains information to display, otherwise false.
  55182. * @returns true if the glow layer should be rendered
  55183. */
  55184. shouldRender(): boolean;
  55185. /**
  55186. * Returns true if the mesh should render, otherwise false.
  55187. * @param mesh The mesh to render
  55188. * @returns true if it should render otherwise false
  55189. */
  55190. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55191. /**
  55192. * Returns true if the mesh can be rendered, otherwise false.
  55193. * @param mesh The mesh to render
  55194. * @param material The material used on the mesh
  55195. * @returns true if it can be rendered otherwise false
  55196. */
  55197. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55198. /**
  55199. * Returns true if the mesh should render, otherwise false.
  55200. * @param mesh The mesh to render
  55201. * @returns true if it should render otherwise false
  55202. */
  55203. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55204. /**
  55205. * Renders the submesh passed in parameter to the generation map.
  55206. */
  55207. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55208. /**
  55209. * Defines whether the current material of the mesh should be use to render the effect.
  55210. * @param mesh defines the current mesh to render
  55211. */
  55212. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55213. /**
  55214. * Rebuild the required buffers.
  55215. * @hidden Internal use only.
  55216. */
  55217. _rebuild(): void;
  55218. /**
  55219. * Dispose only the render target textures and post process.
  55220. */
  55221. private _disposeTextureAndPostProcesses;
  55222. /**
  55223. * Dispose the highlight layer and free resources.
  55224. */
  55225. dispose(): void;
  55226. /**
  55227. * Gets the class name of the effect layer
  55228. * @returns the string with the class name of the effect layer
  55229. */
  55230. getClassName(): string;
  55231. /**
  55232. * Creates an effect layer from parsed effect layer data
  55233. * @param parsedEffectLayer defines effect layer data
  55234. * @param scene defines the current scene
  55235. * @param rootUrl defines the root URL containing the effect layer information
  55236. * @returns a parsed effect Layer
  55237. */
  55238. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55239. }
  55240. }
  55241. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55242. import { Scene } from "babylonjs/scene";
  55243. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55244. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55245. import { AbstractScene } from "babylonjs/abstractScene";
  55246. module "babylonjs/abstractScene" {
  55247. interface AbstractScene {
  55248. /**
  55249. * The list of effect layers (highlights/glow) added to the scene
  55250. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55251. * @see http://doc.babylonjs.com/how_to/glow_layer
  55252. */
  55253. effectLayers: Array<EffectLayer>;
  55254. /**
  55255. * Removes the given effect layer from this scene.
  55256. * @param toRemove defines the effect layer to remove
  55257. * @returns the index of the removed effect layer
  55258. */
  55259. removeEffectLayer(toRemove: EffectLayer): number;
  55260. /**
  55261. * Adds the given effect layer to this scene
  55262. * @param newEffectLayer defines the effect layer to add
  55263. */
  55264. addEffectLayer(newEffectLayer: EffectLayer): void;
  55265. }
  55266. }
  55267. /**
  55268. * Defines the layer scene component responsible to manage any effect layers
  55269. * in a given scene.
  55270. */
  55271. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55272. /**
  55273. * The component name helpfull to identify the component in the list of scene components.
  55274. */
  55275. readonly name: string;
  55276. /**
  55277. * The scene the component belongs to.
  55278. */
  55279. scene: Scene;
  55280. private _engine;
  55281. private _renderEffects;
  55282. private _needStencil;
  55283. private _previousStencilState;
  55284. /**
  55285. * Creates a new instance of the component for the given scene
  55286. * @param scene Defines the scene to register the component in
  55287. */
  55288. constructor(scene: Scene);
  55289. /**
  55290. * Registers the component in a given scene
  55291. */
  55292. register(): void;
  55293. /**
  55294. * Rebuilds the elements related to this component in case of
  55295. * context lost for instance.
  55296. */
  55297. rebuild(): void;
  55298. /**
  55299. * Serializes the component data to the specified json object
  55300. * @param serializationObject The object to serialize to
  55301. */
  55302. serialize(serializationObject: any): void;
  55303. /**
  55304. * Adds all the elements from the container to the scene
  55305. * @param container the container holding the elements
  55306. */
  55307. addFromContainer(container: AbstractScene): void;
  55308. /**
  55309. * Removes all the elements in the container from the scene
  55310. * @param container contains the elements to remove
  55311. * @param dispose if the removed element should be disposed (default: false)
  55312. */
  55313. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55314. /**
  55315. * Disposes the component and the associated ressources.
  55316. */
  55317. dispose(): void;
  55318. private _isReadyForMesh;
  55319. private _renderMainTexture;
  55320. private _setStencil;
  55321. private _setStencilBack;
  55322. private _draw;
  55323. private _drawCamera;
  55324. private _drawRenderingGroup;
  55325. }
  55326. }
  55327. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55328. /** @hidden */
  55329. export var glowMapMergePixelShader: {
  55330. name: string;
  55331. shader: string;
  55332. };
  55333. }
  55334. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55335. /** @hidden */
  55336. export var glowMapMergeVertexShader: {
  55337. name: string;
  55338. shader: string;
  55339. };
  55340. }
  55341. declare module "babylonjs/Layers/glowLayer" {
  55342. import { Nullable } from "babylonjs/types";
  55343. import { Camera } from "babylonjs/Cameras/camera";
  55344. import { Scene } from "babylonjs/scene";
  55345. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55347. import { Mesh } from "babylonjs/Meshes/mesh";
  55348. import { Texture } from "babylonjs/Materials/Textures/texture";
  55349. import { Effect } from "babylonjs/Materials/effect";
  55350. import { Material } from "babylonjs/Materials/material";
  55351. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55352. import { Color4 } from "babylonjs/Maths/math.color";
  55353. import "babylonjs/Shaders/glowMapMerge.fragment";
  55354. import "babylonjs/Shaders/glowMapMerge.vertex";
  55355. import "babylonjs/Layers/effectLayerSceneComponent";
  55356. module "babylonjs/abstractScene" {
  55357. interface AbstractScene {
  55358. /**
  55359. * Return a the first highlight layer of the scene with a given name.
  55360. * @param name The name of the highlight layer to look for.
  55361. * @return The highlight layer if found otherwise null.
  55362. */
  55363. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55364. }
  55365. }
  55366. /**
  55367. * Glow layer options. This helps customizing the behaviour
  55368. * of the glow layer.
  55369. */
  55370. export interface IGlowLayerOptions {
  55371. /**
  55372. * Multiplication factor apply to the canvas size to compute the render target size
  55373. * used to generated the glowing objects (the smaller the faster).
  55374. */
  55375. mainTextureRatio: number;
  55376. /**
  55377. * Enforces a fixed size texture to ensure resize independant blur.
  55378. */
  55379. mainTextureFixedSize?: number;
  55380. /**
  55381. * How big is the kernel of the blur texture.
  55382. */
  55383. blurKernelSize: number;
  55384. /**
  55385. * The camera attached to the layer.
  55386. */
  55387. camera: Nullable<Camera>;
  55388. /**
  55389. * Enable MSAA by chosing the number of samples.
  55390. */
  55391. mainTextureSamples?: number;
  55392. /**
  55393. * The rendering group to draw the layer in.
  55394. */
  55395. renderingGroupId: number;
  55396. }
  55397. /**
  55398. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55399. *
  55400. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55401. *
  55402. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55403. */
  55404. export class GlowLayer extends EffectLayer {
  55405. /**
  55406. * Effect Name of the layer.
  55407. */
  55408. static readonly EffectName: string;
  55409. /**
  55410. * The default blur kernel size used for the glow.
  55411. */
  55412. static DefaultBlurKernelSize: number;
  55413. /**
  55414. * The default texture size ratio used for the glow.
  55415. */
  55416. static DefaultTextureRatio: number;
  55417. /**
  55418. * Sets the kernel size of the blur.
  55419. */
  55420. set blurKernelSize(value: number);
  55421. /**
  55422. * Gets the kernel size of the blur.
  55423. */
  55424. get blurKernelSize(): number;
  55425. /**
  55426. * Sets the glow intensity.
  55427. */
  55428. set intensity(value: number);
  55429. /**
  55430. * Gets the glow intensity.
  55431. */
  55432. get intensity(): number;
  55433. private _options;
  55434. private _intensity;
  55435. private _horizontalBlurPostprocess1;
  55436. private _verticalBlurPostprocess1;
  55437. private _horizontalBlurPostprocess2;
  55438. private _verticalBlurPostprocess2;
  55439. private _blurTexture1;
  55440. private _blurTexture2;
  55441. private _postProcesses1;
  55442. private _postProcesses2;
  55443. private _includedOnlyMeshes;
  55444. private _excludedMeshes;
  55445. private _meshesUsingTheirOwnMaterials;
  55446. /**
  55447. * Callback used to let the user override the color selection on a per mesh basis
  55448. */
  55449. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55450. /**
  55451. * Callback used to let the user override the texture selection on a per mesh basis
  55452. */
  55453. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55454. /**
  55455. * Instantiates a new glow Layer and references it to the scene.
  55456. * @param name The name of the layer
  55457. * @param scene The scene to use the layer in
  55458. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55459. */
  55460. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55461. /**
  55462. * Get the effect name of the layer.
  55463. * @return The effect name
  55464. */
  55465. getEffectName(): string;
  55466. /**
  55467. * Create the merge effect. This is the shader use to blit the information back
  55468. * to the main canvas at the end of the scene rendering.
  55469. */
  55470. protected _createMergeEffect(): Effect;
  55471. /**
  55472. * Creates the render target textures and post processes used in the glow layer.
  55473. */
  55474. protected _createTextureAndPostProcesses(): void;
  55475. /**
  55476. * Checks for the readiness of the element composing the layer.
  55477. * @param subMesh the mesh to check for
  55478. * @param useInstances specify wether or not to use instances to render the mesh
  55479. * @param emissiveTexture the associated emissive texture used to generate the glow
  55480. * @return true if ready otherwise, false
  55481. */
  55482. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55483. /**
  55484. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55485. */
  55486. needStencil(): boolean;
  55487. /**
  55488. * Returns true if the mesh can be rendered, otherwise false.
  55489. * @param mesh The mesh to render
  55490. * @param material The material used on the mesh
  55491. * @returns true if it can be rendered otherwise false
  55492. */
  55493. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55494. /**
  55495. * Implementation specific of rendering the generating effect on the main canvas.
  55496. * @param effect The effect used to render through
  55497. */
  55498. protected _internalRender(effect: Effect): void;
  55499. /**
  55500. * Sets the required values for both the emissive texture and and the main color.
  55501. */
  55502. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55503. /**
  55504. * Returns true if the mesh should render, otherwise false.
  55505. * @param mesh The mesh to render
  55506. * @returns true if it should render otherwise false
  55507. */
  55508. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55509. /**
  55510. * Adds specific effects defines.
  55511. * @param defines The defines to add specifics to.
  55512. */
  55513. protected _addCustomEffectDefines(defines: string[]): void;
  55514. /**
  55515. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55516. * @param mesh The mesh to exclude from the glow layer
  55517. */
  55518. addExcludedMesh(mesh: Mesh): void;
  55519. /**
  55520. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55521. * @param mesh The mesh to remove
  55522. */
  55523. removeExcludedMesh(mesh: Mesh): void;
  55524. /**
  55525. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55526. * @param mesh The mesh to include in the glow layer
  55527. */
  55528. addIncludedOnlyMesh(mesh: Mesh): void;
  55529. /**
  55530. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55531. * @param mesh The mesh to remove
  55532. */
  55533. removeIncludedOnlyMesh(mesh: Mesh): void;
  55534. /**
  55535. * Determine if a given mesh will be used in the glow layer
  55536. * @param mesh The mesh to test
  55537. * @returns true if the mesh will be highlighted by the current glow layer
  55538. */
  55539. hasMesh(mesh: AbstractMesh): boolean;
  55540. /**
  55541. * Defines whether the current material of the mesh should be use to render the effect.
  55542. * @param mesh defines the current mesh to render
  55543. */
  55544. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55545. /**
  55546. * Add a mesh to be rendered through its own material and not with emissive only.
  55547. * @param mesh The mesh for which we need to use its material
  55548. */
  55549. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55550. /**
  55551. * Remove a mesh from being rendered through its own material and not with emissive only.
  55552. * @param mesh The mesh for which we need to not use its material
  55553. */
  55554. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55555. /**
  55556. * Free any resources and references associated to a mesh.
  55557. * Internal use
  55558. * @param mesh The mesh to free.
  55559. * @hidden
  55560. */
  55561. _disposeMesh(mesh: Mesh): void;
  55562. /**
  55563. * Gets the class name of the effect layer
  55564. * @returns the string with the class name of the effect layer
  55565. */
  55566. getClassName(): string;
  55567. /**
  55568. * Serializes this glow layer
  55569. * @returns a serialized glow layer object
  55570. */
  55571. serialize(): any;
  55572. /**
  55573. * Creates a Glow Layer from parsed glow layer data
  55574. * @param parsedGlowLayer defines glow layer data
  55575. * @param scene defines the current scene
  55576. * @param rootUrl defines the root URL containing the glow layer information
  55577. * @returns a parsed Glow Layer
  55578. */
  55579. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55580. }
  55581. }
  55582. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55583. /** @hidden */
  55584. export var glowBlurPostProcessPixelShader: {
  55585. name: string;
  55586. shader: string;
  55587. };
  55588. }
  55589. declare module "babylonjs/Layers/highlightLayer" {
  55590. import { Observable } from "babylonjs/Misc/observable";
  55591. import { Nullable } from "babylonjs/types";
  55592. import { Camera } from "babylonjs/Cameras/camera";
  55593. import { Scene } from "babylonjs/scene";
  55594. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55596. import { Mesh } from "babylonjs/Meshes/mesh";
  55597. import { Effect } from "babylonjs/Materials/effect";
  55598. import { Material } from "babylonjs/Materials/material";
  55599. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55600. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55601. import "babylonjs/Shaders/glowMapMerge.fragment";
  55602. import "babylonjs/Shaders/glowMapMerge.vertex";
  55603. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55604. module "babylonjs/abstractScene" {
  55605. interface AbstractScene {
  55606. /**
  55607. * Return a the first highlight layer of the scene with a given name.
  55608. * @param name The name of the highlight layer to look for.
  55609. * @return The highlight layer if found otherwise null.
  55610. */
  55611. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55612. }
  55613. }
  55614. /**
  55615. * Highlight layer options. This helps customizing the behaviour
  55616. * of the highlight layer.
  55617. */
  55618. export interface IHighlightLayerOptions {
  55619. /**
  55620. * Multiplication factor apply to the canvas size to compute the render target size
  55621. * used to generated the glowing objects (the smaller the faster).
  55622. */
  55623. mainTextureRatio: number;
  55624. /**
  55625. * Enforces a fixed size texture to ensure resize independant blur.
  55626. */
  55627. mainTextureFixedSize?: number;
  55628. /**
  55629. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55630. * of the picture to blur (the smaller the faster).
  55631. */
  55632. blurTextureSizeRatio: number;
  55633. /**
  55634. * How big in texel of the blur texture is the vertical blur.
  55635. */
  55636. blurVerticalSize: number;
  55637. /**
  55638. * How big in texel of the blur texture is the horizontal blur.
  55639. */
  55640. blurHorizontalSize: number;
  55641. /**
  55642. * Alpha blending mode used to apply the blur. Default is combine.
  55643. */
  55644. alphaBlendingMode: number;
  55645. /**
  55646. * The camera attached to the layer.
  55647. */
  55648. camera: Nullable<Camera>;
  55649. /**
  55650. * Should we display highlight as a solid stroke?
  55651. */
  55652. isStroke?: boolean;
  55653. /**
  55654. * The rendering group to draw the layer in.
  55655. */
  55656. renderingGroupId: number;
  55657. }
  55658. /**
  55659. * The highlight layer Helps adding a glow effect around a mesh.
  55660. *
  55661. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55662. * glowy meshes to your scene.
  55663. *
  55664. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55665. */
  55666. export class HighlightLayer extends EffectLayer {
  55667. name: string;
  55668. /**
  55669. * Effect Name of the highlight layer.
  55670. */
  55671. static readonly EffectName: string;
  55672. /**
  55673. * The neutral color used during the preparation of the glow effect.
  55674. * This is black by default as the blend operation is a blend operation.
  55675. */
  55676. static NeutralColor: Color4;
  55677. /**
  55678. * Stencil value used for glowing meshes.
  55679. */
  55680. static GlowingMeshStencilReference: number;
  55681. /**
  55682. * Stencil value used for the other meshes in the scene.
  55683. */
  55684. static NormalMeshStencilReference: number;
  55685. /**
  55686. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55687. */
  55688. innerGlow: boolean;
  55689. /**
  55690. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55691. */
  55692. outerGlow: boolean;
  55693. /**
  55694. * Specifies the horizontal size of the blur.
  55695. */
  55696. set blurHorizontalSize(value: number);
  55697. /**
  55698. * Specifies the vertical size of the blur.
  55699. */
  55700. set blurVerticalSize(value: number);
  55701. /**
  55702. * Gets the horizontal size of the blur.
  55703. */
  55704. get blurHorizontalSize(): number;
  55705. /**
  55706. * Gets the vertical size of the blur.
  55707. */
  55708. get blurVerticalSize(): number;
  55709. /**
  55710. * An event triggered when the highlight layer is being blurred.
  55711. */
  55712. onBeforeBlurObservable: Observable<HighlightLayer>;
  55713. /**
  55714. * An event triggered when the highlight layer has been blurred.
  55715. */
  55716. onAfterBlurObservable: Observable<HighlightLayer>;
  55717. private _instanceGlowingMeshStencilReference;
  55718. private _options;
  55719. private _downSamplePostprocess;
  55720. private _horizontalBlurPostprocess;
  55721. private _verticalBlurPostprocess;
  55722. private _blurTexture;
  55723. private _meshes;
  55724. private _excludedMeshes;
  55725. /**
  55726. * Instantiates a new highlight Layer and references it to the scene..
  55727. * @param name The name of the layer
  55728. * @param scene The scene to use the layer in
  55729. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55730. */
  55731. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55732. /**
  55733. * Get the effect name of the layer.
  55734. * @return The effect name
  55735. */
  55736. getEffectName(): string;
  55737. /**
  55738. * Create the merge effect. This is the shader use to blit the information back
  55739. * to the main canvas at the end of the scene rendering.
  55740. */
  55741. protected _createMergeEffect(): Effect;
  55742. /**
  55743. * Creates the render target textures and post processes used in the highlight layer.
  55744. */
  55745. protected _createTextureAndPostProcesses(): void;
  55746. /**
  55747. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55748. */
  55749. needStencil(): boolean;
  55750. /**
  55751. * Checks for the readiness of the element composing the layer.
  55752. * @param subMesh the mesh to check for
  55753. * @param useInstances specify wether or not to use instances to render the mesh
  55754. * @param emissiveTexture the associated emissive texture used to generate the glow
  55755. * @return true if ready otherwise, false
  55756. */
  55757. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55758. /**
  55759. * Implementation specific of rendering the generating effect on the main canvas.
  55760. * @param effect The effect used to render through
  55761. */
  55762. protected _internalRender(effect: Effect): void;
  55763. /**
  55764. * Returns true if the layer contains information to display, otherwise false.
  55765. */
  55766. shouldRender(): boolean;
  55767. /**
  55768. * Returns true if the mesh should render, otherwise false.
  55769. * @param mesh The mesh to render
  55770. * @returns true if it should render otherwise false
  55771. */
  55772. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55773. /**
  55774. * Sets the required values for both the emissive texture and and the main color.
  55775. */
  55776. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55777. /**
  55778. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55779. * @param mesh The mesh to exclude from the highlight layer
  55780. */
  55781. addExcludedMesh(mesh: Mesh): void;
  55782. /**
  55783. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55784. * @param mesh The mesh to highlight
  55785. */
  55786. removeExcludedMesh(mesh: Mesh): void;
  55787. /**
  55788. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55789. * @param mesh mesh to test
  55790. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55791. */
  55792. hasMesh(mesh: AbstractMesh): boolean;
  55793. /**
  55794. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55795. * @param mesh The mesh to highlight
  55796. * @param color The color of the highlight
  55797. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55798. */
  55799. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55800. /**
  55801. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55802. * @param mesh The mesh to highlight
  55803. */
  55804. removeMesh(mesh: Mesh): void;
  55805. /**
  55806. * Remove all the meshes currently referenced in the highlight layer
  55807. */
  55808. removeAllMeshes(): void;
  55809. /**
  55810. * Force the stencil to the normal expected value for none glowing parts
  55811. */
  55812. private _defaultStencilReference;
  55813. /**
  55814. * Free any resources and references associated to a mesh.
  55815. * Internal use
  55816. * @param mesh The mesh to free.
  55817. * @hidden
  55818. */
  55819. _disposeMesh(mesh: Mesh): void;
  55820. /**
  55821. * Dispose the highlight layer and free resources.
  55822. */
  55823. dispose(): void;
  55824. /**
  55825. * Gets the class name of the effect layer
  55826. * @returns the string with the class name of the effect layer
  55827. */
  55828. getClassName(): string;
  55829. /**
  55830. * Serializes this Highlight layer
  55831. * @returns a serialized Highlight layer object
  55832. */
  55833. serialize(): any;
  55834. /**
  55835. * Creates a Highlight layer from parsed Highlight layer data
  55836. * @param parsedHightlightLayer defines the Highlight layer data
  55837. * @param scene defines the current scene
  55838. * @param rootUrl defines the root URL containing the Highlight layer information
  55839. * @returns a parsed Highlight layer
  55840. */
  55841. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55842. }
  55843. }
  55844. declare module "babylonjs/Layers/layerSceneComponent" {
  55845. import { Scene } from "babylonjs/scene";
  55846. import { ISceneComponent } from "babylonjs/sceneComponent";
  55847. import { Layer } from "babylonjs/Layers/layer";
  55848. import { AbstractScene } from "babylonjs/abstractScene";
  55849. module "babylonjs/abstractScene" {
  55850. interface AbstractScene {
  55851. /**
  55852. * The list of layers (background and foreground) of the scene
  55853. */
  55854. layers: Array<Layer>;
  55855. }
  55856. }
  55857. /**
  55858. * Defines the layer scene component responsible to manage any layers
  55859. * in a given scene.
  55860. */
  55861. export class LayerSceneComponent implements ISceneComponent {
  55862. /**
  55863. * The component name helpfull to identify the component in the list of scene components.
  55864. */
  55865. readonly name: string;
  55866. /**
  55867. * The scene the component belongs to.
  55868. */
  55869. scene: Scene;
  55870. private _engine;
  55871. /**
  55872. * Creates a new instance of the component for the given scene
  55873. * @param scene Defines the scene to register the component in
  55874. */
  55875. constructor(scene: Scene);
  55876. /**
  55877. * Registers the component in a given scene
  55878. */
  55879. register(): void;
  55880. /**
  55881. * Rebuilds the elements related to this component in case of
  55882. * context lost for instance.
  55883. */
  55884. rebuild(): void;
  55885. /**
  55886. * Disposes the component and the associated ressources.
  55887. */
  55888. dispose(): void;
  55889. private _draw;
  55890. private _drawCameraPredicate;
  55891. private _drawCameraBackground;
  55892. private _drawCameraForeground;
  55893. private _drawRenderTargetPredicate;
  55894. private _drawRenderTargetBackground;
  55895. private _drawRenderTargetForeground;
  55896. /**
  55897. * Adds all the elements from the container to the scene
  55898. * @param container the container holding the elements
  55899. */
  55900. addFromContainer(container: AbstractScene): void;
  55901. /**
  55902. * Removes all the elements in the container from the scene
  55903. * @param container contains the elements to remove
  55904. * @param dispose if the removed element should be disposed (default: false)
  55905. */
  55906. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55907. }
  55908. }
  55909. declare module "babylonjs/Shaders/layer.fragment" {
  55910. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55911. /** @hidden */
  55912. export var layerPixelShader: {
  55913. name: string;
  55914. shader: string;
  55915. };
  55916. }
  55917. declare module "babylonjs/Shaders/layer.vertex" {
  55918. /** @hidden */
  55919. export var layerVertexShader: {
  55920. name: string;
  55921. shader: string;
  55922. };
  55923. }
  55924. declare module "babylonjs/Layers/layer" {
  55925. import { Observable } from "babylonjs/Misc/observable";
  55926. import { Nullable } from "babylonjs/types";
  55927. import { Scene } from "babylonjs/scene";
  55928. import { Vector2 } from "babylonjs/Maths/math.vector";
  55929. import { Color4 } from "babylonjs/Maths/math.color";
  55930. import { Texture } from "babylonjs/Materials/Textures/texture";
  55931. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55932. import "babylonjs/Shaders/layer.fragment";
  55933. import "babylonjs/Shaders/layer.vertex";
  55934. /**
  55935. * This represents a full screen 2d layer.
  55936. * This can be useful to display a picture in the background of your scene for instance.
  55937. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55938. */
  55939. export class Layer {
  55940. /**
  55941. * Define the name of the layer.
  55942. */
  55943. name: string;
  55944. /**
  55945. * Define the texture the layer should display.
  55946. */
  55947. texture: Nullable<Texture>;
  55948. /**
  55949. * Is the layer in background or foreground.
  55950. */
  55951. isBackground: boolean;
  55952. /**
  55953. * Define the color of the layer (instead of texture).
  55954. */
  55955. color: Color4;
  55956. /**
  55957. * Define the scale of the layer in order to zoom in out of the texture.
  55958. */
  55959. scale: Vector2;
  55960. /**
  55961. * Define an offset for the layer in order to shift the texture.
  55962. */
  55963. offset: Vector2;
  55964. /**
  55965. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55966. */
  55967. alphaBlendingMode: number;
  55968. /**
  55969. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55970. * Alpha test will not mix with the background color in case of transparency.
  55971. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55972. */
  55973. alphaTest: boolean;
  55974. /**
  55975. * Define a mask to restrict the layer to only some of the scene cameras.
  55976. */
  55977. layerMask: number;
  55978. /**
  55979. * Define the list of render target the layer is visible into.
  55980. */
  55981. renderTargetTextures: RenderTargetTexture[];
  55982. /**
  55983. * Define if the layer is only used in renderTarget or if it also
  55984. * renders in the main frame buffer of the canvas.
  55985. */
  55986. renderOnlyInRenderTargetTextures: boolean;
  55987. private _scene;
  55988. private _vertexBuffers;
  55989. private _indexBuffer;
  55990. private _effect;
  55991. private _previousDefines;
  55992. /**
  55993. * An event triggered when the layer is disposed.
  55994. */
  55995. onDisposeObservable: Observable<Layer>;
  55996. private _onDisposeObserver;
  55997. /**
  55998. * Back compatibility with callback before the onDisposeObservable existed.
  55999. * The set callback will be triggered when the layer has been disposed.
  56000. */
  56001. set onDispose(callback: () => void);
  56002. /**
  56003. * An event triggered before rendering the scene
  56004. */
  56005. onBeforeRenderObservable: Observable<Layer>;
  56006. private _onBeforeRenderObserver;
  56007. /**
  56008. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56009. * The set callback will be triggered just before rendering the layer.
  56010. */
  56011. set onBeforeRender(callback: () => void);
  56012. /**
  56013. * An event triggered after rendering the scene
  56014. */
  56015. onAfterRenderObservable: Observable<Layer>;
  56016. private _onAfterRenderObserver;
  56017. /**
  56018. * Back compatibility with callback before the onAfterRenderObservable existed.
  56019. * The set callback will be triggered just after rendering the layer.
  56020. */
  56021. set onAfterRender(callback: () => void);
  56022. /**
  56023. * Instantiates a new layer.
  56024. * This represents a full screen 2d layer.
  56025. * This can be useful to display a picture in the background of your scene for instance.
  56026. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56027. * @param name Define the name of the layer in the scene
  56028. * @param imgUrl Define the url of the texture to display in the layer
  56029. * @param scene Define the scene the layer belongs to
  56030. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56031. * @param color Defines a color for the layer
  56032. */
  56033. constructor(
  56034. /**
  56035. * Define the name of the layer.
  56036. */
  56037. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56038. private _createIndexBuffer;
  56039. /** @hidden */
  56040. _rebuild(): void;
  56041. /**
  56042. * Renders the layer in the scene.
  56043. */
  56044. render(): void;
  56045. /**
  56046. * Disposes and releases the associated ressources.
  56047. */
  56048. dispose(): void;
  56049. }
  56050. }
  56051. declare module "babylonjs/Layers/index" {
  56052. export * from "babylonjs/Layers/effectLayer";
  56053. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56054. export * from "babylonjs/Layers/glowLayer";
  56055. export * from "babylonjs/Layers/highlightLayer";
  56056. export * from "babylonjs/Layers/layer";
  56057. export * from "babylonjs/Layers/layerSceneComponent";
  56058. }
  56059. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56060. /** @hidden */
  56061. export var lensFlarePixelShader: {
  56062. name: string;
  56063. shader: string;
  56064. };
  56065. }
  56066. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56067. /** @hidden */
  56068. export var lensFlareVertexShader: {
  56069. name: string;
  56070. shader: string;
  56071. };
  56072. }
  56073. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56074. import { Scene } from "babylonjs/scene";
  56075. import { Vector3 } from "babylonjs/Maths/math.vector";
  56076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56077. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56078. import "babylonjs/Shaders/lensFlare.fragment";
  56079. import "babylonjs/Shaders/lensFlare.vertex";
  56080. import { Viewport } from "babylonjs/Maths/math.viewport";
  56081. /**
  56082. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56083. * It is usually composed of several `lensFlare`.
  56084. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56085. */
  56086. export class LensFlareSystem {
  56087. /**
  56088. * Define the name of the lens flare system
  56089. */
  56090. name: string;
  56091. /**
  56092. * List of lens flares used in this system.
  56093. */
  56094. lensFlares: LensFlare[];
  56095. /**
  56096. * Define a limit from the border the lens flare can be visible.
  56097. */
  56098. borderLimit: number;
  56099. /**
  56100. * Define a viewport border we do not want to see the lens flare in.
  56101. */
  56102. viewportBorder: number;
  56103. /**
  56104. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56105. */
  56106. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56107. /**
  56108. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56109. */
  56110. layerMask: number;
  56111. /**
  56112. * Define the id of the lens flare system in the scene.
  56113. * (equal to name by default)
  56114. */
  56115. id: string;
  56116. private _scene;
  56117. private _emitter;
  56118. private _vertexBuffers;
  56119. private _indexBuffer;
  56120. private _effect;
  56121. private _positionX;
  56122. private _positionY;
  56123. private _isEnabled;
  56124. /** @hidden */
  56125. static _SceneComponentInitialization: (scene: Scene) => void;
  56126. /**
  56127. * Instantiates a lens flare system.
  56128. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56129. * It is usually composed of several `lensFlare`.
  56130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56131. * @param name Define the name of the lens flare system in the scene
  56132. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56133. * @param scene Define the scene the lens flare system belongs to
  56134. */
  56135. constructor(
  56136. /**
  56137. * Define the name of the lens flare system
  56138. */
  56139. name: string, emitter: any, scene: Scene);
  56140. /**
  56141. * Define if the lens flare system is enabled.
  56142. */
  56143. get isEnabled(): boolean;
  56144. set isEnabled(value: boolean);
  56145. /**
  56146. * Get the scene the effects belongs to.
  56147. * @returns the scene holding the lens flare system
  56148. */
  56149. getScene(): Scene;
  56150. /**
  56151. * Get the emitter of the lens flare system.
  56152. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56153. * @returns the emitter of the lens flare system
  56154. */
  56155. getEmitter(): any;
  56156. /**
  56157. * Set the emitter of the lens flare system.
  56158. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56159. * @param newEmitter Define the new emitter of the system
  56160. */
  56161. setEmitter(newEmitter: any): void;
  56162. /**
  56163. * Get the lens flare system emitter position.
  56164. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56165. * @returns the position
  56166. */
  56167. getEmitterPosition(): Vector3;
  56168. /**
  56169. * @hidden
  56170. */
  56171. computeEffectivePosition(globalViewport: Viewport): boolean;
  56172. /** @hidden */
  56173. _isVisible(): boolean;
  56174. /**
  56175. * @hidden
  56176. */
  56177. render(): boolean;
  56178. /**
  56179. * Dispose and release the lens flare with its associated resources.
  56180. */
  56181. dispose(): void;
  56182. /**
  56183. * Parse a lens flare system from a JSON repressentation
  56184. * @param parsedLensFlareSystem Define the JSON to parse
  56185. * @param scene Define the scene the parsed system should be instantiated in
  56186. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56187. * @returns the parsed system
  56188. */
  56189. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56190. /**
  56191. * Serialize the current Lens Flare System into a JSON representation.
  56192. * @returns the serialized JSON
  56193. */
  56194. serialize(): any;
  56195. }
  56196. }
  56197. declare module "babylonjs/LensFlares/lensFlare" {
  56198. import { Nullable } from "babylonjs/types";
  56199. import { Color3 } from "babylonjs/Maths/math.color";
  56200. import { Texture } from "babylonjs/Materials/Textures/texture";
  56201. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56202. /**
  56203. * This represents one of the lens effect in a `lensFlareSystem`.
  56204. * It controls one of the indiviual texture used in the effect.
  56205. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56206. */
  56207. export class LensFlare {
  56208. /**
  56209. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56210. */
  56211. size: number;
  56212. /**
  56213. * 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.
  56214. */
  56215. position: number;
  56216. /**
  56217. * Define the lens color.
  56218. */
  56219. color: Color3;
  56220. /**
  56221. * Define the lens texture.
  56222. */
  56223. texture: Nullable<Texture>;
  56224. /**
  56225. * Define the alpha mode to render this particular lens.
  56226. */
  56227. alphaMode: number;
  56228. private _system;
  56229. /**
  56230. * Creates a new Lens Flare.
  56231. * This represents one of the lens effect in a `lensFlareSystem`.
  56232. * It controls one of the indiviual texture used in the effect.
  56233. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56234. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56235. * @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.
  56236. * @param color Define the lens color
  56237. * @param imgUrl Define the lens texture url
  56238. * @param system Define the `lensFlareSystem` this flare is part of
  56239. * @returns The newly created Lens Flare
  56240. */
  56241. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56242. /**
  56243. * Instantiates a new Lens Flare.
  56244. * This represents one of the lens effect in a `lensFlareSystem`.
  56245. * It controls one of the indiviual texture used in the effect.
  56246. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56247. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56248. * @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.
  56249. * @param color Define the lens color
  56250. * @param imgUrl Define the lens texture url
  56251. * @param system Define the `lensFlareSystem` this flare is part of
  56252. */
  56253. constructor(
  56254. /**
  56255. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56256. */
  56257. size: number,
  56258. /**
  56259. * 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.
  56260. */
  56261. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56262. /**
  56263. * Dispose and release the lens flare with its associated resources.
  56264. */
  56265. dispose(): void;
  56266. }
  56267. }
  56268. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56269. import { Nullable } from "babylonjs/types";
  56270. import { Scene } from "babylonjs/scene";
  56271. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56272. import { AbstractScene } from "babylonjs/abstractScene";
  56273. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56274. module "babylonjs/abstractScene" {
  56275. interface AbstractScene {
  56276. /**
  56277. * The list of lens flare system added to the scene
  56278. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56279. */
  56280. lensFlareSystems: Array<LensFlareSystem>;
  56281. /**
  56282. * Removes the given lens flare system from this scene.
  56283. * @param toRemove The lens flare system to remove
  56284. * @returns The index of the removed lens flare system
  56285. */
  56286. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56287. /**
  56288. * Adds the given lens flare system to this scene
  56289. * @param newLensFlareSystem The lens flare system to add
  56290. */
  56291. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56292. /**
  56293. * Gets a lens flare system using its name
  56294. * @param name defines the name to look for
  56295. * @returns the lens flare system or null if not found
  56296. */
  56297. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56298. /**
  56299. * Gets a lens flare system using its id
  56300. * @param id defines the id to look for
  56301. * @returns the lens flare system or null if not found
  56302. */
  56303. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56304. }
  56305. }
  56306. /**
  56307. * Defines the lens flare scene component responsible to manage any lens flares
  56308. * in a given scene.
  56309. */
  56310. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56311. /**
  56312. * The component name helpfull to identify the component in the list of scene components.
  56313. */
  56314. readonly name: string;
  56315. /**
  56316. * The scene the component belongs to.
  56317. */
  56318. scene: Scene;
  56319. /**
  56320. * Creates a new instance of the component for the given scene
  56321. * @param scene Defines the scene to register the component in
  56322. */
  56323. constructor(scene: Scene);
  56324. /**
  56325. * Registers the component in a given scene
  56326. */
  56327. register(): void;
  56328. /**
  56329. * Rebuilds the elements related to this component in case of
  56330. * context lost for instance.
  56331. */
  56332. rebuild(): void;
  56333. /**
  56334. * Adds all the elements from the container to the scene
  56335. * @param container the container holding the elements
  56336. */
  56337. addFromContainer(container: AbstractScene): void;
  56338. /**
  56339. * Removes all the elements in the container from the scene
  56340. * @param container contains the elements to remove
  56341. * @param dispose if the removed element should be disposed (default: false)
  56342. */
  56343. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56344. /**
  56345. * Serializes the component data to the specified json object
  56346. * @param serializationObject The object to serialize to
  56347. */
  56348. serialize(serializationObject: any): void;
  56349. /**
  56350. * Disposes the component and the associated ressources.
  56351. */
  56352. dispose(): void;
  56353. private _draw;
  56354. }
  56355. }
  56356. declare module "babylonjs/LensFlares/index" {
  56357. export * from "babylonjs/LensFlares/lensFlare";
  56358. export * from "babylonjs/LensFlares/lensFlareSystem";
  56359. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56360. }
  56361. declare module "babylonjs/Shaders/depth.fragment" {
  56362. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56363. /** @hidden */
  56364. export var depthPixelShader: {
  56365. name: string;
  56366. shader: string;
  56367. };
  56368. }
  56369. declare module "babylonjs/Shaders/depth.vertex" {
  56370. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56371. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56373. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56374. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56375. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56376. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56377. /** @hidden */
  56378. export var depthVertexShader: {
  56379. name: string;
  56380. shader: string;
  56381. };
  56382. }
  56383. declare module "babylonjs/Rendering/depthRenderer" {
  56384. import { Nullable } from "babylonjs/types";
  56385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56386. import { Scene } from "babylonjs/scene";
  56387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56388. import { Camera } from "babylonjs/Cameras/camera";
  56389. import "babylonjs/Shaders/depth.fragment";
  56390. import "babylonjs/Shaders/depth.vertex";
  56391. /**
  56392. * This represents a depth renderer in Babylon.
  56393. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56394. */
  56395. export class DepthRenderer {
  56396. private _scene;
  56397. private _depthMap;
  56398. private _effect;
  56399. private readonly _storeNonLinearDepth;
  56400. private readonly _clearColor;
  56401. /** Get if the depth renderer is using packed depth or not */
  56402. readonly isPacked: boolean;
  56403. private _cachedDefines;
  56404. private _camera;
  56405. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56406. enabled: boolean;
  56407. /**
  56408. * Specifiess that the depth renderer will only be used within
  56409. * the camera it is created for.
  56410. * This can help forcing its rendering during the camera processing.
  56411. */
  56412. useOnlyInActiveCamera: boolean;
  56413. /** @hidden */
  56414. static _SceneComponentInitialization: (scene: Scene) => void;
  56415. /**
  56416. * Instantiates a depth renderer
  56417. * @param scene The scene the renderer belongs to
  56418. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56419. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56420. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56421. */
  56422. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56423. /**
  56424. * Creates the depth rendering effect and checks if the effect is ready.
  56425. * @param subMesh The submesh to be used to render the depth map of
  56426. * @param useInstances If multiple world instances should be used
  56427. * @returns if the depth renderer is ready to render the depth map
  56428. */
  56429. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56430. /**
  56431. * Gets the texture which the depth map will be written to.
  56432. * @returns The depth map texture
  56433. */
  56434. getDepthMap(): RenderTargetTexture;
  56435. /**
  56436. * Disposes of the depth renderer.
  56437. */
  56438. dispose(): void;
  56439. }
  56440. }
  56441. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56442. /** @hidden */
  56443. export var minmaxReduxPixelShader: {
  56444. name: string;
  56445. shader: string;
  56446. };
  56447. }
  56448. declare module "babylonjs/Misc/minMaxReducer" {
  56449. import { Nullable } from "babylonjs/types";
  56450. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56451. import { Camera } from "babylonjs/Cameras/camera";
  56452. import { Observer } from "babylonjs/Misc/observable";
  56453. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56454. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56455. import { Observable } from "babylonjs/Misc/observable";
  56456. import "babylonjs/Shaders/minmaxRedux.fragment";
  56457. /**
  56458. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56459. * and maximum values from all values of the texture.
  56460. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56461. * The source values are read from the red channel of the texture.
  56462. */
  56463. export class MinMaxReducer {
  56464. /**
  56465. * Observable triggered when the computation has been performed
  56466. */
  56467. onAfterReductionPerformed: Observable<{
  56468. min: number;
  56469. max: number;
  56470. }>;
  56471. protected _camera: Camera;
  56472. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56473. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56474. protected _postProcessManager: PostProcessManager;
  56475. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56476. protected _forceFullscreenViewport: boolean;
  56477. /**
  56478. * Creates a min/max reducer
  56479. * @param camera The camera to use for the post processes
  56480. */
  56481. constructor(camera: Camera);
  56482. /**
  56483. * Gets the texture used to read the values from.
  56484. */
  56485. get sourceTexture(): Nullable<RenderTargetTexture>;
  56486. /**
  56487. * Sets the source texture to read the values from.
  56488. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56489. * because in such textures '1' value must not be taken into account to compute the maximum
  56490. * as this value is used to clear the texture.
  56491. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56492. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56493. * @param depthRedux Indicates if the texture is a depth texture or not
  56494. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56495. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56496. */
  56497. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56498. /**
  56499. * Defines the refresh rate of the computation.
  56500. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56501. */
  56502. get refreshRate(): number;
  56503. set refreshRate(value: number);
  56504. protected _activated: boolean;
  56505. /**
  56506. * Gets the activation status of the reducer
  56507. */
  56508. get activated(): boolean;
  56509. /**
  56510. * Activates the reduction computation.
  56511. * When activated, the observers registered in onAfterReductionPerformed are
  56512. * called after the compuation is performed
  56513. */
  56514. activate(): void;
  56515. /**
  56516. * Deactivates the reduction computation.
  56517. */
  56518. deactivate(): void;
  56519. /**
  56520. * Disposes the min/max reducer
  56521. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  56522. */
  56523. dispose(disposeAll?: boolean): void;
  56524. }
  56525. }
  56526. declare module "babylonjs/Misc/depthReducer" {
  56527. import { Nullable } from "babylonjs/types";
  56528. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56529. import { Camera } from "babylonjs/Cameras/camera";
  56530. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56531. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56532. /**
  56533. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56534. */
  56535. export class DepthReducer extends MinMaxReducer {
  56536. private _depthRenderer;
  56537. private _depthRendererId;
  56538. /**
  56539. * Gets the depth renderer used for the computation.
  56540. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56541. */
  56542. get depthRenderer(): Nullable<DepthRenderer>;
  56543. /**
  56544. * Creates a depth reducer
  56545. * @param camera The camera used to render the depth texture
  56546. */
  56547. constructor(camera: Camera);
  56548. /**
  56549. * Sets the depth renderer to use to generate the depth map
  56550. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56551. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56552. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56553. */
  56554. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56555. /** @hidden */
  56556. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56557. /**
  56558. * Activates the reduction computation.
  56559. * When activated, the observers registered in onAfterReductionPerformed are
  56560. * called after the compuation is performed
  56561. */
  56562. activate(): void;
  56563. /**
  56564. * Deactivates the reduction computation.
  56565. */
  56566. deactivate(): void;
  56567. /**
  56568. * Disposes the depth reducer
  56569. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  56570. */
  56571. dispose(disposeAll?: boolean): void;
  56572. }
  56573. }
  56574. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56575. import { Nullable } from "babylonjs/types";
  56576. import { Scene } from "babylonjs/scene";
  56577. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56579. import { Effect } from "babylonjs/Materials/effect";
  56580. import "babylonjs/Shaders/shadowMap.fragment";
  56581. import "babylonjs/Shaders/shadowMap.vertex";
  56582. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56583. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56584. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56585. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56586. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56587. /**
  56588. * A CSM implementation allowing casting shadows on large scenes.
  56589. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56590. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56591. */
  56592. export class CascadedShadowGenerator extends ShadowGenerator {
  56593. private static readonly frustumCornersNDCSpace;
  56594. /**
  56595. * Name of the CSM class
  56596. */
  56597. static CLASSNAME: string;
  56598. /**
  56599. * Defines the default number of cascades used by the CSM.
  56600. */
  56601. static readonly DEFAULT_CASCADES_COUNT: number;
  56602. /**
  56603. * Defines the minimum number of cascades used by the CSM.
  56604. */
  56605. static readonly MIN_CASCADES_COUNT: number;
  56606. /**
  56607. * Defines the maximum number of cascades used by the CSM.
  56608. */
  56609. static readonly MAX_CASCADES_COUNT: number;
  56610. protected _validateFilter(filter: number): number;
  56611. /**
  56612. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56613. */
  56614. penumbraDarkness: number;
  56615. private _numCascades;
  56616. /**
  56617. * Gets or set the number of cascades used by the CSM.
  56618. */
  56619. get numCascades(): number;
  56620. set numCascades(value: number);
  56621. /**
  56622. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56623. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56624. */
  56625. stabilizeCascades: boolean;
  56626. private _freezeShadowCastersBoundingInfo;
  56627. private _freezeShadowCastersBoundingInfoObservable;
  56628. /**
  56629. * Enables or disables the shadow casters bounding info computation.
  56630. * If your shadow casters don't move, you can disable this feature.
  56631. * If it is enabled, the bounding box computation is done every frame.
  56632. */
  56633. get freezeShadowCastersBoundingInfo(): boolean;
  56634. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56635. private _scbiMin;
  56636. private _scbiMax;
  56637. protected _computeShadowCastersBoundingInfo(): void;
  56638. protected _shadowCastersBoundingInfo: BoundingInfo;
  56639. /**
  56640. * Gets or sets the shadow casters bounding info.
  56641. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56642. * so that the system won't overwrite the bounds you provide
  56643. */
  56644. get shadowCastersBoundingInfo(): BoundingInfo;
  56645. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56646. protected _breaksAreDirty: boolean;
  56647. protected _minDistance: number;
  56648. protected _maxDistance: number;
  56649. /**
  56650. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56651. *
  56652. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56653. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56654. * @param min minimal distance for the breaks (default to 0.)
  56655. * @param max maximal distance for the breaks (default to 1.)
  56656. */
  56657. setMinMaxDistance(min: number, max: number): void;
  56658. /** Gets the minimal distance used in the cascade break computation */
  56659. get minDistance(): number;
  56660. /** Gets the maximal distance used in the cascade break computation */
  56661. get maxDistance(): number;
  56662. /**
  56663. * Gets the class name of that object
  56664. * @returns "CascadedShadowGenerator"
  56665. */
  56666. getClassName(): string;
  56667. private _cascadeMinExtents;
  56668. private _cascadeMaxExtents;
  56669. /**
  56670. * Gets a cascade minimum extents
  56671. * @param cascadeIndex index of the cascade
  56672. * @returns the minimum cascade extents
  56673. */
  56674. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56675. /**
  56676. * Gets a cascade maximum extents
  56677. * @param cascadeIndex index of the cascade
  56678. * @returns the maximum cascade extents
  56679. */
  56680. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56681. private _cascades;
  56682. private _currentLayer;
  56683. private _viewSpaceFrustumsZ;
  56684. private _viewMatrices;
  56685. private _projectionMatrices;
  56686. private _transformMatrices;
  56687. private _transformMatricesAsArray;
  56688. private _frustumLengths;
  56689. private _lightSizeUVCorrection;
  56690. private _depthCorrection;
  56691. private _frustumCornersWorldSpace;
  56692. private _frustumCenter;
  56693. private _shadowCameraPos;
  56694. private _shadowMaxZ;
  56695. /**
  56696. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56697. * It defaults to camera.maxZ
  56698. */
  56699. get shadowMaxZ(): number;
  56700. /**
  56701. * Sets the shadow max z distance.
  56702. */
  56703. set shadowMaxZ(value: number);
  56704. protected _debug: boolean;
  56705. /**
  56706. * Gets or sets the debug flag.
  56707. * When enabled, the cascades are materialized by different colors on the screen.
  56708. */
  56709. get debug(): boolean;
  56710. set debug(dbg: boolean);
  56711. private _depthClamp;
  56712. /**
  56713. * Gets or sets the depth clamping value.
  56714. *
  56715. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56716. * to account for the shadow casters far away.
  56717. *
  56718. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56719. */
  56720. get depthClamp(): boolean;
  56721. set depthClamp(value: boolean);
  56722. private _cascadeBlendPercentage;
  56723. /**
  56724. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56725. * It defaults to 0.1 (10% blending).
  56726. */
  56727. get cascadeBlendPercentage(): number;
  56728. set cascadeBlendPercentage(value: number);
  56729. private _lambda;
  56730. /**
  56731. * Gets or set the lambda parameter.
  56732. * This parameter is used to split the camera frustum and create the cascades.
  56733. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  56734. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56735. */
  56736. get lambda(): number;
  56737. set lambda(value: number);
  56738. /**
  56739. * Gets the view matrix corresponding to a given cascade
  56740. * @param cascadeNum cascade to retrieve the view matrix from
  56741. * @returns the cascade view matrix
  56742. */
  56743. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56744. /**
  56745. * Gets the projection matrix corresponding to a given cascade
  56746. * @param cascadeNum cascade to retrieve the projection matrix from
  56747. * @returns the cascade projection matrix
  56748. */
  56749. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56750. /**
  56751. * Gets the transformation matrix corresponding to a given cascade
  56752. * @param cascadeNum cascade to retrieve the transformation matrix from
  56753. * @returns the cascade transformation matrix
  56754. */
  56755. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56756. private _depthRenderer;
  56757. /**
  56758. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56759. *
  56760. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56761. *
  56762. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56763. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56764. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  56765. */
  56766. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56767. private _depthReducer;
  56768. private _autoCalcDepthBounds;
  56769. /**
  56770. * Gets or sets the autoCalcDepthBounds property.
  56771. *
  56772. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56773. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56774. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56775. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56776. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56777. */
  56778. get autoCalcDepthBounds(): boolean;
  56779. set autoCalcDepthBounds(value: boolean);
  56780. /**
  56781. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56782. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56783. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56784. * for setting the refresh rate on the renderer yourself!
  56785. */
  56786. get autoCalcDepthBoundsRefreshRate(): number;
  56787. set autoCalcDepthBoundsRefreshRate(value: number);
  56788. /**
  56789. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56790. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56791. * you change the camera near/far planes!
  56792. */
  56793. splitFrustum(): void;
  56794. private _splitFrustum;
  56795. private _computeMatrices;
  56796. private _computeFrustumInWorldSpace;
  56797. private _computeCascadeFrustum;
  56798. /** @hidden */
  56799. static _SceneComponentInitialization: (scene: Scene) => void;
  56800. /**
  56801. * Creates a Cascaded Shadow Generator object.
  56802. * A ShadowGenerator is the required tool to use the shadows.
  56803. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56804. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56805. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56806. * @param light The directional light object generating the shadows.
  56807. * @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.
  56808. */
  56809. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56810. protected _initializeGenerator(): void;
  56811. protected _createTargetRenderTexture(): void;
  56812. protected _initializeShadowMap(): void;
  56813. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56814. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56815. /**
  56816. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56817. * @param defines Defines of the material we want to update
  56818. * @param lightIndex Index of the light in the enabled light list of the material
  56819. */
  56820. prepareDefines(defines: any, lightIndex: number): void;
  56821. /**
  56822. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56823. * defined in the generator but impacting the effect).
  56824. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56825. * @param effect The effect we are binfing the information for
  56826. */
  56827. bindShadowLight(lightIndex: string, effect: Effect): void;
  56828. /**
  56829. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56830. * (eq to view projection * shadow projection matrices)
  56831. * @returns The transform matrix used to create the shadow map
  56832. */
  56833. getTransformMatrix(): Matrix;
  56834. /**
  56835. * Disposes the ShadowGenerator.
  56836. * Returns nothing.
  56837. */
  56838. dispose(): void;
  56839. /**
  56840. * Serializes the shadow generator setup to a json object.
  56841. * @returns The serialized JSON object
  56842. */
  56843. serialize(): any;
  56844. /**
  56845. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56846. * @param parsedShadowGenerator The JSON object to parse
  56847. * @param scene The scene to create the shadow map for
  56848. * @returns The parsed shadow generator
  56849. */
  56850. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56851. }
  56852. }
  56853. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56854. import { Scene } from "babylonjs/scene";
  56855. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56856. import { AbstractScene } from "babylonjs/abstractScene";
  56857. /**
  56858. * Defines the shadow generator component responsible to manage any shadow generators
  56859. * in a given scene.
  56860. */
  56861. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56862. /**
  56863. * The component name helpfull to identify the component in the list of scene components.
  56864. */
  56865. readonly name: string;
  56866. /**
  56867. * The scene the component belongs to.
  56868. */
  56869. scene: Scene;
  56870. /**
  56871. * Creates a new instance of the component for the given scene
  56872. * @param scene Defines the scene to register the component in
  56873. */
  56874. constructor(scene: Scene);
  56875. /**
  56876. * Registers the component in a given scene
  56877. */
  56878. register(): void;
  56879. /**
  56880. * Rebuilds the elements related to this component in case of
  56881. * context lost for instance.
  56882. */
  56883. rebuild(): void;
  56884. /**
  56885. * Serializes the component data to the specified json object
  56886. * @param serializationObject The object to serialize to
  56887. */
  56888. serialize(serializationObject: any): void;
  56889. /**
  56890. * Adds all the elements from the container to the scene
  56891. * @param container the container holding the elements
  56892. */
  56893. addFromContainer(container: AbstractScene): void;
  56894. /**
  56895. * Removes all the elements in the container from the scene
  56896. * @param container contains the elements to remove
  56897. * @param dispose if the removed element should be disposed (default: false)
  56898. */
  56899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56900. /**
  56901. * Rebuilds the elements related to this component in case of
  56902. * context lost for instance.
  56903. */
  56904. dispose(): void;
  56905. private _gatherRenderTargets;
  56906. }
  56907. }
  56908. declare module "babylonjs/Lights/Shadows/index" {
  56909. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56910. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56911. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56912. }
  56913. declare module "babylonjs/Lights/pointLight" {
  56914. import { Scene } from "babylonjs/scene";
  56915. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56917. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56918. import { Effect } from "babylonjs/Materials/effect";
  56919. /**
  56920. * A point light is a light defined by an unique point in world space.
  56921. * The light is emitted in every direction from this point.
  56922. * A good example of a point light is a standard light bulb.
  56923. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56924. */
  56925. export class PointLight extends ShadowLight {
  56926. private _shadowAngle;
  56927. /**
  56928. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56929. * This specifies what angle the shadow will use to be created.
  56930. *
  56931. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56932. */
  56933. get shadowAngle(): number;
  56934. /**
  56935. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56936. * This specifies what angle the shadow will use to be created.
  56937. *
  56938. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56939. */
  56940. set shadowAngle(value: number);
  56941. /**
  56942. * Gets the direction if it has been set.
  56943. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56944. */
  56945. get direction(): Vector3;
  56946. /**
  56947. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56948. */
  56949. set direction(value: Vector3);
  56950. /**
  56951. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56952. * A PointLight emits the light in every direction.
  56953. * It can cast shadows.
  56954. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56955. * ```javascript
  56956. * var pointLight = new PointLight("pl", camera.position, scene);
  56957. * ```
  56958. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56959. * @param name The light friendly name
  56960. * @param position The position of the point light in the scene
  56961. * @param scene The scene the lights belongs to
  56962. */
  56963. constructor(name: string, position: Vector3, scene: Scene);
  56964. /**
  56965. * Returns the string "PointLight"
  56966. * @returns the class name
  56967. */
  56968. getClassName(): string;
  56969. /**
  56970. * Returns the integer 0.
  56971. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56972. */
  56973. getTypeID(): number;
  56974. /**
  56975. * Specifies wether or not the shadowmap should be a cube texture.
  56976. * @returns true if the shadowmap needs to be a cube texture.
  56977. */
  56978. needCube(): boolean;
  56979. /**
  56980. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56981. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56982. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56983. */
  56984. getShadowDirection(faceIndex?: number): Vector3;
  56985. /**
  56986. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56987. * - fov = PI / 2
  56988. * - aspect ratio : 1.0
  56989. * - z-near and far equal to the active camera minZ and maxZ.
  56990. * Returns the PointLight.
  56991. */
  56992. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56993. protected _buildUniformLayout(): void;
  56994. /**
  56995. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56996. * @param effect The effect to update
  56997. * @param lightIndex The index of the light in the effect to update
  56998. * @returns The point light
  56999. */
  57000. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57001. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57002. /**
  57003. * Prepares the list of defines specific to the light type.
  57004. * @param defines the list of defines
  57005. * @param lightIndex defines the index of the light for the effect
  57006. */
  57007. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57008. }
  57009. }
  57010. declare module "babylonjs/Lights/index" {
  57011. export * from "babylonjs/Lights/light";
  57012. export * from "babylonjs/Lights/shadowLight";
  57013. export * from "babylonjs/Lights/Shadows/index";
  57014. export * from "babylonjs/Lights/directionalLight";
  57015. export * from "babylonjs/Lights/hemisphericLight";
  57016. export * from "babylonjs/Lights/pointLight";
  57017. export * from "babylonjs/Lights/spotLight";
  57018. }
  57019. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57020. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57021. /**
  57022. * Header information of HDR texture files.
  57023. */
  57024. export interface HDRInfo {
  57025. /**
  57026. * The height of the texture in pixels.
  57027. */
  57028. height: number;
  57029. /**
  57030. * The width of the texture in pixels.
  57031. */
  57032. width: number;
  57033. /**
  57034. * The index of the beginning of the data in the binary file.
  57035. */
  57036. dataPosition: number;
  57037. }
  57038. /**
  57039. * This groups tools to convert HDR texture to native colors array.
  57040. */
  57041. export class HDRTools {
  57042. private static Ldexp;
  57043. private static Rgbe2float;
  57044. private static readStringLine;
  57045. /**
  57046. * Reads header information from an RGBE texture stored in a native array.
  57047. * More information on this format are available here:
  57048. * https://en.wikipedia.org/wiki/RGBE_image_format
  57049. *
  57050. * @param uint8array The binary file stored in native array.
  57051. * @return The header information.
  57052. */
  57053. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57054. /**
  57055. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57056. * This RGBE texture needs to store the information as a panorama.
  57057. *
  57058. * More information on this format are available here:
  57059. * https://en.wikipedia.org/wiki/RGBE_image_format
  57060. *
  57061. * @param buffer The binary file stored in an array buffer.
  57062. * @param size The expected size of the extracted cubemap.
  57063. * @return The Cube Map information.
  57064. */
  57065. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57066. /**
  57067. * Returns the pixels data extracted from an RGBE texture.
  57068. * This pixels will be stored left to right up to down in the R G B order in one array.
  57069. *
  57070. * More information on this format are available here:
  57071. * https://en.wikipedia.org/wiki/RGBE_image_format
  57072. *
  57073. * @param uint8array The binary file stored in an array buffer.
  57074. * @param hdrInfo The header information of the file.
  57075. * @return The pixels data in RGB right to left up to down order.
  57076. */
  57077. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57078. private static RGBE_ReadPixels_RLE;
  57079. }
  57080. }
  57081. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57082. import { Nullable } from "babylonjs/types";
  57083. import { Scene } from "babylonjs/scene";
  57084. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57086. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57087. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57088. /**
  57089. * This represents a texture coming from an HDR input.
  57090. *
  57091. * The only supported format is currently panorama picture stored in RGBE format.
  57092. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57093. */
  57094. export class HDRCubeTexture extends BaseTexture {
  57095. private static _facesMapping;
  57096. private _generateHarmonics;
  57097. private _noMipmap;
  57098. private _textureMatrix;
  57099. private _size;
  57100. private _onLoad;
  57101. private _onError;
  57102. /**
  57103. * The texture URL.
  57104. */
  57105. url: string;
  57106. /**
  57107. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57108. */
  57109. coordinatesMode: number;
  57110. protected _isBlocking: boolean;
  57111. /**
  57112. * Sets wether or not the texture is blocking during loading.
  57113. */
  57114. set isBlocking(value: boolean);
  57115. /**
  57116. * Gets wether or not the texture is blocking during loading.
  57117. */
  57118. get isBlocking(): boolean;
  57119. protected _rotationY: number;
  57120. /**
  57121. * Sets texture matrix rotation angle around Y axis in radians.
  57122. */
  57123. set rotationY(value: number);
  57124. /**
  57125. * Gets texture matrix rotation angle around Y axis radians.
  57126. */
  57127. get rotationY(): number;
  57128. /**
  57129. * Gets or sets the center of the bounding box associated with the cube texture
  57130. * It must define where the camera used to render the texture was set
  57131. */
  57132. boundingBoxPosition: Vector3;
  57133. private _boundingBoxSize;
  57134. /**
  57135. * Gets or sets the size of the bounding box associated with the cube texture
  57136. * When defined, the cubemap will switch to local mode
  57137. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57138. * @example https://www.babylonjs-playground.com/#RNASML
  57139. */
  57140. set boundingBoxSize(value: Vector3);
  57141. get boundingBoxSize(): Vector3;
  57142. /**
  57143. * Instantiates an HDRTexture from the following parameters.
  57144. *
  57145. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57146. * @param scene The scene the texture will be used in
  57147. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57148. * @param noMipmap Forces to not generate the mipmap if true
  57149. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57150. * @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)
  57151. * @param reserved Reserved flag for internal use.
  57152. */
  57153. 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>);
  57154. /**
  57155. * Get the current class name of the texture useful for serialization or dynamic coding.
  57156. * @returns "HDRCubeTexture"
  57157. */
  57158. getClassName(): string;
  57159. /**
  57160. * Occurs when the file is raw .hdr file.
  57161. */
  57162. private loadTexture;
  57163. clone(): HDRCubeTexture;
  57164. delayLoad(): void;
  57165. /**
  57166. * Get the texture reflection matrix used to rotate/transform the reflection.
  57167. * @returns the reflection matrix
  57168. */
  57169. getReflectionTextureMatrix(): Matrix;
  57170. /**
  57171. * Set the texture reflection matrix used to rotate/transform the reflection.
  57172. * @param value Define the reflection matrix to set
  57173. */
  57174. setReflectionTextureMatrix(value: Matrix): void;
  57175. /**
  57176. * Parses a JSON representation of an HDR Texture in order to create the texture
  57177. * @param parsedTexture Define the JSON representation
  57178. * @param scene Define the scene the texture should be created in
  57179. * @param rootUrl Define the root url in case we need to load relative dependencies
  57180. * @returns the newly created texture after parsing
  57181. */
  57182. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57183. serialize(): any;
  57184. }
  57185. }
  57186. declare module "babylonjs/Physics/physicsEngine" {
  57187. import { Nullable } from "babylonjs/types";
  57188. import { Vector3 } from "babylonjs/Maths/math.vector";
  57189. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57190. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57191. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57192. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57193. /**
  57194. * Class used to control physics engine
  57195. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57196. */
  57197. export class PhysicsEngine implements IPhysicsEngine {
  57198. private _physicsPlugin;
  57199. /**
  57200. * Global value used to control the smallest number supported by the simulation
  57201. */
  57202. static Epsilon: number;
  57203. private _impostors;
  57204. private _joints;
  57205. private _subTimeStep;
  57206. /**
  57207. * Gets the gravity vector used by the simulation
  57208. */
  57209. gravity: Vector3;
  57210. /**
  57211. * Factory used to create the default physics plugin.
  57212. * @returns The default physics plugin
  57213. */
  57214. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57215. /**
  57216. * Creates a new Physics Engine
  57217. * @param gravity defines the gravity vector used by the simulation
  57218. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57219. */
  57220. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57221. /**
  57222. * Sets the gravity vector used by the simulation
  57223. * @param gravity defines the gravity vector to use
  57224. */
  57225. setGravity(gravity: Vector3): void;
  57226. /**
  57227. * Set the time step of the physics engine.
  57228. * Default is 1/60.
  57229. * To slow it down, enter 1/600 for example.
  57230. * To speed it up, 1/30
  57231. * @param newTimeStep defines the new timestep to apply to this world.
  57232. */
  57233. setTimeStep(newTimeStep?: number): void;
  57234. /**
  57235. * Get the time step of the physics engine.
  57236. * @returns the current time step
  57237. */
  57238. getTimeStep(): number;
  57239. /**
  57240. * Set the sub time step of the physics engine.
  57241. * Default is 0 meaning there is no sub steps
  57242. * To increase physics resolution precision, set a small value (like 1 ms)
  57243. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57244. */
  57245. setSubTimeStep(subTimeStep?: number): void;
  57246. /**
  57247. * Get the sub time step of the physics engine.
  57248. * @returns the current sub time step
  57249. */
  57250. getSubTimeStep(): number;
  57251. /**
  57252. * Release all resources
  57253. */
  57254. dispose(): void;
  57255. /**
  57256. * Gets the name of the current physics plugin
  57257. * @returns the name of the plugin
  57258. */
  57259. getPhysicsPluginName(): string;
  57260. /**
  57261. * Adding a new impostor for the impostor tracking.
  57262. * This will be done by the impostor itself.
  57263. * @param impostor the impostor to add
  57264. */
  57265. addImpostor(impostor: PhysicsImpostor): void;
  57266. /**
  57267. * Remove an impostor from the engine.
  57268. * This impostor and its mesh will not longer be updated by the physics engine.
  57269. * @param impostor the impostor to remove
  57270. */
  57271. removeImpostor(impostor: PhysicsImpostor): void;
  57272. /**
  57273. * Add a joint to the physics engine
  57274. * @param mainImpostor defines the main impostor to which the joint is added.
  57275. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57276. * @param joint defines the joint that will connect both impostors.
  57277. */
  57278. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57279. /**
  57280. * Removes a joint from the simulation
  57281. * @param mainImpostor defines the impostor used with the joint
  57282. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57283. * @param joint defines the joint to remove
  57284. */
  57285. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57286. /**
  57287. * Called by the scene. No need to call it.
  57288. * @param delta defines the timespam between frames
  57289. */
  57290. _step(delta: number): void;
  57291. /**
  57292. * Gets the current plugin used to run the simulation
  57293. * @returns current plugin
  57294. */
  57295. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57296. /**
  57297. * Gets the list of physic impostors
  57298. * @returns an array of PhysicsImpostor
  57299. */
  57300. getImpostors(): Array<PhysicsImpostor>;
  57301. /**
  57302. * Gets the impostor for a physics enabled object
  57303. * @param object defines the object impersonated by the impostor
  57304. * @returns the PhysicsImpostor or null if not found
  57305. */
  57306. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57307. /**
  57308. * Gets the impostor for a physics body object
  57309. * @param body defines physics body used by the impostor
  57310. * @returns the PhysicsImpostor or null if not found
  57311. */
  57312. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57313. /**
  57314. * Does a raycast in the physics world
  57315. * @param from when should the ray start?
  57316. * @param to when should the ray end?
  57317. * @returns PhysicsRaycastResult
  57318. */
  57319. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57320. }
  57321. }
  57322. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57323. import { Nullable } from "babylonjs/types";
  57324. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57326. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57327. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57328. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57329. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57330. /** @hidden */
  57331. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57332. private _useDeltaForWorldStep;
  57333. world: any;
  57334. name: string;
  57335. private _physicsMaterials;
  57336. private _fixedTimeStep;
  57337. private _cannonRaycastResult;
  57338. private _raycastResult;
  57339. private _physicsBodysToRemoveAfterStep;
  57340. BJSCANNON: any;
  57341. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57342. setGravity(gravity: Vector3): void;
  57343. setTimeStep(timeStep: number): void;
  57344. getTimeStep(): number;
  57345. executeStep(delta: number): void;
  57346. private _removeMarkedPhysicsBodiesFromWorld;
  57347. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57348. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57349. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57350. private _processChildMeshes;
  57351. removePhysicsBody(impostor: PhysicsImpostor): void;
  57352. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57353. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57354. private _addMaterial;
  57355. private _checkWithEpsilon;
  57356. private _createShape;
  57357. private _createHeightmap;
  57358. private _minus90X;
  57359. private _plus90X;
  57360. private _tmpPosition;
  57361. private _tmpDeltaPosition;
  57362. private _tmpUnityRotation;
  57363. private _updatePhysicsBodyTransformation;
  57364. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57365. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57366. isSupported(): boolean;
  57367. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57368. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57369. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57370. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57371. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57372. getBodyMass(impostor: PhysicsImpostor): number;
  57373. getBodyFriction(impostor: PhysicsImpostor): number;
  57374. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57375. getBodyRestitution(impostor: PhysicsImpostor): number;
  57376. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57377. sleepBody(impostor: PhysicsImpostor): void;
  57378. wakeUpBody(impostor: PhysicsImpostor): void;
  57379. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57380. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57381. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57382. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57383. getRadius(impostor: PhysicsImpostor): number;
  57384. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57385. dispose(): void;
  57386. private _extendNamespace;
  57387. /**
  57388. * Does a raycast in the physics world
  57389. * @param from when should the ray start?
  57390. * @param to when should the ray end?
  57391. * @returns PhysicsRaycastResult
  57392. */
  57393. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57394. }
  57395. }
  57396. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57397. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57398. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57399. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57401. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57402. import { Nullable } from "babylonjs/types";
  57403. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57404. /** @hidden */
  57405. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57406. world: any;
  57407. name: string;
  57408. BJSOIMO: any;
  57409. private _raycastResult;
  57410. constructor(iterations?: number, oimoInjection?: any);
  57411. setGravity(gravity: Vector3): void;
  57412. setTimeStep(timeStep: number): void;
  57413. getTimeStep(): number;
  57414. private _tmpImpostorsArray;
  57415. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57419. private _tmpPositionVector;
  57420. removePhysicsBody(impostor: PhysicsImpostor): void;
  57421. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57422. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57423. isSupported(): boolean;
  57424. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57425. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57427. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57428. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57429. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57430. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57431. getBodyMass(impostor: PhysicsImpostor): number;
  57432. getBodyFriction(impostor: PhysicsImpostor): number;
  57433. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57434. getBodyRestitution(impostor: PhysicsImpostor): number;
  57435. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57436. sleepBody(impostor: PhysicsImpostor): void;
  57437. wakeUpBody(impostor: PhysicsImpostor): void;
  57438. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57439. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57440. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57441. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57442. getRadius(impostor: PhysicsImpostor): number;
  57443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57444. dispose(): void;
  57445. /**
  57446. * Does a raycast in the physics world
  57447. * @param from when should the ray start?
  57448. * @param to when should the ray end?
  57449. * @returns PhysicsRaycastResult
  57450. */
  57451. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57452. }
  57453. }
  57454. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57455. import { Nullable } from "babylonjs/types";
  57456. import { Scene } from "babylonjs/scene";
  57457. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57458. import { Color4 } from "babylonjs/Maths/math.color";
  57459. import { Mesh } from "babylonjs/Meshes/mesh";
  57460. /**
  57461. * Class containing static functions to help procedurally build meshes
  57462. */
  57463. export class RibbonBuilder {
  57464. /**
  57465. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57466. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57467. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57468. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57469. * * 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
  57470. * * 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
  57471. * * 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
  57472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57475. * * 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
  57476. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57477. * * 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
  57478. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57480. * @param name defines the name of the mesh
  57481. * @param options defines the options used to create the mesh
  57482. * @param scene defines the hosting scene
  57483. * @returns the ribbon mesh
  57484. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57486. */
  57487. static CreateRibbon(name: string, options: {
  57488. pathArray: Vector3[][];
  57489. closeArray?: boolean;
  57490. closePath?: boolean;
  57491. offset?: number;
  57492. updatable?: boolean;
  57493. sideOrientation?: number;
  57494. frontUVs?: Vector4;
  57495. backUVs?: Vector4;
  57496. instance?: Mesh;
  57497. invertUV?: boolean;
  57498. uvs?: Vector2[];
  57499. colors?: Color4[];
  57500. }, scene?: Nullable<Scene>): Mesh;
  57501. }
  57502. }
  57503. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57504. import { Nullable } from "babylonjs/types";
  57505. import { Scene } from "babylonjs/scene";
  57506. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57507. import { Mesh } from "babylonjs/Meshes/mesh";
  57508. /**
  57509. * Class containing static functions to help procedurally build meshes
  57510. */
  57511. export class ShapeBuilder {
  57512. /**
  57513. * 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.
  57514. * * 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.
  57515. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57516. * * 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.
  57517. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57518. * * 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
  57519. * * 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
  57520. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57523. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57525. * @param name defines the name of the mesh
  57526. * @param options defines the options used to create the mesh
  57527. * @param scene defines the hosting scene
  57528. * @returns the extruded shape mesh
  57529. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57531. */
  57532. static ExtrudeShape(name: string, options: {
  57533. shape: Vector3[];
  57534. path: Vector3[];
  57535. scale?: number;
  57536. rotation?: number;
  57537. cap?: number;
  57538. updatable?: boolean;
  57539. sideOrientation?: number;
  57540. frontUVs?: Vector4;
  57541. backUVs?: Vector4;
  57542. instance?: Mesh;
  57543. invertUV?: boolean;
  57544. }, scene?: Nullable<Scene>): Mesh;
  57545. /**
  57546. * Creates an custom extruded shape mesh.
  57547. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57548. * * 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.
  57549. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57550. * * 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
  57551. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57552. * * 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
  57553. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57554. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57555. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57556. * * 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
  57557. * * 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
  57558. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57561. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57563. * @param name defines the name of the mesh
  57564. * @param options defines the options used to create the mesh
  57565. * @param scene defines the hosting scene
  57566. * @returns the custom extruded shape mesh
  57567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57568. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57570. */
  57571. static ExtrudeShapeCustom(name: string, options: {
  57572. shape: Vector3[];
  57573. path: Vector3[];
  57574. scaleFunction?: any;
  57575. rotationFunction?: any;
  57576. ribbonCloseArray?: boolean;
  57577. ribbonClosePath?: boolean;
  57578. cap?: number;
  57579. updatable?: boolean;
  57580. sideOrientation?: number;
  57581. frontUVs?: Vector4;
  57582. backUVs?: Vector4;
  57583. instance?: Mesh;
  57584. invertUV?: boolean;
  57585. }, scene?: Nullable<Scene>): Mesh;
  57586. private static _ExtrudeShapeGeneric;
  57587. }
  57588. }
  57589. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57590. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57591. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57592. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57593. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57594. import { Nullable } from "babylonjs/types";
  57595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57596. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57597. /**
  57598. * AmmoJS Physics plugin
  57599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57600. * @see https://github.com/kripken/ammo.js/
  57601. */
  57602. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57603. private _useDeltaForWorldStep;
  57604. /**
  57605. * Reference to the Ammo library
  57606. */
  57607. bjsAMMO: any;
  57608. /**
  57609. * Created ammoJS world which physics bodies are added to
  57610. */
  57611. world: any;
  57612. /**
  57613. * Name of the plugin
  57614. */
  57615. name: string;
  57616. private _timeStep;
  57617. private _fixedTimeStep;
  57618. private _maxSteps;
  57619. private _tmpQuaternion;
  57620. private _tmpAmmoTransform;
  57621. private _tmpAmmoQuaternion;
  57622. private _tmpAmmoConcreteContactResultCallback;
  57623. private _collisionConfiguration;
  57624. private _dispatcher;
  57625. private _overlappingPairCache;
  57626. private _solver;
  57627. private _softBodySolver;
  57628. private _tmpAmmoVectorA;
  57629. private _tmpAmmoVectorB;
  57630. private _tmpAmmoVectorC;
  57631. private _tmpAmmoVectorD;
  57632. private _tmpContactCallbackResult;
  57633. private _tmpAmmoVectorRCA;
  57634. private _tmpAmmoVectorRCB;
  57635. private _raycastResult;
  57636. private static readonly DISABLE_COLLISION_FLAG;
  57637. private static readonly KINEMATIC_FLAG;
  57638. private static readonly DISABLE_DEACTIVATION_FLAG;
  57639. /**
  57640. * Initializes the ammoJS plugin
  57641. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57642. * @param ammoInjection can be used to inject your own ammo reference
  57643. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57644. */
  57645. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57646. /**
  57647. * Sets the gravity of the physics world (m/(s^2))
  57648. * @param gravity Gravity to set
  57649. */
  57650. setGravity(gravity: Vector3): void;
  57651. /**
  57652. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57653. * @param timeStep timestep to use in seconds
  57654. */
  57655. setTimeStep(timeStep: number): void;
  57656. /**
  57657. * 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)
  57658. * @param fixedTimeStep fixedTimeStep to use in seconds
  57659. */
  57660. setFixedTimeStep(fixedTimeStep: number): void;
  57661. /**
  57662. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57663. * @param maxSteps the maximum number of steps by the physics engine per frame
  57664. */
  57665. setMaxSteps(maxSteps: number): void;
  57666. /**
  57667. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57668. * @returns the current timestep in seconds
  57669. */
  57670. getTimeStep(): number;
  57671. /**
  57672. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57673. */
  57674. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57675. private _isImpostorInContact;
  57676. private _isImpostorPairInContact;
  57677. private _stepSimulation;
  57678. /**
  57679. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57680. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57681. * After the step the babylon meshes are set to the position of the physics imposters
  57682. * @param delta amount of time to step forward
  57683. * @param impostors array of imposters to update before/after the step
  57684. */
  57685. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57686. /**
  57687. * Update babylon mesh to match physics world object
  57688. * @param impostor imposter to match
  57689. */
  57690. private _afterSoftStep;
  57691. /**
  57692. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57693. * @param impostor imposter to match
  57694. */
  57695. private _ropeStep;
  57696. /**
  57697. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57698. * @param impostor imposter to match
  57699. */
  57700. private _softbodyOrClothStep;
  57701. private _tmpVector;
  57702. private _tmpMatrix;
  57703. /**
  57704. * Applies an impulse on the imposter
  57705. * @param impostor imposter to apply impulse to
  57706. * @param force amount of force to be applied to the imposter
  57707. * @param contactPoint the location to apply the impulse on the imposter
  57708. */
  57709. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57710. /**
  57711. * Applies a force on the imposter
  57712. * @param impostor imposter to apply force
  57713. * @param force amount of force to be applied to the imposter
  57714. * @param contactPoint the location to apply the force on the imposter
  57715. */
  57716. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57717. /**
  57718. * Creates a physics body using the plugin
  57719. * @param impostor the imposter to create the physics body on
  57720. */
  57721. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57722. /**
  57723. * Removes the physics body from the imposter and disposes of the body's memory
  57724. * @param impostor imposter to remove the physics body from
  57725. */
  57726. removePhysicsBody(impostor: PhysicsImpostor): void;
  57727. /**
  57728. * Generates a joint
  57729. * @param impostorJoint the imposter joint to create the joint with
  57730. */
  57731. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57732. /**
  57733. * Removes a joint
  57734. * @param impostorJoint the imposter joint to remove the joint from
  57735. */
  57736. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57737. private _addMeshVerts;
  57738. /**
  57739. * Initialise the soft body vertices to match its object's (mesh) vertices
  57740. * Softbody vertices (nodes) are in world space and to match this
  57741. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57742. * @param impostor to create the softbody for
  57743. */
  57744. private _softVertexData;
  57745. /**
  57746. * Create an impostor's soft body
  57747. * @param impostor to create the softbody for
  57748. */
  57749. private _createSoftbody;
  57750. /**
  57751. * Create cloth for an impostor
  57752. * @param impostor to create the softbody for
  57753. */
  57754. private _createCloth;
  57755. /**
  57756. * Create rope for an impostor
  57757. * @param impostor to create the softbody for
  57758. */
  57759. private _createRope;
  57760. /**
  57761. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57762. * @param impostor to create the custom physics shape for
  57763. */
  57764. private _createCustom;
  57765. private _addHullVerts;
  57766. private _createShape;
  57767. /**
  57768. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57769. * @param impostor imposter containing the physics body and babylon object
  57770. */
  57771. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57772. /**
  57773. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57774. * @param impostor imposter containing the physics body and babylon object
  57775. * @param newPosition new position
  57776. * @param newRotation new rotation
  57777. */
  57778. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57779. /**
  57780. * If this plugin is supported
  57781. * @returns true if its supported
  57782. */
  57783. isSupported(): boolean;
  57784. /**
  57785. * Sets the linear velocity of the physics body
  57786. * @param impostor imposter to set the velocity on
  57787. * @param velocity velocity to set
  57788. */
  57789. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57790. /**
  57791. * Sets the angular velocity of the physics body
  57792. * @param impostor imposter to set the velocity on
  57793. * @param velocity velocity to set
  57794. */
  57795. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57796. /**
  57797. * gets the linear velocity
  57798. * @param impostor imposter to get linear velocity from
  57799. * @returns linear velocity
  57800. */
  57801. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57802. /**
  57803. * gets the angular velocity
  57804. * @param impostor imposter to get angular velocity from
  57805. * @returns angular velocity
  57806. */
  57807. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57808. /**
  57809. * Sets the mass of physics body
  57810. * @param impostor imposter to set the mass on
  57811. * @param mass mass to set
  57812. */
  57813. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57814. /**
  57815. * Gets the mass of the physics body
  57816. * @param impostor imposter to get the mass from
  57817. * @returns mass
  57818. */
  57819. getBodyMass(impostor: PhysicsImpostor): number;
  57820. /**
  57821. * Gets friction of the impostor
  57822. * @param impostor impostor to get friction from
  57823. * @returns friction value
  57824. */
  57825. getBodyFriction(impostor: PhysicsImpostor): number;
  57826. /**
  57827. * Sets friction of the impostor
  57828. * @param impostor impostor to set friction on
  57829. * @param friction friction value
  57830. */
  57831. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57832. /**
  57833. * Gets restitution of the impostor
  57834. * @param impostor impostor to get restitution from
  57835. * @returns restitution value
  57836. */
  57837. getBodyRestitution(impostor: PhysicsImpostor): number;
  57838. /**
  57839. * Sets resitution of the impostor
  57840. * @param impostor impostor to set resitution on
  57841. * @param restitution resitution value
  57842. */
  57843. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57844. /**
  57845. * Gets pressure inside the impostor
  57846. * @param impostor impostor to get pressure from
  57847. * @returns pressure value
  57848. */
  57849. getBodyPressure(impostor: PhysicsImpostor): number;
  57850. /**
  57851. * Sets pressure inside a soft body impostor
  57852. * Cloth and rope must remain 0 pressure
  57853. * @param impostor impostor to set pressure on
  57854. * @param pressure pressure value
  57855. */
  57856. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57857. /**
  57858. * Gets stiffness of the impostor
  57859. * @param impostor impostor to get stiffness from
  57860. * @returns pressure value
  57861. */
  57862. getBodyStiffness(impostor: PhysicsImpostor): number;
  57863. /**
  57864. * Sets stiffness of the impostor
  57865. * @param impostor impostor to set stiffness on
  57866. * @param stiffness stiffness value from 0 to 1
  57867. */
  57868. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57869. /**
  57870. * Gets velocityIterations of the impostor
  57871. * @param impostor impostor to get velocity iterations from
  57872. * @returns velocityIterations value
  57873. */
  57874. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57875. /**
  57876. * Sets velocityIterations of the impostor
  57877. * @param impostor impostor to set velocity iterations on
  57878. * @param velocityIterations velocityIterations value
  57879. */
  57880. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57881. /**
  57882. * Gets positionIterations of the impostor
  57883. * @param impostor impostor to get position iterations from
  57884. * @returns positionIterations value
  57885. */
  57886. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57887. /**
  57888. * Sets positionIterations of the impostor
  57889. * @param impostor impostor to set position on
  57890. * @param positionIterations positionIterations value
  57891. */
  57892. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57893. /**
  57894. * Append an anchor to a cloth object
  57895. * @param impostor is the cloth impostor to add anchor to
  57896. * @param otherImpostor is the rigid impostor to anchor to
  57897. * @param width ratio across width from 0 to 1
  57898. * @param height ratio up height from 0 to 1
  57899. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57900. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57901. */
  57902. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57903. /**
  57904. * Append an hook to a rope object
  57905. * @param impostor is the rope impostor to add hook to
  57906. * @param otherImpostor is the rigid impostor to hook to
  57907. * @param length ratio along the rope from 0 to 1
  57908. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57909. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57910. */
  57911. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57912. /**
  57913. * Sleeps the physics body and stops it from being active
  57914. * @param impostor impostor to sleep
  57915. */
  57916. sleepBody(impostor: PhysicsImpostor): void;
  57917. /**
  57918. * Activates the physics body
  57919. * @param impostor impostor to activate
  57920. */
  57921. wakeUpBody(impostor: PhysicsImpostor): void;
  57922. /**
  57923. * Updates the distance parameters of the joint
  57924. * @param joint joint to update
  57925. * @param maxDistance maximum distance of the joint
  57926. * @param minDistance minimum distance of the joint
  57927. */
  57928. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57929. /**
  57930. * Sets a motor on the joint
  57931. * @param joint joint to set motor on
  57932. * @param speed speed of the motor
  57933. * @param maxForce maximum force of the motor
  57934. * @param motorIndex index of the motor
  57935. */
  57936. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57937. /**
  57938. * Sets the motors limit
  57939. * @param joint joint to set limit on
  57940. * @param upperLimit upper limit
  57941. * @param lowerLimit lower limit
  57942. */
  57943. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57944. /**
  57945. * Syncs the position and rotation of a mesh with the impostor
  57946. * @param mesh mesh to sync
  57947. * @param impostor impostor to update the mesh with
  57948. */
  57949. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57950. /**
  57951. * Gets the radius of the impostor
  57952. * @param impostor impostor to get radius from
  57953. * @returns the radius
  57954. */
  57955. getRadius(impostor: PhysicsImpostor): number;
  57956. /**
  57957. * Gets the box size of the impostor
  57958. * @param impostor impostor to get box size from
  57959. * @param result the resulting box size
  57960. */
  57961. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57962. /**
  57963. * Disposes of the impostor
  57964. */
  57965. dispose(): void;
  57966. /**
  57967. * Does a raycast in the physics world
  57968. * @param from when should the ray start?
  57969. * @param to when should the ray end?
  57970. * @returns PhysicsRaycastResult
  57971. */
  57972. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57973. }
  57974. }
  57975. declare module "babylonjs/Probes/reflectionProbe" {
  57976. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57977. import { Vector3 } from "babylonjs/Maths/math.vector";
  57978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57979. import { Nullable } from "babylonjs/types";
  57980. import { Scene } from "babylonjs/scene";
  57981. module "babylonjs/abstractScene" {
  57982. interface AbstractScene {
  57983. /**
  57984. * The list of reflection probes added to the scene
  57985. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57986. */
  57987. reflectionProbes: Array<ReflectionProbe>;
  57988. /**
  57989. * Removes the given reflection probe from this scene.
  57990. * @param toRemove The reflection probe to remove
  57991. * @returns The index of the removed reflection probe
  57992. */
  57993. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57994. /**
  57995. * Adds the given reflection probe to this scene.
  57996. * @param newReflectionProbe The reflection probe to add
  57997. */
  57998. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57999. }
  58000. }
  58001. /**
  58002. * Class used to generate realtime reflection / refraction cube textures
  58003. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58004. */
  58005. export class ReflectionProbe {
  58006. /** defines the name of the probe */
  58007. name: string;
  58008. private _scene;
  58009. private _renderTargetTexture;
  58010. private _projectionMatrix;
  58011. private _viewMatrix;
  58012. private _target;
  58013. private _add;
  58014. private _attachedMesh;
  58015. private _invertYAxis;
  58016. /** Gets or sets probe position (center of the cube map) */
  58017. position: Vector3;
  58018. /**
  58019. * Creates a new reflection probe
  58020. * @param name defines the name of the probe
  58021. * @param size defines the texture resolution (for each face)
  58022. * @param scene defines the hosting scene
  58023. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58024. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58025. */
  58026. constructor(
  58027. /** defines the name of the probe */
  58028. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58029. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58030. get samples(): number;
  58031. set samples(value: number);
  58032. /** Gets or sets the refresh rate to use (on every frame by default) */
  58033. get refreshRate(): number;
  58034. set refreshRate(value: number);
  58035. /**
  58036. * Gets the hosting scene
  58037. * @returns a Scene
  58038. */
  58039. getScene(): Scene;
  58040. /** Gets the internal CubeTexture used to render to */
  58041. get cubeTexture(): RenderTargetTexture;
  58042. /** Gets the list of meshes to render */
  58043. get renderList(): Nullable<AbstractMesh[]>;
  58044. /**
  58045. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58046. * @param mesh defines the mesh to attach to
  58047. */
  58048. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58049. /**
  58050. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58051. * @param renderingGroupId The rendering group id corresponding to its index
  58052. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58053. */
  58054. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58055. /**
  58056. * Clean all associated resources
  58057. */
  58058. dispose(): void;
  58059. /**
  58060. * Converts the reflection probe information to a readable string for debug purpose.
  58061. * @param fullDetails Supports for multiple levels of logging within scene loading
  58062. * @returns the human readable reflection probe info
  58063. */
  58064. toString(fullDetails?: boolean): string;
  58065. /**
  58066. * Get the class name of the relfection probe.
  58067. * @returns "ReflectionProbe"
  58068. */
  58069. getClassName(): string;
  58070. /**
  58071. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58072. * @returns The JSON representation of the texture
  58073. */
  58074. serialize(): any;
  58075. /**
  58076. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58077. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58078. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58079. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58080. * @returns The parsed reflection probe if successful
  58081. */
  58082. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58083. }
  58084. }
  58085. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58086. /** @hidden */
  58087. export var _BabylonLoaderRegistered: boolean;
  58088. /**
  58089. * Helps setting up some configuration for the babylon file loader.
  58090. */
  58091. export class BabylonFileLoaderConfiguration {
  58092. /**
  58093. * The loader does not allow injecting custom physix engine into the plugins.
  58094. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58095. * So you could set this variable to your engine import to make it work.
  58096. */
  58097. static LoaderInjectedPhysicsEngine: any;
  58098. }
  58099. }
  58100. declare module "babylonjs/Loading/Plugins/index" {
  58101. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58102. }
  58103. declare module "babylonjs/Loading/index" {
  58104. export * from "babylonjs/Loading/loadingScreen";
  58105. export * from "babylonjs/Loading/Plugins/index";
  58106. export * from "babylonjs/Loading/sceneLoader";
  58107. export * from "babylonjs/Loading/sceneLoaderFlags";
  58108. }
  58109. declare module "babylonjs/Materials/Background/index" {
  58110. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58111. }
  58112. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58113. import { Scene } from "babylonjs/scene";
  58114. import { Color3 } from "babylonjs/Maths/math.color";
  58115. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58117. /**
  58118. * The Physically based simple base material of BJS.
  58119. *
  58120. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58121. * It is used as the base class for both the specGloss and metalRough conventions.
  58122. */
  58123. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58124. /**
  58125. * Number of Simultaneous lights allowed on the material.
  58126. */
  58127. maxSimultaneousLights: number;
  58128. /**
  58129. * If sets to true, disables all the lights affecting the material.
  58130. */
  58131. disableLighting: boolean;
  58132. /**
  58133. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58134. */
  58135. environmentTexture: BaseTexture;
  58136. /**
  58137. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58138. */
  58139. invertNormalMapX: boolean;
  58140. /**
  58141. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58142. */
  58143. invertNormalMapY: boolean;
  58144. /**
  58145. * Normal map used in the model.
  58146. */
  58147. normalTexture: BaseTexture;
  58148. /**
  58149. * Emissivie color used to self-illuminate the model.
  58150. */
  58151. emissiveColor: Color3;
  58152. /**
  58153. * Emissivie texture used to self-illuminate the model.
  58154. */
  58155. emissiveTexture: BaseTexture;
  58156. /**
  58157. * Occlusion Channel Strenght.
  58158. */
  58159. occlusionStrength: number;
  58160. /**
  58161. * Occlusion Texture of the material (adding extra occlusion effects).
  58162. */
  58163. occlusionTexture: BaseTexture;
  58164. /**
  58165. * Defines the alpha limits in alpha test mode.
  58166. */
  58167. alphaCutOff: number;
  58168. /**
  58169. * Gets the current double sided mode.
  58170. */
  58171. get doubleSided(): boolean;
  58172. /**
  58173. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58174. */
  58175. set doubleSided(value: boolean);
  58176. /**
  58177. * Stores the pre-calculated light information of a mesh in a texture.
  58178. */
  58179. lightmapTexture: BaseTexture;
  58180. /**
  58181. * If true, the light map contains occlusion information instead of lighting info.
  58182. */
  58183. useLightmapAsShadowmap: boolean;
  58184. /**
  58185. * Instantiates a new PBRMaterial instance.
  58186. *
  58187. * @param name The material name
  58188. * @param scene The scene the material will be use in.
  58189. */
  58190. constructor(name: string, scene: Scene);
  58191. getClassName(): string;
  58192. }
  58193. }
  58194. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58195. import { Scene } from "babylonjs/scene";
  58196. import { Color3 } from "babylonjs/Maths/math.color";
  58197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58198. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58199. /**
  58200. * The PBR material of BJS following the metal roughness convention.
  58201. *
  58202. * This fits to the PBR convention in the GLTF definition:
  58203. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58204. */
  58205. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58206. /**
  58207. * The base color has two different interpretations depending on the value of metalness.
  58208. * When the material is a metal, the base color is the specific measured reflectance value
  58209. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58210. * of the material.
  58211. */
  58212. baseColor: Color3;
  58213. /**
  58214. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58215. * well as opacity information in the alpha channel.
  58216. */
  58217. baseTexture: BaseTexture;
  58218. /**
  58219. * Specifies the metallic scalar value of the material.
  58220. * Can also be used to scale the metalness values of the metallic texture.
  58221. */
  58222. metallic: number;
  58223. /**
  58224. * Specifies the roughness scalar value of the material.
  58225. * Can also be used to scale the roughness values of the metallic texture.
  58226. */
  58227. roughness: number;
  58228. /**
  58229. * Texture containing both the metallic value in the B channel and the
  58230. * roughness value in the G channel to keep better precision.
  58231. */
  58232. metallicRoughnessTexture: BaseTexture;
  58233. /**
  58234. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58235. *
  58236. * @param name The material name
  58237. * @param scene The scene the material will be use in.
  58238. */
  58239. constructor(name: string, scene: Scene);
  58240. /**
  58241. * Return the currrent class name of the material.
  58242. */
  58243. getClassName(): string;
  58244. /**
  58245. * Makes a duplicate of the current material.
  58246. * @param name - name to use for the new material.
  58247. */
  58248. clone(name: string): PBRMetallicRoughnessMaterial;
  58249. /**
  58250. * Serialize the material to a parsable JSON object.
  58251. */
  58252. serialize(): any;
  58253. /**
  58254. * Parses a JSON object correponding to the serialize function.
  58255. */
  58256. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58257. }
  58258. }
  58259. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58260. import { Scene } from "babylonjs/scene";
  58261. import { Color3 } from "babylonjs/Maths/math.color";
  58262. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58263. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58264. /**
  58265. * The PBR material of BJS following the specular glossiness convention.
  58266. *
  58267. * This fits to the PBR convention in the GLTF definition:
  58268. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58269. */
  58270. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58271. /**
  58272. * Specifies the diffuse color of the material.
  58273. */
  58274. diffuseColor: Color3;
  58275. /**
  58276. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58277. * channel.
  58278. */
  58279. diffuseTexture: BaseTexture;
  58280. /**
  58281. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58282. */
  58283. specularColor: Color3;
  58284. /**
  58285. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58286. */
  58287. glossiness: number;
  58288. /**
  58289. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58290. */
  58291. specularGlossinessTexture: BaseTexture;
  58292. /**
  58293. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58294. *
  58295. * @param name The material name
  58296. * @param scene The scene the material will be use in.
  58297. */
  58298. constructor(name: string, scene: Scene);
  58299. /**
  58300. * Return the currrent class name of the material.
  58301. */
  58302. getClassName(): string;
  58303. /**
  58304. * Makes a duplicate of the current material.
  58305. * @param name - name to use for the new material.
  58306. */
  58307. clone(name: string): PBRSpecularGlossinessMaterial;
  58308. /**
  58309. * Serialize the material to a parsable JSON object.
  58310. */
  58311. serialize(): any;
  58312. /**
  58313. * Parses a JSON object correponding to the serialize function.
  58314. */
  58315. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58316. }
  58317. }
  58318. declare module "babylonjs/Materials/PBR/index" {
  58319. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58320. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58321. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58322. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58323. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58324. }
  58325. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58326. import { Nullable } from "babylonjs/types";
  58327. import { Scene } from "babylonjs/scene";
  58328. import { Matrix } from "babylonjs/Maths/math.vector";
  58329. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58330. /**
  58331. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58332. * It can help converting any input color in a desired output one. This can then be used to create effects
  58333. * from sepia, black and white to sixties or futuristic rendering...
  58334. *
  58335. * The only supported format is currently 3dl.
  58336. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58337. */
  58338. export class ColorGradingTexture extends BaseTexture {
  58339. /**
  58340. * The current texture matrix. (will always be identity in color grading texture)
  58341. */
  58342. private _textureMatrix;
  58343. /**
  58344. * The texture URL.
  58345. */
  58346. url: string;
  58347. /**
  58348. * Empty line regex stored for GC.
  58349. */
  58350. private static _noneEmptyLineRegex;
  58351. private _engine;
  58352. /**
  58353. * Instantiates a ColorGradingTexture from the following parameters.
  58354. *
  58355. * @param url The location of the color gradind data (currently only supporting 3dl)
  58356. * @param scene The scene the texture will be used in
  58357. */
  58358. constructor(url: string, scene: Scene);
  58359. /**
  58360. * Returns the texture matrix used in most of the material.
  58361. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58362. */
  58363. getTextureMatrix(): Matrix;
  58364. /**
  58365. * Occurs when the file being loaded is a .3dl LUT file.
  58366. */
  58367. private load3dlTexture;
  58368. /**
  58369. * Starts the loading process of the texture.
  58370. */
  58371. private loadTexture;
  58372. /**
  58373. * Clones the color gradind texture.
  58374. */
  58375. clone(): ColorGradingTexture;
  58376. /**
  58377. * Called during delayed load for textures.
  58378. */
  58379. delayLoad(): void;
  58380. /**
  58381. * Parses a color grading texture serialized by Babylon.
  58382. * @param parsedTexture The texture information being parsedTexture
  58383. * @param scene The scene to load the texture in
  58384. * @param rootUrl The root url of the data assets to load
  58385. * @return A color gradind texture
  58386. */
  58387. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58388. /**
  58389. * Serializes the LUT texture to json format.
  58390. */
  58391. serialize(): any;
  58392. }
  58393. }
  58394. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58395. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58396. import { Scene } from "babylonjs/scene";
  58397. import { Nullable } from "babylonjs/types";
  58398. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58399. /**
  58400. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58401. */
  58402. export class EquiRectangularCubeTexture extends BaseTexture {
  58403. /** The six faces of the cube. */
  58404. private static _FacesMapping;
  58405. private _noMipmap;
  58406. private _onLoad;
  58407. private _onError;
  58408. /** The size of the cubemap. */
  58409. private _size;
  58410. /** The buffer of the image. */
  58411. private _buffer;
  58412. /** The width of the input image. */
  58413. private _width;
  58414. /** The height of the input image. */
  58415. private _height;
  58416. /** The URL to the image. */
  58417. url: string;
  58418. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58419. coordinatesMode: number;
  58420. /**
  58421. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58422. * @param url The location of the image
  58423. * @param scene The scene the texture will be used in
  58424. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58425. * @param noMipmap Forces to not generate the mipmap if true
  58426. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58427. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58428. * @param onLoad — defines a callback called when texture is loaded
  58429. * @param onError — defines a callback called if there is an error
  58430. */
  58431. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58432. /**
  58433. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58434. */
  58435. private loadImage;
  58436. /**
  58437. * Convert the image buffer into a cubemap and create a CubeTexture.
  58438. */
  58439. private loadTexture;
  58440. /**
  58441. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58442. * @param buffer The ArrayBuffer that should be converted.
  58443. * @returns The buffer as Float32Array.
  58444. */
  58445. private getFloat32ArrayFromArrayBuffer;
  58446. /**
  58447. * Get the current class name of the texture useful for serialization or dynamic coding.
  58448. * @returns "EquiRectangularCubeTexture"
  58449. */
  58450. getClassName(): string;
  58451. /**
  58452. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58453. * @returns A clone of the current EquiRectangularCubeTexture.
  58454. */
  58455. clone(): EquiRectangularCubeTexture;
  58456. }
  58457. }
  58458. declare module "babylonjs/Misc/tga" {
  58459. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58460. /**
  58461. * Based on jsTGALoader - Javascript loader for TGA file
  58462. * By Vincent Thibault
  58463. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58464. */
  58465. export class TGATools {
  58466. private static _TYPE_INDEXED;
  58467. private static _TYPE_RGB;
  58468. private static _TYPE_GREY;
  58469. private static _TYPE_RLE_INDEXED;
  58470. private static _TYPE_RLE_RGB;
  58471. private static _TYPE_RLE_GREY;
  58472. private static _ORIGIN_MASK;
  58473. private static _ORIGIN_SHIFT;
  58474. private static _ORIGIN_BL;
  58475. private static _ORIGIN_BR;
  58476. private static _ORIGIN_UL;
  58477. private static _ORIGIN_UR;
  58478. /**
  58479. * Gets the header of a TGA file
  58480. * @param data defines the TGA data
  58481. * @returns the header
  58482. */
  58483. static GetTGAHeader(data: Uint8Array): any;
  58484. /**
  58485. * Uploads TGA content to a Babylon Texture
  58486. * @hidden
  58487. */
  58488. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58489. /** @hidden */
  58490. 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;
  58491. /** @hidden */
  58492. 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;
  58493. /** @hidden */
  58494. 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;
  58495. /** @hidden */
  58496. 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;
  58497. /** @hidden */
  58498. 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;
  58499. /** @hidden */
  58500. 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;
  58501. }
  58502. }
  58503. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58504. import { Nullable } from "babylonjs/types";
  58505. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58506. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58507. /**
  58508. * Implementation of the TGA Texture Loader.
  58509. * @hidden
  58510. */
  58511. export class _TGATextureLoader implements IInternalTextureLoader {
  58512. /**
  58513. * Defines wether the loader supports cascade loading the different faces.
  58514. */
  58515. readonly supportCascades: boolean;
  58516. /**
  58517. * This returns if the loader support the current file information.
  58518. * @param extension defines the file extension of the file being loaded
  58519. * @returns true if the loader can load the specified file
  58520. */
  58521. canLoad(extension: string): boolean;
  58522. /**
  58523. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58524. * @param data contains the texture data
  58525. * @param texture defines the BabylonJS internal texture
  58526. * @param createPolynomials will be true if polynomials have been requested
  58527. * @param onLoad defines the callback to trigger once the texture is ready
  58528. * @param onError defines the callback to trigger in case of error
  58529. */
  58530. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58531. /**
  58532. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58533. * @param data contains the texture data
  58534. * @param texture defines the BabylonJS internal texture
  58535. * @param callback defines the method to call once ready to upload
  58536. */
  58537. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58538. }
  58539. }
  58540. declare module "babylonjs/Misc/basis" {
  58541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58542. /**
  58543. * Info about the .basis files
  58544. */
  58545. class BasisFileInfo {
  58546. /**
  58547. * If the file has alpha
  58548. */
  58549. hasAlpha: boolean;
  58550. /**
  58551. * Info about each image of the basis file
  58552. */
  58553. images: Array<{
  58554. levels: Array<{
  58555. width: number;
  58556. height: number;
  58557. transcodedPixels: ArrayBufferView;
  58558. }>;
  58559. }>;
  58560. }
  58561. /**
  58562. * Result of transcoding a basis file
  58563. */
  58564. class TranscodeResult {
  58565. /**
  58566. * Info about the .basis file
  58567. */
  58568. fileInfo: BasisFileInfo;
  58569. /**
  58570. * Format to use when loading the file
  58571. */
  58572. format: number;
  58573. }
  58574. /**
  58575. * Configuration options for the Basis transcoder
  58576. */
  58577. export class BasisTranscodeConfiguration {
  58578. /**
  58579. * Supported compression formats used to determine the supported output format of the transcoder
  58580. */
  58581. supportedCompressionFormats?: {
  58582. /**
  58583. * etc1 compression format
  58584. */
  58585. etc1?: boolean;
  58586. /**
  58587. * s3tc compression format
  58588. */
  58589. s3tc?: boolean;
  58590. /**
  58591. * pvrtc compression format
  58592. */
  58593. pvrtc?: boolean;
  58594. /**
  58595. * etc2 compression format
  58596. */
  58597. etc2?: boolean;
  58598. };
  58599. /**
  58600. * If mipmap levels should be loaded for transcoded images (Default: true)
  58601. */
  58602. loadMipmapLevels?: boolean;
  58603. /**
  58604. * Index of a single image to load (Default: all images)
  58605. */
  58606. loadSingleImage?: number;
  58607. }
  58608. /**
  58609. * Used to load .Basis files
  58610. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58611. */
  58612. export class BasisTools {
  58613. private static _IgnoreSupportedFormats;
  58614. /**
  58615. * URL to use when loading the basis transcoder
  58616. */
  58617. static JSModuleURL: string;
  58618. /**
  58619. * URL to use when loading the wasm module for the transcoder
  58620. */
  58621. static WasmModuleURL: string;
  58622. /**
  58623. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58624. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58625. * @returns internal format corresponding to the Basis format
  58626. */
  58627. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58628. private static _WorkerPromise;
  58629. private static _Worker;
  58630. private static _actionId;
  58631. private static _CreateWorkerAsync;
  58632. /**
  58633. * Transcodes a loaded image file to compressed pixel data
  58634. * @param data image data to transcode
  58635. * @param config configuration options for the transcoding
  58636. * @returns a promise resulting in the transcoded image
  58637. */
  58638. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58639. /**
  58640. * Loads a texture from the transcode result
  58641. * @param texture texture load to
  58642. * @param transcodeResult the result of transcoding the basis file to load from
  58643. */
  58644. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58645. }
  58646. }
  58647. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58648. import { Nullable } from "babylonjs/types";
  58649. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58650. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58651. /**
  58652. * Loader for .basis file format
  58653. */
  58654. export class _BasisTextureLoader implements IInternalTextureLoader {
  58655. /**
  58656. * Defines whether the loader supports cascade loading the different faces.
  58657. */
  58658. readonly supportCascades: boolean;
  58659. /**
  58660. * This returns if the loader support the current file information.
  58661. * @param extension defines the file extension of the file being loaded
  58662. * @returns true if the loader can load the specified file
  58663. */
  58664. canLoad(extension: string): boolean;
  58665. /**
  58666. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58667. * @param data contains the texture data
  58668. * @param texture defines the BabylonJS internal texture
  58669. * @param createPolynomials will be true if polynomials have been requested
  58670. * @param onLoad defines the callback to trigger once the texture is ready
  58671. * @param onError defines the callback to trigger in case of error
  58672. */
  58673. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58674. /**
  58675. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58676. * @param data contains the texture data
  58677. * @param texture defines the BabylonJS internal texture
  58678. * @param callback defines the method to call once ready to upload
  58679. */
  58680. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58681. }
  58682. }
  58683. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58684. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58685. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58686. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58687. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58688. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58689. }
  58690. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58691. import { Scene } from "babylonjs/scene";
  58692. import { Texture } from "babylonjs/Materials/Textures/texture";
  58693. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58694. /**
  58695. * 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.
  58696. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58697. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58698. */
  58699. export class CustomProceduralTexture extends ProceduralTexture {
  58700. private _animate;
  58701. private _time;
  58702. private _config;
  58703. private _texturePath;
  58704. /**
  58705. * Instantiates a new Custom Procedural Texture.
  58706. * 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.
  58707. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58708. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58709. * @param name Define the name of the texture
  58710. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58711. * @param size Define the size of the texture to create
  58712. * @param scene Define the scene the texture belongs to
  58713. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58714. * @param generateMipMaps Define if the texture should creates mip maps or not
  58715. */
  58716. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58717. private _loadJson;
  58718. /**
  58719. * Is the texture ready to be used ? (rendered at least once)
  58720. * @returns true if ready, otherwise, false.
  58721. */
  58722. isReady(): boolean;
  58723. /**
  58724. * Render the texture to its associated render target.
  58725. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58726. */
  58727. render(useCameraPostProcess?: boolean): void;
  58728. /**
  58729. * Update the list of dependant textures samplers in the shader.
  58730. */
  58731. updateTextures(): void;
  58732. /**
  58733. * Update the uniform values of the procedural texture in the shader.
  58734. */
  58735. updateShaderUniforms(): void;
  58736. /**
  58737. * Define if the texture animates or not.
  58738. */
  58739. get animate(): boolean;
  58740. set animate(value: boolean);
  58741. }
  58742. }
  58743. declare module "babylonjs/Shaders/noise.fragment" {
  58744. /** @hidden */
  58745. export var noisePixelShader: {
  58746. name: string;
  58747. shader: string;
  58748. };
  58749. }
  58750. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58751. import { Nullable } from "babylonjs/types";
  58752. import { Scene } from "babylonjs/scene";
  58753. import { Texture } from "babylonjs/Materials/Textures/texture";
  58754. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58755. import "babylonjs/Shaders/noise.fragment";
  58756. /**
  58757. * Class used to generate noise procedural textures
  58758. */
  58759. export class NoiseProceduralTexture extends ProceduralTexture {
  58760. private _time;
  58761. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58762. brightness: number;
  58763. /** Defines the number of octaves to process */
  58764. octaves: number;
  58765. /** Defines the level of persistence (0.8 by default) */
  58766. persistence: number;
  58767. /** Gets or sets animation speed factor (default is 1) */
  58768. animationSpeedFactor: number;
  58769. /**
  58770. * Creates a new NoiseProceduralTexture
  58771. * @param name defines the name fo the texture
  58772. * @param size defines the size of the texture (default is 256)
  58773. * @param scene defines the hosting scene
  58774. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58775. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58776. */
  58777. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58778. private _updateShaderUniforms;
  58779. protected _getDefines(): string;
  58780. /** Generate the current state of the procedural texture */
  58781. render(useCameraPostProcess?: boolean): void;
  58782. /**
  58783. * Serializes this noise procedural texture
  58784. * @returns a serialized noise procedural texture object
  58785. */
  58786. serialize(): any;
  58787. /**
  58788. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58789. * @param parsedTexture defines parsed texture data
  58790. * @param scene defines the current scene
  58791. * @param rootUrl defines the root URL containing noise procedural texture information
  58792. * @returns a parsed NoiseProceduralTexture
  58793. */
  58794. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58795. }
  58796. }
  58797. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58798. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58799. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58800. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58801. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58802. }
  58803. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58804. import { Nullable } from "babylonjs/types";
  58805. import { Scene } from "babylonjs/scene";
  58806. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58807. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58808. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58809. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58810. /**
  58811. * Raw cube texture where the raw buffers are passed in
  58812. */
  58813. export class RawCubeTexture extends CubeTexture {
  58814. /**
  58815. * Creates a cube texture where the raw buffers are passed in.
  58816. * @param scene defines the scene the texture is attached to
  58817. * @param data defines the array of data to use to create each face
  58818. * @param size defines the size of the textures
  58819. * @param format defines the format of the data
  58820. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58821. * @param generateMipMaps defines if the engine should generate the mip levels
  58822. * @param invertY defines if data must be stored with Y axis inverted
  58823. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58824. * @param compression defines the compression used (null by default)
  58825. */
  58826. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58827. /**
  58828. * Updates the raw cube texture.
  58829. * @param data defines the data to store
  58830. * @param format defines the data format
  58831. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58832. * @param invertY defines if data must be stored with Y axis inverted
  58833. * @param compression defines the compression used (null by default)
  58834. * @param level defines which level of the texture to update
  58835. */
  58836. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58837. /**
  58838. * Updates a raw cube texture with RGBD encoded data.
  58839. * @param data defines the array of data [mipmap][face] to use to create each face
  58840. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58841. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58842. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58843. * @returns a promsie that resolves when the operation is complete
  58844. */
  58845. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58846. /**
  58847. * Clones the raw cube texture.
  58848. * @return a new cube texture
  58849. */
  58850. clone(): CubeTexture;
  58851. /** @hidden */
  58852. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58853. }
  58854. }
  58855. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58856. import { Scene } from "babylonjs/scene";
  58857. import { Texture } from "babylonjs/Materials/Textures/texture";
  58858. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58859. /**
  58860. * Class used to store 3D textures containing user data
  58861. */
  58862. export class RawTexture3D extends Texture {
  58863. /** Gets or sets the texture format to use */
  58864. format: number;
  58865. private _engine;
  58866. /**
  58867. * Create a new RawTexture3D
  58868. * @param data defines the data of the texture
  58869. * @param width defines the width of the texture
  58870. * @param height defines the height of the texture
  58871. * @param depth defines the depth of the texture
  58872. * @param format defines the texture format to use
  58873. * @param scene defines the hosting scene
  58874. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58875. * @param invertY defines if texture must be stored with Y axis inverted
  58876. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58877. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58878. */
  58879. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58880. /** Gets or sets the texture format to use */
  58881. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58882. /**
  58883. * Update the texture with new data
  58884. * @param data defines the data to store in the texture
  58885. */
  58886. update(data: ArrayBufferView): void;
  58887. }
  58888. }
  58889. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58890. import { Scene } from "babylonjs/scene";
  58891. import { Texture } from "babylonjs/Materials/Textures/texture";
  58892. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58893. /**
  58894. * Class used to store 2D array textures containing user data
  58895. */
  58896. export class RawTexture2DArray extends Texture {
  58897. /** Gets or sets the texture format to use */
  58898. format: number;
  58899. private _engine;
  58900. /**
  58901. * Create a new RawTexture2DArray
  58902. * @param data defines the data of the texture
  58903. * @param width defines the width of the texture
  58904. * @param height defines the height of the texture
  58905. * @param depth defines the number of layers of the texture
  58906. * @param format defines the texture format to use
  58907. * @param scene defines the hosting scene
  58908. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58909. * @param invertY defines if texture must be stored with Y axis inverted
  58910. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58911. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58912. */
  58913. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58914. /** Gets or sets the texture format to use */
  58915. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58916. /**
  58917. * Update the texture with new data
  58918. * @param data defines the data to store in the texture
  58919. */
  58920. update(data: ArrayBufferView): void;
  58921. }
  58922. }
  58923. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58924. import { Scene } from "babylonjs/scene";
  58925. import { Plane } from "babylonjs/Maths/math.plane";
  58926. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58927. /**
  58928. * Creates a refraction texture used by refraction channel of the standard material.
  58929. * It is like a mirror but to see through a material.
  58930. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58931. */
  58932. export class RefractionTexture extends RenderTargetTexture {
  58933. /**
  58934. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58935. * 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.
  58936. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58937. */
  58938. refractionPlane: Plane;
  58939. /**
  58940. * Define how deep under the surface we should see.
  58941. */
  58942. depth: number;
  58943. /**
  58944. * Creates a refraction texture used by refraction channel of the standard material.
  58945. * It is like a mirror but to see through a material.
  58946. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58947. * @param name Define the texture name
  58948. * @param size Define the size of the underlying texture
  58949. * @param scene Define the scene the refraction belongs to
  58950. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58951. */
  58952. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58953. /**
  58954. * Clone the refraction texture.
  58955. * @returns the cloned texture
  58956. */
  58957. clone(): RefractionTexture;
  58958. /**
  58959. * Serialize the texture to a JSON representation you could use in Parse later on
  58960. * @returns the serialized JSON representation
  58961. */
  58962. serialize(): any;
  58963. }
  58964. }
  58965. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58966. import { Nullable } from "babylonjs/types";
  58967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58968. import { Matrix } from "babylonjs/Maths/math.vector";
  58969. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58970. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58971. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58972. import { Scene } from "babylonjs/scene";
  58973. /**
  58974. * Defines the options related to the creation of an HtmlElementTexture
  58975. */
  58976. export interface IHtmlElementTextureOptions {
  58977. /**
  58978. * Defines wether mip maps should be created or not.
  58979. */
  58980. generateMipMaps?: boolean;
  58981. /**
  58982. * Defines the sampling mode of the texture.
  58983. */
  58984. samplingMode?: number;
  58985. /**
  58986. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58987. */
  58988. engine: Nullable<ThinEngine>;
  58989. /**
  58990. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58991. */
  58992. scene: Nullable<Scene>;
  58993. }
  58994. /**
  58995. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58996. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58997. * is automatically managed.
  58998. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58999. * in your application.
  59000. *
  59001. * As the update is not automatic, you need to call them manually.
  59002. */
  59003. export class HtmlElementTexture extends BaseTexture {
  59004. /**
  59005. * The texture URL.
  59006. */
  59007. element: HTMLVideoElement | HTMLCanvasElement;
  59008. private static readonly DefaultOptions;
  59009. private _textureMatrix;
  59010. private _engine;
  59011. private _isVideo;
  59012. private _generateMipMaps;
  59013. private _samplingMode;
  59014. /**
  59015. * Instantiates a HtmlElementTexture from the following parameters.
  59016. *
  59017. * @param name Defines the name of the texture
  59018. * @param element Defines the video or canvas the texture is filled with
  59019. * @param options Defines the other none mandatory texture creation options
  59020. */
  59021. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59022. private _createInternalTexture;
  59023. /**
  59024. * Returns the texture matrix used in most of the material.
  59025. */
  59026. getTextureMatrix(): Matrix;
  59027. /**
  59028. * Updates the content of the texture.
  59029. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59030. */
  59031. update(invertY?: Nullable<boolean>): void;
  59032. }
  59033. }
  59034. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59035. import { Vector2 } from "babylonjs/Maths/math.vector";
  59036. /**
  59037. * Defines the basic options interface of a TexturePacker Frame
  59038. */
  59039. export interface ITexturePackerFrame {
  59040. /**
  59041. * The frame ID
  59042. */
  59043. id: number;
  59044. /**
  59045. * The frames Scale
  59046. */
  59047. scale: Vector2;
  59048. /**
  59049. * The Frames offset
  59050. */
  59051. offset: Vector2;
  59052. }
  59053. /**
  59054. * This is a support class for frame Data on texture packer sets.
  59055. */
  59056. export class TexturePackerFrame implements ITexturePackerFrame {
  59057. /**
  59058. * The frame ID
  59059. */
  59060. id: number;
  59061. /**
  59062. * The frames Scale
  59063. */
  59064. scale: Vector2;
  59065. /**
  59066. * The Frames offset
  59067. */
  59068. offset: Vector2;
  59069. /**
  59070. * Initializes a texture package frame.
  59071. * @param id The numerical frame identifier
  59072. * @param scale Scalar Vector2 for UV frame
  59073. * @param offset Vector2 for the frame position in UV units.
  59074. * @returns TexturePackerFrame
  59075. */
  59076. constructor(id: number, scale: Vector2, offset: Vector2);
  59077. }
  59078. }
  59079. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59081. import { Scene } from "babylonjs/scene";
  59082. import { Nullable } from "babylonjs/types";
  59083. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59084. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59085. /**
  59086. * Defines the basic options interface of a TexturePacker
  59087. */
  59088. export interface ITexturePackerOptions {
  59089. /**
  59090. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59091. */
  59092. map?: string[];
  59093. /**
  59094. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59095. */
  59096. uvsIn?: string;
  59097. /**
  59098. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59099. */
  59100. uvsOut?: string;
  59101. /**
  59102. * number representing the layout style. Defaults to LAYOUT_STRIP
  59103. */
  59104. layout?: number;
  59105. /**
  59106. * number of columns if using custom column count layout(2). This defaults to 4.
  59107. */
  59108. colnum?: number;
  59109. /**
  59110. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59111. */
  59112. updateInputMeshes?: boolean;
  59113. /**
  59114. * boolean flag to dispose all the source textures. Defaults to true.
  59115. */
  59116. disposeSources?: boolean;
  59117. /**
  59118. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59119. */
  59120. fillBlanks?: boolean;
  59121. /**
  59122. * string value representing the context fill style color. Defaults to 'black'.
  59123. */
  59124. customFillColor?: string;
  59125. /**
  59126. * Width and Height Value of each Frame in the TexturePacker Sets
  59127. */
  59128. frameSize?: number;
  59129. /**
  59130. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59131. */
  59132. paddingRatio?: number;
  59133. /**
  59134. * Number that declares the fill method for the padding gutter.
  59135. */
  59136. paddingMode?: number;
  59137. /**
  59138. * If in SUBUV_COLOR padding mode what color to use.
  59139. */
  59140. paddingColor?: Color3 | Color4;
  59141. }
  59142. /**
  59143. * Defines the basic interface of a TexturePacker JSON File
  59144. */
  59145. export interface ITexturePackerJSON {
  59146. /**
  59147. * The frame ID
  59148. */
  59149. name: string;
  59150. /**
  59151. * The base64 channel data
  59152. */
  59153. sets: any;
  59154. /**
  59155. * The options of the Packer
  59156. */
  59157. options: ITexturePackerOptions;
  59158. /**
  59159. * The frame data of the Packer
  59160. */
  59161. frames: Array<number>;
  59162. }
  59163. /**
  59164. * This is a support class that generates a series of packed texture sets.
  59165. * @see https://doc.babylonjs.com/babylon101/materials
  59166. */
  59167. export class TexturePacker {
  59168. /** Packer Layout Constant 0 */
  59169. static readonly LAYOUT_STRIP: number;
  59170. /** Packer Layout Constant 1 */
  59171. static readonly LAYOUT_POWER2: number;
  59172. /** Packer Layout Constant 2 */
  59173. static readonly LAYOUT_COLNUM: number;
  59174. /** Packer Layout Constant 0 */
  59175. static readonly SUBUV_WRAP: number;
  59176. /** Packer Layout Constant 1 */
  59177. static readonly SUBUV_EXTEND: number;
  59178. /** Packer Layout Constant 2 */
  59179. static readonly SUBUV_COLOR: number;
  59180. /** The Name of the Texture Package */
  59181. name: string;
  59182. /** The scene scope of the TexturePacker */
  59183. scene: Scene;
  59184. /** The Meshes to target */
  59185. meshes: AbstractMesh[];
  59186. /** Arguments passed with the Constructor */
  59187. options: ITexturePackerOptions;
  59188. /** The promise that is started upon initialization */
  59189. promise: Nullable<Promise<TexturePacker | string>>;
  59190. /** The Container object for the channel sets that are generated */
  59191. sets: object;
  59192. /** The Container array for the frames that are generated */
  59193. frames: TexturePackerFrame[];
  59194. /** The expected number of textures the system is parsing. */
  59195. private _expecting;
  59196. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59197. private _paddingValue;
  59198. /**
  59199. * Initializes a texture package series from an array of meshes or a single mesh.
  59200. * @param name The name of the package
  59201. * @param meshes The target meshes to compose the package from
  59202. * @param options The arguments that texture packer should follow while building.
  59203. * @param scene The scene which the textures are scoped to.
  59204. * @returns TexturePacker
  59205. */
  59206. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59207. /**
  59208. * Starts the package process
  59209. * @param resolve The promises resolution function
  59210. * @returns TexturePacker
  59211. */
  59212. private _createFrames;
  59213. /**
  59214. * Calculates the Size of the Channel Sets
  59215. * @returns Vector2
  59216. */
  59217. private _calculateSize;
  59218. /**
  59219. * Calculates the UV data for the frames.
  59220. * @param baseSize the base frameSize
  59221. * @param padding the base frame padding
  59222. * @param dtSize size of the Dynamic Texture for that channel
  59223. * @param dtUnits is 1/dtSize
  59224. * @param update flag to update the input meshes
  59225. */
  59226. private _calculateMeshUVFrames;
  59227. /**
  59228. * Calculates the frames Offset.
  59229. * @param index of the frame
  59230. * @returns Vector2
  59231. */
  59232. private _getFrameOffset;
  59233. /**
  59234. * Updates a Mesh to the frame data
  59235. * @param mesh that is the target
  59236. * @param frameID or the frame index
  59237. */
  59238. private _updateMeshUV;
  59239. /**
  59240. * Updates a Meshes materials to use the texture packer channels
  59241. * @param m is the mesh to target
  59242. * @param force all channels on the packer to be set.
  59243. */
  59244. private _updateTextureReferences;
  59245. /**
  59246. * Public method to set a Mesh to a frame
  59247. * @param m that is the target
  59248. * @param frameID or the frame index
  59249. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59250. */
  59251. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59252. /**
  59253. * Starts the async promise to compile the texture packer.
  59254. * @returns Promise<void>
  59255. */
  59256. processAsync(): Promise<void>;
  59257. /**
  59258. * Disposes all textures associated with this packer
  59259. */
  59260. dispose(): void;
  59261. /**
  59262. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59263. * @param imageType is the image type to use.
  59264. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59265. */
  59266. download(imageType?: string, quality?: number): void;
  59267. /**
  59268. * Public method to load a texturePacker JSON file.
  59269. * @param data of the JSON file in string format.
  59270. */
  59271. updateFromJSON(data: string): void;
  59272. }
  59273. }
  59274. declare module "babylonjs/Materials/Textures/Packer/index" {
  59275. export * from "babylonjs/Materials/Textures/Packer/packer";
  59276. export * from "babylonjs/Materials/Textures/Packer/frame";
  59277. }
  59278. declare module "babylonjs/Materials/Textures/index" {
  59279. export * from "babylonjs/Materials/Textures/baseTexture";
  59280. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59281. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59282. export * from "babylonjs/Materials/Textures/cubeTexture";
  59283. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59284. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59285. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59286. export * from "babylonjs/Materials/Textures/internalTexture";
  59287. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59288. export * from "babylonjs/Materials/Textures/Loaders/index";
  59289. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59290. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59291. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59292. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59293. export * from "babylonjs/Materials/Textures/rawTexture";
  59294. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59295. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59296. export * from "babylonjs/Materials/Textures/refractionTexture";
  59297. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59298. export * from "babylonjs/Materials/Textures/texture";
  59299. export * from "babylonjs/Materials/Textures/videoTexture";
  59300. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59301. export * from "babylonjs/Materials/Textures/Packer/index";
  59302. }
  59303. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59304. /**
  59305. * Enum used to define the target of a block
  59306. */
  59307. export enum NodeMaterialBlockTargets {
  59308. /** Vertex shader */
  59309. Vertex = 1,
  59310. /** Fragment shader */
  59311. Fragment = 2,
  59312. /** Neutral */
  59313. Neutral = 4,
  59314. /** Vertex and Fragment */
  59315. VertexAndFragment = 3
  59316. }
  59317. }
  59318. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59319. /**
  59320. * Defines the kind of connection point for node based material
  59321. */
  59322. export enum NodeMaterialBlockConnectionPointTypes {
  59323. /** Float */
  59324. Float = 1,
  59325. /** Int */
  59326. Int = 2,
  59327. /** Vector2 */
  59328. Vector2 = 4,
  59329. /** Vector3 */
  59330. Vector3 = 8,
  59331. /** Vector4 */
  59332. Vector4 = 16,
  59333. /** Color3 */
  59334. Color3 = 32,
  59335. /** Color4 */
  59336. Color4 = 64,
  59337. /** Matrix */
  59338. Matrix = 128,
  59339. /** Detect type based on connection */
  59340. AutoDetect = 1024,
  59341. /** Output type that will be defined by input type */
  59342. BasedOnInput = 2048
  59343. }
  59344. }
  59345. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59346. /**
  59347. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59348. */
  59349. export enum NodeMaterialBlockConnectionPointMode {
  59350. /** Value is an uniform */
  59351. Uniform = 0,
  59352. /** Value is a mesh attribute */
  59353. Attribute = 1,
  59354. /** Value is a varying between vertex and fragment shaders */
  59355. Varying = 2,
  59356. /** Mode is undefined */
  59357. Undefined = 3
  59358. }
  59359. }
  59360. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59361. /**
  59362. * Enum used to define system values e.g. values automatically provided by the system
  59363. */
  59364. export enum NodeMaterialSystemValues {
  59365. /** World */
  59366. World = 1,
  59367. /** View */
  59368. View = 2,
  59369. /** Projection */
  59370. Projection = 3,
  59371. /** ViewProjection */
  59372. ViewProjection = 4,
  59373. /** WorldView */
  59374. WorldView = 5,
  59375. /** WorldViewProjection */
  59376. WorldViewProjection = 6,
  59377. /** CameraPosition */
  59378. CameraPosition = 7,
  59379. /** Fog Color */
  59380. FogColor = 8,
  59381. /** Delta time */
  59382. DeltaTime = 9
  59383. }
  59384. }
  59385. declare module "babylonjs/Materials/Node/Enums/index" {
  59386. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59387. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59388. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59389. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59390. }
  59391. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59393. /**
  59394. * Root class for all node material optimizers
  59395. */
  59396. export class NodeMaterialOptimizer {
  59397. /**
  59398. * Function used to optimize a NodeMaterial graph
  59399. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59400. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59401. */
  59402. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59403. }
  59404. }
  59405. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59406. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59407. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59408. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59409. import { Scene } from "babylonjs/scene";
  59410. /**
  59411. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59412. */
  59413. export class TransformBlock extends NodeMaterialBlock {
  59414. /**
  59415. * Defines the value to use to complement W value to transform it to a Vector4
  59416. */
  59417. complementW: number;
  59418. /**
  59419. * Defines the value to use to complement z value to transform it to a Vector4
  59420. */
  59421. complementZ: number;
  59422. /**
  59423. * Creates a new TransformBlock
  59424. * @param name defines the block name
  59425. */
  59426. constructor(name: string);
  59427. /**
  59428. * Gets the current class name
  59429. * @returns the class name
  59430. */
  59431. getClassName(): string;
  59432. /**
  59433. * Gets the vector input
  59434. */
  59435. get vector(): NodeMaterialConnectionPoint;
  59436. /**
  59437. * Gets the output component
  59438. */
  59439. get output(): NodeMaterialConnectionPoint;
  59440. /**
  59441. * Gets the xyz output component
  59442. */
  59443. get xyz(): NodeMaterialConnectionPoint;
  59444. /**
  59445. * Gets the matrix transform input
  59446. */
  59447. get transform(): NodeMaterialConnectionPoint;
  59448. protected _buildBlock(state: NodeMaterialBuildState): this;
  59449. serialize(): any;
  59450. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59451. protected _dumpPropertiesCode(): string;
  59452. }
  59453. }
  59454. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59458. /**
  59459. * Block used to output the vertex position
  59460. */
  59461. export class VertexOutputBlock extends NodeMaterialBlock {
  59462. /**
  59463. * Creates a new VertexOutputBlock
  59464. * @param name defines the block name
  59465. */
  59466. constructor(name: string);
  59467. /**
  59468. * Gets the current class name
  59469. * @returns the class name
  59470. */
  59471. getClassName(): string;
  59472. /**
  59473. * Gets the vector input component
  59474. */
  59475. get vector(): NodeMaterialConnectionPoint;
  59476. protected _buildBlock(state: NodeMaterialBuildState): this;
  59477. }
  59478. }
  59479. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59483. /**
  59484. * Block used to output the final color
  59485. */
  59486. export class FragmentOutputBlock extends NodeMaterialBlock {
  59487. /**
  59488. * Create a new FragmentOutputBlock
  59489. * @param name defines the block name
  59490. */
  59491. constructor(name: string);
  59492. /**
  59493. * Gets the current class name
  59494. * @returns the class name
  59495. */
  59496. getClassName(): string;
  59497. /**
  59498. * Gets the rgba input component
  59499. */
  59500. get rgba(): NodeMaterialConnectionPoint;
  59501. /**
  59502. * Gets the rgb input component
  59503. */
  59504. get rgb(): NodeMaterialConnectionPoint;
  59505. /**
  59506. * Gets the a input component
  59507. */
  59508. get a(): NodeMaterialConnectionPoint;
  59509. protected _buildBlock(state: NodeMaterialBuildState): this;
  59510. }
  59511. }
  59512. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59516. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59518. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59519. import { Effect } from "babylonjs/Materials/effect";
  59520. import { Mesh } from "babylonjs/Meshes/mesh";
  59521. import { Nullable } from "babylonjs/types";
  59522. import { Scene } from "babylonjs/scene";
  59523. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59524. /**
  59525. * Block used to read a reflection texture from a sampler
  59526. */
  59527. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59528. private _define3DName;
  59529. private _defineCubicName;
  59530. private _defineExplicitName;
  59531. private _defineProjectionName;
  59532. private _defineLocalCubicName;
  59533. private _defineSphericalName;
  59534. private _definePlanarName;
  59535. private _defineEquirectangularName;
  59536. private _defineMirroredEquirectangularFixedName;
  59537. private _defineEquirectangularFixedName;
  59538. private _defineSkyboxName;
  59539. private _cubeSamplerName;
  59540. private _2DSamplerName;
  59541. private _positionUVWName;
  59542. private _directionWName;
  59543. private _reflectionCoordsName;
  59544. private _reflection2DCoordsName;
  59545. private _reflectionColorName;
  59546. private _reflectionMatrixName;
  59547. /**
  59548. * Gets or sets the texture associated with the node
  59549. */
  59550. texture: Nullable<BaseTexture>;
  59551. /**
  59552. * Create a new TextureBlock
  59553. * @param name defines the block name
  59554. */
  59555. constructor(name: string);
  59556. /**
  59557. * Gets the current class name
  59558. * @returns the class name
  59559. */
  59560. getClassName(): string;
  59561. /**
  59562. * Gets the world position input component
  59563. */
  59564. get position(): NodeMaterialConnectionPoint;
  59565. /**
  59566. * Gets the world position input component
  59567. */
  59568. get worldPosition(): NodeMaterialConnectionPoint;
  59569. /**
  59570. * Gets the world normal input component
  59571. */
  59572. get worldNormal(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the world input component
  59575. */
  59576. get world(): NodeMaterialConnectionPoint;
  59577. /**
  59578. * Gets the camera (or eye) position component
  59579. */
  59580. get cameraPosition(): NodeMaterialConnectionPoint;
  59581. /**
  59582. * Gets the view input component
  59583. */
  59584. get view(): NodeMaterialConnectionPoint;
  59585. /**
  59586. * Gets the rgb output component
  59587. */
  59588. get rgb(): NodeMaterialConnectionPoint;
  59589. /**
  59590. * Gets the r output component
  59591. */
  59592. get r(): NodeMaterialConnectionPoint;
  59593. /**
  59594. * Gets the g output component
  59595. */
  59596. get g(): NodeMaterialConnectionPoint;
  59597. /**
  59598. * Gets the b output component
  59599. */
  59600. get b(): NodeMaterialConnectionPoint;
  59601. autoConfigure(material: NodeMaterial): void;
  59602. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59603. isReady(): boolean;
  59604. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59605. private _injectVertexCode;
  59606. private _writeOutput;
  59607. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59608. protected _dumpPropertiesCode(): string;
  59609. serialize(): any;
  59610. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59611. }
  59612. }
  59613. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59615. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59616. import { Scene } from "babylonjs/scene";
  59617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59618. import { Matrix } from "babylonjs/Maths/math.vector";
  59619. import { Mesh } from "babylonjs/Meshes/mesh";
  59620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59621. import { Observable } from "babylonjs/Misc/observable";
  59622. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59623. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59624. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59625. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59626. import { Nullable } from "babylonjs/types";
  59627. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59628. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59629. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59630. /**
  59631. * Interface used to configure the node material editor
  59632. */
  59633. export interface INodeMaterialEditorOptions {
  59634. /** Define the URl to load node editor script */
  59635. editorURL?: string;
  59636. }
  59637. /** @hidden */
  59638. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59639. NORMAL: boolean;
  59640. TANGENT: boolean;
  59641. UV1: boolean;
  59642. /** BONES */
  59643. NUM_BONE_INFLUENCERS: number;
  59644. BonesPerMesh: number;
  59645. BONETEXTURE: boolean;
  59646. /** MORPH TARGETS */
  59647. MORPHTARGETS: boolean;
  59648. MORPHTARGETS_NORMAL: boolean;
  59649. MORPHTARGETS_TANGENT: boolean;
  59650. MORPHTARGETS_UV: boolean;
  59651. NUM_MORPH_INFLUENCERS: number;
  59652. /** IMAGE PROCESSING */
  59653. IMAGEPROCESSING: boolean;
  59654. VIGNETTE: boolean;
  59655. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59656. VIGNETTEBLENDMODEOPAQUE: boolean;
  59657. TONEMAPPING: boolean;
  59658. TONEMAPPING_ACES: boolean;
  59659. CONTRAST: boolean;
  59660. EXPOSURE: boolean;
  59661. COLORCURVES: boolean;
  59662. COLORGRADING: boolean;
  59663. COLORGRADING3D: boolean;
  59664. SAMPLER3DGREENDEPTH: boolean;
  59665. SAMPLER3DBGRMAP: boolean;
  59666. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59667. /** MISC. */
  59668. BUMPDIRECTUV: number;
  59669. constructor();
  59670. setValue(name: string, value: boolean): void;
  59671. }
  59672. /**
  59673. * Class used to configure NodeMaterial
  59674. */
  59675. export interface INodeMaterialOptions {
  59676. /**
  59677. * Defines if blocks should emit comments
  59678. */
  59679. emitComments: boolean;
  59680. }
  59681. /**
  59682. * Class used to create a node based material built by assembling shader blocks
  59683. */
  59684. export class NodeMaterial extends PushMaterial {
  59685. private static _BuildIdGenerator;
  59686. private _options;
  59687. private _vertexCompilationState;
  59688. private _fragmentCompilationState;
  59689. private _sharedData;
  59690. private _buildId;
  59691. private _buildWasSuccessful;
  59692. private _cachedWorldViewMatrix;
  59693. private _cachedWorldViewProjectionMatrix;
  59694. private _optimizers;
  59695. private _animationFrame;
  59696. /** Define the Url to load node editor script */
  59697. static EditorURL: string;
  59698. /** Define the Url to load snippets */
  59699. static SnippetUrl: string;
  59700. private BJSNODEMATERIALEDITOR;
  59701. /** Get the inspector from bundle or global */
  59702. private _getGlobalNodeMaterialEditor;
  59703. /**
  59704. * Gets or sets data used by visual editor
  59705. * @see https://nme.babylonjs.com
  59706. */
  59707. editorData: any;
  59708. /**
  59709. * 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)
  59710. */
  59711. ignoreAlpha: boolean;
  59712. /**
  59713. * Defines the maximum number of lights that can be used in the material
  59714. */
  59715. maxSimultaneousLights: number;
  59716. /**
  59717. * Observable raised when the material is built
  59718. */
  59719. onBuildObservable: Observable<NodeMaterial>;
  59720. /**
  59721. * Gets or sets the root nodes of the material vertex shader
  59722. */
  59723. _vertexOutputNodes: NodeMaterialBlock[];
  59724. /**
  59725. * Gets or sets the root nodes of the material fragment (pixel) shader
  59726. */
  59727. _fragmentOutputNodes: NodeMaterialBlock[];
  59728. /** Gets or sets options to control the node material overall behavior */
  59729. get options(): INodeMaterialOptions;
  59730. set options(options: INodeMaterialOptions);
  59731. /**
  59732. * Default configuration related to image processing available in the standard Material.
  59733. */
  59734. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59735. /**
  59736. * Gets the image processing configuration used either in this material.
  59737. */
  59738. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59739. /**
  59740. * Sets the Default image processing configuration used either in the this material.
  59741. *
  59742. * If sets to null, the scene one is in use.
  59743. */
  59744. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59745. /**
  59746. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59747. */
  59748. attachedBlocks: NodeMaterialBlock[];
  59749. /**
  59750. * Create a new node based material
  59751. * @param name defines the material name
  59752. * @param scene defines the hosting scene
  59753. * @param options defines creation option
  59754. */
  59755. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59756. /**
  59757. * Gets the current class name of the material e.g. "NodeMaterial"
  59758. * @returns the class name
  59759. */
  59760. getClassName(): string;
  59761. /**
  59762. * Keep track of the image processing observer to allow dispose and replace.
  59763. */
  59764. private _imageProcessingObserver;
  59765. /**
  59766. * Attaches a new image processing configuration to the Standard Material.
  59767. * @param configuration
  59768. */
  59769. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59770. /**
  59771. * Get a block by its name
  59772. * @param name defines the name of the block to retrieve
  59773. * @returns the required block or null if not found
  59774. */
  59775. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59776. /**
  59777. * Get a block by its name
  59778. * @param predicate defines the predicate used to find the good candidate
  59779. * @returns the required block or null if not found
  59780. */
  59781. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59782. /**
  59783. * Get an input block by its name
  59784. * @param predicate defines the predicate used to find the good candidate
  59785. * @returns the required input block or null if not found
  59786. */
  59787. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59788. /**
  59789. * Gets the list of input blocks attached to this material
  59790. * @returns an array of InputBlocks
  59791. */
  59792. getInputBlocks(): InputBlock[];
  59793. /**
  59794. * Adds a new optimizer to the list of optimizers
  59795. * @param optimizer defines the optimizers to add
  59796. * @returns the current material
  59797. */
  59798. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59799. /**
  59800. * Remove an optimizer from the list of optimizers
  59801. * @param optimizer defines the optimizers to remove
  59802. * @returns the current material
  59803. */
  59804. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59805. /**
  59806. * Add a new block to the list of output nodes
  59807. * @param node defines the node to add
  59808. * @returns the current material
  59809. */
  59810. addOutputNode(node: NodeMaterialBlock): this;
  59811. /**
  59812. * Remove a block from the list of root nodes
  59813. * @param node defines the node to remove
  59814. * @returns the current material
  59815. */
  59816. removeOutputNode(node: NodeMaterialBlock): this;
  59817. private _addVertexOutputNode;
  59818. private _removeVertexOutputNode;
  59819. private _addFragmentOutputNode;
  59820. private _removeFragmentOutputNode;
  59821. /**
  59822. * Specifies if the material will require alpha blending
  59823. * @returns a boolean specifying if alpha blending is needed
  59824. */
  59825. needAlphaBlending(): boolean;
  59826. /**
  59827. * Specifies if this material should be rendered in alpha test mode
  59828. * @returns a boolean specifying if an alpha test is needed.
  59829. */
  59830. needAlphaTesting(): boolean;
  59831. private _initializeBlock;
  59832. private _resetDualBlocks;
  59833. /**
  59834. * Remove a block from the current node material
  59835. * @param block defines the block to remove
  59836. */
  59837. removeBlock(block: NodeMaterialBlock): void;
  59838. /**
  59839. * Build the material and generates the inner effect
  59840. * @param verbose defines if the build should log activity
  59841. */
  59842. build(verbose?: boolean): void;
  59843. /**
  59844. * Runs an otpimization phase to try to improve the shader code
  59845. */
  59846. optimize(): void;
  59847. private _prepareDefinesForAttributes;
  59848. /**
  59849. * Get if the submesh is ready to be used and all its information available.
  59850. * Child classes can use it to update shaders
  59851. * @param mesh defines the mesh to check
  59852. * @param subMesh defines which submesh to check
  59853. * @param useInstances specifies that instances should be used
  59854. * @returns a boolean indicating that the submesh is ready or not
  59855. */
  59856. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59857. /**
  59858. * Get a string representing the shaders built by the current node graph
  59859. */
  59860. get compiledShaders(): string;
  59861. /**
  59862. * Binds the world matrix to the material
  59863. * @param world defines the world transformation matrix
  59864. */
  59865. bindOnlyWorldMatrix(world: Matrix): void;
  59866. /**
  59867. * Binds the submesh to this material by preparing the effect and shader to draw
  59868. * @param world defines the world transformation matrix
  59869. * @param mesh defines the mesh containing the submesh
  59870. * @param subMesh defines the submesh to bind the material to
  59871. */
  59872. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59873. /**
  59874. * Gets the active textures from the material
  59875. * @returns an array of textures
  59876. */
  59877. getActiveTextures(): BaseTexture[];
  59878. /**
  59879. * Gets the list of texture blocks
  59880. * @returns an array of texture blocks
  59881. */
  59882. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59883. /**
  59884. * Specifies if the material uses a texture
  59885. * @param texture defines the texture to check against the material
  59886. * @returns a boolean specifying if the material uses the texture
  59887. */
  59888. hasTexture(texture: BaseTexture): boolean;
  59889. /**
  59890. * Disposes the material
  59891. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59892. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59893. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59894. */
  59895. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59896. /** Creates the node editor window. */
  59897. private _createNodeEditor;
  59898. /**
  59899. * Launch the node material editor
  59900. * @param config Define the configuration of the editor
  59901. * @return a promise fulfilled when the node editor is visible
  59902. */
  59903. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59904. /**
  59905. * Clear the current material
  59906. */
  59907. clear(): void;
  59908. /**
  59909. * Clear the current material and set it to a default state
  59910. */
  59911. setToDefault(): void;
  59912. /**
  59913. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59914. * @param url defines the url to load from
  59915. * @returns a promise that will fullfil when the material is fully loaded
  59916. */
  59917. loadAsync(url: string): Promise<void>;
  59918. private _gatherBlocks;
  59919. /**
  59920. * Generate a string containing the code declaration required to create an equivalent of this material
  59921. * @returns a string
  59922. */
  59923. generateCode(): string;
  59924. /**
  59925. * Serializes this material in a JSON representation
  59926. * @returns the serialized material object
  59927. */
  59928. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59929. private _restoreConnections;
  59930. /**
  59931. * Clear the current graph and load a new one from a serialization object
  59932. * @param source defines the JSON representation of the material
  59933. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59934. */
  59935. loadFromSerialization(source: any, rootUrl?: string): void;
  59936. /**
  59937. * Creates a node material from parsed material data
  59938. * @param source defines the JSON representation of the material
  59939. * @param scene defines the hosting scene
  59940. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59941. * @returns a new node material
  59942. */
  59943. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59944. /**
  59945. * Creates a node material from a snippet saved in a remote file
  59946. * @param name defines the name of the material to create
  59947. * @param url defines the url to load from
  59948. * @param scene defines the hosting scene
  59949. * @returns a promise that will resolve to the new node material
  59950. */
  59951. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59952. /**
  59953. * Creates a node material from a snippet saved by the node material editor
  59954. * @param snippetId defines the snippet to load
  59955. * @param scene defines the hosting scene
  59956. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59957. * @returns a promise that will resolve to the new node material
  59958. */
  59959. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59960. /**
  59961. * Creates a new node material set to default basic configuration
  59962. * @param name defines the name of the material
  59963. * @param scene defines the hosting scene
  59964. * @returns a new NodeMaterial
  59965. */
  59966. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59967. }
  59968. }
  59969. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59972. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59975. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59976. import { Effect } from "babylonjs/Materials/effect";
  59977. import { Mesh } from "babylonjs/Meshes/mesh";
  59978. import { Nullable } from "babylonjs/types";
  59979. import { Texture } from "babylonjs/Materials/Textures/texture";
  59980. import { Scene } from "babylonjs/scene";
  59981. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59982. /**
  59983. * Block used to read a texture from a sampler
  59984. */
  59985. export class TextureBlock extends NodeMaterialBlock {
  59986. private _defineName;
  59987. private _linearDefineName;
  59988. private _tempTextureRead;
  59989. private _samplerName;
  59990. private _transformedUVName;
  59991. private _textureTransformName;
  59992. private _textureInfoName;
  59993. private _mainUVName;
  59994. private _mainUVDefineName;
  59995. /**
  59996. * Gets or sets the texture associated with the node
  59997. */
  59998. texture: Nullable<Texture>;
  59999. /**
  60000. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60001. */
  60002. convertToGammaSpace: boolean;
  60003. /**
  60004. * Create a new TextureBlock
  60005. * @param name defines the block name
  60006. */
  60007. constructor(name: string);
  60008. /**
  60009. * Gets the current class name
  60010. * @returns the class name
  60011. */
  60012. getClassName(): string;
  60013. /**
  60014. * Gets the uv input component
  60015. */
  60016. get uv(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the rgba output component
  60019. */
  60020. get rgba(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the rgb output component
  60023. */
  60024. get rgb(): NodeMaterialConnectionPoint;
  60025. /**
  60026. * Gets the r output component
  60027. */
  60028. get r(): NodeMaterialConnectionPoint;
  60029. /**
  60030. * Gets the g output component
  60031. */
  60032. get g(): NodeMaterialConnectionPoint;
  60033. /**
  60034. * Gets the b output component
  60035. */
  60036. get b(): NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the a output component
  60039. */
  60040. get a(): NodeMaterialConnectionPoint;
  60041. get target(): NodeMaterialBlockTargets;
  60042. autoConfigure(material: NodeMaterial): void;
  60043. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60045. isReady(): boolean;
  60046. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60047. private get _isMixed();
  60048. private _injectVertexCode;
  60049. private _writeTextureRead;
  60050. private _writeOutput;
  60051. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60052. protected _dumpPropertiesCode(): string;
  60053. serialize(): any;
  60054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60055. }
  60056. }
  60057. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60060. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60061. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60062. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60063. import { Scene } from "babylonjs/scene";
  60064. /**
  60065. * Class used to store shared data between 2 NodeMaterialBuildState
  60066. */
  60067. export class NodeMaterialBuildStateSharedData {
  60068. /**
  60069. * Gets the list of emitted varyings
  60070. */
  60071. temps: string[];
  60072. /**
  60073. * Gets the list of emitted varyings
  60074. */
  60075. varyings: string[];
  60076. /**
  60077. * Gets the varying declaration string
  60078. */
  60079. varyingDeclaration: string;
  60080. /**
  60081. * Input blocks
  60082. */
  60083. inputBlocks: InputBlock[];
  60084. /**
  60085. * Input blocks
  60086. */
  60087. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60088. /**
  60089. * Bindable blocks (Blocks that need to set data to the effect)
  60090. */
  60091. bindableBlocks: NodeMaterialBlock[];
  60092. /**
  60093. * List of blocks that can provide a compilation fallback
  60094. */
  60095. blocksWithFallbacks: NodeMaterialBlock[];
  60096. /**
  60097. * List of blocks that can provide a define update
  60098. */
  60099. blocksWithDefines: NodeMaterialBlock[];
  60100. /**
  60101. * List of blocks that can provide a repeatable content
  60102. */
  60103. repeatableContentBlocks: NodeMaterialBlock[];
  60104. /**
  60105. * List of blocks that can provide a dynamic list of uniforms
  60106. */
  60107. dynamicUniformBlocks: NodeMaterialBlock[];
  60108. /**
  60109. * List of blocks that can block the isReady function for the material
  60110. */
  60111. blockingBlocks: NodeMaterialBlock[];
  60112. /**
  60113. * Gets the list of animated inputs
  60114. */
  60115. animatedInputs: InputBlock[];
  60116. /**
  60117. * Build Id used to avoid multiple recompilations
  60118. */
  60119. buildId: number;
  60120. /** List of emitted variables */
  60121. variableNames: {
  60122. [key: string]: number;
  60123. };
  60124. /** List of emitted defines */
  60125. defineNames: {
  60126. [key: string]: number;
  60127. };
  60128. /** Should emit comments? */
  60129. emitComments: boolean;
  60130. /** Emit build activity */
  60131. verbose: boolean;
  60132. /** Gets or sets the hosting scene */
  60133. scene: Scene;
  60134. /**
  60135. * Gets the compilation hints emitted at compilation time
  60136. */
  60137. hints: {
  60138. needWorldViewMatrix: boolean;
  60139. needWorldViewProjectionMatrix: boolean;
  60140. needAlphaBlending: boolean;
  60141. needAlphaTesting: boolean;
  60142. };
  60143. /**
  60144. * List of compilation checks
  60145. */
  60146. checks: {
  60147. emitVertex: boolean;
  60148. emitFragment: boolean;
  60149. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60150. };
  60151. /** Creates a new shared data */
  60152. constructor();
  60153. /**
  60154. * Emits console errors and exceptions if there is a failing check
  60155. */
  60156. emitErrors(): void;
  60157. }
  60158. }
  60159. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60160. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60161. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60162. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60163. /**
  60164. * Class used to store node based material build state
  60165. */
  60166. export class NodeMaterialBuildState {
  60167. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60168. supportUniformBuffers: boolean;
  60169. /**
  60170. * Gets the list of emitted attributes
  60171. */
  60172. attributes: string[];
  60173. /**
  60174. * Gets the list of emitted uniforms
  60175. */
  60176. uniforms: string[];
  60177. /**
  60178. * Gets the list of emitted constants
  60179. */
  60180. constants: string[];
  60181. /**
  60182. * Gets the list of emitted samplers
  60183. */
  60184. samplers: string[];
  60185. /**
  60186. * Gets the list of emitted functions
  60187. */
  60188. functions: {
  60189. [key: string]: string;
  60190. };
  60191. /**
  60192. * Gets the list of emitted extensions
  60193. */
  60194. extensions: {
  60195. [key: string]: string;
  60196. };
  60197. /**
  60198. * Gets the target of the compilation state
  60199. */
  60200. target: NodeMaterialBlockTargets;
  60201. /**
  60202. * Gets the list of emitted counters
  60203. */
  60204. counters: {
  60205. [key: string]: number;
  60206. };
  60207. /**
  60208. * Shared data between multiple NodeMaterialBuildState instances
  60209. */
  60210. sharedData: NodeMaterialBuildStateSharedData;
  60211. /** @hidden */
  60212. _vertexState: NodeMaterialBuildState;
  60213. /** @hidden */
  60214. _attributeDeclaration: string;
  60215. /** @hidden */
  60216. _uniformDeclaration: string;
  60217. /** @hidden */
  60218. _constantDeclaration: string;
  60219. /** @hidden */
  60220. _samplerDeclaration: string;
  60221. /** @hidden */
  60222. _varyingTransfer: string;
  60223. private _repeatableContentAnchorIndex;
  60224. /** @hidden */
  60225. _builtCompilationString: string;
  60226. /**
  60227. * Gets the emitted compilation strings
  60228. */
  60229. compilationString: string;
  60230. /**
  60231. * Finalize the compilation strings
  60232. * @param state defines the current compilation state
  60233. */
  60234. finalize(state: NodeMaterialBuildState): void;
  60235. /** @hidden */
  60236. get _repeatableContentAnchor(): string;
  60237. /** @hidden */
  60238. _getFreeVariableName(prefix: string): string;
  60239. /** @hidden */
  60240. _getFreeDefineName(prefix: string): string;
  60241. /** @hidden */
  60242. _excludeVariableName(name: string): void;
  60243. /** @hidden */
  60244. _emit2DSampler(name: string): void;
  60245. /** @hidden */
  60246. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60247. /** @hidden */
  60248. _emitExtension(name: string, extension: string): void;
  60249. /** @hidden */
  60250. _emitFunction(name: string, code: string, comments: string): void;
  60251. /** @hidden */
  60252. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60253. replaceStrings?: {
  60254. search: RegExp;
  60255. replace: string;
  60256. }[];
  60257. repeatKey?: string;
  60258. }): string;
  60259. /** @hidden */
  60260. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60261. repeatKey?: string;
  60262. removeAttributes?: boolean;
  60263. removeUniforms?: boolean;
  60264. removeVaryings?: boolean;
  60265. removeIfDef?: boolean;
  60266. replaceStrings?: {
  60267. search: RegExp;
  60268. replace: string;
  60269. }[];
  60270. }, storeKey?: string): void;
  60271. /** @hidden */
  60272. _registerTempVariable(name: string): boolean;
  60273. /** @hidden */
  60274. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60275. /** @hidden */
  60276. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60277. /** @hidden */
  60278. _emitFloat(value: number): string;
  60279. }
  60280. }
  60281. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60282. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60284. import { Nullable } from "babylonjs/types";
  60285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60286. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60287. import { Effect } from "babylonjs/Materials/effect";
  60288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60289. import { Mesh } from "babylonjs/Meshes/mesh";
  60290. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60291. import { Scene } from "babylonjs/scene";
  60292. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60293. /**
  60294. * Defines a block that can be used inside a node based material
  60295. */
  60296. export class NodeMaterialBlock {
  60297. private _buildId;
  60298. private _buildTarget;
  60299. private _target;
  60300. private _isFinalMerger;
  60301. private _isInput;
  60302. protected _isUnique: boolean;
  60303. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60304. inputsAreExclusive: boolean;
  60305. /** @hidden */
  60306. _codeVariableName: string;
  60307. /** @hidden */
  60308. _inputs: NodeMaterialConnectionPoint[];
  60309. /** @hidden */
  60310. _outputs: NodeMaterialConnectionPoint[];
  60311. /** @hidden */
  60312. _preparationId: number;
  60313. /**
  60314. * Gets or sets the name of the block
  60315. */
  60316. name: string;
  60317. /**
  60318. * Gets or sets the unique id of the node
  60319. */
  60320. uniqueId: number;
  60321. /**
  60322. * Gets or sets the comments associated with this block
  60323. */
  60324. comments: string;
  60325. /**
  60326. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60327. */
  60328. get isUnique(): boolean;
  60329. /**
  60330. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60331. */
  60332. get isFinalMerger(): boolean;
  60333. /**
  60334. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60335. */
  60336. get isInput(): boolean;
  60337. /**
  60338. * Gets or sets the build Id
  60339. */
  60340. get buildId(): number;
  60341. set buildId(value: number);
  60342. /**
  60343. * Gets or sets the target of the block
  60344. */
  60345. get target(): NodeMaterialBlockTargets;
  60346. set target(value: NodeMaterialBlockTargets);
  60347. /**
  60348. * Gets the list of input points
  60349. */
  60350. get inputs(): NodeMaterialConnectionPoint[];
  60351. /** Gets the list of output points */
  60352. get outputs(): NodeMaterialConnectionPoint[];
  60353. /**
  60354. * Find an input by its name
  60355. * @param name defines the name of the input to look for
  60356. * @returns the input or null if not found
  60357. */
  60358. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60359. /**
  60360. * Find an output by its name
  60361. * @param name defines the name of the outputto look for
  60362. * @returns the output or null if not found
  60363. */
  60364. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60365. /**
  60366. * Creates a new NodeMaterialBlock
  60367. * @param name defines the block name
  60368. * @param target defines the target of that block (Vertex by default)
  60369. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60370. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60371. */
  60372. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60373. /**
  60374. * Initialize the block and prepare the context for build
  60375. * @param state defines the state that will be used for the build
  60376. */
  60377. initialize(state: NodeMaterialBuildState): void;
  60378. /**
  60379. * Bind data to effect. Will only be called for blocks with isBindable === true
  60380. * @param effect defines the effect to bind data to
  60381. * @param nodeMaterial defines the hosting NodeMaterial
  60382. * @param mesh defines the mesh that will be rendered
  60383. */
  60384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60385. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60386. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60387. protected _writeFloat(value: number): string;
  60388. /**
  60389. * Gets the current class name e.g. "NodeMaterialBlock"
  60390. * @returns the class name
  60391. */
  60392. getClassName(): string;
  60393. /**
  60394. * Register a new input. Must be called inside a block constructor
  60395. * @param name defines the connection point name
  60396. * @param type defines the connection point type
  60397. * @param isOptional defines a boolean indicating that this input can be omitted
  60398. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60399. * @returns the current block
  60400. */
  60401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60402. /**
  60403. * Register a new output. Must be called inside a block constructor
  60404. * @param name defines the connection point name
  60405. * @param type defines the connection point type
  60406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60407. * @returns the current block
  60408. */
  60409. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60410. /**
  60411. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60412. * @param forOutput defines an optional connection point to check compatibility with
  60413. * @returns the first available input or null
  60414. */
  60415. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60416. /**
  60417. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60418. * @param forBlock defines an optional block to check compatibility with
  60419. * @returns the first available input or null
  60420. */
  60421. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60422. /**
  60423. * Gets the sibling of the given output
  60424. * @param current defines the current output
  60425. * @returns the next output in the list or null
  60426. */
  60427. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60428. /**
  60429. * Connect current block with another block
  60430. * @param other defines the block to connect with
  60431. * @param options define the various options to help pick the right connections
  60432. * @returns the current block
  60433. */
  60434. connectTo(other: NodeMaterialBlock, options?: {
  60435. input?: string;
  60436. output?: string;
  60437. outputSwizzle?: string;
  60438. }): this | undefined;
  60439. protected _buildBlock(state: NodeMaterialBuildState): void;
  60440. /**
  60441. * Add uniforms, samplers and uniform buffers at compilation time
  60442. * @param state defines the state to update
  60443. * @param nodeMaterial defines the node material requesting the update
  60444. * @param defines defines the material defines to update
  60445. * @param uniformBuffers defines the list of uniform buffer names
  60446. */
  60447. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60448. /**
  60449. * Add potential fallbacks if shader compilation fails
  60450. * @param mesh defines the mesh to be rendered
  60451. * @param fallbacks defines the current prioritized list of fallbacks
  60452. */
  60453. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60454. /**
  60455. * Initialize defines for shader compilation
  60456. * @param mesh defines the mesh to be rendered
  60457. * @param nodeMaterial defines the node material requesting the update
  60458. * @param defines defines the material defines to update
  60459. * @param useInstances specifies that instances should be used
  60460. */
  60461. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60462. /**
  60463. * Update defines for shader compilation
  60464. * @param mesh defines the mesh to be rendered
  60465. * @param nodeMaterial defines the node material requesting the update
  60466. * @param defines defines the material defines to update
  60467. * @param useInstances specifies that instances should be used
  60468. */
  60469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60470. /**
  60471. * Lets the block try to connect some inputs automatically
  60472. * @param material defines the hosting NodeMaterial
  60473. */
  60474. autoConfigure(material: NodeMaterial): void;
  60475. /**
  60476. * Function called when a block is declared as repeatable content generator
  60477. * @param vertexShaderState defines the current compilation state for the vertex shader
  60478. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60479. * @param mesh defines the mesh to be rendered
  60480. * @param defines defines the material defines to update
  60481. */
  60482. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60483. /**
  60484. * Checks if the block is ready
  60485. * @param mesh defines the mesh to be rendered
  60486. * @param nodeMaterial defines the node material requesting the update
  60487. * @param defines defines the material defines to update
  60488. * @param useInstances specifies that instances should be used
  60489. * @returns true if the block is ready
  60490. */
  60491. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60492. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60493. private _processBuild;
  60494. /**
  60495. * Compile the current node and generate the shader code
  60496. * @param state defines the current compilation state (uniforms, samplers, current string)
  60497. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60498. * @returns true if already built
  60499. */
  60500. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60501. protected _inputRename(name: string): string;
  60502. protected _outputRename(name: string): string;
  60503. protected _dumpPropertiesCode(): string;
  60504. /** @hidden */
  60505. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60506. /** @hidden */
  60507. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60508. /**
  60509. * Clone the current block to a new identical block
  60510. * @param scene defines the hosting scene
  60511. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60512. * @returns a copy of the current block
  60513. */
  60514. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60515. /**
  60516. * Serializes this block in a JSON representation
  60517. * @returns the serialized block object
  60518. */
  60519. serialize(): any;
  60520. /** @hidden */
  60521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60522. /**
  60523. * Release resources
  60524. */
  60525. dispose(): void;
  60526. }
  60527. }
  60528. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60529. /**
  60530. * Enum defining the type of animations supported by InputBlock
  60531. */
  60532. export enum AnimatedInputBlockTypes {
  60533. /** No animation */
  60534. None = 0,
  60535. /** Time based animation. Will only work for floats */
  60536. Time = 1
  60537. }
  60538. }
  60539. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60541. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60542. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60543. import { Nullable } from "babylonjs/types";
  60544. import { Effect } from "babylonjs/Materials/effect";
  60545. import { Matrix } from "babylonjs/Maths/math.vector";
  60546. import { Scene } from "babylonjs/scene";
  60547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60549. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60550. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60551. import { Observable } from "babylonjs/Misc/observable";
  60552. /**
  60553. * Block used to expose an input value
  60554. */
  60555. export class InputBlock extends NodeMaterialBlock {
  60556. private _mode;
  60557. private _associatedVariableName;
  60558. private _storedValue;
  60559. private _valueCallback;
  60560. private _type;
  60561. private _animationType;
  60562. /** Gets or set a value used to limit the range of float values */
  60563. min: number;
  60564. /** Gets or set a value used to limit the range of float values */
  60565. max: number;
  60566. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60567. isBoolean: boolean;
  60568. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60569. matrixMode: number;
  60570. /** @hidden */
  60571. _systemValue: Nullable<NodeMaterialSystemValues>;
  60572. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60573. visibleInInspector: boolean;
  60574. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60575. isConstant: boolean;
  60576. /** Gets or sets the group to use to display this block in the Inspector */
  60577. groupInInspector: string;
  60578. /** Gets an observable raised when the value is changed */
  60579. onValueChangedObservable: Observable<InputBlock>;
  60580. /**
  60581. * Gets or sets the connection point type (default is float)
  60582. */
  60583. get type(): NodeMaterialBlockConnectionPointTypes;
  60584. /**
  60585. * Creates a new InputBlock
  60586. * @param name defines the block name
  60587. * @param target defines the target of that block (Vertex by default)
  60588. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60589. */
  60590. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60591. /**
  60592. * Gets the output component
  60593. */
  60594. get output(): NodeMaterialConnectionPoint;
  60595. /**
  60596. * Set the source of this connection point to a vertex attribute
  60597. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60598. * @returns the current connection point
  60599. */
  60600. setAsAttribute(attributeName?: string): InputBlock;
  60601. /**
  60602. * Set the source of this connection point to a system value
  60603. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60604. * @returns the current connection point
  60605. */
  60606. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60607. /**
  60608. * Gets or sets the value of that point.
  60609. * Please note that this value will be ignored if valueCallback is defined
  60610. */
  60611. get value(): any;
  60612. set value(value: any);
  60613. /**
  60614. * Gets or sets a callback used to get the value of that point.
  60615. * Please note that setting this value will force the connection point to ignore the value property
  60616. */
  60617. get valueCallback(): () => any;
  60618. set valueCallback(value: () => any);
  60619. /**
  60620. * Gets or sets the associated variable name in the shader
  60621. */
  60622. get associatedVariableName(): string;
  60623. set associatedVariableName(value: string);
  60624. /** Gets or sets the type of animation applied to the input */
  60625. get animationType(): AnimatedInputBlockTypes;
  60626. set animationType(value: AnimatedInputBlockTypes);
  60627. /**
  60628. * Gets a boolean indicating that this connection point not defined yet
  60629. */
  60630. get isUndefined(): boolean;
  60631. /**
  60632. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60633. * In this case the connection point name must be the name of the uniform to use.
  60634. * Can only be set on inputs
  60635. */
  60636. get isUniform(): boolean;
  60637. set isUniform(value: boolean);
  60638. /**
  60639. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60640. * In this case the connection point name must be the name of the attribute to use
  60641. * Can only be set on inputs
  60642. */
  60643. get isAttribute(): boolean;
  60644. set isAttribute(value: boolean);
  60645. /**
  60646. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60647. * Can only be set on exit points
  60648. */
  60649. get isVarying(): boolean;
  60650. set isVarying(value: boolean);
  60651. /**
  60652. * Gets a boolean indicating that the current connection point is a system value
  60653. */
  60654. get isSystemValue(): boolean;
  60655. /**
  60656. * Gets or sets the current well known value or null if not defined as a system value
  60657. */
  60658. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60659. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60660. /**
  60661. * Gets the current class name
  60662. * @returns the class name
  60663. */
  60664. getClassName(): string;
  60665. /**
  60666. * Animate the input if animationType !== None
  60667. * @param scene defines the rendering scene
  60668. */
  60669. animate(scene: Scene): void;
  60670. private _emitDefine;
  60671. initialize(state: NodeMaterialBuildState): void;
  60672. /**
  60673. * Set the input block to its default value (based on its type)
  60674. */
  60675. setDefaultValue(): void;
  60676. private _emitConstant;
  60677. private _emit;
  60678. /** @hidden */
  60679. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60680. /** @hidden */
  60681. _transmit(effect: Effect, scene: Scene): void;
  60682. protected _buildBlock(state: NodeMaterialBuildState): void;
  60683. protected _dumpPropertiesCode(): string;
  60684. dispose(): void;
  60685. serialize(): any;
  60686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60687. }
  60688. }
  60689. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60690. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60691. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60692. import { Nullable } from "babylonjs/types";
  60693. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60694. import { Observable } from "babylonjs/Misc/observable";
  60695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60696. /**
  60697. * Enum used to define the compatibility state between two connection points
  60698. */
  60699. export enum NodeMaterialConnectionPointCompatibilityStates {
  60700. /** Points are compatibles */
  60701. Compatible = 0,
  60702. /** Points are incompatible because of their types */
  60703. TypeIncompatible = 1,
  60704. /** Points are incompatible because of their targets (vertex vs fragment) */
  60705. TargetIncompatible = 2
  60706. }
  60707. /**
  60708. * Defines the direction of a connection point
  60709. */
  60710. export enum NodeMaterialConnectionPointDirection {
  60711. /** Input */
  60712. Input = 0,
  60713. /** Output */
  60714. Output = 1
  60715. }
  60716. /**
  60717. * Defines a connection point for a block
  60718. */
  60719. export class NodeMaterialConnectionPoint {
  60720. /** @hidden */
  60721. _ownerBlock: NodeMaterialBlock;
  60722. /** @hidden */
  60723. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60724. private _endpoints;
  60725. private _associatedVariableName;
  60726. private _direction;
  60727. /** @hidden */
  60728. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60729. /** @hidden */
  60730. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60731. private _type;
  60732. /** @hidden */
  60733. _enforceAssociatedVariableName: boolean;
  60734. /** Gets the direction of the point */
  60735. get direction(): NodeMaterialConnectionPointDirection;
  60736. /**
  60737. * Gets or sets the additional types supported by this connection point
  60738. */
  60739. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60740. /**
  60741. * Gets or sets the additional types excluded by this connection point
  60742. */
  60743. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60744. /**
  60745. * Observable triggered when this point is connected
  60746. */
  60747. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60748. /**
  60749. * Gets or sets the associated variable name in the shader
  60750. */
  60751. get associatedVariableName(): string;
  60752. set associatedVariableName(value: string);
  60753. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60754. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60755. /**
  60756. * Gets or sets the connection point type (default is float)
  60757. */
  60758. get type(): NodeMaterialBlockConnectionPointTypes;
  60759. set type(value: NodeMaterialBlockConnectionPointTypes);
  60760. /**
  60761. * Gets or sets the connection point name
  60762. */
  60763. name: string;
  60764. /**
  60765. * Gets or sets a boolean indicating that this connection point can be omitted
  60766. */
  60767. isOptional: boolean;
  60768. /**
  60769. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60770. */
  60771. define: string;
  60772. /** @hidden */
  60773. _prioritizeVertex: boolean;
  60774. private _target;
  60775. /** Gets or sets the target of that connection point */
  60776. get target(): NodeMaterialBlockTargets;
  60777. set target(value: NodeMaterialBlockTargets);
  60778. /**
  60779. * Gets a boolean indicating that the current point is connected
  60780. */
  60781. get isConnected(): boolean;
  60782. /**
  60783. * Gets a boolean indicating that the current point is connected to an input block
  60784. */
  60785. get isConnectedToInputBlock(): boolean;
  60786. /**
  60787. * Gets a the connected input block (if any)
  60788. */
  60789. get connectInputBlock(): Nullable<InputBlock>;
  60790. /** Get the other side of the connection (if any) */
  60791. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60792. /** Get the block that owns this connection point */
  60793. get ownerBlock(): NodeMaterialBlock;
  60794. /** Get the block connected on the other side of this connection (if any) */
  60795. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60796. /** Get the block connected on the endpoints of this connection (if any) */
  60797. get connectedBlocks(): Array<NodeMaterialBlock>;
  60798. /** Gets the list of connected endpoints */
  60799. get endpoints(): NodeMaterialConnectionPoint[];
  60800. /** Gets a boolean indicating if that output point is connected to at least one input */
  60801. get hasEndpoints(): boolean;
  60802. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60803. get isConnectedInVertexShader(): boolean;
  60804. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60805. get isConnectedInFragmentShader(): boolean;
  60806. /**
  60807. * Creates a new connection point
  60808. * @param name defines the connection point name
  60809. * @param ownerBlock defines the block hosting this connection point
  60810. * @param direction defines the direction of the connection point
  60811. */
  60812. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60813. /**
  60814. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60815. * @returns the class name
  60816. */
  60817. getClassName(): string;
  60818. /**
  60819. * Gets a boolean indicating if the current point can be connected to another point
  60820. * @param connectionPoint defines the other connection point
  60821. * @returns a boolean
  60822. */
  60823. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60824. /**
  60825. * Gets a number indicating if the current point can be connected to another point
  60826. * @param connectionPoint defines the other connection point
  60827. * @returns a number defining the compatibility state
  60828. */
  60829. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60830. /**
  60831. * Connect this point to another connection point
  60832. * @param connectionPoint defines the other connection point
  60833. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60834. * @returns the current connection point
  60835. */
  60836. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60837. /**
  60838. * Disconnect this point from one of his endpoint
  60839. * @param endpoint defines the other connection point
  60840. * @returns the current connection point
  60841. */
  60842. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60843. /**
  60844. * Serializes this point in a JSON representation
  60845. * @returns the serialized point object
  60846. */
  60847. serialize(): any;
  60848. /**
  60849. * Release resources
  60850. */
  60851. dispose(): void;
  60852. }
  60853. }
  60854. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60858. import { Mesh } from "babylonjs/Meshes/mesh";
  60859. import { Effect } from "babylonjs/Materials/effect";
  60860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60861. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60862. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60863. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60864. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60865. /**
  60866. * Block used to add support for vertex skinning (bones)
  60867. */
  60868. export class BonesBlock extends NodeMaterialBlock {
  60869. /**
  60870. * Creates a new BonesBlock
  60871. * @param name defines the block name
  60872. */
  60873. constructor(name: string);
  60874. /**
  60875. * Initialize the block and prepare the context for build
  60876. * @param state defines the state that will be used for the build
  60877. */
  60878. initialize(state: NodeMaterialBuildState): void;
  60879. /**
  60880. * Gets the current class name
  60881. * @returns the class name
  60882. */
  60883. getClassName(): string;
  60884. /**
  60885. * Gets the matrix indices input component
  60886. */
  60887. get matricesIndices(): NodeMaterialConnectionPoint;
  60888. /**
  60889. * Gets the matrix weights input component
  60890. */
  60891. get matricesWeights(): NodeMaterialConnectionPoint;
  60892. /**
  60893. * Gets the extra matrix indices input component
  60894. */
  60895. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60896. /**
  60897. * Gets the extra matrix weights input component
  60898. */
  60899. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60900. /**
  60901. * Gets the world input component
  60902. */
  60903. get world(): NodeMaterialConnectionPoint;
  60904. /**
  60905. * Gets the output component
  60906. */
  60907. get output(): NodeMaterialConnectionPoint;
  60908. autoConfigure(material: NodeMaterial): void;
  60909. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60910. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60912. protected _buildBlock(state: NodeMaterialBuildState): this;
  60913. }
  60914. }
  60915. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60920. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60921. /**
  60922. * Block used to add support for instances
  60923. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60924. */
  60925. export class InstancesBlock extends NodeMaterialBlock {
  60926. /**
  60927. * Creates a new InstancesBlock
  60928. * @param name defines the block name
  60929. */
  60930. constructor(name: string);
  60931. /**
  60932. * Gets the current class name
  60933. * @returns the class name
  60934. */
  60935. getClassName(): string;
  60936. /**
  60937. * Gets the first world row input component
  60938. */
  60939. get world0(): NodeMaterialConnectionPoint;
  60940. /**
  60941. * Gets the second world row input component
  60942. */
  60943. get world1(): NodeMaterialConnectionPoint;
  60944. /**
  60945. * Gets the third world row input component
  60946. */
  60947. get world2(): NodeMaterialConnectionPoint;
  60948. /**
  60949. * Gets the forth world row input component
  60950. */
  60951. get world3(): NodeMaterialConnectionPoint;
  60952. /**
  60953. * Gets the world input component
  60954. */
  60955. get world(): NodeMaterialConnectionPoint;
  60956. /**
  60957. * Gets the output component
  60958. */
  60959. get output(): NodeMaterialConnectionPoint;
  60960. /**
  60961. * Gets the isntanceID component
  60962. */
  60963. get instanceID(): NodeMaterialConnectionPoint;
  60964. autoConfigure(material: NodeMaterial): void;
  60965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60966. protected _buildBlock(state: NodeMaterialBuildState): this;
  60967. }
  60968. }
  60969. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60974. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60975. import { Effect } from "babylonjs/Materials/effect";
  60976. import { Mesh } from "babylonjs/Meshes/mesh";
  60977. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60978. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60979. /**
  60980. * Block used to add morph targets support to vertex shader
  60981. */
  60982. export class MorphTargetsBlock extends NodeMaterialBlock {
  60983. private _repeatableContentAnchor;
  60984. /**
  60985. * Create a new MorphTargetsBlock
  60986. * @param name defines the block name
  60987. */
  60988. constructor(name: string);
  60989. /**
  60990. * Gets the current class name
  60991. * @returns the class name
  60992. */
  60993. getClassName(): string;
  60994. /**
  60995. * Gets the position input component
  60996. */
  60997. get position(): NodeMaterialConnectionPoint;
  60998. /**
  60999. * Gets the normal input component
  61000. */
  61001. get normal(): NodeMaterialConnectionPoint;
  61002. /**
  61003. * Gets the tangent input component
  61004. */
  61005. get tangent(): NodeMaterialConnectionPoint;
  61006. /**
  61007. * Gets the tangent input component
  61008. */
  61009. get uv(): NodeMaterialConnectionPoint;
  61010. /**
  61011. * Gets the position output component
  61012. */
  61013. get positionOutput(): NodeMaterialConnectionPoint;
  61014. /**
  61015. * Gets the normal output component
  61016. */
  61017. get normalOutput(): NodeMaterialConnectionPoint;
  61018. /**
  61019. * Gets the tangent output component
  61020. */
  61021. get tangentOutput(): NodeMaterialConnectionPoint;
  61022. /**
  61023. * Gets the tangent output component
  61024. */
  61025. get uvOutput(): NodeMaterialConnectionPoint;
  61026. initialize(state: NodeMaterialBuildState): void;
  61027. autoConfigure(material: NodeMaterial): void;
  61028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61029. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61030. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61031. protected _buildBlock(state: NodeMaterialBuildState): this;
  61032. }
  61033. }
  61034. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61038. import { Nullable } from "babylonjs/types";
  61039. import { Scene } from "babylonjs/scene";
  61040. import { Effect } from "babylonjs/Materials/effect";
  61041. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61042. import { Mesh } from "babylonjs/Meshes/mesh";
  61043. import { Light } from "babylonjs/Lights/light";
  61044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61045. /**
  61046. * Block used to get data information from a light
  61047. */
  61048. export class LightInformationBlock extends NodeMaterialBlock {
  61049. private _lightDataUniformName;
  61050. private _lightColorUniformName;
  61051. private _lightTypeDefineName;
  61052. /**
  61053. * Gets or sets the light associated with this block
  61054. */
  61055. light: Nullable<Light>;
  61056. /**
  61057. * Creates a new LightInformationBlock
  61058. * @param name defines the block name
  61059. */
  61060. constructor(name: string);
  61061. /**
  61062. * Gets the current class name
  61063. * @returns the class name
  61064. */
  61065. getClassName(): string;
  61066. /**
  61067. * Gets the world position input component
  61068. */
  61069. get worldPosition(): NodeMaterialConnectionPoint;
  61070. /**
  61071. * Gets the direction output component
  61072. */
  61073. get direction(): NodeMaterialConnectionPoint;
  61074. /**
  61075. * Gets the direction output component
  61076. */
  61077. get color(): NodeMaterialConnectionPoint;
  61078. /**
  61079. * Gets the direction output component
  61080. */
  61081. get intensity(): NodeMaterialConnectionPoint;
  61082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61083. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61084. protected _buildBlock(state: NodeMaterialBuildState): this;
  61085. serialize(): any;
  61086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61087. }
  61088. }
  61089. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61090. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61091. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61092. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61093. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61094. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61095. }
  61096. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61101. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61102. import { Effect } from "babylonjs/Materials/effect";
  61103. import { Mesh } from "babylonjs/Meshes/mesh";
  61104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61105. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61106. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61107. /**
  61108. * Block used to add image processing support to fragment shader
  61109. */
  61110. export class ImageProcessingBlock extends NodeMaterialBlock {
  61111. /**
  61112. * Create a new ImageProcessingBlock
  61113. * @param name defines the block name
  61114. */
  61115. constructor(name: string);
  61116. /**
  61117. * Gets the current class name
  61118. * @returns the class name
  61119. */
  61120. getClassName(): string;
  61121. /**
  61122. * Gets the color input component
  61123. */
  61124. get color(): NodeMaterialConnectionPoint;
  61125. /**
  61126. * Gets the output component
  61127. */
  61128. get output(): NodeMaterialConnectionPoint;
  61129. /**
  61130. * Initialize the block and prepare the context for build
  61131. * @param state defines the state that will be used for the build
  61132. */
  61133. initialize(state: NodeMaterialBuildState): void;
  61134. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61136. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61137. protected _buildBlock(state: NodeMaterialBuildState): this;
  61138. }
  61139. }
  61140. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61144. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61146. import { Effect } from "babylonjs/Materials/effect";
  61147. import { Mesh } from "babylonjs/Meshes/mesh";
  61148. import { Scene } from "babylonjs/scene";
  61149. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61150. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61151. /**
  61152. * Block used to pertub normals based on a normal map
  61153. */
  61154. export class PerturbNormalBlock extends NodeMaterialBlock {
  61155. private _tangentSpaceParameterName;
  61156. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61157. invertX: boolean;
  61158. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61159. invertY: boolean;
  61160. /**
  61161. * Create a new PerturbNormalBlock
  61162. * @param name defines the block name
  61163. */
  61164. constructor(name: string);
  61165. /**
  61166. * Gets the current class name
  61167. * @returns the class name
  61168. */
  61169. getClassName(): string;
  61170. /**
  61171. * Gets the world position input component
  61172. */
  61173. get worldPosition(): NodeMaterialConnectionPoint;
  61174. /**
  61175. * Gets the world normal input component
  61176. */
  61177. get worldNormal(): NodeMaterialConnectionPoint;
  61178. /**
  61179. * Gets the world tangent input component
  61180. */
  61181. get worldTangent(): NodeMaterialConnectionPoint;
  61182. /**
  61183. * Gets the uv input component
  61184. */
  61185. get uv(): NodeMaterialConnectionPoint;
  61186. /**
  61187. * Gets the normal map color input component
  61188. */
  61189. get normalMapColor(): NodeMaterialConnectionPoint;
  61190. /**
  61191. * Gets the strength input component
  61192. */
  61193. get strength(): NodeMaterialConnectionPoint;
  61194. /**
  61195. * Gets the output component
  61196. */
  61197. get output(): NodeMaterialConnectionPoint;
  61198. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61200. autoConfigure(material: NodeMaterial): void;
  61201. protected _buildBlock(state: NodeMaterialBuildState): this;
  61202. protected _dumpPropertiesCode(): string;
  61203. serialize(): any;
  61204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61205. }
  61206. }
  61207. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61211. /**
  61212. * Block used to discard a pixel if a value is smaller than a cutoff
  61213. */
  61214. export class DiscardBlock extends NodeMaterialBlock {
  61215. /**
  61216. * Create a new DiscardBlock
  61217. * @param name defines the block name
  61218. */
  61219. constructor(name: string);
  61220. /**
  61221. * Gets the current class name
  61222. * @returns the class name
  61223. */
  61224. getClassName(): string;
  61225. /**
  61226. * Gets the color input component
  61227. */
  61228. get value(): NodeMaterialConnectionPoint;
  61229. /**
  61230. * Gets the cutoff input component
  61231. */
  61232. get cutoff(): NodeMaterialConnectionPoint;
  61233. protected _buildBlock(state: NodeMaterialBuildState): this;
  61234. }
  61235. }
  61236. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61240. /**
  61241. * Block used to test if the fragment shader is front facing
  61242. */
  61243. export class FrontFacingBlock extends NodeMaterialBlock {
  61244. /**
  61245. * Creates a new FrontFacingBlock
  61246. * @param name defines the block name
  61247. */
  61248. constructor(name: string);
  61249. /**
  61250. * Gets the current class name
  61251. * @returns the class name
  61252. */
  61253. getClassName(): string;
  61254. /**
  61255. * Gets the output component
  61256. */
  61257. get output(): NodeMaterialConnectionPoint;
  61258. protected _buildBlock(state: NodeMaterialBuildState): this;
  61259. }
  61260. }
  61261. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61265. /**
  61266. * Block used to get the derivative value on x and y of a given input
  61267. */
  61268. export class DerivativeBlock extends NodeMaterialBlock {
  61269. /**
  61270. * Create a new DerivativeBlock
  61271. * @param name defines the block name
  61272. */
  61273. constructor(name: string);
  61274. /**
  61275. * Gets the current class name
  61276. * @returns the class name
  61277. */
  61278. getClassName(): string;
  61279. /**
  61280. * Gets the input component
  61281. */
  61282. get input(): NodeMaterialConnectionPoint;
  61283. /**
  61284. * Gets the derivative output on x
  61285. */
  61286. get dx(): NodeMaterialConnectionPoint;
  61287. /**
  61288. * Gets the derivative output on y
  61289. */
  61290. get dy(): NodeMaterialConnectionPoint;
  61291. protected _buildBlock(state: NodeMaterialBuildState): this;
  61292. }
  61293. }
  61294. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61295. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61296. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61297. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61298. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61299. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61300. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61301. }
  61302. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61305. import { Mesh } from "babylonjs/Meshes/mesh";
  61306. import { Effect } from "babylonjs/Materials/effect";
  61307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61309. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61310. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61311. /**
  61312. * Block used to add support for scene fog
  61313. */
  61314. export class FogBlock extends NodeMaterialBlock {
  61315. private _fogDistanceName;
  61316. private _fogParameters;
  61317. /**
  61318. * Create a new FogBlock
  61319. * @param name defines the block name
  61320. */
  61321. constructor(name: string);
  61322. /**
  61323. * Gets the current class name
  61324. * @returns the class name
  61325. */
  61326. getClassName(): string;
  61327. /**
  61328. * Gets the world position input component
  61329. */
  61330. get worldPosition(): NodeMaterialConnectionPoint;
  61331. /**
  61332. * Gets the view input component
  61333. */
  61334. get view(): NodeMaterialConnectionPoint;
  61335. /**
  61336. * Gets the color input component
  61337. */
  61338. get input(): NodeMaterialConnectionPoint;
  61339. /**
  61340. * Gets the fog color input component
  61341. */
  61342. get fogColor(): NodeMaterialConnectionPoint;
  61343. /**
  61344. * Gets the output component
  61345. */
  61346. get output(): NodeMaterialConnectionPoint;
  61347. autoConfigure(material: NodeMaterial): void;
  61348. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61349. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61350. protected _buildBlock(state: NodeMaterialBuildState): this;
  61351. }
  61352. }
  61353. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61358. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61359. import { Effect } from "babylonjs/Materials/effect";
  61360. import { Mesh } from "babylonjs/Meshes/mesh";
  61361. import { Light } from "babylonjs/Lights/light";
  61362. import { Nullable } from "babylonjs/types";
  61363. import { Scene } from "babylonjs/scene";
  61364. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61365. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61366. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61367. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61368. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61369. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61370. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61371. /**
  61372. * Block used to add light in the fragment shader
  61373. */
  61374. export class LightBlock extends NodeMaterialBlock {
  61375. private _lightId;
  61376. /**
  61377. * Gets or sets the light associated with this block
  61378. */
  61379. light: Nullable<Light>;
  61380. /**
  61381. * Create a new LightBlock
  61382. * @param name defines the block name
  61383. */
  61384. constructor(name: string);
  61385. /**
  61386. * Gets the current class name
  61387. * @returns the class name
  61388. */
  61389. getClassName(): string;
  61390. /**
  61391. * Gets the world position input component
  61392. */
  61393. get worldPosition(): NodeMaterialConnectionPoint;
  61394. /**
  61395. * Gets the world normal input component
  61396. */
  61397. get worldNormal(): NodeMaterialConnectionPoint;
  61398. /**
  61399. * Gets the camera (or eye) position component
  61400. */
  61401. get cameraPosition(): NodeMaterialConnectionPoint;
  61402. /**
  61403. * Gets the glossiness component
  61404. */
  61405. get glossiness(): NodeMaterialConnectionPoint;
  61406. /**
  61407. * Gets the glossinness power component
  61408. */
  61409. get glossPower(): NodeMaterialConnectionPoint;
  61410. /**
  61411. * Gets the diffuse color component
  61412. */
  61413. get diffuseColor(): NodeMaterialConnectionPoint;
  61414. /**
  61415. * Gets the specular color component
  61416. */
  61417. get specularColor(): NodeMaterialConnectionPoint;
  61418. /**
  61419. * Gets the diffuse output component
  61420. */
  61421. get diffuseOutput(): NodeMaterialConnectionPoint;
  61422. /**
  61423. * Gets the specular output component
  61424. */
  61425. get specularOutput(): NodeMaterialConnectionPoint;
  61426. /**
  61427. * Gets the shadow output component
  61428. */
  61429. get shadow(): NodeMaterialConnectionPoint;
  61430. autoConfigure(material: NodeMaterial): void;
  61431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61432. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61434. private _injectVertexCode;
  61435. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61436. serialize(): any;
  61437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61438. }
  61439. }
  61440. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61441. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61442. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61443. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61444. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61445. }
  61446. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61447. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61448. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61449. }
  61450. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61454. /**
  61455. * Block used to multiply 2 values
  61456. */
  61457. export class MultiplyBlock extends NodeMaterialBlock {
  61458. /**
  61459. * Creates a new MultiplyBlock
  61460. * @param name defines the block name
  61461. */
  61462. constructor(name: string);
  61463. /**
  61464. * Gets the current class name
  61465. * @returns the class name
  61466. */
  61467. getClassName(): string;
  61468. /**
  61469. * Gets the left operand input component
  61470. */
  61471. get left(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the right operand input component
  61474. */
  61475. get right(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the output component
  61478. */
  61479. get output(): NodeMaterialConnectionPoint;
  61480. protected _buildBlock(state: NodeMaterialBuildState): this;
  61481. }
  61482. }
  61483. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61487. /**
  61488. * Block used to add 2 vectors
  61489. */
  61490. export class AddBlock extends NodeMaterialBlock {
  61491. /**
  61492. * Creates a new AddBlock
  61493. * @param name defines the block name
  61494. */
  61495. constructor(name: string);
  61496. /**
  61497. * Gets the current class name
  61498. * @returns the class name
  61499. */
  61500. getClassName(): string;
  61501. /**
  61502. * Gets the left operand input component
  61503. */
  61504. get left(): NodeMaterialConnectionPoint;
  61505. /**
  61506. * Gets the right operand input component
  61507. */
  61508. get right(): NodeMaterialConnectionPoint;
  61509. /**
  61510. * Gets the output component
  61511. */
  61512. get output(): NodeMaterialConnectionPoint;
  61513. protected _buildBlock(state: NodeMaterialBuildState): this;
  61514. }
  61515. }
  61516. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61520. /**
  61521. * Block used to scale a vector by a float
  61522. */
  61523. export class ScaleBlock extends NodeMaterialBlock {
  61524. /**
  61525. * Creates a new ScaleBlock
  61526. * @param name defines the block name
  61527. */
  61528. constructor(name: string);
  61529. /**
  61530. * Gets the current class name
  61531. * @returns the class name
  61532. */
  61533. getClassName(): string;
  61534. /**
  61535. * Gets the input component
  61536. */
  61537. get input(): NodeMaterialConnectionPoint;
  61538. /**
  61539. * Gets the factor input component
  61540. */
  61541. get factor(): NodeMaterialConnectionPoint;
  61542. /**
  61543. * Gets the output component
  61544. */
  61545. get output(): NodeMaterialConnectionPoint;
  61546. protected _buildBlock(state: NodeMaterialBuildState): this;
  61547. }
  61548. }
  61549. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61553. import { Scene } from "babylonjs/scene";
  61554. /**
  61555. * Block used to clamp a float
  61556. */
  61557. export class ClampBlock extends NodeMaterialBlock {
  61558. /** Gets or sets the minimum range */
  61559. minimum: number;
  61560. /** Gets or sets the maximum range */
  61561. maximum: number;
  61562. /**
  61563. * Creates a new ClampBlock
  61564. * @param name defines the block name
  61565. */
  61566. constructor(name: string);
  61567. /**
  61568. * Gets the current class name
  61569. * @returns the class name
  61570. */
  61571. getClassName(): string;
  61572. /**
  61573. * Gets the value input component
  61574. */
  61575. get value(): NodeMaterialConnectionPoint;
  61576. /**
  61577. * Gets the output component
  61578. */
  61579. get output(): NodeMaterialConnectionPoint;
  61580. protected _buildBlock(state: NodeMaterialBuildState): this;
  61581. protected _dumpPropertiesCode(): string;
  61582. serialize(): any;
  61583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61584. }
  61585. }
  61586. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61590. /**
  61591. * Block used to apply a cross product between 2 vectors
  61592. */
  61593. export class CrossBlock extends NodeMaterialBlock {
  61594. /**
  61595. * Creates a new CrossBlock
  61596. * @param name defines the block name
  61597. */
  61598. constructor(name: string);
  61599. /**
  61600. * Gets the current class name
  61601. * @returns the class name
  61602. */
  61603. getClassName(): string;
  61604. /**
  61605. * Gets the left operand input component
  61606. */
  61607. get left(): NodeMaterialConnectionPoint;
  61608. /**
  61609. * Gets the right operand input component
  61610. */
  61611. get right(): NodeMaterialConnectionPoint;
  61612. /**
  61613. * Gets the output component
  61614. */
  61615. get output(): NodeMaterialConnectionPoint;
  61616. protected _buildBlock(state: NodeMaterialBuildState): this;
  61617. }
  61618. }
  61619. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61623. /**
  61624. * Block used to apply a dot product between 2 vectors
  61625. */
  61626. export class DotBlock extends NodeMaterialBlock {
  61627. /**
  61628. * Creates a new DotBlock
  61629. * @param name defines the block name
  61630. */
  61631. constructor(name: string);
  61632. /**
  61633. * Gets the current class name
  61634. * @returns the class name
  61635. */
  61636. getClassName(): string;
  61637. /**
  61638. * Gets the left operand input component
  61639. */
  61640. get left(): NodeMaterialConnectionPoint;
  61641. /**
  61642. * Gets the right operand input component
  61643. */
  61644. get right(): NodeMaterialConnectionPoint;
  61645. /**
  61646. * Gets the output component
  61647. */
  61648. get output(): NodeMaterialConnectionPoint;
  61649. protected _buildBlock(state: NodeMaterialBuildState): this;
  61650. }
  61651. }
  61652. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61656. import { Vector2 } from "babylonjs/Maths/math.vector";
  61657. import { Scene } from "babylonjs/scene";
  61658. /**
  61659. * Block used to remap a float from a range to a new one
  61660. */
  61661. export class RemapBlock extends NodeMaterialBlock {
  61662. /**
  61663. * Gets or sets the source range
  61664. */
  61665. sourceRange: Vector2;
  61666. /**
  61667. * Gets or sets the target range
  61668. */
  61669. targetRange: Vector2;
  61670. /**
  61671. * Creates a new RemapBlock
  61672. * @param name defines the block name
  61673. */
  61674. constructor(name: string);
  61675. /**
  61676. * Gets the current class name
  61677. * @returns the class name
  61678. */
  61679. getClassName(): string;
  61680. /**
  61681. * Gets the input component
  61682. */
  61683. get input(): NodeMaterialConnectionPoint;
  61684. /**
  61685. * Gets the source min input component
  61686. */
  61687. get sourceMin(): NodeMaterialConnectionPoint;
  61688. /**
  61689. * Gets the source max input component
  61690. */
  61691. get sourceMax(): NodeMaterialConnectionPoint;
  61692. /**
  61693. * Gets the target min input component
  61694. */
  61695. get targetMin(): NodeMaterialConnectionPoint;
  61696. /**
  61697. * Gets the target max input component
  61698. */
  61699. get targetMax(): NodeMaterialConnectionPoint;
  61700. /**
  61701. * Gets the output component
  61702. */
  61703. get output(): NodeMaterialConnectionPoint;
  61704. protected _buildBlock(state: NodeMaterialBuildState): this;
  61705. protected _dumpPropertiesCode(): string;
  61706. serialize(): any;
  61707. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61708. }
  61709. }
  61710. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61714. /**
  61715. * Block used to normalize a vector
  61716. */
  61717. export class NormalizeBlock extends NodeMaterialBlock {
  61718. /**
  61719. * Creates a new NormalizeBlock
  61720. * @param name defines the block name
  61721. */
  61722. constructor(name: string);
  61723. /**
  61724. * Gets the current class name
  61725. * @returns the class name
  61726. */
  61727. getClassName(): string;
  61728. /**
  61729. * Gets the input component
  61730. */
  61731. get input(): NodeMaterialConnectionPoint;
  61732. /**
  61733. * Gets the output component
  61734. */
  61735. get output(): NodeMaterialConnectionPoint;
  61736. protected _buildBlock(state: NodeMaterialBuildState): this;
  61737. }
  61738. }
  61739. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61743. import { Scene } from "babylonjs/scene";
  61744. /**
  61745. * Operations supported by the Trigonometry block
  61746. */
  61747. export enum TrigonometryBlockOperations {
  61748. /** Cos */
  61749. Cos = 0,
  61750. /** Sin */
  61751. Sin = 1,
  61752. /** Abs */
  61753. Abs = 2,
  61754. /** Exp */
  61755. Exp = 3,
  61756. /** Exp2 */
  61757. Exp2 = 4,
  61758. /** Round */
  61759. Round = 5,
  61760. /** Floor */
  61761. Floor = 6,
  61762. /** Ceiling */
  61763. Ceiling = 7,
  61764. /** Square root */
  61765. Sqrt = 8,
  61766. /** Log */
  61767. Log = 9,
  61768. /** Tangent */
  61769. Tan = 10,
  61770. /** Arc tangent */
  61771. ArcTan = 11,
  61772. /** Arc cosinus */
  61773. ArcCos = 12,
  61774. /** Arc sinus */
  61775. ArcSin = 13,
  61776. /** Fraction */
  61777. Fract = 14,
  61778. /** Sign */
  61779. Sign = 15,
  61780. /** To radians (from degrees) */
  61781. Radians = 16,
  61782. /** To degrees (from radians) */
  61783. Degrees = 17
  61784. }
  61785. /**
  61786. * Block used to apply trigonometry operation to floats
  61787. */
  61788. export class TrigonometryBlock extends NodeMaterialBlock {
  61789. /**
  61790. * Gets or sets the operation applied by the block
  61791. */
  61792. operation: TrigonometryBlockOperations;
  61793. /**
  61794. * Creates a new TrigonometryBlock
  61795. * @param name defines the block name
  61796. */
  61797. constructor(name: string);
  61798. /**
  61799. * Gets the current class name
  61800. * @returns the class name
  61801. */
  61802. getClassName(): string;
  61803. /**
  61804. * Gets the input component
  61805. */
  61806. get input(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the output component
  61809. */
  61810. get output(): NodeMaterialConnectionPoint;
  61811. protected _buildBlock(state: NodeMaterialBuildState): this;
  61812. serialize(): any;
  61813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61814. protected _dumpPropertiesCode(): string;
  61815. }
  61816. }
  61817. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61821. /**
  61822. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61823. */
  61824. export class ColorMergerBlock extends NodeMaterialBlock {
  61825. /**
  61826. * Create a new ColorMergerBlock
  61827. * @param name defines the block name
  61828. */
  61829. constructor(name: string);
  61830. /**
  61831. * Gets the current class name
  61832. * @returns the class name
  61833. */
  61834. getClassName(): string;
  61835. /**
  61836. * Gets the rgb component (input)
  61837. */
  61838. get rgbIn(): NodeMaterialConnectionPoint;
  61839. /**
  61840. * Gets the r component (input)
  61841. */
  61842. get r(): NodeMaterialConnectionPoint;
  61843. /**
  61844. * Gets the g component (input)
  61845. */
  61846. get g(): NodeMaterialConnectionPoint;
  61847. /**
  61848. * Gets the b component (input)
  61849. */
  61850. get b(): NodeMaterialConnectionPoint;
  61851. /**
  61852. * Gets the a component (input)
  61853. */
  61854. get a(): NodeMaterialConnectionPoint;
  61855. /**
  61856. * Gets the rgba component (output)
  61857. */
  61858. get rgba(): NodeMaterialConnectionPoint;
  61859. /**
  61860. * Gets the rgb component (output)
  61861. */
  61862. get rgbOut(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the rgb component (output)
  61865. * @deprecated Please use rgbOut instead.
  61866. */
  61867. get rgb(): NodeMaterialConnectionPoint;
  61868. protected _buildBlock(state: NodeMaterialBuildState): this;
  61869. }
  61870. }
  61871. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61875. /**
  61876. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61877. */
  61878. export class VectorMergerBlock extends NodeMaterialBlock {
  61879. /**
  61880. * Create a new VectorMergerBlock
  61881. * @param name defines the block name
  61882. */
  61883. constructor(name: string);
  61884. /**
  61885. * Gets the current class name
  61886. * @returns the class name
  61887. */
  61888. getClassName(): string;
  61889. /**
  61890. * Gets the xyz component (input)
  61891. */
  61892. get xyzIn(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the xy component (input)
  61895. */
  61896. get xyIn(): NodeMaterialConnectionPoint;
  61897. /**
  61898. * Gets the x component (input)
  61899. */
  61900. get x(): NodeMaterialConnectionPoint;
  61901. /**
  61902. * Gets the y component (input)
  61903. */
  61904. get y(): NodeMaterialConnectionPoint;
  61905. /**
  61906. * Gets the z component (input)
  61907. */
  61908. get z(): NodeMaterialConnectionPoint;
  61909. /**
  61910. * Gets the w component (input)
  61911. */
  61912. get w(): NodeMaterialConnectionPoint;
  61913. /**
  61914. * Gets the xyzw component (output)
  61915. */
  61916. get xyzw(): NodeMaterialConnectionPoint;
  61917. /**
  61918. * Gets the xyz component (output)
  61919. */
  61920. get xyzOut(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the xy component (output)
  61923. */
  61924. get xyOut(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the xy component (output)
  61927. * @deprecated Please use xyOut instead.
  61928. */
  61929. get xy(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the xyz component (output)
  61932. * @deprecated Please use xyzOut instead.
  61933. */
  61934. get xyz(): NodeMaterialConnectionPoint;
  61935. protected _buildBlock(state: NodeMaterialBuildState): this;
  61936. }
  61937. }
  61938. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61939. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61941. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61942. /**
  61943. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61944. */
  61945. export class ColorSplitterBlock extends NodeMaterialBlock {
  61946. /**
  61947. * Create a new ColorSplitterBlock
  61948. * @param name defines the block name
  61949. */
  61950. constructor(name: string);
  61951. /**
  61952. * Gets the current class name
  61953. * @returns the class name
  61954. */
  61955. getClassName(): string;
  61956. /**
  61957. * Gets the rgba component (input)
  61958. */
  61959. get rgba(): NodeMaterialConnectionPoint;
  61960. /**
  61961. * Gets the rgb component (input)
  61962. */
  61963. get rgbIn(): NodeMaterialConnectionPoint;
  61964. /**
  61965. * Gets the rgb component (output)
  61966. */
  61967. get rgbOut(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the r component (output)
  61970. */
  61971. get r(): NodeMaterialConnectionPoint;
  61972. /**
  61973. * Gets the g component (output)
  61974. */
  61975. get g(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the b component (output)
  61978. */
  61979. get b(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the a component (output)
  61982. */
  61983. get a(): NodeMaterialConnectionPoint;
  61984. protected _inputRename(name: string): string;
  61985. protected _outputRename(name: string): string;
  61986. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61987. }
  61988. }
  61989. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61993. /**
  61994. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61995. */
  61996. export class VectorSplitterBlock extends NodeMaterialBlock {
  61997. /**
  61998. * Create a new VectorSplitterBlock
  61999. * @param name defines the block name
  62000. */
  62001. constructor(name: string);
  62002. /**
  62003. * Gets the current class name
  62004. * @returns the class name
  62005. */
  62006. getClassName(): string;
  62007. /**
  62008. * Gets the xyzw component (input)
  62009. */
  62010. get xyzw(): NodeMaterialConnectionPoint;
  62011. /**
  62012. * Gets the xyz component (input)
  62013. */
  62014. get xyzIn(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the xy component (input)
  62017. */
  62018. get xyIn(): NodeMaterialConnectionPoint;
  62019. /**
  62020. * Gets the xyz component (output)
  62021. */
  62022. get xyzOut(): NodeMaterialConnectionPoint;
  62023. /**
  62024. * Gets the xy component (output)
  62025. */
  62026. get xyOut(): NodeMaterialConnectionPoint;
  62027. /**
  62028. * Gets the x component (output)
  62029. */
  62030. get x(): NodeMaterialConnectionPoint;
  62031. /**
  62032. * Gets the y component (output)
  62033. */
  62034. get y(): NodeMaterialConnectionPoint;
  62035. /**
  62036. * Gets the z component (output)
  62037. */
  62038. get z(): NodeMaterialConnectionPoint;
  62039. /**
  62040. * Gets the w component (output)
  62041. */
  62042. get w(): NodeMaterialConnectionPoint;
  62043. protected _inputRename(name: string): string;
  62044. protected _outputRename(name: string): string;
  62045. protected _buildBlock(state: NodeMaterialBuildState): this;
  62046. }
  62047. }
  62048. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62049. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62052. /**
  62053. * Block used to lerp between 2 values
  62054. */
  62055. export class LerpBlock extends NodeMaterialBlock {
  62056. /**
  62057. * Creates a new LerpBlock
  62058. * @param name defines the block name
  62059. */
  62060. constructor(name: string);
  62061. /**
  62062. * Gets the current class name
  62063. * @returns the class name
  62064. */
  62065. getClassName(): string;
  62066. /**
  62067. * Gets the left operand input component
  62068. */
  62069. get left(): NodeMaterialConnectionPoint;
  62070. /**
  62071. * Gets the right operand input component
  62072. */
  62073. get right(): NodeMaterialConnectionPoint;
  62074. /**
  62075. * Gets the gradient operand input component
  62076. */
  62077. get gradient(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the output component
  62080. */
  62081. get output(): NodeMaterialConnectionPoint;
  62082. protected _buildBlock(state: NodeMaterialBuildState): this;
  62083. }
  62084. }
  62085. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62089. /**
  62090. * Block used to divide 2 vectors
  62091. */
  62092. export class DivideBlock extends NodeMaterialBlock {
  62093. /**
  62094. * Creates a new DivideBlock
  62095. * @param name defines the block name
  62096. */
  62097. constructor(name: string);
  62098. /**
  62099. * Gets the current class name
  62100. * @returns the class name
  62101. */
  62102. getClassName(): string;
  62103. /**
  62104. * Gets the left operand input component
  62105. */
  62106. get left(): NodeMaterialConnectionPoint;
  62107. /**
  62108. * Gets the right operand input component
  62109. */
  62110. get right(): NodeMaterialConnectionPoint;
  62111. /**
  62112. * Gets the output component
  62113. */
  62114. get output(): NodeMaterialConnectionPoint;
  62115. protected _buildBlock(state: NodeMaterialBuildState): this;
  62116. }
  62117. }
  62118. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62122. /**
  62123. * Block used to subtract 2 vectors
  62124. */
  62125. export class SubtractBlock extends NodeMaterialBlock {
  62126. /**
  62127. * Creates a new SubtractBlock
  62128. * @param name defines the block name
  62129. */
  62130. constructor(name: string);
  62131. /**
  62132. * Gets the current class name
  62133. * @returns the class name
  62134. */
  62135. getClassName(): string;
  62136. /**
  62137. * Gets the left operand input component
  62138. */
  62139. get left(): NodeMaterialConnectionPoint;
  62140. /**
  62141. * Gets the right operand input component
  62142. */
  62143. get right(): NodeMaterialConnectionPoint;
  62144. /**
  62145. * Gets the output component
  62146. */
  62147. get output(): NodeMaterialConnectionPoint;
  62148. protected _buildBlock(state: NodeMaterialBuildState): this;
  62149. }
  62150. }
  62151. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62155. /**
  62156. * Block used to step a value
  62157. */
  62158. export class StepBlock extends NodeMaterialBlock {
  62159. /**
  62160. * Creates a new StepBlock
  62161. * @param name defines the block name
  62162. */
  62163. constructor(name: string);
  62164. /**
  62165. * Gets the current class name
  62166. * @returns the class name
  62167. */
  62168. getClassName(): string;
  62169. /**
  62170. * Gets the value operand input component
  62171. */
  62172. get value(): NodeMaterialConnectionPoint;
  62173. /**
  62174. * Gets the edge operand input component
  62175. */
  62176. get edge(): NodeMaterialConnectionPoint;
  62177. /**
  62178. * Gets the output component
  62179. */
  62180. get output(): NodeMaterialConnectionPoint;
  62181. protected _buildBlock(state: NodeMaterialBuildState): this;
  62182. }
  62183. }
  62184. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62188. /**
  62189. * Block used to get the opposite (1 - x) of a value
  62190. */
  62191. export class OneMinusBlock extends NodeMaterialBlock {
  62192. /**
  62193. * Creates a new OneMinusBlock
  62194. * @param name defines the block name
  62195. */
  62196. constructor(name: string);
  62197. /**
  62198. * Gets the current class name
  62199. * @returns the class name
  62200. */
  62201. getClassName(): string;
  62202. /**
  62203. * Gets the input component
  62204. */
  62205. get input(): NodeMaterialConnectionPoint;
  62206. /**
  62207. * Gets the output component
  62208. */
  62209. get output(): NodeMaterialConnectionPoint;
  62210. protected _buildBlock(state: NodeMaterialBuildState): this;
  62211. }
  62212. }
  62213. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62217. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62218. /**
  62219. * Block used to get the view direction
  62220. */
  62221. export class ViewDirectionBlock extends NodeMaterialBlock {
  62222. /**
  62223. * Creates a new ViewDirectionBlock
  62224. * @param name defines the block name
  62225. */
  62226. constructor(name: string);
  62227. /**
  62228. * Gets the current class name
  62229. * @returns the class name
  62230. */
  62231. getClassName(): string;
  62232. /**
  62233. * Gets the world position component
  62234. */
  62235. get worldPosition(): NodeMaterialConnectionPoint;
  62236. /**
  62237. * Gets the camera position component
  62238. */
  62239. get cameraPosition(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the output component
  62242. */
  62243. get output(): NodeMaterialConnectionPoint;
  62244. autoConfigure(material: NodeMaterial): void;
  62245. protected _buildBlock(state: NodeMaterialBuildState): this;
  62246. }
  62247. }
  62248. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62249. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62250. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62251. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62252. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62253. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62254. /**
  62255. * Block used to compute fresnel value
  62256. */
  62257. export class FresnelBlock extends NodeMaterialBlock {
  62258. /**
  62259. * Create a new FresnelBlock
  62260. * @param name defines the block name
  62261. */
  62262. constructor(name: string);
  62263. /**
  62264. * Gets the current class name
  62265. * @returns the class name
  62266. */
  62267. getClassName(): string;
  62268. /**
  62269. * Gets the world normal input component
  62270. */
  62271. get worldNormal(): NodeMaterialConnectionPoint;
  62272. /**
  62273. * Gets the view direction input component
  62274. */
  62275. get viewDirection(): NodeMaterialConnectionPoint;
  62276. /**
  62277. * Gets the bias input component
  62278. */
  62279. get bias(): NodeMaterialConnectionPoint;
  62280. /**
  62281. * Gets the camera (or eye) position component
  62282. */
  62283. get power(): NodeMaterialConnectionPoint;
  62284. /**
  62285. * Gets the fresnel output component
  62286. */
  62287. get fresnel(): NodeMaterialConnectionPoint;
  62288. autoConfigure(material: NodeMaterial): void;
  62289. protected _buildBlock(state: NodeMaterialBuildState): this;
  62290. }
  62291. }
  62292. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62296. /**
  62297. * Block used to get the max of 2 values
  62298. */
  62299. export class MaxBlock extends NodeMaterialBlock {
  62300. /**
  62301. * Creates a new MaxBlock
  62302. * @param name defines the block name
  62303. */
  62304. constructor(name: string);
  62305. /**
  62306. * Gets the current class name
  62307. * @returns the class name
  62308. */
  62309. getClassName(): string;
  62310. /**
  62311. * Gets the left operand input component
  62312. */
  62313. get left(): NodeMaterialConnectionPoint;
  62314. /**
  62315. * Gets the right operand input component
  62316. */
  62317. get right(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the output component
  62320. */
  62321. get output(): NodeMaterialConnectionPoint;
  62322. protected _buildBlock(state: NodeMaterialBuildState): this;
  62323. }
  62324. }
  62325. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62329. /**
  62330. * Block used to get the min of 2 values
  62331. */
  62332. export class MinBlock extends NodeMaterialBlock {
  62333. /**
  62334. * Creates a new MinBlock
  62335. * @param name defines the block name
  62336. */
  62337. constructor(name: string);
  62338. /**
  62339. * Gets the current class name
  62340. * @returns the class name
  62341. */
  62342. getClassName(): string;
  62343. /**
  62344. * Gets the left operand input component
  62345. */
  62346. get left(): NodeMaterialConnectionPoint;
  62347. /**
  62348. * Gets the right operand input component
  62349. */
  62350. get right(): NodeMaterialConnectionPoint;
  62351. /**
  62352. * Gets the output component
  62353. */
  62354. get output(): NodeMaterialConnectionPoint;
  62355. protected _buildBlock(state: NodeMaterialBuildState): this;
  62356. }
  62357. }
  62358. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62362. /**
  62363. * Block used to get the distance between 2 values
  62364. */
  62365. export class DistanceBlock extends NodeMaterialBlock {
  62366. /**
  62367. * Creates a new DistanceBlock
  62368. * @param name defines the block name
  62369. */
  62370. constructor(name: string);
  62371. /**
  62372. * Gets the current class name
  62373. * @returns the class name
  62374. */
  62375. getClassName(): string;
  62376. /**
  62377. * Gets the left operand input component
  62378. */
  62379. get left(): NodeMaterialConnectionPoint;
  62380. /**
  62381. * Gets the right operand input component
  62382. */
  62383. get right(): NodeMaterialConnectionPoint;
  62384. /**
  62385. * Gets the output component
  62386. */
  62387. get output(): NodeMaterialConnectionPoint;
  62388. protected _buildBlock(state: NodeMaterialBuildState): this;
  62389. }
  62390. }
  62391. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62395. /**
  62396. * Block used to get the length of a vector
  62397. */
  62398. export class LengthBlock extends NodeMaterialBlock {
  62399. /**
  62400. * Creates a new LengthBlock
  62401. * @param name defines the block name
  62402. */
  62403. constructor(name: string);
  62404. /**
  62405. * Gets the current class name
  62406. * @returns the class name
  62407. */
  62408. getClassName(): string;
  62409. /**
  62410. * Gets the value input component
  62411. */
  62412. get value(): NodeMaterialConnectionPoint;
  62413. /**
  62414. * Gets the output component
  62415. */
  62416. get output(): NodeMaterialConnectionPoint;
  62417. protected _buildBlock(state: NodeMaterialBuildState): this;
  62418. }
  62419. }
  62420. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62422. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62424. /**
  62425. * Block used to get negative version of a value (i.e. x * -1)
  62426. */
  62427. export class NegateBlock extends NodeMaterialBlock {
  62428. /**
  62429. * Creates a new NegateBlock
  62430. * @param name defines the block name
  62431. */
  62432. constructor(name: string);
  62433. /**
  62434. * Gets the current class name
  62435. * @returns the class name
  62436. */
  62437. getClassName(): string;
  62438. /**
  62439. * Gets the value input component
  62440. */
  62441. get value(): NodeMaterialConnectionPoint;
  62442. /**
  62443. * Gets the output component
  62444. */
  62445. get output(): NodeMaterialConnectionPoint;
  62446. protected _buildBlock(state: NodeMaterialBuildState): this;
  62447. }
  62448. }
  62449. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62453. /**
  62454. * Block used to get the value of the first parameter raised to the power of the second
  62455. */
  62456. export class PowBlock extends NodeMaterialBlock {
  62457. /**
  62458. * Creates a new PowBlock
  62459. * @param name defines the block name
  62460. */
  62461. constructor(name: string);
  62462. /**
  62463. * Gets the current class name
  62464. * @returns the class name
  62465. */
  62466. getClassName(): string;
  62467. /**
  62468. * Gets the value operand input component
  62469. */
  62470. get value(): NodeMaterialConnectionPoint;
  62471. /**
  62472. * Gets the power operand input component
  62473. */
  62474. get power(): NodeMaterialConnectionPoint;
  62475. /**
  62476. * Gets the output component
  62477. */
  62478. get output(): NodeMaterialConnectionPoint;
  62479. protected _buildBlock(state: NodeMaterialBuildState): this;
  62480. }
  62481. }
  62482. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62486. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62487. /**
  62488. * Block used to get a random number
  62489. */
  62490. export class RandomNumberBlock extends NodeMaterialBlock {
  62491. /**
  62492. * Creates a new RandomNumberBlock
  62493. * @param name defines the block name
  62494. */
  62495. constructor(name: string);
  62496. /**
  62497. * Gets the current class name
  62498. * @returns the class name
  62499. */
  62500. getClassName(): string;
  62501. /**
  62502. * Gets the seed input component
  62503. */
  62504. get seed(): NodeMaterialConnectionPoint;
  62505. /**
  62506. * Gets the output component
  62507. */
  62508. get output(): NodeMaterialConnectionPoint;
  62509. protected _buildBlock(state: NodeMaterialBuildState): this;
  62510. }
  62511. }
  62512. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62516. /**
  62517. * Block used to compute arc tangent of 2 values
  62518. */
  62519. export class ArcTan2Block extends NodeMaterialBlock {
  62520. /**
  62521. * Creates a new ArcTan2Block
  62522. * @param name defines the block name
  62523. */
  62524. constructor(name: string);
  62525. /**
  62526. * Gets the current class name
  62527. * @returns the class name
  62528. */
  62529. getClassName(): string;
  62530. /**
  62531. * Gets the x operand input component
  62532. */
  62533. get x(): NodeMaterialConnectionPoint;
  62534. /**
  62535. * Gets the y operand input component
  62536. */
  62537. get y(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the output component
  62540. */
  62541. get output(): NodeMaterialConnectionPoint;
  62542. protected _buildBlock(state: NodeMaterialBuildState): this;
  62543. }
  62544. }
  62545. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62549. /**
  62550. * Block used to smooth step a value
  62551. */
  62552. export class SmoothStepBlock extends NodeMaterialBlock {
  62553. /**
  62554. * Creates a new SmoothStepBlock
  62555. * @param name defines the block name
  62556. */
  62557. constructor(name: string);
  62558. /**
  62559. * Gets the current class name
  62560. * @returns the class name
  62561. */
  62562. getClassName(): string;
  62563. /**
  62564. * Gets the value operand input component
  62565. */
  62566. get value(): NodeMaterialConnectionPoint;
  62567. /**
  62568. * Gets the first edge operand input component
  62569. */
  62570. get edge0(): NodeMaterialConnectionPoint;
  62571. /**
  62572. * Gets the second edge operand input component
  62573. */
  62574. get edge1(): NodeMaterialConnectionPoint;
  62575. /**
  62576. * Gets the output component
  62577. */
  62578. get output(): NodeMaterialConnectionPoint;
  62579. protected _buildBlock(state: NodeMaterialBuildState): this;
  62580. }
  62581. }
  62582. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62586. /**
  62587. * Block used to get the reciprocal (1 / x) of a value
  62588. */
  62589. export class ReciprocalBlock extends NodeMaterialBlock {
  62590. /**
  62591. * Creates a new ReciprocalBlock
  62592. * @param name defines the block name
  62593. */
  62594. constructor(name: string);
  62595. /**
  62596. * Gets the current class name
  62597. * @returns the class name
  62598. */
  62599. getClassName(): string;
  62600. /**
  62601. * Gets the input component
  62602. */
  62603. get input(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the output component
  62606. */
  62607. get output(): NodeMaterialConnectionPoint;
  62608. protected _buildBlock(state: NodeMaterialBuildState): this;
  62609. }
  62610. }
  62611. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62615. /**
  62616. * Block used to replace a color by another one
  62617. */
  62618. export class ReplaceColorBlock extends NodeMaterialBlock {
  62619. /**
  62620. * Creates a new ReplaceColorBlock
  62621. * @param name defines the block name
  62622. */
  62623. constructor(name: string);
  62624. /**
  62625. * Gets the current class name
  62626. * @returns the class name
  62627. */
  62628. getClassName(): string;
  62629. /**
  62630. * Gets the value input component
  62631. */
  62632. get value(): NodeMaterialConnectionPoint;
  62633. /**
  62634. * Gets the reference input component
  62635. */
  62636. get reference(): NodeMaterialConnectionPoint;
  62637. /**
  62638. * Gets the distance input component
  62639. */
  62640. get distance(): NodeMaterialConnectionPoint;
  62641. /**
  62642. * Gets the replacement input component
  62643. */
  62644. get replacement(): NodeMaterialConnectionPoint;
  62645. /**
  62646. * Gets the output component
  62647. */
  62648. get output(): NodeMaterialConnectionPoint;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this;
  62650. }
  62651. }
  62652. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62656. /**
  62657. * Block used to posterize a value
  62658. * @see https://en.wikipedia.org/wiki/Posterization
  62659. */
  62660. export class PosterizeBlock extends NodeMaterialBlock {
  62661. /**
  62662. * Creates a new PosterizeBlock
  62663. * @param name defines the block name
  62664. */
  62665. constructor(name: string);
  62666. /**
  62667. * Gets the current class name
  62668. * @returns the class name
  62669. */
  62670. getClassName(): string;
  62671. /**
  62672. * Gets the value input component
  62673. */
  62674. get value(): NodeMaterialConnectionPoint;
  62675. /**
  62676. * Gets the steps input component
  62677. */
  62678. get steps(): NodeMaterialConnectionPoint;
  62679. /**
  62680. * Gets the output component
  62681. */
  62682. get output(): NodeMaterialConnectionPoint;
  62683. protected _buildBlock(state: NodeMaterialBuildState): this;
  62684. }
  62685. }
  62686. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62690. import { Scene } from "babylonjs/scene";
  62691. /**
  62692. * Operations supported by the Wave block
  62693. */
  62694. export enum WaveBlockKind {
  62695. /** SawTooth */
  62696. SawTooth = 0,
  62697. /** Square */
  62698. Square = 1,
  62699. /** Triangle */
  62700. Triangle = 2
  62701. }
  62702. /**
  62703. * Block used to apply wave operation to floats
  62704. */
  62705. export class WaveBlock extends NodeMaterialBlock {
  62706. /**
  62707. * Gets or sets the kibnd of wave to be applied by the block
  62708. */
  62709. kind: WaveBlockKind;
  62710. /**
  62711. * Creates a new WaveBlock
  62712. * @param name defines the block name
  62713. */
  62714. constructor(name: string);
  62715. /**
  62716. * Gets the current class name
  62717. * @returns the class name
  62718. */
  62719. getClassName(): string;
  62720. /**
  62721. * Gets the input component
  62722. */
  62723. get input(): NodeMaterialConnectionPoint;
  62724. /**
  62725. * Gets the output component
  62726. */
  62727. get output(): NodeMaterialConnectionPoint;
  62728. protected _buildBlock(state: NodeMaterialBuildState): this;
  62729. serialize(): any;
  62730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62731. }
  62732. }
  62733. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62737. import { Color3 } from "babylonjs/Maths/math.color";
  62738. import { Scene } from "babylonjs/scene";
  62739. /**
  62740. * Class used to store a color step for the GradientBlock
  62741. */
  62742. export class GradientBlockColorStep {
  62743. /**
  62744. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62745. */
  62746. step: number;
  62747. /**
  62748. * Gets or sets the color associated with this step
  62749. */
  62750. color: Color3;
  62751. /**
  62752. * Creates a new GradientBlockColorStep
  62753. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62754. * @param color defines the color associated with this step
  62755. */
  62756. constructor(
  62757. /**
  62758. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62759. */
  62760. step: number,
  62761. /**
  62762. * Gets or sets the color associated with this step
  62763. */
  62764. color: Color3);
  62765. }
  62766. /**
  62767. * Block used to return a color from a gradient based on an input value between 0 and 1
  62768. */
  62769. export class GradientBlock extends NodeMaterialBlock {
  62770. /**
  62771. * Gets or sets the list of color steps
  62772. */
  62773. colorSteps: GradientBlockColorStep[];
  62774. /**
  62775. * Creates a new GradientBlock
  62776. * @param name defines the block name
  62777. */
  62778. constructor(name: string);
  62779. /**
  62780. * Gets the current class name
  62781. * @returns the class name
  62782. */
  62783. getClassName(): string;
  62784. /**
  62785. * Gets the gradient input component
  62786. */
  62787. get gradient(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the output component
  62790. */
  62791. get output(): NodeMaterialConnectionPoint;
  62792. private _writeColorConstant;
  62793. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62794. serialize(): any;
  62795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62796. protected _dumpPropertiesCode(): string;
  62797. }
  62798. }
  62799. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62803. /**
  62804. * Block used to normalize lerp between 2 values
  62805. */
  62806. export class NLerpBlock extends NodeMaterialBlock {
  62807. /**
  62808. * Creates a new NLerpBlock
  62809. * @param name defines the block name
  62810. */
  62811. constructor(name: string);
  62812. /**
  62813. * Gets the current class name
  62814. * @returns the class name
  62815. */
  62816. getClassName(): string;
  62817. /**
  62818. * Gets the left operand input component
  62819. */
  62820. get left(): NodeMaterialConnectionPoint;
  62821. /**
  62822. * Gets the right operand input component
  62823. */
  62824. get right(): NodeMaterialConnectionPoint;
  62825. /**
  62826. * Gets the gradient operand input component
  62827. */
  62828. get gradient(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the output component
  62831. */
  62832. get output(): NodeMaterialConnectionPoint;
  62833. protected _buildBlock(state: NodeMaterialBuildState): this;
  62834. }
  62835. }
  62836. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62840. import { Scene } from "babylonjs/scene";
  62841. /**
  62842. * block used to Generate a Worley Noise 3D Noise Pattern
  62843. */
  62844. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62845. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62846. manhattanDistance: boolean;
  62847. /**
  62848. * Creates a new WorleyNoise3DBlock
  62849. * @param name defines the block name
  62850. */
  62851. constructor(name: string);
  62852. /**
  62853. * Gets the current class name
  62854. * @returns the class name
  62855. */
  62856. getClassName(): string;
  62857. /**
  62858. * Gets the seed input component
  62859. */
  62860. get seed(): NodeMaterialConnectionPoint;
  62861. /**
  62862. * Gets the jitter input component
  62863. */
  62864. get jitter(): NodeMaterialConnectionPoint;
  62865. /**
  62866. * Gets the output component
  62867. */
  62868. get output(): NodeMaterialConnectionPoint;
  62869. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62870. /**
  62871. * Exposes the properties to the UI?
  62872. */
  62873. protected _dumpPropertiesCode(): string;
  62874. /**
  62875. * Exposes the properties to the Seralize?
  62876. */
  62877. serialize(): any;
  62878. /**
  62879. * Exposes the properties to the deseralize?
  62880. */
  62881. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62882. }
  62883. }
  62884. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62888. /**
  62889. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62890. */
  62891. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62892. /**
  62893. * Creates a new SimplexPerlin3DBlock
  62894. * @param name defines the block name
  62895. */
  62896. constructor(name: string);
  62897. /**
  62898. * Gets the current class name
  62899. * @returns the class name
  62900. */
  62901. getClassName(): string;
  62902. /**
  62903. * Gets the seed operand input component
  62904. */
  62905. get seed(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Gets the output component
  62908. */
  62909. get output(): NodeMaterialConnectionPoint;
  62910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62911. }
  62912. }
  62913. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62917. /**
  62918. * Block used to blend normals
  62919. */
  62920. export class NormalBlendBlock extends NodeMaterialBlock {
  62921. /**
  62922. * Creates a new NormalBlendBlock
  62923. * @param name defines the block name
  62924. */
  62925. constructor(name: string);
  62926. /**
  62927. * Gets the current class name
  62928. * @returns the class name
  62929. */
  62930. getClassName(): string;
  62931. /**
  62932. * Gets the first input component
  62933. */
  62934. get normalMap0(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the second input component
  62937. */
  62938. get normalMap1(): NodeMaterialConnectionPoint;
  62939. /**
  62940. * Gets the output component
  62941. */
  62942. get output(): NodeMaterialConnectionPoint;
  62943. protected _buildBlock(state: NodeMaterialBuildState): this;
  62944. }
  62945. }
  62946. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62950. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62951. /**
  62952. * Block used to rotate a 2d vector by a given angle
  62953. */
  62954. export class Rotate2dBlock extends NodeMaterialBlock {
  62955. /**
  62956. * Creates a new Rotate2dBlock
  62957. * @param name defines the block name
  62958. */
  62959. constructor(name: string);
  62960. /**
  62961. * Gets the current class name
  62962. * @returns the class name
  62963. */
  62964. getClassName(): string;
  62965. /**
  62966. * Gets the input vector
  62967. */
  62968. get input(): NodeMaterialConnectionPoint;
  62969. /**
  62970. * Gets the input angle
  62971. */
  62972. get angle(): NodeMaterialConnectionPoint;
  62973. /**
  62974. * Gets the output component
  62975. */
  62976. get output(): NodeMaterialConnectionPoint;
  62977. autoConfigure(material: NodeMaterial): void;
  62978. protected _buildBlock(state: NodeMaterialBuildState): this;
  62979. }
  62980. }
  62981. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62985. /**
  62986. * Block used to get the reflected vector from a direction and a normal
  62987. */
  62988. export class ReflectBlock extends NodeMaterialBlock {
  62989. /**
  62990. * Creates a new ReflectBlock
  62991. * @param name defines the block name
  62992. */
  62993. constructor(name: string);
  62994. /**
  62995. * Gets the current class name
  62996. * @returns the class name
  62997. */
  62998. getClassName(): string;
  62999. /**
  63000. * Gets the incident component
  63001. */
  63002. get incident(): NodeMaterialConnectionPoint;
  63003. /**
  63004. * Gets the normal component
  63005. */
  63006. get normal(): NodeMaterialConnectionPoint;
  63007. /**
  63008. * Gets the output component
  63009. */
  63010. get output(): NodeMaterialConnectionPoint;
  63011. protected _buildBlock(state: NodeMaterialBuildState): this;
  63012. }
  63013. }
  63014. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63018. /**
  63019. * Block used to get the refracted vector from a direction and a normal
  63020. */
  63021. export class RefractBlock extends NodeMaterialBlock {
  63022. /**
  63023. * Creates a new RefractBlock
  63024. * @param name defines the block name
  63025. */
  63026. constructor(name: string);
  63027. /**
  63028. * Gets the current class name
  63029. * @returns the class name
  63030. */
  63031. getClassName(): string;
  63032. /**
  63033. * Gets the incident component
  63034. */
  63035. get incident(): NodeMaterialConnectionPoint;
  63036. /**
  63037. * Gets the normal component
  63038. */
  63039. get normal(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the index of refraction component
  63042. */
  63043. get ior(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the output component
  63046. */
  63047. get output(): NodeMaterialConnectionPoint;
  63048. protected _buildBlock(state: NodeMaterialBuildState): this;
  63049. }
  63050. }
  63051. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63055. /**
  63056. * Block used to desaturate a color
  63057. */
  63058. export class DesaturateBlock extends NodeMaterialBlock {
  63059. /**
  63060. * Creates a new DesaturateBlock
  63061. * @param name defines the block name
  63062. */
  63063. constructor(name: string);
  63064. /**
  63065. * Gets the current class name
  63066. * @returns the class name
  63067. */
  63068. getClassName(): string;
  63069. /**
  63070. * Gets the color operand input component
  63071. */
  63072. get color(): NodeMaterialConnectionPoint;
  63073. /**
  63074. * Gets the level operand input component
  63075. */
  63076. get level(): NodeMaterialConnectionPoint;
  63077. /**
  63078. * Gets the output component
  63079. */
  63080. get output(): NodeMaterialConnectionPoint;
  63081. protected _buildBlock(state: NodeMaterialBuildState): this;
  63082. }
  63083. }
  63084. declare module "babylonjs/Materials/Node/Blocks/index" {
  63085. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63086. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63087. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63088. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63089. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63093. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63094. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63095. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63096. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63097. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63098. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63099. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63100. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63101. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63102. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63103. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63104. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63105. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63106. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63107. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63108. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63109. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63110. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63111. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63112. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63113. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63114. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63115. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63116. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63117. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63118. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63119. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63120. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63121. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63122. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63123. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63124. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63125. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63126. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63127. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63128. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63129. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63130. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63131. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63132. }
  63133. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63134. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63135. }
  63136. declare module "babylonjs/Materials/Node/index" {
  63137. export * from "babylonjs/Materials/Node/Enums/index";
  63138. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63139. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63140. export * from "babylonjs/Materials/Node/nodeMaterial";
  63141. export * from "babylonjs/Materials/Node/Blocks/index";
  63142. export * from "babylonjs/Materials/Node/Optimizers/index";
  63143. }
  63144. declare module "babylonjs/Materials/effectRenderer" {
  63145. import { Nullable } from "babylonjs/types";
  63146. import { Texture } from "babylonjs/Materials/Textures/texture";
  63147. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63148. import { Viewport } from "babylonjs/Maths/math.viewport";
  63149. import { Observable } from "babylonjs/Misc/observable";
  63150. import { Effect } from "babylonjs/Materials/effect";
  63151. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63152. import "babylonjs/Shaders/postprocess.vertex";
  63153. /**
  63154. * Effect Render Options
  63155. */
  63156. export interface IEffectRendererOptions {
  63157. /**
  63158. * Defines the vertices positions.
  63159. */
  63160. positions?: number[];
  63161. /**
  63162. * Defines the indices.
  63163. */
  63164. indices?: number[];
  63165. }
  63166. /**
  63167. * Helper class to render one or more effects
  63168. */
  63169. export class EffectRenderer {
  63170. private engine;
  63171. private static _DefaultOptions;
  63172. private _vertexBuffers;
  63173. private _indexBuffer;
  63174. private _ringBufferIndex;
  63175. private _ringScreenBuffer;
  63176. private _fullscreenViewport;
  63177. private _getNextFrameBuffer;
  63178. /**
  63179. * Creates an effect renderer
  63180. * @param engine the engine to use for rendering
  63181. * @param options defines the options of the effect renderer
  63182. */
  63183. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63184. /**
  63185. * Sets the current viewport in normalized coordinates 0-1
  63186. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63187. */
  63188. setViewport(viewport?: Viewport): void;
  63189. /**
  63190. * Binds the embedded attributes buffer to the effect.
  63191. * @param effect Defines the effect to bind the attributes for
  63192. */
  63193. bindBuffers(effect: Effect): void;
  63194. /**
  63195. * Sets the current effect wrapper to use during draw.
  63196. * The effect needs to be ready before calling this api.
  63197. * This also sets the default full screen position attribute.
  63198. * @param effectWrapper Defines the effect to draw with
  63199. */
  63200. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63201. /**
  63202. * Draws a full screen quad.
  63203. */
  63204. draw(): void;
  63205. /**
  63206. * renders one or more effects to a specified texture
  63207. * @param effectWrappers list of effects to renderer
  63208. * @param outputTexture texture to draw to, if null it will render to the screen
  63209. */
  63210. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63211. /**
  63212. * Disposes of the effect renderer
  63213. */
  63214. dispose(): void;
  63215. }
  63216. /**
  63217. * Options to create an EffectWrapper
  63218. */
  63219. interface EffectWrapperCreationOptions {
  63220. /**
  63221. * Engine to use to create the effect
  63222. */
  63223. engine: ThinEngine;
  63224. /**
  63225. * Fragment shader for the effect
  63226. */
  63227. fragmentShader: string;
  63228. /**
  63229. * Vertex shader for the effect
  63230. */
  63231. vertexShader?: string;
  63232. /**
  63233. * Attributes to use in the shader
  63234. */
  63235. attributeNames?: Array<string>;
  63236. /**
  63237. * Uniforms to use in the shader
  63238. */
  63239. uniformNames?: Array<string>;
  63240. /**
  63241. * Texture sampler names to use in the shader
  63242. */
  63243. samplerNames?: Array<string>;
  63244. /**
  63245. * The friendly name of the effect displayed in Spector.
  63246. */
  63247. name?: string;
  63248. }
  63249. /**
  63250. * Wraps an effect to be used for rendering
  63251. */
  63252. export class EffectWrapper {
  63253. /**
  63254. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63255. */
  63256. onApplyObservable: Observable<{}>;
  63257. /**
  63258. * The underlying effect
  63259. */
  63260. effect: Effect;
  63261. /**
  63262. * Creates an effect to be renderer
  63263. * @param creationOptions options to create the effect
  63264. */
  63265. constructor(creationOptions: EffectWrapperCreationOptions);
  63266. /**
  63267. * Disposes of the effect wrapper
  63268. */
  63269. dispose(): void;
  63270. }
  63271. }
  63272. declare module "babylonjs/Materials/index" {
  63273. export * from "babylonjs/Materials/Background/index";
  63274. export * from "babylonjs/Materials/colorCurves";
  63275. export * from "babylonjs/Materials/iEffectFallbacks";
  63276. export * from "babylonjs/Materials/effectFallbacks";
  63277. export * from "babylonjs/Materials/effect";
  63278. export * from "babylonjs/Materials/fresnelParameters";
  63279. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63280. export * from "babylonjs/Materials/material";
  63281. export * from "babylonjs/Materials/materialDefines";
  63282. export * from "babylonjs/Materials/materialHelper";
  63283. export * from "babylonjs/Materials/multiMaterial";
  63284. export * from "babylonjs/Materials/PBR/index";
  63285. export * from "babylonjs/Materials/pushMaterial";
  63286. export * from "babylonjs/Materials/shaderMaterial";
  63287. export * from "babylonjs/Materials/standardMaterial";
  63288. export * from "babylonjs/Materials/Textures/index";
  63289. export * from "babylonjs/Materials/uniformBuffer";
  63290. export * from "babylonjs/Materials/materialFlags";
  63291. export * from "babylonjs/Materials/Node/index";
  63292. export * from "babylonjs/Materials/effectRenderer";
  63293. }
  63294. declare module "babylonjs/Maths/index" {
  63295. export * from "babylonjs/Maths/math.scalar";
  63296. export * from "babylonjs/Maths/math";
  63297. export * from "babylonjs/Maths/sphericalPolynomial";
  63298. }
  63299. declare module "babylonjs/Misc/workerPool" {
  63300. import { IDisposable } from "babylonjs/scene";
  63301. /**
  63302. * Helper class to push actions to a pool of workers.
  63303. */
  63304. export class WorkerPool implements IDisposable {
  63305. private _workerInfos;
  63306. private _pendingActions;
  63307. /**
  63308. * Constructor
  63309. * @param workers Array of workers to use for actions
  63310. */
  63311. constructor(workers: Array<Worker>);
  63312. /**
  63313. * Terminates all workers and clears any pending actions.
  63314. */
  63315. dispose(): void;
  63316. /**
  63317. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63318. * pended until a worker has completed its action.
  63319. * @param action The action to perform. Call onComplete when the action is complete.
  63320. */
  63321. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63322. private _execute;
  63323. }
  63324. }
  63325. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63326. import { IDisposable } from "babylonjs/scene";
  63327. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63328. /**
  63329. * Configuration for Draco compression
  63330. */
  63331. export interface IDracoCompressionConfiguration {
  63332. /**
  63333. * Configuration for the decoder.
  63334. */
  63335. decoder: {
  63336. /**
  63337. * The url to the WebAssembly module.
  63338. */
  63339. wasmUrl?: string;
  63340. /**
  63341. * The url to the WebAssembly binary.
  63342. */
  63343. wasmBinaryUrl?: string;
  63344. /**
  63345. * The url to the fallback JavaScript module.
  63346. */
  63347. fallbackUrl?: string;
  63348. };
  63349. }
  63350. /**
  63351. * Draco compression (https://google.github.io/draco/)
  63352. *
  63353. * This class wraps the Draco module.
  63354. *
  63355. * **Encoder**
  63356. *
  63357. * The encoder is not currently implemented.
  63358. *
  63359. * **Decoder**
  63360. *
  63361. * 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.
  63362. *
  63363. * To update the configuration, use the following code:
  63364. * ```javascript
  63365. * DracoCompression.Configuration = {
  63366. * decoder: {
  63367. * wasmUrl: "<url to the WebAssembly library>",
  63368. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63369. * fallbackUrl: "<url to the fallback JavaScript library>",
  63370. * }
  63371. * };
  63372. * ```
  63373. *
  63374. * 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.
  63375. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63376. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63377. *
  63378. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63379. * ```javascript
  63380. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63381. * ```
  63382. *
  63383. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63384. */
  63385. export class DracoCompression implements IDisposable {
  63386. private _workerPoolPromise?;
  63387. private _decoderModulePromise?;
  63388. /**
  63389. * The configuration. Defaults to the following urls:
  63390. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63391. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63392. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63393. */
  63394. static Configuration: IDracoCompressionConfiguration;
  63395. /**
  63396. * Returns true if the decoder configuration is available.
  63397. */
  63398. static get DecoderAvailable(): boolean;
  63399. /**
  63400. * Default number of workers to create when creating the draco compression object.
  63401. */
  63402. static DefaultNumWorkers: number;
  63403. private static GetDefaultNumWorkers;
  63404. private static _Default;
  63405. /**
  63406. * Default instance for the draco compression object.
  63407. */
  63408. static get Default(): DracoCompression;
  63409. /**
  63410. * Constructor
  63411. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63412. */
  63413. constructor(numWorkers?: number);
  63414. /**
  63415. * Stop all async operations and release resources.
  63416. */
  63417. dispose(): void;
  63418. /**
  63419. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63420. * @returns a promise that resolves when ready
  63421. */
  63422. whenReadyAsync(): Promise<void>;
  63423. /**
  63424. * Decode Draco compressed mesh data to vertex data.
  63425. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63426. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63427. * @returns A promise that resolves with the decoded vertex data
  63428. */
  63429. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63430. [kind: string]: number;
  63431. }): Promise<VertexData>;
  63432. }
  63433. }
  63434. declare module "babylonjs/Meshes/Compression/index" {
  63435. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63436. }
  63437. declare module "babylonjs/Meshes/csg" {
  63438. import { Nullable } from "babylonjs/types";
  63439. import { Scene } from "babylonjs/scene";
  63440. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63441. import { Mesh } from "babylonjs/Meshes/mesh";
  63442. import { Material } from "babylonjs/Materials/material";
  63443. /**
  63444. * Class for building Constructive Solid Geometry
  63445. */
  63446. export class CSG {
  63447. private polygons;
  63448. /**
  63449. * The world matrix
  63450. */
  63451. matrix: Matrix;
  63452. /**
  63453. * Stores the position
  63454. */
  63455. position: Vector3;
  63456. /**
  63457. * Stores the rotation
  63458. */
  63459. rotation: Vector3;
  63460. /**
  63461. * Stores the rotation quaternion
  63462. */
  63463. rotationQuaternion: Nullable<Quaternion>;
  63464. /**
  63465. * Stores the scaling vector
  63466. */
  63467. scaling: Vector3;
  63468. /**
  63469. * Convert the Mesh to CSG
  63470. * @param mesh The Mesh to convert to CSG
  63471. * @returns A new CSG from the Mesh
  63472. */
  63473. static FromMesh(mesh: Mesh): CSG;
  63474. /**
  63475. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63476. * @param polygons Polygons used to construct a CSG solid
  63477. */
  63478. private static FromPolygons;
  63479. /**
  63480. * Clones, or makes a deep copy, of the CSG
  63481. * @returns A new CSG
  63482. */
  63483. clone(): CSG;
  63484. /**
  63485. * Unions this CSG with another CSG
  63486. * @param csg The CSG to union against this CSG
  63487. * @returns The unioned CSG
  63488. */
  63489. union(csg: CSG): CSG;
  63490. /**
  63491. * Unions this CSG with another CSG in place
  63492. * @param csg The CSG to union against this CSG
  63493. */
  63494. unionInPlace(csg: CSG): void;
  63495. /**
  63496. * Subtracts this CSG with another CSG
  63497. * @param csg The CSG to subtract against this CSG
  63498. * @returns A new CSG
  63499. */
  63500. subtract(csg: CSG): CSG;
  63501. /**
  63502. * Subtracts this CSG with another CSG in place
  63503. * @param csg The CSG to subtact against this CSG
  63504. */
  63505. subtractInPlace(csg: CSG): void;
  63506. /**
  63507. * Intersect this CSG with another CSG
  63508. * @param csg The CSG to intersect against this CSG
  63509. * @returns A new CSG
  63510. */
  63511. intersect(csg: CSG): CSG;
  63512. /**
  63513. * Intersects this CSG with another CSG in place
  63514. * @param csg The CSG to intersect against this CSG
  63515. */
  63516. intersectInPlace(csg: CSG): void;
  63517. /**
  63518. * Return a new CSG solid with solid and empty space switched. This solid is
  63519. * not modified.
  63520. * @returns A new CSG solid with solid and empty space switched
  63521. */
  63522. inverse(): CSG;
  63523. /**
  63524. * Inverses the CSG in place
  63525. */
  63526. inverseInPlace(): void;
  63527. /**
  63528. * This is used to keep meshes transformations so they can be restored
  63529. * when we build back a Babylon Mesh
  63530. * NB : All CSG operations are performed in world coordinates
  63531. * @param csg The CSG to copy the transform attributes from
  63532. * @returns This CSG
  63533. */
  63534. copyTransformAttributes(csg: CSG): CSG;
  63535. /**
  63536. * Build Raw mesh from CSG
  63537. * Coordinates here are in world space
  63538. * @param name The name of the mesh geometry
  63539. * @param scene The Scene
  63540. * @param keepSubMeshes Specifies if the submeshes should be kept
  63541. * @returns A new Mesh
  63542. */
  63543. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63544. /**
  63545. * Build Mesh from CSG taking material and transforms into account
  63546. * @param name The name of the Mesh
  63547. * @param material The material of the Mesh
  63548. * @param scene The Scene
  63549. * @param keepSubMeshes Specifies if submeshes should be kept
  63550. * @returns The new Mesh
  63551. */
  63552. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63553. }
  63554. }
  63555. declare module "babylonjs/Meshes/trailMesh" {
  63556. import { Mesh } from "babylonjs/Meshes/mesh";
  63557. import { Scene } from "babylonjs/scene";
  63558. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63559. /**
  63560. * Class used to create a trail following a mesh
  63561. */
  63562. export class TrailMesh extends Mesh {
  63563. private _generator;
  63564. private _autoStart;
  63565. private _running;
  63566. private _diameter;
  63567. private _length;
  63568. private _sectionPolygonPointsCount;
  63569. private _sectionVectors;
  63570. private _sectionNormalVectors;
  63571. private _beforeRenderObserver;
  63572. /**
  63573. * @constructor
  63574. * @param name The value used by scene.getMeshByName() to do a lookup.
  63575. * @param generator The mesh or transform node to generate a trail.
  63576. * @param scene The scene to add this mesh to.
  63577. * @param diameter Diameter of trailing mesh. Default is 1.
  63578. * @param length Length of trailing mesh. Default is 60.
  63579. * @param autoStart Automatically start trailing mesh. Default true.
  63580. */
  63581. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63582. /**
  63583. * "TrailMesh"
  63584. * @returns "TrailMesh"
  63585. */
  63586. getClassName(): string;
  63587. private _createMesh;
  63588. /**
  63589. * Start trailing mesh.
  63590. */
  63591. start(): void;
  63592. /**
  63593. * Stop trailing mesh.
  63594. */
  63595. stop(): void;
  63596. /**
  63597. * Update trailing mesh geometry.
  63598. */
  63599. update(): void;
  63600. /**
  63601. * Returns a new TrailMesh object.
  63602. * @param name is a string, the name given to the new mesh
  63603. * @param newGenerator use new generator object for cloned trail mesh
  63604. * @returns a new mesh
  63605. */
  63606. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63607. /**
  63608. * Serializes this trail mesh
  63609. * @param serializationObject object to write serialization to
  63610. */
  63611. serialize(serializationObject: any): void;
  63612. /**
  63613. * Parses a serialized trail mesh
  63614. * @param parsedMesh the serialized mesh
  63615. * @param scene the scene to create the trail mesh in
  63616. * @returns the created trail mesh
  63617. */
  63618. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63619. }
  63620. }
  63621. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63622. import { Nullable } from "babylonjs/types";
  63623. import { Scene } from "babylonjs/scene";
  63624. import { Vector4 } from "babylonjs/Maths/math.vector";
  63625. import { Color4 } from "babylonjs/Maths/math.color";
  63626. import { Mesh } from "babylonjs/Meshes/mesh";
  63627. /**
  63628. * Class containing static functions to help procedurally build meshes
  63629. */
  63630. export class TiledBoxBuilder {
  63631. /**
  63632. * Creates a box mesh
  63633. * 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)
  63634. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63638. * @param name defines the name of the mesh
  63639. * @param options defines the options used to create the mesh
  63640. * @param scene defines the hosting scene
  63641. * @returns the box mesh
  63642. */
  63643. static CreateTiledBox(name: string, options: {
  63644. pattern?: number;
  63645. width?: number;
  63646. height?: number;
  63647. depth?: number;
  63648. tileSize?: number;
  63649. tileWidth?: number;
  63650. tileHeight?: number;
  63651. alignHorizontal?: number;
  63652. alignVertical?: number;
  63653. faceUV?: Vector4[];
  63654. faceColors?: Color4[];
  63655. sideOrientation?: number;
  63656. updatable?: boolean;
  63657. }, scene?: Nullable<Scene>): Mesh;
  63658. }
  63659. }
  63660. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63661. import { Vector4 } from "babylonjs/Maths/math.vector";
  63662. import { Mesh } from "babylonjs/Meshes/mesh";
  63663. /**
  63664. * Class containing static functions to help procedurally build meshes
  63665. */
  63666. export class TorusKnotBuilder {
  63667. /**
  63668. * Creates a torus knot mesh
  63669. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63670. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63671. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63672. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63676. * @param name defines the name of the mesh
  63677. * @param options defines the options used to create the mesh
  63678. * @param scene defines the hosting scene
  63679. * @returns the torus knot mesh
  63680. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63681. */
  63682. static CreateTorusKnot(name: string, options: {
  63683. radius?: number;
  63684. tube?: number;
  63685. radialSegments?: number;
  63686. tubularSegments?: number;
  63687. p?: number;
  63688. q?: number;
  63689. updatable?: boolean;
  63690. sideOrientation?: number;
  63691. frontUVs?: Vector4;
  63692. backUVs?: Vector4;
  63693. }, scene: any): Mesh;
  63694. }
  63695. }
  63696. declare module "babylonjs/Meshes/polygonMesh" {
  63697. import { Scene } from "babylonjs/scene";
  63698. import { Vector2 } from "babylonjs/Maths/math.vector";
  63699. import { Mesh } from "babylonjs/Meshes/mesh";
  63700. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63701. import { Path2 } from "babylonjs/Maths/math.path";
  63702. /**
  63703. * Polygon
  63704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63705. */
  63706. export class Polygon {
  63707. /**
  63708. * Creates a rectangle
  63709. * @param xmin bottom X coord
  63710. * @param ymin bottom Y coord
  63711. * @param xmax top X coord
  63712. * @param ymax top Y coord
  63713. * @returns points that make the resulting rectation
  63714. */
  63715. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63716. /**
  63717. * Creates a circle
  63718. * @param radius radius of circle
  63719. * @param cx scale in x
  63720. * @param cy scale in y
  63721. * @param numberOfSides number of sides that make up the circle
  63722. * @returns points that make the resulting circle
  63723. */
  63724. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63725. /**
  63726. * Creates a polygon from input string
  63727. * @param input Input polygon data
  63728. * @returns the parsed points
  63729. */
  63730. static Parse(input: string): Vector2[];
  63731. /**
  63732. * Starts building a polygon from x and y coordinates
  63733. * @param x x coordinate
  63734. * @param y y coordinate
  63735. * @returns the started path2
  63736. */
  63737. static StartingAt(x: number, y: number): Path2;
  63738. }
  63739. /**
  63740. * Builds a polygon
  63741. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63742. */
  63743. export class PolygonMeshBuilder {
  63744. private _points;
  63745. private _outlinepoints;
  63746. private _holes;
  63747. private _name;
  63748. private _scene;
  63749. private _epoints;
  63750. private _eholes;
  63751. private _addToepoint;
  63752. /**
  63753. * Babylon reference to the earcut plugin.
  63754. */
  63755. bjsEarcut: any;
  63756. /**
  63757. * Creates a PolygonMeshBuilder
  63758. * @param name name of the builder
  63759. * @param contours Path of the polygon
  63760. * @param scene scene to add to when creating the mesh
  63761. * @param earcutInjection can be used to inject your own earcut reference
  63762. */
  63763. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63764. /**
  63765. * Adds a whole within the polygon
  63766. * @param hole Array of points defining the hole
  63767. * @returns this
  63768. */
  63769. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63770. /**
  63771. * Creates the polygon
  63772. * @param updatable If the mesh should be updatable
  63773. * @param depth The depth of the mesh created
  63774. * @returns the created mesh
  63775. */
  63776. build(updatable?: boolean, depth?: number): Mesh;
  63777. /**
  63778. * Creates the polygon
  63779. * @param depth The depth of the mesh created
  63780. * @returns the created VertexData
  63781. */
  63782. buildVertexData(depth?: number): VertexData;
  63783. /**
  63784. * Adds a side to the polygon
  63785. * @param positions points that make the polygon
  63786. * @param normals normals of the polygon
  63787. * @param uvs uvs of the polygon
  63788. * @param indices indices of the polygon
  63789. * @param bounds bounds of the polygon
  63790. * @param points points of the polygon
  63791. * @param depth depth of the polygon
  63792. * @param flip flip of the polygon
  63793. */
  63794. private addSide;
  63795. }
  63796. }
  63797. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63798. import { Scene } from "babylonjs/scene";
  63799. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63800. import { Color4 } from "babylonjs/Maths/math.color";
  63801. import { Mesh } from "babylonjs/Meshes/mesh";
  63802. import { Nullable } from "babylonjs/types";
  63803. /**
  63804. * Class containing static functions to help procedurally build meshes
  63805. */
  63806. export class PolygonBuilder {
  63807. /**
  63808. * Creates a polygon mesh
  63809. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63810. * * 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
  63811. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63814. * * Remember you can only change the shape positions, not their number when updating a polygon
  63815. * @param name defines the name of the mesh
  63816. * @param options defines the options used to create the mesh
  63817. * @param scene defines the hosting scene
  63818. * @param earcutInjection can be used to inject your own earcut reference
  63819. * @returns the polygon mesh
  63820. */
  63821. static CreatePolygon(name: string, options: {
  63822. shape: Vector3[];
  63823. holes?: Vector3[][];
  63824. depth?: number;
  63825. faceUV?: Vector4[];
  63826. faceColors?: Color4[];
  63827. updatable?: boolean;
  63828. sideOrientation?: number;
  63829. frontUVs?: Vector4;
  63830. backUVs?: Vector4;
  63831. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63832. /**
  63833. * Creates an extruded polygon mesh, with depth in the Y direction.
  63834. * * 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)
  63835. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63836. * @param name defines the name of the mesh
  63837. * @param options defines the options used to create the mesh
  63838. * @param scene defines the hosting scene
  63839. * @param earcutInjection can be used to inject your own earcut reference
  63840. * @returns the polygon mesh
  63841. */
  63842. static ExtrudePolygon(name: string, options: {
  63843. shape: Vector3[];
  63844. holes?: Vector3[][];
  63845. depth?: number;
  63846. faceUV?: Vector4[];
  63847. faceColors?: Color4[];
  63848. updatable?: boolean;
  63849. sideOrientation?: number;
  63850. frontUVs?: Vector4;
  63851. backUVs?: Vector4;
  63852. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63853. }
  63854. }
  63855. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63856. import { Scene } from "babylonjs/scene";
  63857. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63858. import { Mesh } from "babylonjs/Meshes/mesh";
  63859. import { Nullable } from "babylonjs/types";
  63860. /**
  63861. * Class containing static functions to help procedurally build meshes
  63862. */
  63863. export class LatheBuilder {
  63864. /**
  63865. * Creates lathe mesh.
  63866. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63867. * * 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
  63868. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63869. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63870. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63871. * * 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
  63872. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63873. * * 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
  63874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63878. * @param name defines the name of the mesh
  63879. * @param options defines the options used to create the mesh
  63880. * @param scene defines the hosting scene
  63881. * @returns the lathe mesh
  63882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63883. */
  63884. static CreateLathe(name: string, options: {
  63885. shape: Vector3[];
  63886. radius?: number;
  63887. tessellation?: number;
  63888. clip?: number;
  63889. arc?: number;
  63890. closed?: boolean;
  63891. updatable?: boolean;
  63892. sideOrientation?: number;
  63893. frontUVs?: Vector4;
  63894. backUVs?: Vector4;
  63895. cap?: number;
  63896. invertUV?: boolean;
  63897. }, scene?: Nullable<Scene>): Mesh;
  63898. }
  63899. }
  63900. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63901. import { Nullable } from "babylonjs/types";
  63902. import { Scene } from "babylonjs/scene";
  63903. import { Vector4 } from "babylonjs/Maths/math.vector";
  63904. import { Mesh } from "babylonjs/Meshes/mesh";
  63905. /**
  63906. * Class containing static functions to help procedurally build meshes
  63907. */
  63908. export class TiledPlaneBuilder {
  63909. /**
  63910. * Creates a tiled plane mesh
  63911. * * The parameter `pattern` will, depending on value, do nothing or
  63912. * * * flip (reflect about central vertical) alternate tiles across and up
  63913. * * * flip every tile on alternate rows
  63914. * * * rotate (180 degs) alternate tiles across and up
  63915. * * * rotate every tile on alternate rows
  63916. * * * flip and rotate alternate tiles across and up
  63917. * * * flip and rotate every tile on alternate rows
  63918. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63919. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63922. * * 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)
  63923. * * 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)
  63924. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63925. * @param name defines the name of the mesh
  63926. * @param options defines the options used to create the mesh
  63927. * @param scene defines the hosting scene
  63928. * @returns the box mesh
  63929. */
  63930. static CreateTiledPlane(name: string, options: {
  63931. pattern?: number;
  63932. tileSize?: number;
  63933. tileWidth?: number;
  63934. tileHeight?: number;
  63935. size?: number;
  63936. width?: number;
  63937. height?: number;
  63938. alignHorizontal?: number;
  63939. alignVertical?: number;
  63940. sideOrientation?: number;
  63941. frontUVs?: Vector4;
  63942. backUVs?: Vector4;
  63943. updatable?: boolean;
  63944. }, scene?: Nullable<Scene>): Mesh;
  63945. }
  63946. }
  63947. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63948. import { Nullable } from "babylonjs/types";
  63949. import { Scene } from "babylonjs/scene";
  63950. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63951. import { Mesh } from "babylonjs/Meshes/mesh";
  63952. /**
  63953. * Class containing static functions to help procedurally build meshes
  63954. */
  63955. export class TubeBuilder {
  63956. /**
  63957. * Creates a tube mesh.
  63958. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63959. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63960. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63961. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63962. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63963. * * 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)
  63964. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63965. * * 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
  63966. * * 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
  63967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63969. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63971. * @param name defines the name of the mesh
  63972. * @param options defines the options used to create the mesh
  63973. * @param scene defines the hosting scene
  63974. * @returns the tube mesh
  63975. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63976. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63977. */
  63978. static CreateTube(name: string, options: {
  63979. path: Vector3[];
  63980. radius?: number;
  63981. tessellation?: number;
  63982. radiusFunction?: {
  63983. (i: number, distance: number): number;
  63984. };
  63985. cap?: number;
  63986. arc?: number;
  63987. updatable?: boolean;
  63988. sideOrientation?: number;
  63989. frontUVs?: Vector4;
  63990. backUVs?: Vector4;
  63991. instance?: Mesh;
  63992. invertUV?: boolean;
  63993. }, scene?: Nullable<Scene>): Mesh;
  63994. }
  63995. }
  63996. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63997. import { Scene } from "babylonjs/scene";
  63998. import { Vector4 } from "babylonjs/Maths/math.vector";
  63999. import { Mesh } from "babylonjs/Meshes/mesh";
  64000. import { Nullable } from "babylonjs/types";
  64001. /**
  64002. * Class containing static functions to help procedurally build meshes
  64003. */
  64004. export class IcoSphereBuilder {
  64005. /**
  64006. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64007. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64008. * * 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`)
  64009. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64010. * * 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
  64011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64014. * @param name defines the name of the mesh
  64015. * @param options defines the options used to create the mesh
  64016. * @param scene defines the hosting scene
  64017. * @returns the icosahedron mesh
  64018. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64019. */
  64020. static CreateIcoSphere(name: string, options: {
  64021. radius?: number;
  64022. radiusX?: number;
  64023. radiusY?: number;
  64024. radiusZ?: number;
  64025. flat?: boolean;
  64026. subdivisions?: number;
  64027. sideOrientation?: number;
  64028. frontUVs?: Vector4;
  64029. backUVs?: Vector4;
  64030. updatable?: boolean;
  64031. }, scene?: Nullable<Scene>): Mesh;
  64032. }
  64033. }
  64034. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64035. import { Vector3 } from "babylonjs/Maths/math.vector";
  64036. import { Mesh } from "babylonjs/Meshes/mesh";
  64037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64038. /**
  64039. * Class containing static functions to help procedurally build meshes
  64040. */
  64041. export class DecalBuilder {
  64042. /**
  64043. * Creates a decal mesh.
  64044. * 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
  64045. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64046. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64047. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64048. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64049. * @param name defines the name of the mesh
  64050. * @param sourceMesh defines the mesh where the decal must be applied
  64051. * @param options defines the options used to create the mesh
  64052. * @param scene defines the hosting scene
  64053. * @returns the decal mesh
  64054. * @see https://doc.babylonjs.com/how_to/decals
  64055. */
  64056. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64057. position?: Vector3;
  64058. normal?: Vector3;
  64059. size?: Vector3;
  64060. angle?: number;
  64061. }): Mesh;
  64062. }
  64063. }
  64064. declare module "babylonjs/Meshes/meshBuilder" {
  64065. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64066. import { Nullable } from "babylonjs/types";
  64067. import { Scene } from "babylonjs/scene";
  64068. import { Mesh } from "babylonjs/Meshes/mesh";
  64069. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64070. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64072. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64073. import { Plane } from "babylonjs/Maths/math.plane";
  64074. /**
  64075. * Class containing static functions to help procedurally build meshes
  64076. */
  64077. export class MeshBuilder {
  64078. /**
  64079. * Creates a box mesh
  64080. * * The parameter `size` sets the size (float) of each box side (default 1)
  64081. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64082. * * 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)
  64083. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64087. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64088. * @param name defines the name of the mesh
  64089. * @param options defines the options used to create the mesh
  64090. * @param scene defines the hosting scene
  64091. * @returns the box mesh
  64092. */
  64093. static CreateBox(name: string, options: {
  64094. size?: number;
  64095. width?: number;
  64096. height?: number;
  64097. depth?: number;
  64098. faceUV?: Vector4[];
  64099. faceColors?: Color4[];
  64100. sideOrientation?: number;
  64101. frontUVs?: Vector4;
  64102. backUVs?: Vector4;
  64103. updatable?: boolean;
  64104. }, scene?: Nullable<Scene>): Mesh;
  64105. /**
  64106. * Creates a tiled box mesh
  64107. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64109. * @param name defines the name of the mesh
  64110. * @param options defines the options used to create the mesh
  64111. * @param scene defines the hosting scene
  64112. * @returns the tiled box mesh
  64113. */
  64114. static CreateTiledBox(name: string, options: {
  64115. pattern?: number;
  64116. size?: number;
  64117. width?: number;
  64118. height?: number;
  64119. depth: number;
  64120. tileSize?: number;
  64121. tileWidth?: number;
  64122. tileHeight?: number;
  64123. faceUV?: Vector4[];
  64124. faceColors?: Color4[];
  64125. alignHorizontal?: number;
  64126. alignVertical?: number;
  64127. sideOrientation?: number;
  64128. updatable?: boolean;
  64129. }, scene?: Nullable<Scene>): Mesh;
  64130. /**
  64131. * Creates a sphere mesh
  64132. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64133. * * 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`)
  64134. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64135. * * 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
  64136. * * 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)
  64137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64140. * @param name defines the name of the mesh
  64141. * @param options defines the options used to create the mesh
  64142. * @param scene defines the hosting scene
  64143. * @returns the sphere mesh
  64144. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64145. */
  64146. static CreateSphere(name: string, options: {
  64147. segments?: number;
  64148. diameter?: number;
  64149. diameterX?: number;
  64150. diameterY?: number;
  64151. diameterZ?: number;
  64152. arc?: number;
  64153. slice?: number;
  64154. sideOrientation?: number;
  64155. frontUVs?: Vector4;
  64156. backUVs?: Vector4;
  64157. updatable?: boolean;
  64158. }, scene?: Nullable<Scene>): Mesh;
  64159. /**
  64160. * Creates a plane polygonal mesh. By default, this is a disc
  64161. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64162. * * 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
  64163. * * 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
  64164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64167. * @param name defines the name of the mesh
  64168. * @param options defines the options used to create the mesh
  64169. * @param scene defines the hosting scene
  64170. * @returns the plane polygonal mesh
  64171. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64172. */
  64173. static CreateDisc(name: string, options: {
  64174. radius?: number;
  64175. tessellation?: number;
  64176. arc?: number;
  64177. updatable?: boolean;
  64178. sideOrientation?: number;
  64179. frontUVs?: Vector4;
  64180. backUVs?: Vector4;
  64181. }, scene?: Nullable<Scene>): Mesh;
  64182. /**
  64183. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64184. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64185. * * 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`)
  64186. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64187. * * 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
  64188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64191. * @param name defines the name of the mesh
  64192. * @param options defines the options used to create the mesh
  64193. * @param scene defines the hosting scene
  64194. * @returns the icosahedron mesh
  64195. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64196. */
  64197. static CreateIcoSphere(name: string, options: {
  64198. radius?: number;
  64199. radiusX?: number;
  64200. radiusY?: number;
  64201. radiusZ?: number;
  64202. flat?: boolean;
  64203. subdivisions?: number;
  64204. sideOrientation?: number;
  64205. frontUVs?: Vector4;
  64206. backUVs?: Vector4;
  64207. updatable?: boolean;
  64208. }, scene?: Nullable<Scene>): Mesh;
  64209. /**
  64210. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64211. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64212. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64213. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64214. * * 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
  64215. * * 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
  64216. * * 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
  64217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64220. * * 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
  64221. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64222. * * 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
  64223. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64225. * @param name defines the name of the mesh
  64226. * @param options defines the options used to create the mesh
  64227. * @param scene defines the hosting scene
  64228. * @returns the ribbon mesh
  64229. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64231. */
  64232. static CreateRibbon(name: string, options: {
  64233. pathArray: Vector3[][];
  64234. closeArray?: boolean;
  64235. closePath?: boolean;
  64236. offset?: number;
  64237. updatable?: boolean;
  64238. sideOrientation?: number;
  64239. frontUVs?: Vector4;
  64240. backUVs?: Vector4;
  64241. instance?: Mesh;
  64242. invertUV?: boolean;
  64243. uvs?: Vector2[];
  64244. colors?: Color4[];
  64245. }, scene?: Nullable<Scene>): Mesh;
  64246. /**
  64247. * Creates a cylinder or a cone mesh
  64248. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64249. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64250. * * 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.
  64251. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64252. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64253. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64254. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64255. * * 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).
  64256. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64257. * * 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).
  64258. * * 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
  64259. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64260. * * 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
  64261. * * 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.
  64262. * * If `enclose` is false, a ring surface is one element.
  64263. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64264. * * 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
  64265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64268. * @param name defines the name of the mesh
  64269. * @param options defines the options used to create the mesh
  64270. * @param scene defines the hosting scene
  64271. * @returns the cylinder mesh
  64272. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64273. */
  64274. static CreateCylinder(name: string, options: {
  64275. height?: number;
  64276. diameterTop?: number;
  64277. diameterBottom?: number;
  64278. diameter?: number;
  64279. tessellation?: number;
  64280. subdivisions?: number;
  64281. arc?: number;
  64282. faceColors?: Color4[];
  64283. faceUV?: Vector4[];
  64284. updatable?: boolean;
  64285. hasRings?: boolean;
  64286. enclose?: boolean;
  64287. cap?: number;
  64288. sideOrientation?: number;
  64289. frontUVs?: Vector4;
  64290. backUVs?: Vector4;
  64291. }, scene?: Nullable<Scene>): Mesh;
  64292. /**
  64293. * Creates a torus mesh
  64294. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64295. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64296. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64300. * @param name defines the name of the mesh
  64301. * @param options defines the options used to create the mesh
  64302. * @param scene defines the hosting scene
  64303. * @returns the torus mesh
  64304. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64305. */
  64306. static CreateTorus(name: string, options: {
  64307. diameter?: number;
  64308. thickness?: number;
  64309. tessellation?: number;
  64310. updatable?: boolean;
  64311. sideOrientation?: number;
  64312. frontUVs?: Vector4;
  64313. backUVs?: Vector4;
  64314. }, scene?: Nullable<Scene>): Mesh;
  64315. /**
  64316. * Creates a torus knot mesh
  64317. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64318. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64319. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64320. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64324. * @param name defines the name of the mesh
  64325. * @param options defines the options used to create the mesh
  64326. * @param scene defines the hosting scene
  64327. * @returns the torus knot mesh
  64328. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64329. */
  64330. static CreateTorusKnot(name: string, options: {
  64331. radius?: number;
  64332. tube?: number;
  64333. radialSegments?: number;
  64334. tubularSegments?: number;
  64335. p?: number;
  64336. q?: number;
  64337. updatable?: boolean;
  64338. sideOrientation?: number;
  64339. frontUVs?: Vector4;
  64340. backUVs?: Vector4;
  64341. }, scene?: Nullable<Scene>): Mesh;
  64342. /**
  64343. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64344. * * 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
  64345. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64346. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64347. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64348. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64349. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64350. * * 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
  64351. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64354. * @param name defines the name of the new line system
  64355. * @param options defines the options used to create the line system
  64356. * @param scene defines the hosting scene
  64357. * @returns a new line system mesh
  64358. */
  64359. static CreateLineSystem(name: string, options: {
  64360. lines: Vector3[][];
  64361. updatable?: boolean;
  64362. instance?: Nullable<LinesMesh>;
  64363. colors?: Nullable<Color4[][]>;
  64364. useVertexAlpha?: boolean;
  64365. }, scene: Nullable<Scene>): LinesMesh;
  64366. /**
  64367. * Creates a line mesh
  64368. * 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
  64369. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64370. * * The parameter `points` is an array successive Vector3
  64371. * * 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
  64372. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64373. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64374. * * When updating an instance, remember that only point positions can change, not the number of points
  64375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64377. * @param name defines the name of the new line system
  64378. * @param options defines the options used to create the line system
  64379. * @param scene defines the hosting scene
  64380. * @returns a new line mesh
  64381. */
  64382. static CreateLines(name: string, options: {
  64383. points: Vector3[];
  64384. updatable?: boolean;
  64385. instance?: Nullable<LinesMesh>;
  64386. colors?: Color4[];
  64387. useVertexAlpha?: boolean;
  64388. }, scene?: Nullable<Scene>): LinesMesh;
  64389. /**
  64390. * Creates a dashed line mesh
  64391. * * 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
  64392. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64393. * * The parameter `points` is an array successive Vector3
  64394. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64395. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64396. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64397. * * 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
  64398. * * When updating an instance, remember that only point positions can change, not the number of points
  64399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64400. * @param name defines the name of the mesh
  64401. * @param options defines the options used to create the mesh
  64402. * @param scene defines the hosting scene
  64403. * @returns the dashed line mesh
  64404. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64405. */
  64406. static CreateDashedLines(name: string, options: {
  64407. points: Vector3[];
  64408. dashSize?: number;
  64409. gapSize?: number;
  64410. dashNb?: number;
  64411. updatable?: boolean;
  64412. instance?: LinesMesh;
  64413. }, scene?: Nullable<Scene>): LinesMesh;
  64414. /**
  64415. * 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.
  64416. * * 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.
  64417. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64418. * * 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.
  64419. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64420. * * 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
  64421. * * 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
  64422. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64427. * @param name defines the name of the mesh
  64428. * @param options defines the options used to create the mesh
  64429. * @param scene defines the hosting scene
  64430. * @returns the extruded shape mesh
  64431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64433. */
  64434. static ExtrudeShape(name: string, options: {
  64435. shape: Vector3[];
  64436. path: Vector3[];
  64437. scale?: number;
  64438. rotation?: number;
  64439. cap?: number;
  64440. updatable?: boolean;
  64441. sideOrientation?: number;
  64442. frontUVs?: Vector4;
  64443. backUVs?: Vector4;
  64444. instance?: Mesh;
  64445. invertUV?: boolean;
  64446. }, scene?: Nullable<Scene>): Mesh;
  64447. /**
  64448. * Creates an custom extruded shape mesh.
  64449. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64450. * * 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.
  64451. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64452. * * 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
  64453. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64454. * * 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
  64455. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64456. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64457. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64458. * * 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
  64459. * * 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
  64460. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64465. * @param name defines the name of the mesh
  64466. * @param options defines the options used to create the mesh
  64467. * @param scene defines the hosting scene
  64468. * @returns the custom extruded shape mesh
  64469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64472. */
  64473. static ExtrudeShapeCustom(name: string, options: {
  64474. shape: Vector3[];
  64475. path: Vector3[];
  64476. scaleFunction?: any;
  64477. rotationFunction?: any;
  64478. ribbonCloseArray?: boolean;
  64479. ribbonClosePath?: boolean;
  64480. cap?: number;
  64481. updatable?: boolean;
  64482. sideOrientation?: number;
  64483. frontUVs?: Vector4;
  64484. backUVs?: Vector4;
  64485. instance?: Mesh;
  64486. invertUV?: boolean;
  64487. }, scene?: Nullable<Scene>): Mesh;
  64488. /**
  64489. * Creates lathe mesh.
  64490. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64491. * * 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
  64492. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64493. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64494. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64495. * * 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
  64496. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64497. * * 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
  64498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64502. * @param name defines the name of the mesh
  64503. * @param options defines the options used to create the mesh
  64504. * @param scene defines the hosting scene
  64505. * @returns the lathe mesh
  64506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64507. */
  64508. static CreateLathe(name: string, options: {
  64509. shape: Vector3[];
  64510. radius?: number;
  64511. tessellation?: number;
  64512. clip?: number;
  64513. arc?: number;
  64514. closed?: boolean;
  64515. updatable?: boolean;
  64516. sideOrientation?: number;
  64517. frontUVs?: Vector4;
  64518. backUVs?: Vector4;
  64519. cap?: number;
  64520. invertUV?: boolean;
  64521. }, scene?: Nullable<Scene>): Mesh;
  64522. /**
  64523. * Creates a tiled plane mesh
  64524. * * You can set a limited pattern arrangement with the tiles
  64525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64528. * @param name defines the name of the mesh
  64529. * @param options defines the options used to create the mesh
  64530. * @param scene defines the hosting scene
  64531. * @returns the plane mesh
  64532. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64533. */
  64534. static CreateTiledPlane(name: string, options: {
  64535. pattern?: number;
  64536. tileSize?: number;
  64537. tileWidth?: number;
  64538. tileHeight?: number;
  64539. size?: number;
  64540. width?: number;
  64541. height?: number;
  64542. alignHorizontal?: number;
  64543. alignVertical?: number;
  64544. sideOrientation?: number;
  64545. frontUVs?: Vector4;
  64546. backUVs?: Vector4;
  64547. updatable?: boolean;
  64548. }, scene?: Nullable<Scene>): Mesh;
  64549. /**
  64550. * Creates a plane mesh
  64551. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64552. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64553. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64557. * @param name defines the name of the mesh
  64558. * @param options defines the options used to create the mesh
  64559. * @param scene defines the hosting scene
  64560. * @returns the plane mesh
  64561. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64562. */
  64563. static CreatePlane(name: string, options: {
  64564. size?: number;
  64565. width?: number;
  64566. height?: number;
  64567. sideOrientation?: number;
  64568. frontUVs?: Vector4;
  64569. backUVs?: Vector4;
  64570. updatable?: boolean;
  64571. sourcePlane?: Plane;
  64572. }, scene?: Nullable<Scene>): Mesh;
  64573. /**
  64574. * Creates a ground mesh
  64575. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64576. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64578. * @param name defines the name of the mesh
  64579. * @param options defines the options used to create the mesh
  64580. * @param scene defines the hosting scene
  64581. * @returns the ground mesh
  64582. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64583. */
  64584. static CreateGround(name: string, options: {
  64585. width?: number;
  64586. height?: number;
  64587. subdivisions?: number;
  64588. subdivisionsX?: number;
  64589. subdivisionsY?: number;
  64590. updatable?: boolean;
  64591. }, scene?: Nullable<Scene>): Mesh;
  64592. /**
  64593. * Creates a tiled ground mesh
  64594. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64595. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64596. * * 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
  64597. * * 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
  64598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64599. * @param name defines the name of the mesh
  64600. * @param options defines the options used to create the mesh
  64601. * @param scene defines the hosting scene
  64602. * @returns the tiled ground mesh
  64603. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64604. */
  64605. static CreateTiledGround(name: string, options: {
  64606. xmin: number;
  64607. zmin: number;
  64608. xmax: number;
  64609. zmax: number;
  64610. subdivisions?: {
  64611. w: number;
  64612. h: number;
  64613. };
  64614. precision?: {
  64615. w: number;
  64616. h: number;
  64617. };
  64618. updatable?: boolean;
  64619. }, scene?: Nullable<Scene>): Mesh;
  64620. /**
  64621. * Creates a ground mesh from a height map
  64622. * * The parameter `url` sets the URL of the height map image resource.
  64623. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64624. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64625. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64626. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64627. * * 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.
  64628. * * 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).
  64629. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64631. * @param name defines the name of the mesh
  64632. * @param url defines the url to the height map
  64633. * @param options defines the options used to create the mesh
  64634. * @param scene defines the hosting scene
  64635. * @returns the ground mesh
  64636. * @see https://doc.babylonjs.com/babylon101/height_map
  64637. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64638. */
  64639. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64640. width?: number;
  64641. height?: number;
  64642. subdivisions?: number;
  64643. minHeight?: number;
  64644. maxHeight?: number;
  64645. colorFilter?: Color3;
  64646. alphaFilter?: number;
  64647. updatable?: boolean;
  64648. onReady?: (mesh: GroundMesh) => void;
  64649. }, scene?: Nullable<Scene>): GroundMesh;
  64650. /**
  64651. * Creates a polygon mesh
  64652. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64653. * * 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
  64654. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64657. * * Remember you can only change the shape positions, not their number when updating a polygon
  64658. * @param name defines the name of the mesh
  64659. * @param options defines the options used to create the mesh
  64660. * @param scene defines the hosting scene
  64661. * @param earcutInjection can be used to inject your own earcut reference
  64662. * @returns the polygon mesh
  64663. */
  64664. static CreatePolygon(name: string, options: {
  64665. shape: Vector3[];
  64666. holes?: Vector3[][];
  64667. depth?: number;
  64668. faceUV?: Vector4[];
  64669. faceColors?: Color4[];
  64670. updatable?: boolean;
  64671. sideOrientation?: number;
  64672. frontUVs?: Vector4;
  64673. backUVs?: Vector4;
  64674. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64675. /**
  64676. * Creates an extruded polygon mesh, with depth in the Y direction.
  64677. * * 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)
  64678. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64679. * @param name defines the name of the mesh
  64680. * @param options defines the options used to create the mesh
  64681. * @param scene defines the hosting scene
  64682. * @param earcutInjection can be used to inject your own earcut reference
  64683. * @returns the polygon mesh
  64684. */
  64685. static ExtrudePolygon(name: string, options: {
  64686. shape: Vector3[];
  64687. holes?: Vector3[][];
  64688. depth?: number;
  64689. faceUV?: Vector4[];
  64690. faceColors?: Color4[];
  64691. updatable?: boolean;
  64692. sideOrientation?: number;
  64693. frontUVs?: Vector4;
  64694. backUVs?: Vector4;
  64695. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64696. /**
  64697. * Creates a tube mesh.
  64698. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64699. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64700. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64701. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64702. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64703. * * 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)
  64704. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64705. * * 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
  64706. * * 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
  64707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64709. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64711. * @param name defines the name of the mesh
  64712. * @param options defines the options used to create the mesh
  64713. * @param scene defines the hosting scene
  64714. * @returns the tube mesh
  64715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64716. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64717. */
  64718. static CreateTube(name: string, options: {
  64719. path: Vector3[];
  64720. radius?: number;
  64721. tessellation?: number;
  64722. radiusFunction?: {
  64723. (i: number, distance: number): number;
  64724. };
  64725. cap?: number;
  64726. arc?: number;
  64727. updatable?: boolean;
  64728. sideOrientation?: number;
  64729. frontUVs?: Vector4;
  64730. backUVs?: Vector4;
  64731. instance?: Mesh;
  64732. invertUV?: boolean;
  64733. }, scene?: Nullable<Scene>): Mesh;
  64734. /**
  64735. * Creates a polyhedron mesh
  64736. * * 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
  64737. * * The parameter `size` (positive float, default 1) sets the polygon size
  64738. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64739. * * 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`
  64740. * * 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
  64741. * * 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)`)
  64742. * * 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
  64743. * * 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
  64744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64747. * @param name defines the name of the mesh
  64748. * @param options defines the options used to create the mesh
  64749. * @param scene defines the hosting scene
  64750. * @returns the polyhedron mesh
  64751. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64752. */
  64753. static CreatePolyhedron(name: string, options: {
  64754. type?: number;
  64755. size?: number;
  64756. sizeX?: number;
  64757. sizeY?: number;
  64758. sizeZ?: number;
  64759. custom?: any;
  64760. faceUV?: Vector4[];
  64761. faceColors?: Color4[];
  64762. flat?: boolean;
  64763. updatable?: boolean;
  64764. sideOrientation?: number;
  64765. frontUVs?: Vector4;
  64766. backUVs?: Vector4;
  64767. }, scene?: Nullable<Scene>): Mesh;
  64768. /**
  64769. * Creates a decal mesh.
  64770. * 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
  64771. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64772. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64773. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64774. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64775. * @param name defines the name of the mesh
  64776. * @param sourceMesh defines the mesh where the decal must be applied
  64777. * @param options defines the options used to create the mesh
  64778. * @param scene defines the hosting scene
  64779. * @returns the decal mesh
  64780. * @see https://doc.babylonjs.com/how_to/decals
  64781. */
  64782. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64783. position?: Vector3;
  64784. normal?: Vector3;
  64785. size?: Vector3;
  64786. angle?: number;
  64787. }): Mesh;
  64788. }
  64789. }
  64790. declare module "babylonjs/Meshes/meshSimplification" {
  64791. import { Mesh } from "babylonjs/Meshes/mesh";
  64792. /**
  64793. * A simplifier interface for future simplification implementations
  64794. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64795. */
  64796. export interface ISimplifier {
  64797. /**
  64798. * Simplification of a given mesh according to the given settings.
  64799. * Since this requires computation, it is assumed that the function runs async.
  64800. * @param settings The settings of the simplification, including quality and distance
  64801. * @param successCallback A callback that will be called after the mesh was simplified.
  64802. * @param errorCallback in case of an error, this callback will be called. optional.
  64803. */
  64804. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64805. }
  64806. /**
  64807. * Expected simplification settings.
  64808. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64809. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64810. */
  64811. export interface ISimplificationSettings {
  64812. /**
  64813. * Gets or sets the expected quality
  64814. */
  64815. quality: number;
  64816. /**
  64817. * Gets or sets the distance when this optimized version should be used
  64818. */
  64819. distance: number;
  64820. /**
  64821. * Gets an already optimized mesh
  64822. */
  64823. optimizeMesh?: boolean;
  64824. }
  64825. /**
  64826. * Class used to specify simplification options
  64827. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64828. */
  64829. export class SimplificationSettings implements ISimplificationSettings {
  64830. /** expected quality */
  64831. quality: number;
  64832. /** distance when this optimized version should be used */
  64833. distance: number;
  64834. /** already optimized mesh */
  64835. optimizeMesh?: boolean | undefined;
  64836. /**
  64837. * Creates a SimplificationSettings
  64838. * @param quality expected quality
  64839. * @param distance distance when this optimized version should be used
  64840. * @param optimizeMesh already optimized mesh
  64841. */
  64842. constructor(
  64843. /** expected quality */
  64844. quality: number,
  64845. /** distance when this optimized version should be used */
  64846. distance: number,
  64847. /** already optimized mesh */
  64848. optimizeMesh?: boolean | undefined);
  64849. }
  64850. /**
  64851. * Interface used to define a simplification task
  64852. */
  64853. export interface ISimplificationTask {
  64854. /**
  64855. * Array of settings
  64856. */
  64857. settings: Array<ISimplificationSettings>;
  64858. /**
  64859. * Simplification type
  64860. */
  64861. simplificationType: SimplificationType;
  64862. /**
  64863. * Mesh to simplify
  64864. */
  64865. mesh: Mesh;
  64866. /**
  64867. * Callback called on success
  64868. */
  64869. successCallback?: () => void;
  64870. /**
  64871. * Defines if parallel processing can be used
  64872. */
  64873. parallelProcessing: boolean;
  64874. }
  64875. /**
  64876. * Queue used to order the simplification tasks
  64877. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64878. */
  64879. export class SimplificationQueue {
  64880. private _simplificationArray;
  64881. /**
  64882. * Gets a boolean indicating that the process is still running
  64883. */
  64884. running: boolean;
  64885. /**
  64886. * Creates a new queue
  64887. */
  64888. constructor();
  64889. /**
  64890. * Adds a new simplification task
  64891. * @param task defines a task to add
  64892. */
  64893. addTask(task: ISimplificationTask): void;
  64894. /**
  64895. * Execute next task
  64896. */
  64897. executeNext(): void;
  64898. /**
  64899. * Execute a simplification task
  64900. * @param task defines the task to run
  64901. */
  64902. runSimplification(task: ISimplificationTask): void;
  64903. private getSimplifier;
  64904. }
  64905. /**
  64906. * The implemented types of simplification
  64907. * At the moment only Quadratic Error Decimation is implemented
  64908. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64909. */
  64910. export enum SimplificationType {
  64911. /** Quadratic error decimation */
  64912. QUADRATIC = 0
  64913. }
  64914. /**
  64915. * An implementation of the Quadratic Error simplification algorithm.
  64916. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64917. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64918. * @author RaananW
  64919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64920. */
  64921. export class QuadraticErrorSimplification implements ISimplifier {
  64922. private _mesh;
  64923. private triangles;
  64924. private vertices;
  64925. private references;
  64926. private _reconstructedMesh;
  64927. /** Gets or sets the number pf sync interations */
  64928. syncIterations: number;
  64929. /** Gets or sets the aggressiveness of the simplifier */
  64930. aggressiveness: number;
  64931. /** Gets or sets the number of allowed iterations for decimation */
  64932. decimationIterations: number;
  64933. /** Gets or sets the espilon to use for bounding box computation */
  64934. boundingBoxEpsilon: number;
  64935. /**
  64936. * Creates a new QuadraticErrorSimplification
  64937. * @param _mesh defines the target mesh
  64938. */
  64939. constructor(_mesh: Mesh);
  64940. /**
  64941. * Simplification of a given mesh according to the given settings.
  64942. * Since this requires computation, it is assumed that the function runs async.
  64943. * @param settings The settings of the simplification, including quality and distance
  64944. * @param successCallback A callback that will be called after the mesh was simplified.
  64945. */
  64946. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64947. private runDecimation;
  64948. private initWithMesh;
  64949. private init;
  64950. private reconstructMesh;
  64951. private initDecimatedMesh;
  64952. private isFlipped;
  64953. private updateTriangles;
  64954. private identifyBorder;
  64955. private updateMesh;
  64956. private vertexError;
  64957. private calculateError;
  64958. }
  64959. }
  64960. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64961. import { Scene } from "babylonjs/scene";
  64962. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64963. import { ISceneComponent } from "babylonjs/sceneComponent";
  64964. module "babylonjs/scene" {
  64965. interface Scene {
  64966. /** @hidden (Backing field) */
  64967. _simplificationQueue: SimplificationQueue;
  64968. /**
  64969. * Gets or sets the simplification queue attached to the scene
  64970. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64971. */
  64972. simplificationQueue: SimplificationQueue;
  64973. }
  64974. }
  64975. module "babylonjs/Meshes/mesh" {
  64976. interface Mesh {
  64977. /**
  64978. * Simplify the mesh according to the given array of settings.
  64979. * Function will return immediately and will simplify async
  64980. * @param settings a collection of simplification settings
  64981. * @param parallelProcessing should all levels calculate parallel or one after the other
  64982. * @param simplificationType the type of simplification to run
  64983. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64984. * @returns the current mesh
  64985. */
  64986. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64987. }
  64988. }
  64989. /**
  64990. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64991. * created in a scene
  64992. */
  64993. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64994. /**
  64995. * The component name helpfull to identify the component in the list of scene components.
  64996. */
  64997. readonly name: string;
  64998. /**
  64999. * The scene the component belongs to.
  65000. */
  65001. scene: Scene;
  65002. /**
  65003. * Creates a new instance of the component for the given scene
  65004. * @param scene Defines the scene to register the component in
  65005. */
  65006. constructor(scene: Scene);
  65007. /**
  65008. * Registers the component in a given scene
  65009. */
  65010. register(): void;
  65011. /**
  65012. * Rebuilds the elements related to this component in case of
  65013. * context lost for instance.
  65014. */
  65015. rebuild(): void;
  65016. /**
  65017. * Disposes the component and the associated ressources
  65018. */
  65019. dispose(): void;
  65020. private _beforeCameraUpdate;
  65021. }
  65022. }
  65023. declare module "babylonjs/Meshes/Builders/index" {
  65024. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65025. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65026. export * from "babylonjs/Meshes/Builders/discBuilder";
  65027. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65028. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65029. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65030. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65031. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65032. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65033. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65034. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65035. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65036. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65037. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65038. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65039. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65040. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65041. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65042. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65043. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65044. }
  65045. declare module "babylonjs/Meshes/index" {
  65046. export * from "babylonjs/Meshes/abstractMesh";
  65047. export * from "babylonjs/Meshes/buffer";
  65048. export * from "babylonjs/Meshes/Compression/index";
  65049. export * from "babylonjs/Meshes/csg";
  65050. export * from "babylonjs/Meshes/geometry";
  65051. export * from "babylonjs/Meshes/groundMesh";
  65052. export * from "babylonjs/Meshes/trailMesh";
  65053. export * from "babylonjs/Meshes/instancedMesh";
  65054. export * from "babylonjs/Meshes/linesMesh";
  65055. export * from "babylonjs/Meshes/mesh";
  65056. export * from "babylonjs/Meshes/mesh.vertexData";
  65057. export * from "babylonjs/Meshes/meshBuilder";
  65058. export * from "babylonjs/Meshes/meshSimplification";
  65059. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65060. export * from "babylonjs/Meshes/polygonMesh";
  65061. export * from "babylonjs/Meshes/subMesh";
  65062. export * from "babylonjs/Meshes/meshLODLevel";
  65063. export * from "babylonjs/Meshes/transformNode";
  65064. export * from "babylonjs/Meshes/Builders/index";
  65065. export * from "babylonjs/Meshes/dataBuffer";
  65066. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65067. }
  65068. declare module "babylonjs/Morph/index" {
  65069. export * from "babylonjs/Morph/morphTarget";
  65070. export * from "babylonjs/Morph/morphTargetManager";
  65071. }
  65072. declare module "babylonjs/Navigation/INavigationEngine" {
  65073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65074. import { Vector3 } from "babylonjs/Maths/math";
  65075. import { Mesh } from "babylonjs/Meshes/mesh";
  65076. import { Scene } from "babylonjs/scene";
  65077. /**
  65078. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65079. */
  65080. export interface INavigationEnginePlugin {
  65081. /**
  65082. * plugin name
  65083. */
  65084. name: string;
  65085. /**
  65086. * Creates a navigation mesh
  65087. * @param meshes array of all the geometry used to compute the navigatio mesh
  65088. * @param parameters bunch of parameters used to filter geometry
  65089. */
  65090. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65091. /**
  65092. * Create a navigation mesh debug mesh
  65093. * @param scene is where the mesh will be added
  65094. * @returns debug display mesh
  65095. */
  65096. createDebugNavMesh(scene: Scene): Mesh;
  65097. /**
  65098. * Get a navigation mesh constrained position, closest to the parameter position
  65099. * @param position world position
  65100. * @returns the closest point to position constrained by the navigation mesh
  65101. */
  65102. getClosestPoint(position: Vector3): Vector3;
  65103. /**
  65104. * Get a navigation mesh constrained position, within a particular radius
  65105. * @param position world position
  65106. * @param maxRadius the maximum distance to the constrained world position
  65107. * @returns the closest point to position constrained by the navigation mesh
  65108. */
  65109. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65110. /**
  65111. * Compute the final position from a segment made of destination-position
  65112. * @param position world position
  65113. * @param destination world position
  65114. * @returns the resulting point along the navmesh
  65115. */
  65116. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65117. /**
  65118. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65119. * @param start world position
  65120. * @param end world position
  65121. * @returns array containing world position composing the path
  65122. */
  65123. computePath(start: Vector3, end: Vector3): Vector3[];
  65124. /**
  65125. * If this plugin is supported
  65126. * @returns true if plugin is supported
  65127. */
  65128. isSupported(): boolean;
  65129. /**
  65130. * Create a new Crowd so you can add agents
  65131. * @param maxAgents the maximum agent count in the crowd
  65132. * @param maxAgentRadius the maximum radius an agent can have
  65133. * @param scene to attach the crowd to
  65134. * @returns the crowd you can add agents to
  65135. */
  65136. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65137. /**
  65138. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65139. * The queries will try to find a solution within those bounds
  65140. * default is (1,1,1)
  65141. * @param extent x,y,z value that define the extent around the queries point of reference
  65142. */
  65143. setDefaultQueryExtent(extent: Vector3): void;
  65144. /**
  65145. * Get the Bounding box extent specified by setDefaultQueryExtent
  65146. * @returns the box extent values
  65147. */
  65148. getDefaultQueryExtent(): Vector3;
  65149. /**
  65150. * Release all resources
  65151. */
  65152. dispose(): void;
  65153. }
  65154. /**
  65155. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65156. */
  65157. export interface ICrowd {
  65158. /**
  65159. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65160. * You can attach anything to that node. The node position is updated in the scene update tick.
  65161. * @param pos world position that will be constrained by the navigation mesh
  65162. * @param parameters agent parameters
  65163. * @param transform hooked to the agent that will be update by the scene
  65164. * @returns agent index
  65165. */
  65166. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65167. /**
  65168. * Returns the agent position in world space
  65169. * @param index agent index returned by addAgent
  65170. * @returns world space position
  65171. */
  65172. getAgentPosition(index: number): Vector3;
  65173. /**
  65174. * Gets the agent velocity in world space
  65175. * @param index agent index returned by addAgent
  65176. * @returns world space velocity
  65177. */
  65178. getAgentVelocity(index: number): Vector3;
  65179. /**
  65180. * remove a particular agent previously created
  65181. * @param index agent index returned by addAgent
  65182. */
  65183. removeAgent(index: number): void;
  65184. /**
  65185. * get the list of all agents attached to this crowd
  65186. * @returns list of agent indices
  65187. */
  65188. getAgents(): number[];
  65189. /**
  65190. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65191. * @param deltaTime in seconds
  65192. */
  65193. update(deltaTime: number): void;
  65194. /**
  65195. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65196. * @param index agent index returned by addAgent
  65197. * @param destination targeted world position
  65198. */
  65199. agentGoto(index: number, destination: Vector3): void;
  65200. /**
  65201. * Teleport the agent to a new position
  65202. * @param index agent index returned by addAgent
  65203. * @param destination targeted world position
  65204. */
  65205. agentTeleport(index: number, destination: Vector3): void;
  65206. /**
  65207. * Update agent parameters
  65208. * @param index agent index returned by addAgent
  65209. * @param parameters agent parameters
  65210. */
  65211. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65212. /**
  65213. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65214. * The queries will try to find a solution within those bounds
  65215. * default is (1,1,1)
  65216. * @param extent x,y,z value that define the extent around the queries point of reference
  65217. */
  65218. setDefaultQueryExtent(extent: Vector3): void;
  65219. /**
  65220. * Get the Bounding box extent specified by setDefaultQueryExtent
  65221. * @returns the box extent values
  65222. */
  65223. getDefaultQueryExtent(): Vector3;
  65224. /**
  65225. * Release all resources
  65226. */
  65227. dispose(): void;
  65228. }
  65229. /**
  65230. * Configures an agent
  65231. */
  65232. export interface IAgentParameters {
  65233. /**
  65234. * Agent radius. [Limit: >= 0]
  65235. */
  65236. radius: number;
  65237. /**
  65238. * Agent height. [Limit: > 0]
  65239. */
  65240. height: number;
  65241. /**
  65242. * Maximum allowed acceleration. [Limit: >= 0]
  65243. */
  65244. maxAcceleration: number;
  65245. /**
  65246. * Maximum allowed speed. [Limit: >= 0]
  65247. */
  65248. maxSpeed: number;
  65249. /**
  65250. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65251. */
  65252. collisionQueryRange: number;
  65253. /**
  65254. * The path visibility optimization range. [Limit: > 0]
  65255. */
  65256. pathOptimizationRange: number;
  65257. /**
  65258. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65259. */
  65260. separationWeight: number;
  65261. }
  65262. /**
  65263. * Configures the navigation mesh creation
  65264. */
  65265. export interface INavMeshParameters {
  65266. /**
  65267. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65268. */
  65269. cs: number;
  65270. /**
  65271. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65272. */
  65273. ch: number;
  65274. /**
  65275. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65276. */
  65277. walkableSlopeAngle: number;
  65278. /**
  65279. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65280. * be considered walkable. [Limit: >= 3] [Units: vx]
  65281. */
  65282. walkableHeight: number;
  65283. /**
  65284. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65285. */
  65286. walkableClimb: number;
  65287. /**
  65288. * The distance to erode/shrink the walkable area of the heightfield away from
  65289. * obstructions. [Limit: >=0] [Units: vx]
  65290. */
  65291. walkableRadius: number;
  65292. /**
  65293. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65294. */
  65295. maxEdgeLen: number;
  65296. /**
  65297. * The maximum distance a simplfied contour's border edges should deviate
  65298. * the original raw contour. [Limit: >=0] [Units: vx]
  65299. */
  65300. maxSimplificationError: number;
  65301. /**
  65302. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65303. */
  65304. minRegionArea: number;
  65305. /**
  65306. * Any regions with a span count smaller than this value will, if possible,
  65307. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65308. */
  65309. mergeRegionArea: number;
  65310. /**
  65311. * The maximum number of vertices allowed for polygons generated during the
  65312. * contour to polygon conversion process. [Limit: >= 3]
  65313. */
  65314. maxVertsPerPoly: number;
  65315. /**
  65316. * Sets the sampling distance to use when generating the detail mesh.
  65317. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65318. */
  65319. detailSampleDist: number;
  65320. /**
  65321. * The maximum distance the detail mesh surface should deviate from heightfield
  65322. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65323. */
  65324. detailSampleMaxError: number;
  65325. }
  65326. }
  65327. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65328. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65329. import { Mesh } from "babylonjs/Meshes/mesh";
  65330. import { Scene } from "babylonjs/scene";
  65331. import { Vector3 } from "babylonjs/Maths/math";
  65332. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65333. /**
  65334. * RecastJS navigation plugin
  65335. */
  65336. export class RecastJSPlugin implements INavigationEnginePlugin {
  65337. /**
  65338. * Reference to the Recast library
  65339. */
  65340. bjsRECAST: any;
  65341. /**
  65342. * plugin name
  65343. */
  65344. name: string;
  65345. /**
  65346. * the first navmesh created. We might extend this to support multiple navmeshes
  65347. */
  65348. navMesh: any;
  65349. /**
  65350. * Initializes the recastJS plugin
  65351. * @param recastInjection can be used to inject your own recast reference
  65352. */
  65353. constructor(recastInjection?: any);
  65354. /**
  65355. * Creates a navigation mesh
  65356. * @param meshes array of all the geometry used to compute the navigatio mesh
  65357. * @param parameters bunch of parameters used to filter geometry
  65358. */
  65359. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65360. /**
  65361. * Create a navigation mesh debug mesh
  65362. * @param scene is where the mesh will be added
  65363. * @returns debug display mesh
  65364. */
  65365. createDebugNavMesh(scene: Scene): Mesh;
  65366. /**
  65367. * Get a navigation mesh constrained position, closest to the parameter position
  65368. * @param position world position
  65369. * @returns the closest point to position constrained by the navigation mesh
  65370. */
  65371. getClosestPoint(position: Vector3): Vector3;
  65372. /**
  65373. * Get a navigation mesh constrained position, within a particular radius
  65374. * @param position world position
  65375. * @param maxRadius the maximum distance to the constrained world position
  65376. * @returns the closest point to position constrained by the navigation mesh
  65377. */
  65378. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65379. /**
  65380. * Compute the final position from a segment made of destination-position
  65381. * @param position world position
  65382. * @param destination world position
  65383. * @returns the resulting point along the navmesh
  65384. */
  65385. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65386. /**
  65387. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65388. * @param start world position
  65389. * @param end world position
  65390. * @returns array containing world position composing the path
  65391. */
  65392. computePath(start: Vector3, end: Vector3): Vector3[];
  65393. /**
  65394. * Create a new Crowd so you can add agents
  65395. * @param maxAgents the maximum agent count in the crowd
  65396. * @param maxAgentRadius the maximum radius an agent can have
  65397. * @param scene to attach the crowd to
  65398. * @returns the crowd you can add agents to
  65399. */
  65400. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65401. /**
  65402. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65403. * The queries will try to find a solution within those bounds
  65404. * default is (1,1,1)
  65405. * @param extent x,y,z value that define the extent around the queries point of reference
  65406. */
  65407. setDefaultQueryExtent(extent: Vector3): void;
  65408. /**
  65409. * Get the Bounding box extent specified by setDefaultQueryExtent
  65410. * @returns the box extent values
  65411. */
  65412. getDefaultQueryExtent(): Vector3;
  65413. /**
  65414. * Disposes
  65415. */
  65416. dispose(): void;
  65417. /**
  65418. * If this plugin is supported
  65419. * @returns true if plugin is supported
  65420. */
  65421. isSupported(): boolean;
  65422. }
  65423. /**
  65424. * Recast detour crowd implementation
  65425. */
  65426. export class RecastJSCrowd implements ICrowd {
  65427. /**
  65428. * Recast/detour plugin
  65429. */
  65430. bjsRECASTPlugin: RecastJSPlugin;
  65431. /**
  65432. * Link to the detour crowd
  65433. */
  65434. recastCrowd: any;
  65435. /**
  65436. * One transform per agent
  65437. */
  65438. transforms: TransformNode[];
  65439. /**
  65440. * All agents created
  65441. */
  65442. agents: number[];
  65443. /**
  65444. * Link to the scene is kept to unregister the crowd from the scene
  65445. */
  65446. private _scene;
  65447. /**
  65448. * Observer for crowd updates
  65449. */
  65450. private _onBeforeAnimationsObserver;
  65451. /**
  65452. * Constructor
  65453. * @param plugin recastJS plugin
  65454. * @param maxAgents the maximum agent count in the crowd
  65455. * @param maxAgentRadius the maximum radius an agent can have
  65456. * @param scene to attach the crowd to
  65457. * @returns the crowd you can add agents to
  65458. */
  65459. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65460. /**
  65461. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65462. * You can attach anything to that node. The node position is updated in the scene update tick.
  65463. * @param pos world position that will be constrained by the navigation mesh
  65464. * @param parameters agent parameters
  65465. * @param transform hooked to the agent that will be update by the scene
  65466. * @returns agent index
  65467. */
  65468. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65469. /**
  65470. * Returns the agent position in world space
  65471. * @param index agent index returned by addAgent
  65472. * @returns world space position
  65473. */
  65474. getAgentPosition(index: number): Vector3;
  65475. /**
  65476. * Returns the agent velocity in world space
  65477. * @param index agent index returned by addAgent
  65478. * @returns world space velocity
  65479. */
  65480. getAgentVelocity(index: number): Vector3;
  65481. /**
  65482. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65483. * @param index agent index returned by addAgent
  65484. * @param destination targeted world position
  65485. */
  65486. agentGoto(index: number, destination: Vector3): void;
  65487. /**
  65488. * Teleport the agent to a new position
  65489. * @param index agent index returned by addAgent
  65490. * @param destination targeted world position
  65491. */
  65492. agentTeleport(index: number, destination: Vector3): void;
  65493. /**
  65494. * Update agent parameters
  65495. * @param index agent index returned by addAgent
  65496. * @param parameters agent parameters
  65497. */
  65498. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65499. /**
  65500. * remove a particular agent previously created
  65501. * @param index agent index returned by addAgent
  65502. */
  65503. removeAgent(index: number): void;
  65504. /**
  65505. * get the list of all agents attached to this crowd
  65506. * @returns list of agent indices
  65507. */
  65508. getAgents(): number[];
  65509. /**
  65510. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65511. * @param deltaTime in seconds
  65512. */
  65513. update(deltaTime: number): void;
  65514. /**
  65515. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65516. * The queries will try to find a solution within those bounds
  65517. * default is (1,1,1)
  65518. * @param extent x,y,z value that define the extent around the queries point of reference
  65519. */
  65520. setDefaultQueryExtent(extent: Vector3): void;
  65521. /**
  65522. * Get the Bounding box extent specified by setDefaultQueryExtent
  65523. * @returns the box extent values
  65524. */
  65525. getDefaultQueryExtent(): Vector3;
  65526. /**
  65527. * Release all resources
  65528. */
  65529. dispose(): void;
  65530. }
  65531. }
  65532. declare module "babylonjs/Navigation/Plugins/index" {
  65533. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65534. }
  65535. declare module "babylonjs/Navigation/index" {
  65536. export * from "babylonjs/Navigation/INavigationEngine";
  65537. export * from "babylonjs/Navigation/Plugins/index";
  65538. }
  65539. declare module "babylonjs/Offline/database" {
  65540. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65541. /**
  65542. * Class used to enable access to IndexedDB
  65543. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65544. */
  65545. export class Database implements IOfflineProvider {
  65546. private _callbackManifestChecked;
  65547. private _currentSceneUrl;
  65548. private _db;
  65549. private _enableSceneOffline;
  65550. private _enableTexturesOffline;
  65551. private _manifestVersionFound;
  65552. private _mustUpdateRessources;
  65553. private _hasReachedQuota;
  65554. private _isSupported;
  65555. private _idbFactory;
  65556. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65557. private static IsUASupportingBlobStorage;
  65558. /**
  65559. * Gets a boolean indicating if Database storate is enabled (off by default)
  65560. */
  65561. static IDBStorageEnabled: boolean;
  65562. /**
  65563. * Gets a boolean indicating if scene must be saved in the database
  65564. */
  65565. get enableSceneOffline(): boolean;
  65566. /**
  65567. * Gets a boolean indicating if textures must be saved in the database
  65568. */
  65569. get enableTexturesOffline(): boolean;
  65570. /**
  65571. * Creates a new Database
  65572. * @param urlToScene defines the url to load the scene
  65573. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65574. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65575. */
  65576. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65577. private static _ParseURL;
  65578. private static _ReturnFullUrlLocation;
  65579. private _checkManifestFile;
  65580. /**
  65581. * Open the database and make it available
  65582. * @param successCallback defines the callback to call on success
  65583. * @param errorCallback defines the callback to call on error
  65584. */
  65585. open(successCallback: () => void, errorCallback: () => void): void;
  65586. /**
  65587. * Loads an image from the database
  65588. * @param url defines the url to load from
  65589. * @param image defines the target DOM image
  65590. */
  65591. loadImage(url: string, image: HTMLImageElement): void;
  65592. private _loadImageFromDBAsync;
  65593. private _saveImageIntoDBAsync;
  65594. private _checkVersionFromDB;
  65595. private _loadVersionFromDBAsync;
  65596. private _saveVersionIntoDBAsync;
  65597. /**
  65598. * Loads a file from database
  65599. * @param url defines the URL to load from
  65600. * @param sceneLoaded defines a callback to call on success
  65601. * @param progressCallBack defines a callback to call when progress changed
  65602. * @param errorCallback defines a callback to call on error
  65603. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65604. */
  65605. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65606. private _loadFileAsync;
  65607. private _saveFileAsync;
  65608. /**
  65609. * Validates if xhr data is correct
  65610. * @param xhr defines the request to validate
  65611. * @param dataType defines the expected data type
  65612. * @returns true if data is correct
  65613. */
  65614. private static _ValidateXHRData;
  65615. }
  65616. }
  65617. declare module "babylonjs/Offline/index" {
  65618. export * from "babylonjs/Offline/database";
  65619. export * from "babylonjs/Offline/IOfflineProvider";
  65620. }
  65621. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65622. /** @hidden */
  65623. export var gpuUpdateParticlesPixelShader: {
  65624. name: string;
  65625. shader: string;
  65626. };
  65627. }
  65628. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65629. /** @hidden */
  65630. export var gpuUpdateParticlesVertexShader: {
  65631. name: string;
  65632. shader: string;
  65633. };
  65634. }
  65635. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65636. /** @hidden */
  65637. export var clipPlaneFragmentDeclaration2: {
  65638. name: string;
  65639. shader: string;
  65640. };
  65641. }
  65642. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65643. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65644. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65645. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65646. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65647. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65648. /** @hidden */
  65649. export var gpuRenderParticlesPixelShader: {
  65650. name: string;
  65651. shader: string;
  65652. };
  65653. }
  65654. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65655. /** @hidden */
  65656. export var clipPlaneVertexDeclaration2: {
  65657. name: string;
  65658. shader: string;
  65659. };
  65660. }
  65661. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65662. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65663. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65664. /** @hidden */
  65665. export var gpuRenderParticlesVertexShader: {
  65666. name: string;
  65667. shader: string;
  65668. };
  65669. }
  65670. declare module "babylonjs/Particles/gpuParticleSystem" {
  65671. import { Nullable } from "babylonjs/types";
  65672. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65673. import { Observable } from "babylonjs/Misc/observable";
  65674. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65675. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65676. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65677. import { Scene, IDisposable } from "babylonjs/scene";
  65678. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65679. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65680. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65681. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65682. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65683. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65684. /**
  65685. * This represents a GPU particle system in Babylon
  65686. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65687. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65688. */
  65689. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65690. /**
  65691. * The layer mask we are rendering the particles through.
  65692. */
  65693. layerMask: number;
  65694. private _capacity;
  65695. private _activeCount;
  65696. private _currentActiveCount;
  65697. private _accumulatedCount;
  65698. private _renderEffect;
  65699. private _updateEffect;
  65700. private _buffer0;
  65701. private _buffer1;
  65702. private _spriteBuffer;
  65703. private _updateVAO;
  65704. private _renderVAO;
  65705. private _targetIndex;
  65706. private _sourceBuffer;
  65707. private _targetBuffer;
  65708. private _engine;
  65709. private _currentRenderId;
  65710. private _started;
  65711. private _stopped;
  65712. private _timeDelta;
  65713. private _randomTexture;
  65714. private _randomTexture2;
  65715. private _attributesStrideSize;
  65716. private _updateEffectOptions;
  65717. private _randomTextureSize;
  65718. private _actualFrame;
  65719. private readonly _rawTextureWidth;
  65720. /**
  65721. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65722. */
  65723. static get IsSupported(): boolean;
  65724. /**
  65725. * An event triggered when the system is disposed.
  65726. */
  65727. onDisposeObservable: Observable<GPUParticleSystem>;
  65728. /**
  65729. * Gets the maximum number of particles active at the same time.
  65730. * @returns The max number of active particles.
  65731. */
  65732. getCapacity(): number;
  65733. /**
  65734. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65735. * to override the particles.
  65736. */
  65737. forceDepthWrite: boolean;
  65738. /**
  65739. * Gets or set the number of active particles
  65740. */
  65741. get activeParticleCount(): number;
  65742. set activeParticleCount(value: number);
  65743. private _preWarmDone;
  65744. /**
  65745. * Specifies if the particles are updated in emitter local space or world space.
  65746. * This is always false for GPU particles
  65747. */
  65748. get isLocal(): boolean;
  65749. set isLocal(value: boolean);
  65750. /**
  65751. * Is this system ready to be used/rendered
  65752. * @return true if the system is ready
  65753. */
  65754. isReady(): boolean;
  65755. /**
  65756. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65757. * @returns True if it has been started, otherwise false.
  65758. */
  65759. isStarted(): boolean;
  65760. /**
  65761. * Starts the particle system and begins to emit
  65762. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65763. */
  65764. start(delay?: number): void;
  65765. /**
  65766. * Stops the particle system.
  65767. */
  65768. stop(): void;
  65769. /**
  65770. * Remove all active particles
  65771. */
  65772. reset(): void;
  65773. /**
  65774. * Returns the string "GPUParticleSystem"
  65775. * @returns a string containing the class name
  65776. */
  65777. getClassName(): string;
  65778. private _colorGradientsTexture;
  65779. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65780. /**
  65781. * Adds a new color gradient
  65782. * @param gradient defines the gradient to use (between 0 and 1)
  65783. * @param color1 defines the color to affect to the specified gradient
  65784. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65785. * @returns the current particle system
  65786. */
  65787. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65788. /**
  65789. * Remove a specific color gradient
  65790. * @param gradient defines the gradient to remove
  65791. * @returns the current particle system
  65792. */
  65793. removeColorGradient(gradient: number): GPUParticleSystem;
  65794. private _angularSpeedGradientsTexture;
  65795. private _sizeGradientsTexture;
  65796. private _velocityGradientsTexture;
  65797. private _limitVelocityGradientsTexture;
  65798. private _dragGradientsTexture;
  65799. private _addFactorGradient;
  65800. /**
  65801. * Adds a new size gradient
  65802. * @param gradient defines the gradient to use (between 0 and 1)
  65803. * @param factor defines the size factor to affect to the specified gradient
  65804. * @returns the current particle system
  65805. */
  65806. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65807. /**
  65808. * Remove a specific size gradient
  65809. * @param gradient defines the gradient to remove
  65810. * @returns the current particle system
  65811. */
  65812. removeSizeGradient(gradient: number): GPUParticleSystem;
  65813. /**
  65814. * Adds a new angular speed gradient
  65815. * @param gradient defines the gradient to use (between 0 and 1)
  65816. * @param factor defines the angular speed to affect to the specified gradient
  65817. * @returns the current particle system
  65818. */
  65819. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65820. /**
  65821. * Remove a specific angular speed gradient
  65822. * @param gradient defines the gradient to remove
  65823. * @returns the current particle system
  65824. */
  65825. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65826. /**
  65827. * Adds a new velocity gradient
  65828. * @param gradient defines the gradient to use (between 0 and 1)
  65829. * @param factor defines the velocity to affect to the specified gradient
  65830. * @returns the current particle system
  65831. */
  65832. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65833. /**
  65834. * Remove a specific velocity gradient
  65835. * @param gradient defines the gradient to remove
  65836. * @returns the current particle system
  65837. */
  65838. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65839. /**
  65840. * Adds a new limit velocity gradient
  65841. * @param gradient defines the gradient to use (between 0 and 1)
  65842. * @param factor defines the limit velocity value to affect to the specified gradient
  65843. * @returns the current particle system
  65844. */
  65845. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65846. /**
  65847. * Remove a specific limit velocity gradient
  65848. * @param gradient defines the gradient to remove
  65849. * @returns the current particle system
  65850. */
  65851. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65852. /**
  65853. * Adds a new drag gradient
  65854. * @param gradient defines the gradient to use (between 0 and 1)
  65855. * @param factor defines the drag value to affect to the specified gradient
  65856. * @returns the current particle system
  65857. */
  65858. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65859. /**
  65860. * Remove a specific drag gradient
  65861. * @param gradient defines the gradient to remove
  65862. * @returns the current particle system
  65863. */
  65864. removeDragGradient(gradient: number): GPUParticleSystem;
  65865. /**
  65866. * Not supported by GPUParticleSystem
  65867. * @param gradient defines the gradient to use (between 0 and 1)
  65868. * @param factor defines the emit rate value to affect to the specified gradient
  65869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65870. * @returns the current particle system
  65871. */
  65872. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65873. /**
  65874. * Not supported by GPUParticleSystem
  65875. * @param gradient defines the gradient to remove
  65876. * @returns the current particle system
  65877. */
  65878. removeEmitRateGradient(gradient: number): IParticleSystem;
  65879. /**
  65880. * Not supported by GPUParticleSystem
  65881. * @param gradient defines the gradient to use (between 0 and 1)
  65882. * @param factor defines the start size value to affect to the specified gradient
  65883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65884. * @returns the current particle system
  65885. */
  65886. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65887. /**
  65888. * Not supported by GPUParticleSystem
  65889. * @param gradient defines the gradient to remove
  65890. * @returns the current particle system
  65891. */
  65892. removeStartSizeGradient(gradient: number): IParticleSystem;
  65893. /**
  65894. * Not supported by GPUParticleSystem
  65895. * @param gradient defines the gradient to use (between 0 and 1)
  65896. * @param min defines the color remap minimal range
  65897. * @param max defines the color remap maximal range
  65898. * @returns the current particle system
  65899. */
  65900. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65901. /**
  65902. * Not supported by GPUParticleSystem
  65903. * @param gradient defines the gradient to remove
  65904. * @returns the current particle system
  65905. */
  65906. removeColorRemapGradient(): IParticleSystem;
  65907. /**
  65908. * Not supported by GPUParticleSystem
  65909. * @param gradient defines the gradient to use (between 0 and 1)
  65910. * @param min defines the alpha remap minimal range
  65911. * @param max defines the alpha remap maximal range
  65912. * @returns the current particle system
  65913. */
  65914. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65915. /**
  65916. * Not supported by GPUParticleSystem
  65917. * @param gradient defines the gradient to remove
  65918. * @returns the current particle system
  65919. */
  65920. removeAlphaRemapGradient(): IParticleSystem;
  65921. /**
  65922. * Not supported by GPUParticleSystem
  65923. * @param gradient defines the gradient to use (between 0 and 1)
  65924. * @param color defines the color to affect to the specified gradient
  65925. * @returns the current particle system
  65926. */
  65927. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65928. /**
  65929. * Not supported by GPUParticleSystem
  65930. * @param gradient defines the gradient to remove
  65931. * @returns the current particle system
  65932. */
  65933. removeRampGradient(): IParticleSystem;
  65934. /**
  65935. * Not supported by GPUParticleSystem
  65936. * @returns the list of ramp gradients
  65937. */
  65938. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65939. /**
  65940. * Not supported by GPUParticleSystem
  65941. * Gets or sets a boolean indicating that ramp gradients must be used
  65942. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65943. */
  65944. get useRampGradients(): boolean;
  65945. set useRampGradients(value: boolean);
  65946. /**
  65947. * Not supported by GPUParticleSystem
  65948. * @param gradient defines the gradient to use (between 0 and 1)
  65949. * @param factor defines the life time factor to affect to the specified gradient
  65950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65951. * @returns the current particle system
  65952. */
  65953. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65954. /**
  65955. * Not supported by GPUParticleSystem
  65956. * @param gradient defines the gradient to remove
  65957. * @returns the current particle system
  65958. */
  65959. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65960. /**
  65961. * Instantiates a GPU particle system.
  65962. * 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.
  65963. * @param name The name of the particle system
  65964. * @param options The options used to create the system
  65965. * @param scene The scene the particle system belongs to
  65966. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65967. */
  65968. constructor(name: string, options: Partial<{
  65969. capacity: number;
  65970. randomTextureSize: number;
  65971. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65972. protected _reset(): void;
  65973. private _createUpdateVAO;
  65974. private _createRenderVAO;
  65975. private _initialize;
  65976. /** @hidden */
  65977. _recreateUpdateEffect(): void;
  65978. /** @hidden */
  65979. _recreateRenderEffect(): void;
  65980. /**
  65981. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65982. * @param preWarm defines if we are in the pre-warmimg phase
  65983. */
  65984. animate(preWarm?: boolean): void;
  65985. private _createFactorGradientTexture;
  65986. private _createSizeGradientTexture;
  65987. private _createAngularSpeedGradientTexture;
  65988. private _createVelocityGradientTexture;
  65989. private _createLimitVelocityGradientTexture;
  65990. private _createDragGradientTexture;
  65991. private _createColorGradientTexture;
  65992. /**
  65993. * Renders the particle system in its current state
  65994. * @param preWarm defines if the system should only update the particles but not render them
  65995. * @returns the current number of particles
  65996. */
  65997. render(preWarm?: boolean): number;
  65998. /**
  65999. * Rebuilds the particle system
  66000. */
  66001. rebuild(): void;
  66002. private _releaseBuffers;
  66003. private _releaseVAOs;
  66004. /**
  66005. * Disposes the particle system and free the associated resources
  66006. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66007. */
  66008. dispose(disposeTexture?: boolean): void;
  66009. /**
  66010. * Clones the particle system.
  66011. * @param name The name of the cloned object
  66012. * @param newEmitter The new emitter to use
  66013. * @returns the cloned particle system
  66014. */
  66015. clone(name: string, newEmitter: any): GPUParticleSystem;
  66016. /**
  66017. * Serializes the particle system to a JSON object.
  66018. * @returns the JSON object
  66019. */
  66020. serialize(): any;
  66021. /**
  66022. * Parses a JSON object to create a GPU particle system.
  66023. * @param parsedParticleSystem The JSON object to parse
  66024. * @param scene The scene to create the particle system in
  66025. * @param rootUrl The root url to use to load external dependencies like texture
  66026. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66027. * @returns the parsed GPU particle system
  66028. */
  66029. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66030. }
  66031. }
  66032. declare module "babylonjs/Particles/particleSystemSet" {
  66033. import { Nullable } from "babylonjs/types";
  66034. import { Color3 } from "babylonjs/Maths/math.color";
  66035. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66037. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66038. import { Scene, IDisposable } from "babylonjs/scene";
  66039. /**
  66040. * Represents a set of particle systems working together to create a specific effect
  66041. */
  66042. export class ParticleSystemSet implements IDisposable {
  66043. /**
  66044. * Gets or sets base Assets URL
  66045. */
  66046. static BaseAssetsUrl: string;
  66047. private _emitterCreationOptions;
  66048. private _emitterNode;
  66049. /**
  66050. * Gets the particle system list
  66051. */
  66052. systems: IParticleSystem[];
  66053. /**
  66054. * Gets the emitter node used with this set
  66055. */
  66056. get emitterNode(): Nullable<TransformNode>;
  66057. /**
  66058. * Creates a new emitter mesh as a sphere
  66059. * @param options defines the options used to create the sphere
  66060. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66061. * @param scene defines the hosting scene
  66062. */
  66063. setEmitterAsSphere(options: {
  66064. diameter: number;
  66065. segments: number;
  66066. color: Color3;
  66067. }, renderingGroupId: number, scene: Scene): void;
  66068. /**
  66069. * Starts all particle systems of the set
  66070. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66071. */
  66072. start(emitter?: AbstractMesh): void;
  66073. /**
  66074. * Release all associated resources
  66075. */
  66076. dispose(): void;
  66077. /**
  66078. * Serialize the set into a JSON compatible object
  66079. * @returns a JSON compatible representation of the set
  66080. */
  66081. serialize(): any;
  66082. /**
  66083. * Parse a new ParticleSystemSet from a serialized source
  66084. * @param data defines a JSON compatible representation of the set
  66085. * @param scene defines the hosting scene
  66086. * @param gpu defines if we want GPU particles or CPU particles
  66087. * @returns a new ParticleSystemSet
  66088. */
  66089. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66090. }
  66091. }
  66092. declare module "babylonjs/Particles/particleHelper" {
  66093. import { Nullable } from "babylonjs/types";
  66094. import { Scene } from "babylonjs/scene";
  66095. import { Vector3 } from "babylonjs/Maths/math.vector";
  66096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66097. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66098. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66099. /**
  66100. * This class is made for on one-liner static method to help creating particle system set.
  66101. */
  66102. export class ParticleHelper {
  66103. /**
  66104. * Gets or sets base Assets URL
  66105. */
  66106. static BaseAssetsUrl: string;
  66107. /**
  66108. * Create a default particle system that you can tweak
  66109. * @param emitter defines the emitter to use
  66110. * @param capacity defines the system capacity (default is 500 particles)
  66111. * @param scene defines the hosting scene
  66112. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66113. * @returns the new Particle system
  66114. */
  66115. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66116. /**
  66117. * This is the main static method (one-liner) of this helper to create different particle systems
  66118. * @param type This string represents the type to the particle system to create
  66119. * @param scene The scene where the particle system should live
  66120. * @param gpu If the system will use gpu
  66121. * @returns the ParticleSystemSet created
  66122. */
  66123. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66124. /**
  66125. * Static function used to export a particle system to a ParticleSystemSet variable.
  66126. * Please note that the emitter shape is not exported
  66127. * @param systems defines the particle systems to export
  66128. * @returns the created particle system set
  66129. */
  66130. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66131. }
  66132. }
  66133. declare module "babylonjs/Particles/particleSystemComponent" {
  66134. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66135. import { Effect } from "babylonjs/Materials/effect";
  66136. import "babylonjs/Shaders/particles.vertex";
  66137. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66138. module "babylonjs/Engines/engine" {
  66139. interface Engine {
  66140. /**
  66141. * Create an effect to use with particle systems.
  66142. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66143. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66144. * @param uniformsNames defines a list of attribute names
  66145. * @param samplers defines an array of string used to represent textures
  66146. * @param defines defines the string containing the defines to use to compile the shaders
  66147. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66148. * @param onCompiled defines a function to call when the effect creation is successful
  66149. * @param onError defines a function to call when the effect creation has failed
  66150. * @returns the new Effect
  66151. */
  66152. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66153. }
  66154. }
  66155. module "babylonjs/Meshes/mesh" {
  66156. interface Mesh {
  66157. /**
  66158. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66159. * @returns an array of IParticleSystem
  66160. */
  66161. getEmittedParticleSystems(): IParticleSystem[];
  66162. /**
  66163. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66164. * @returns an array of IParticleSystem
  66165. */
  66166. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66167. }
  66168. }
  66169. /**
  66170. * @hidden
  66171. */
  66172. export var _IDoNeedToBeInTheBuild: number;
  66173. }
  66174. declare module "babylonjs/Particles/pointsCloudSystem" {
  66175. import { Color4 } from "babylonjs/Maths/math";
  66176. import { Mesh } from "babylonjs/Meshes/mesh";
  66177. import { Scene, IDisposable } from "babylonjs/scene";
  66178. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66179. /** Defines the 4 color options */
  66180. export enum PointColor {
  66181. /** color value */
  66182. Color = 2,
  66183. /** uv value */
  66184. UV = 1,
  66185. /** random value */
  66186. Random = 0,
  66187. /** stated value */
  66188. Stated = 3
  66189. }
  66190. /**
  66191. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66192. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  66193. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66194. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66195. *
  66196. * Full documentation here : TO BE ENTERED
  66197. */
  66198. export class PointsCloudSystem implements IDisposable {
  66199. /**
  66200. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66201. * Example : var p = SPS.particles[i];
  66202. */
  66203. particles: CloudPoint[];
  66204. /**
  66205. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66206. */
  66207. nbParticles: number;
  66208. /**
  66209. * This a counter for your own usage. It's not set by any SPS functions.
  66210. */
  66211. counter: number;
  66212. /**
  66213. * The PCS name. This name is also given to the underlying mesh.
  66214. */
  66215. name: string;
  66216. /**
  66217. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66218. */
  66219. mesh: Mesh;
  66220. /**
  66221. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66222. * Please read :
  66223. */
  66224. vars: any;
  66225. /**
  66226. * @hidden
  66227. */
  66228. _size: number;
  66229. private _scene;
  66230. private _promises;
  66231. private _positions;
  66232. private _indices;
  66233. private _normals;
  66234. private _colors;
  66235. private _uvs;
  66236. private _indices32;
  66237. private _positions32;
  66238. private _colors32;
  66239. private _uvs32;
  66240. private _updatable;
  66241. private _isVisibilityBoxLocked;
  66242. private _alwaysVisible;
  66243. private _groups;
  66244. private _groupCounter;
  66245. private _computeParticleColor;
  66246. private _computeParticleTexture;
  66247. private _computeParticleRotation;
  66248. private _computeBoundingBox;
  66249. private _isReady;
  66250. /**
  66251. * Creates a PCS (Points Cloud System) object
  66252. * @param name (String) is the PCS name, this will be the underlying mesh name
  66253. * @param pointSize (number) is the size for each point
  66254. * @param scene (Scene) is the scene in which the PCS is added
  66255. * @param options defines the options of the PCS e.g.
  66256. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66257. */
  66258. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66259. updatable?: boolean;
  66260. });
  66261. /**
  66262. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66263. * If no points were added to the PCS, the returned mesh is just a single point.
  66264. * @returns a promise for the created mesh
  66265. */
  66266. buildMeshAsync(): Promise<Mesh>;
  66267. /**
  66268. * @hidden
  66269. */
  66270. private _buildMesh;
  66271. private _addParticle;
  66272. private _randomUnitVector;
  66273. private _getColorIndicesForCoord;
  66274. private _setPointsColorOrUV;
  66275. private _colorFromTexture;
  66276. private _calculateDensity;
  66277. /**
  66278. * Adds points to the PCS in random positions within a unit sphere
  66279. * @param nb (positive integer) the number of particles to be created from this model
  66280. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66281. * @returns the number of groups in the system
  66282. */
  66283. addPoints(nb: number, pointFunction?: any): number;
  66284. /**
  66285. * Adds points to the PCS from the surface of the model shape
  66286. * @param mesh is any Mesh object that will be used as a surface model for the points
  66287. * @param nb (positive integer) the number of particles to be created from this model
  66288. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66289. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66290. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66291. * @returns the number of groups in the system
  66292. */
  66293. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66294. /**
  66295. * Adds points to the PCS inside the model shape
  66296. * @param mesh is any Mesh object that will be used as a surface model for the points
  66297. * @param nb (positive integer) the number of particles to be created from this model
  66298. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66299. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66300. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66301. * @returns the number of groups in the system
  66302. */
  66303. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66304. /**
  66305. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66306. * This method calls `updateParticle()` for each particle of the SPS.
  66307. * For an animated SPS, it is usually called within the render loop.
  66308. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66309. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66310. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66311. * @returns the PCS.
  66312. */
  66313. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66314. /**
  66315. * Disposes the PCS.
  66316. */
  66317. dispose(): void;
  66318. /**
  66319. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66320. * doc :
  66321. * @returns the PCS.
  66322. */
  66323. refreshVisibleSize(): PointsCloudSystem;
  66324. /**
  66325. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66326. * @param size the size (float) of the visibility box
  66327. * note : this doesn't lock the PCS mesh bounding box.
  66328. * doc :
  66329. */
  66330. setVisibilityBox(size: number): void;
  66331. /**
  66332. * Gets whether the PCS is always visible or not
  66333. * doc :
  66334. */
  66335. get isAlwaysVisible(): boolean;
  66336. /**
  66337. * Sets the PCS as always visible or not
  66338. * doc :
  66339. */
  66340. set isAlwaysVisible(val: boolean);
  66341. /**
  66342. * Tells to `setParticles()` to compute the particle rotations or not
  66343. * Default value : false. The PCS is faster when it's set to false
  66344. * Note : particle rotations are only applied to parent particles
  66345. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66346. */
  66347. set computeParticleRotation(val: boolean);
  66348. /**
  66349. * Tells to `setParticles()` to compute the particle colors or not.
  66350. * Default value : true. The PCS is faster when it's set to false.
  66351. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66352. */
  66353. set computeParticleColor(val: boolean);
  66354. set computeParticleTexture(val: boolean);
  66355. /**
  66356. * Gets if `setParticles()` computes the particle colors or not.
  66357. * Default value : false. The PCS is faster when it's set to false.
  66358. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66359. */
  66360. get computeParticleColor(): boolean;
  66361. /**
  66362. * Gets if `setParticles()` computes the particle textures or not.
  66363. * Default value : false. The PCS is faster when it's set to false.
  66364. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66365. */
  66366. get computeParticleTexture(): boolean;
  66367. /**
  66368. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66369. */
  66370. set computeBoundingBox(val: boolean);
  66371. /**
  66372. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66373. */
  66374. get computeBoundingBox(): boolean;
  66375. /**
  66376. * This function does nothing. It may be overwritten to set all the particle first values.
  66377. * The PCS doesn't call this function, you may have to call it by your own.
  66378. * doc :
  66379. */
  66380. initParticles(): void;
  66381. /**
  66382. * This function does nothing. It may be overwritten to recycle a particle
  66383. * The PCS doesn't call this function, you can to call it
  66384. * doc :
  66385. * @param particle The particle to recycle
  66386. * @returns the recycled particle
  66387. */
  66388. recycleParticle(particle: CloudPoint): CloudPoint;
  66389. /**
  66390. * Updates a particle : this function should be overwritten by the user.
  66391. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66392. * doc :
  66393. * @example : just set a particle position or velocity and recycle conditions
  66394. * @param particle The particle to update
  66395. * @returns the updated particle
  66396. */
  66397. updateParticle(particle: CloudPoint): CloudPoint;
  66398. /**
  66399. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66400. * This does nothing and may be overwritten by the user.
  66401. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66402. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66403. * @param update the boolean update value actually passed to setParticles()
  66404. */
  66405. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66406. /**
  66407. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66408. * This will be passed three parameters.
  66409. * This does nothing and may be overwritten by the user.
  66410. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66411. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66412. * @param update the boolean update value actually passed to setParticles()
  66413. */
  66414. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66415. }
  66416. }
  66417. declare module "babylonjs/Particles/cloudPoint" {
  66418. import { Nullable } from "babylonjs/types";
  66419. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66420. import { Mesh } from "babylonjs/Meshes/mesh";
  66421. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66422. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66423. /**
  66424. * Represents one particle of a points cloud system.
  66425. */
  66426. export class CloudPoint {
  66427. /**
  66428. * particle global index
  66429. */
  66430. idx: number;
  66431. /**
  66432. * The color of the particle
  66433. */
  66434. color: Nullable<Color4>;
  66435. /**
  66436. * The world space position of the particle.
  66437. */
  66438. position: Vector3;
  66439. /**
  66440. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66441. */
  66442. rotation: Vector3;
  66443. /**
  66444. * The world space rotation quaternion of the particle.
  66445. */
  66446. rotationQuaternion: Nullable<Quaternion>;
  66447. /**
  66448. * The uv of the particle.
  66449. */
  66450. uv: Nullable<Vector2>;
  66451. /**
  66452. * The current speed of the particle.
  66453. */
  66454. velocity: Vector3;
  66455. /**
  66456. * The pivot point in the particle local space.
  66457. */
  66458. pivot: Vector3;
  66459. /**
  66460. * Must the particle be translated from its pivot point in its local space ?
  66461. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66462. * Default : false
  66463. */
  66464. translateFromPivot: boolean;
  66465. /**
  66466. * Index of this particle in the global "positions" array (Internal use)
  66467. * @hidden
  66468. */
  66469. _pos: number;
  66470. /**
  66471. * @hidden Index of this particle in the global "indices" array (Internal use)
  66472. */
  66473. _ind: number;
  66474. /**
  66475. * Group this particle belongs to
  66476. */
  66477. _group: PointsGroup;
  66478. /**
  66479. * Group id of this particle
  66480. */
  66481. groupId: number;
  66482. /**
  66483. * Index of the particle in its group id (Internal use)
  66484. */
  66485. idxInGroup: number;
  66486. /**
  66487. * @hidden Particle BoundingInfo object (Internal use)
  66488. */
  66489. _boundingInfo: BoundingInfo;
  66490. /**
  66491. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66492. */
  66493. _pcs: PointsCloudSystem;
  66494. /**
  66495. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66496. */
  66497. _stillInvisible: boolean;
  66498. /**
  66499. * @hidden Last computed particle rotation matrix
  66500. */
  66501. _rotationMatrix: number[];
  66502. /**
  66503. * Parent particle Id, if any.
  66504. * Default null.
  66505. */
  66506. parentId: Nullable<number>;
  66507. /**
  66508. * @hidden Internal global position in the PCS.
  66509. */
  66510. _globalPosition: Vector3;
  66511. /**
  66512. * Creates a Point Cloud object.
  66513. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66514. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66515. * @param group (PointsGroup) is the group the particle belongs to
  66516. * @param groupId (integer) is the group identifier in the PCS.
  66517. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66518. * @param pcs defines the PCS it is associated to
  66519. */
  66520. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66521. /**
  66522. * get point size
  66523. */
  66524. get size(): Vector3;
  66525. /**
  66526. * Set point size
  66527. */
  66528. set size(scale: Vector3);
  66529. /**
  66530. * Legacy support, changed quaternion to rotationQuaternion
  66531. */
  66532. get quaternion(): Nullable<Quaternion>;
  66533. /**
  66534. * Legacy support, changed quaternion to rotationQuaternion
  66535. */
  66536. set quaternion(q: Nullable<Quaternion>);
  66537. /**
  66538. * Returns a boolean. True if the particle intersects a mesh, else false
  66539. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66540. * @param target is the object (point or mesh) what the intersection is computed against
  66541. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66542. * @returns true if it intersects
  66543. */
  66544. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66545. /**
  66546. * get the rotation matrix of the particle
  66547. * @hidden
  66548. */
  66549. getRotationMatrix(m: Matrix): void;
  66550. }
  66551. /**
  66552. * Represents a group of points in a points cloud system
  66553. * * PCS internal tool, don't use it manually.
  66554. */
  66555. export class PointsGroup {
  66556. /**
  66557. * The group id
  66558. * @hidden
  66559. */
  66560. groupID: number;
  66561. /**
  66562. * image data for group (internal use)
  66563. * @hidden
  66564. */
  66565. _groupImageData: Nullable<ArrayBufferView>;
  66566. /**
  66567. * Image Width (internal use)
  66568. * @hidden
  66569. */
  66570. _groupImgWidth: number;
  66571. /**
  66572. * Image Height (internal use)
  66573. * @hidden
  66574. */
  66575. _groupImgHeight: number;
  66576. /**
  66577. * Custom position function (internal use)
  66578. * @hidden
  66579. */
  66580. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66581. /**
  66582. * density per facet for surface points
  66583. * @hidden
  66584. */
  66585. _groupDensity: number[];
  66586. /**
  66587. * Only when points are colored by texture carries pointer to texture list array
  66588. * @hidden
  66589. */
  66590. _textureNb: number;
  66591. /**
  66592. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66593. * PCS internal tool, don't use it manually.
  66594. * @hidden
  66595. */
  66596. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66597. }
  66598. }
  66599. declare module "babylonjs/Particles/index" {
  66600. export * from "babylonjs/Particles/baseParticleSystem";
  66601. export * from "babylonjs/Particles/EmitterTypes/index";
  66602. export * from "babylonjs/Particles/gpuParticleSystem";
  66603. export * from "babylonjs/Particles/IParticleSystem";
  66604. export * from "babylonjs/Particles/particle";
  66605. export * from "babylonjs/Particles/particleHelper";
  66606. export * from "babylonjs/Particles/particleSystem";
  66607. export * from "babylonjs/Particles/particleSystemComponent";
  66608. export * from "babylonjs/Particles/particleSystemSet";
  66609. export * from "babylonjs/Particles/solidParticle";
  66610. export * from "babylonjs/Particles/solidParticleSystem";
  66611. export * from "babylonjs/Particles/cloudPoint";
  66612. export * from "babylonjs/Particles/pointsCloudSystem";
  66613. export * from "babylonjs/Particles/subEmitter";
  66614. }
  66615. declare module "babylonjs/Physics/physicsEngineComponent" {
  66616. import { Nullable } from "babylonjs/types";
  66617. import { Observable, Observer } from "babylonjs/Misc/observable";
  66618. import { Vector3 } from "babylonjs/Maths/math.vector";
  66619. import { Mesh } from "babylonjs/Meshes/mesh";
  66620. import { ISceneComponent } from "babylonjs/sceneComponent";
  66621. import { Scene } from "babylonjs/scene";
  66622. import { Node } from "babylonjs/node";
  66623. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66624. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66625. module "babylonjs/scene" {
  66626. interface Scene {
  66627. /** @hidden (Backing field) */
  66628. _physicsEngine: Nullable<IPhysicsEngine>;
  66629. /** @hidden */
  66630. _physicsTimeAccumulator: number;
  66631. /**
  66632. * Gets the current physics engine
  66633. * @returns a IPhysicsEngine or null if none attached
  66634. */
  66635. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66636. /**
  66637. * Enables physics to the current scene
  66638. * @param gravity defines the scene's gravity for the physics engine
  66639. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66640. * @return a boolean indicating if the physics engine was initialized
  66641. */
  66642. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66643. /**
  66644. * Disables and disposes the physics engine associated with the scene
  66645. */
  66646. disablePhysicsEngine(): void;
  66647. /**
  66648. * Gets a boolean indicating if there is an active physics engine
  66649. * @returns a boolean indicating if there is an active physics engine
  66650. */
  66651. isPhysicsEnabled(): boolean;
  66652. /**
  66653. * Deletes a physics compound impostor
  66654. * @param compound defines the compound to delete
  66655. */
  66656. deleteCompoundImpostor(compound: any): void;
  66657. /**
  66658. * An event triggered when physic simulation is about to be run
  66659. */
  66660. onBeforePhysicsObservable: Observable<Scene>;
  66661. /**
  66662. * An event triggered when physic simulation has been done
  66663. */
  66664. onAfterPhysicsObservable: Observable<Scene>;
  66665. }
  66666. }
  66667. module "babylonjs/Meshes/abstractMesh" {
  66668. interface AbstractMesh {
  66669. /** @hidden */
  66670. _physicsImpostor: Nullable<PhysicsImpostor>;
  66671. /**
  66672. * Gets or sets impostor used for physic simulation
  66673. * @see http://doc.babylonjs.com/features/physics_engine
  66674. */
  66675. physicsImpostor: Nullable<PhysicsImpostor>;
  66676. /**
  66677. * Gets the current physics impostor
  66678. * @see http://doc.babylonjs.com/features/physics_engine
  66679. * @returns a physics impostor or null
  66680. */
  66681. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66682. /** Apply a physic impulse to the mesh
  66683. * @param force defines the force to apply
  66684. * @param contactPoint defines where to apply the force
  66685. * @returns the current mesh
  66686. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66687. */
  66688. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66689. /**
  66690. * Creates a physic joint between two meshes
  66691. * @param otherMesh defines the other mesh to use
  66692. * @param pivot1 defines the pivot to use on this mesh
  66693. * @param pivot2 defines the pivot to use on the other mesh
  66694. * @param options defines additional options (can be plugin dependent)
  66695. * @returns the current mesh
  66696. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66697. */
  66698. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66699. /** @hidden */
  66700. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66701. }
  66702. }
  66703. /**
  66704. * Defines the physics engine scene component responsible to manage a physics engine
  66705. */
  66706. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66707. /**
  66708. * The component name helpful to identify the component in the list of scene components.
  66709. */
  66710. readonly name: string;
  66711. /**
  66712. * The scene the component belongs to.
  66713. */
  66714. scene: Scene;
  66715. /**
  66716. * Creates a new instance of the component for the given scene
  66717. * @param scene Defines the scene to register the component in
  66718. */
  66719. constructor(scene: Scene);
  66720. /**
  66721. * Registers the component in a given scene
  66722. */
  66723. register(): void;
  66724. /**
  66725. * Rebuilds the elements related to this component in case of
  66726. * context lost for instance.
  66727. */
  66728. rebuild(): void;
  66729. /**
  66730. * Disposes the component and the associated ressources
  66731. */
  66732. dispose(): void;
  66733. }
  66734. }
  66735. declare module "babylonjs/Physics/physicsHelper" {
  66736. import { Nullable } from "babylonjs/types";
  66737. import { Vector3 } from "babylonjs/Maths/math.vector";
  66738. import { Mesh } from "babylonjs/Meshes/mesh";
  66739. import { Scene } from "babylonjs/scene";
  66740. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66741. /**
  66742. * A helper for physics simulations
  66743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66744. */
  66745. export class PhysicsHelper {
  66746. private _scene;
  66747. private _physicsEngine;
  66748. /**
  66749. * Initializes the Physics helper
  66750. * @param scene Babylon.js scene
  66751. */
  66752. constructor(scene: Scene);
  66753. /**
  66754. * Applies a radial explosion impulse
  66755. * @param origin the origin of the explosion
  66756. * @param radiusOrEventOptions the radius or the options of radial explosion
  66757. * @param strength the explosion strength
  66758. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66759. * @returns A physics radial explosion event, or null
  66760. */
  66761. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66762. /**
  66763. * Applies a radial explosion force
  66764. * @param origin the origin of the explosion
  66765. * @param radiusOrEventOptions the radius or the options of radial explosion
  66766. * @param strength the explosion strength
  66767. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66768. * @returns A physics radial explosion event, or null
  66769. */
  66770. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66771. /**
  66772. * Creates a gravitational field
  66773. * @param origin the origin of the explosion
  66774. * @param radiusOrEventOptions the radius or the options of radial explosion
  66775. * @param strength the explosion strength
  66776. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66777. * @returns A physics gravitational field event, or null
  66778. */
  66779. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66780. /**
  66781. * Creates a physics updraft event
  66782. * @param origin the origin of the updraft
  66783. * @param radiusOrEventOptions the radius or the options of the updraft
  66784. * @param strength the strength of the updraft
  66785. * @param height the height of the updraft
  66786. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66787. * @returns A physics updraft event, or null
  66788. */
  66789. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66790. /**
  66791. * Creates a physics vortex event
  66792. * @param origin the of the vortex
  66793. * @param radiusOrEventOptions the radius or the options of the vortex
  66794. * @param strength the strength of the vortex
  66795. * @param height the height of the vortex
  66796. * @returns a Physics vortex event, or null
  66797. * A physics vortex event or null
  66798. */
  66799. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66800. }
  66801. /**
  66802. * Represents a physics radial explosion event
  66803. */
  66804. class PhysicsRadialExplosionEvent {
  66805. private _scene;
  66806. private _options;
  66807. private _sphere;
  66808. private _dataFetched;
  66809. /**
  66810. * Initializes a radial explosioin event
  66811. * @param _scene BabylonJS scene
  66812. * @param _options The options for the vortex event
  66813. */
  66814. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66815. /**
  66816. * Returns the data related to the radial explosion event (sphere).
  66817. * @returns The radial explosion event data
  66818. */
  66819. getData(): PhysicsRadialExplosionEventData;
  66820. /**
  66821. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66822. * @param impostor A physics imposter
  66823. * @param origin the origin of the explosion
  66824. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66825. */
  66826. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66827. /**
  66828. * Triggers affecterd impostors callbacks
  66829. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66830. */
  66831. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66832. /**
  66833. * Disposes the sphere.
  66834. * @param force Specifies if the sphere should be disposed by force
  66835. */
  66836. dispose(force?: boolean): void;
  66837. /*** Helpers ***/
  66838. private _prepareSphere;
  66839. private _intersectsWithSphere;
  66840. }
  66841. /**
  66842. * Represents a gravitational field event
  66843. */
  66844. class PhysicsGravitationalFieldEvent {
  66845. private _physicsHelper;
  66846. private _scene;
  66847. private _origin;
  66848. private _options;
  66849. private _tickCallback;
  66850. private _sphere;
  66851. private _dataFetched;
  66852. /**
  66853. * Initializes the physics gravitational field event
  66854. * @param _physicsHelper A physics helper
  66855. * @param _scene BabylonJS scene
  66856. * @param _origin The origin position of the gravitational field event
  66857. * @param _options The options for the vortex event
  66858. */
  66859. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66860. /**
  66861. * Returns the data related to the gravitational field event (sphere).
  66862. * @returns A gravitational field event
  66863. */
  66864. getData(): PhysicsGravitationalFieldEventData;
  66865. /**
  66866. * Enables the gravitational field.
  66867. */
  66868. enable(): void;
  66869. /**
  66870. * Disables the gravitational field.
  66871. */
  66872. disable(): void;
  66873. /**
  66874. * Disposes the sphere.
  66875. * @param force The force to dispose from the gravitational field event
  66876. */
  66877. dispose(force?: boolean): void;
  66878. private _tick;
  66879. }
  66880. /**
  66881. * Represents a physics updraft event
  66882. */
  66883. class PhysicsUpdraftEvent {
  66884. private _scene;
  66885. private _origin;
  66886. private _options;
  66887. private _physicsEngine;
  66888. private _originTop;
  66889. private _originDirection;
  66890. private _tickCallback;
  66891. private _cylinder;
  66892. private _cylinderPosition;
  66893. private _dataFetched;
  66894. /**
  66895. * Initializes the physics updraft event
  66896. * @param _scene BabylonJS scene
  66897. * @param _origin The origin position of the updraft
  66898. * @param _options The options for the updraft event
  66899. */
  66900. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66901. /**
  66902. * Returns the data related to the updraft event (cylinder).
  66903. * @returns A physics updraft event
  66904. */
  66905. getData(): PhysicsUpdraftEventData;
  66906. /**
  66907. * Enables the updraft.
  66908. */
  66909. enable(): void;
  66910. /**
  66911. * Disables the updraft.
  66912. */
  66913. disable(): void;
  66914. /**
  66915. * Disposes the cylinder.
  66916. * @param force Specifies if the updraft should be disposed by force
  66917. */
  66918. dispose(force?: boolean): void;
  66919. private getImpostorHitData;
  66920. private _tick;
  66921. /*** Helpers ***/
  66922. private _prepareCylinder;
  66923. private _intersectsWithCylinder;
  66924. }
  66925. /**
  66926. * Represents a physics vortex event
  66927. */
  66928. class PhysicsVortexEvent {
  66929. private _scene;
  66930. private _origin;
  66931. private _options;
  66932. private _physicsEngine;
  66933. private _originTop;
  66934. private _tickCallback;
  66935. private _cylinder;
  66936. private _cylinderPosition;
  66937. private _dataFetched;
  66938. /**
  66939. * Initializes the physics vortex event
  66940. * @param _scene The BabylonJS scene
  66941. * @param _origin The origin position of the vortex
  66942. * @param _options The options for the vortex event
  66943. */
  66944. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66945. /**
  66946. * Returns the data related to the vortex event (cylinder).
  66947. * @returns The physics vortex event data
  66948. */
  66949. getData(): PhysicsVortexEventData;
  66950. /**
  66951. * Enables the vortex.
  66952. */
  66953. enable(): void;
  66954. /**
  66955. * Disables the cortex.
  66956. */
  66957. disable(): void;
  66958. /**
  66959. * Disposes the sphere.
  66960. * @param force
  66961. */
  66962. dispose(force?: boolean): void;
  66963. private getImpostorHitData;
  66964. private _tick;
  66965. /*** Helpers ***/
  66966. private _prepareCylinder;
  66967. private _intersectsWithCylinder;
  66968. }
  66969. /**
  66970. * Options fot the radial explosion event
  66971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66972. */
  66973. export class PhysicsRadialExplosionEventOptions {
  66974. /**
  66975. * The radius of the sphere for the radial explosion.
  66976. */
  66977. radius: number;
  66978. /**
  66979. * The strenth of the explosion.
  66980. */
  66981. strength: number;
  66982. /**
  66983. * The strenght of the force in correspondence to the distance of the affected object
  66984. */
  66985. falloff: PhysicsRadialImpulseFalloff;
  66986. /**
  66987. * Sphere options for the radial explosion.
  66988. */
  66989. sphere: {
  66990. segments: number;
  66991. diameter: number;
  66992. };
  66993. /**
  66994. * Sphere options for the radial explosion.
  66995. */
  66996. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66997. }
  66998. /**
  66999. * Options fot the updraft event
  67000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67001. */
  67002. export class PhysicsUpdraftEventOptions {
  67003. /**
  67004. * The radius of the cylinder for the vortex
  67005. */
  67006. radius: number;
  67007. /**
  67008. * The strenth of the updraft.
  67009. */
  67010. strength: number;
  67011. /**
  67012. * The height of the cylinder for the updraft.
  67013. */
  67014. height: number;
  67015. /**
  67016. * The mode for the the updraft.
  67017. */
  67018. updraftMode: PhysicsUpdraftMode;
  67019. }
  67020. /**
  67021. * Options fot the vortex event
  67022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67023. */
  67024. export class PhysicsVortexEventOptions {
  67025. /**
  67026. * The radius of the cylinder for the vortex
  67027. */
  67028. radius: number;
  67029. /**
  67030. * The strenth of the vortex.
  67031. */
  67032. strength: number;
  67033. /**
  67034. * The height of the cylinder for the vortex.
  67035. */
  67036. height: number;
  67037. /**
  67038. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67039. */
  67040. centripetalForceThreshold: number;
  67041. /**
  67042. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67043. */
  67044. centripetalForceMultiplier: number;
  67045. /**
  67046. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67047. */
  67048. centrifugalForceMultiplier: number;
  67049. /**
  67050. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67051. */
  67052. updraftForceMultiplier: number;
  67053. }
  67054. /**
  67055. * The strenght of the force in correspondence to the distance of the affected object
  67056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67057. */
  67058. export enum PhysicsRadialImpulseFalloff {
  67059. /** Defines that impulse is constant in strength across it's whole radius */
  67060. Constant = 0,
  67061. /** Defines that impulse gets weaker if it's further from the origin */
  67062. Linear = 1
  67063. }
  67064. /**
  67065. * The strength of the force in correspondence to the distance of the affected object
  67066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67067. */
  67068. export enum PhysicsUpdraftMode {
  67069. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67070. Center = 0,
  67071. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67072. Perpendicular = 1
  67073. }
  67074. /**
  67075. * Interface for a physics hit data
  67076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67077. */
  67078. export interface PhysicsHitData {
  67079. /**
  67080. * The force applied at the contact point
  67081. */
  67082. force: Vector3;
  67083. /**
  67084. * The contact point
  67085. */
  67086. contactPoint: Vector3;
  67087. /**
  67088. * The distance from the origin to the contact point
  67089. */
  67090. distanceFromOrigin: number;
  67091. }
  67092. /**
  67093. * Interface for radial explosion event data
  67094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67095. */
  67096. export interface PhysicsRadialExplosionEventData {
  67097. /**
  67098. * A sphere used for the radial explosion event
  67099. */
  67100. sphere: Mesh;
  67101. }
  67102. /**
  67103. * Interface for gravitational field event data
  67104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67105. */
  67106. export interface PhysicsGravitationalFieldEventData {
  67107. /**
  67108. * A sphere mesh used for the gravitational field event
  67109. */
  67110. sphere: Mesh;
  67111. }
  67112. /**
  67113. * Interface for updraft event data
  67114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67115. */
  67116. export interface PhysicsUpdraftEventData {
  67117. /**
  67118. * A cylinder used for the updraft event
  67119. */
  67120. cylinder: Mesh;
  67121. }
  67122. /**
  67123. * Interface for vortex event data
  67124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67125. */
  67126. export interface PhysicsVortexEventData {
  67127. /**
  67128. * A cylinder used for the vortex event
  67129. */
  67130. cylinder: Mesh;
  67131. }
  67132. /**
  67133. * Interface for an affected physics impostor
  67134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67135. */
  67136. export interface PhysicsAffectedImpostorWithData {
  67137. /**
  67138. * The impostor affected by the effect
  67139. */
  67140. impostor: PhysicsImpostor;
  67141. /**
  67142. * The data about the hit/horce from the explosion
  67143. */
  67144. hitData: PhysicsHitData;
  67145. }
  67146. }
  67147. declare module "babylonjs/Physics/Plugins/index" {
  67148. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67149. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67150. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67151. }
  67152. declare module "babylonjs/Physics/index" {
  67153. export * from "babylonjs/Physics/IPhysicsEngine";
  67154. export * from "babylonjs/Physics/physicsEngine";
  67155. export * from "babylonjs/Physics/physicsEngineComponent";
  67156. export * from "babylonjs/Physics/physicsHelper";
  67157. export * from "babylonjs/Physics/physicsImpostor";
  67158. export * from "babylonjs/Physics/physicsJoint";
  67159. export * from "babylonjs/Physics/Plugins/index";
  67160. }
  67161. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67162. /** @hidden */
  67163. export var blackAndWhitePixelShader: {
  67164. name: string;
  67165. shader: string;
  67166. };
  67167. }
  67168. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67170. import { Camera } from "babylonjs/Cameras/camera";
  67171. import { Engine } from "babylonjs/Engines/engine";
  67172. import "babylonjs/Shaders/blackAndWhite.fragment";
  67173. /**
  67174. * Post process used to render in black and white
  67175. */
  67176. export class BlackAndWhitePostProcess extends PostProcess {
  67177. /**
  67178. * Linear about to convert he result to black and white (default: 1)
  67179. */
  67180. degree: number;
  67181. /**
  67182. * Creates a black and white post process
  67183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67184. * @param name The name of the effect.
  67185. * @param options The required width/height ratio to downsize to before computing the render pass.
  67186. * @param camera The camera to apply the render pass to.
  67187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67188. * @param engine The engine which the post process will be applied. (default: current engine)
  67189. * @param reusable If the post process can be reused on the same frame. (default: false)
  67190. */
  67191. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67192. }
  67193. }
  67194. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67195. import { Nullable } from "babylonjs/types";
  67196. import { Camera } from "babylonjs/Cameras/camera";
  67197. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67198. import { Engine } from "babylonjs/Engines/engine";
  67199. /**
  67200. * This represents a set of one or more post processes in Babylon.
  67201. * A post process can be used to apply a shader to a texture after it is rendered.
  67202. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67203. */
  67204. export class PostProcessRenderEffect {
  67205. private _postProcesses;
  67206. private _getPostProcesses;
  67207. private _singleInstance;
  67208. private _cameras;
  67209. private _indicesForCamera;
  67210. /**
  67211. * Name of the effect
  67212. * @hidden
  67213. */
  67214. _name: string;
  67215. /**
  67216. * Instantiates a post process render effect.
  67217. * A post process can be used to apply a shader to a texture after it is rendered.
  67218. * @param engine The engine the effect is tied to
  67219. * @param name The name of the effect
  67220. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67221. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67222. */
  67223. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67224. /**
  67225. * Checks if all the post processes in the effect are supported.
  67226. */
  67227. get isSupported(): boolean;
  67228. /**
  67229. * Updates the current state of the effect
  67230. * @hidden
  67231. */
  67232. _update(): void;
  67233. /**
  67234. * Attaches the effect on cameras
  67235. * @param cameras The camera to attach to.
  67236. * @hidden
  67237. */
  67238. _attachCameras(cameras: Camera): void;
  67239. /**
  67240. * Attaches the effect on cameras
  67241. * @param cameras The camera to attach to.
  67242. * @hidden
  67243. */
  67244. _attachCameras(cameras: Camera[]): void;
  67245. /**
  67246. * Detaches the effect on cameras
  67247. * @param cameras The camera to detatch from.
  67248. * @hidden
  67249. */
  67250. _detachCameras(cameras: Camera): void;
  67251. /**
  67252. * Detatches the effect on cameras
  67253. * @param cameras The camera to detatch from.
  67254. * @hidden
  67255. */
  67256. _detachCameras(cameras: Camera[]): void;
  67257. /**
  67258. * Enables the effect on given cameras
  67259. * @param cameras The camera to enable.
  67260. * @hidden
  67261. */
  67262. _enable(cameras: Camera): void;
  67263. /**
  67264. * Enables the effect on given cameras
  67265. * @param cameras The camera to enable.
  67266. * @hidden
  67267. */
  67268. _enable(cameras: Nullable<Camera[]>): void;
  67269. /**
  67270. * Disables the effect on the given cameras
  67271. * @param cameras The camera to disable.
  67272. * @hidden
  67273. */
  67274. _disable(cameras: Camera): void;
  67275. /**
  67276. * Disables the effect on the given cameras
  67277. * @param cameras The camera to disable.
  67278. * @hidden
  67279. */
  67280. _disable(cameras: Nullable<Camera[]>): void;
  67281. /**
  67282. * Gets a list of the post processes contained in the effect.
  67283. * @param camera The camera to get the post processes on.
  67284. * @returns The list of the post processes in the effect.
  67285. */
  67286. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67287. }
  67288. }
  67289. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67290. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67291. /** @hidden */
  67292. export var extractHighlightsPixelShader: {
  67293. name: string;
  67294. shader: string;
  67295. };
  67296. }
  67297. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67298. import { Nullable } from "babylonjs/types";
  67299. import { Camera } from "babylonjs/Cameras/camera";
  67300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67301. import { Engine } from "babylonjs/Engines/engine";
  67302. import "babylonjs/Shaders/extractHighlights.fragment";
  67303. /**
  67304. * 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.
  67305. */
  67306. export class ExtractHighlightsPostProcess extends PostProcess {
  67307. /**
  67308. * The luminance threshold, pixels below this value will be set to black.
  67309. */
  67310. threshold: number;
  67311. /** @hidden */
  67312. _exposure: number;
  67313. /**
  67314. * Post process which has the input texture to be used when performing highlight extraction
  67315. * @hidden
  67316. */
  67317. _inputPostProcess: Nullable<PostProcess>;
  67318. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67319. }
  67320. }
  67321. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67322. /** @hidden */
  67323. export var bloomMergePixelShader: {
  67324. name: string;
  67325. shader: string;
  67326. };
  67327. }
  67328. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67329. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67330. import { Nullable } from "babylonjs/types";
  67331. import { Engine } from "babylonjs/Engines/engine";
  67332. import { Camera } from "babylonjs/Cameras/camera";
  67333. import "babylonjs/Shaders/bloomMerge.fragment";
  67334. /**
  67335. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67336. */
  67337. export class BloomMergePostProcess extends PostProcess {
  67338. /** Weight of the bloom to be added to the original input. */
  67339. weight: number;
  67340. /**
  67341. * Creates a new instance of @see BloomMergePostProcess
  67342. * @param name The name of the effect.
  67343. * @param originalFromInput Post process which's input will be used for the merge.
  67344. * @param blurred Blurred highlights post process which's output will be used.
  67345. * @param weight Weight of the bloom to be added to the original input.
  67346. * @param options The required width/height ratio to downsize to before computing the render pass.
  67347. * @param camera The camera to apply the render pass to.
  67348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67349. * @param engine The engine which the post process will be applied. (default: current engine)
  67350. * @param reusable If the post process can be reused on the same frame. (default: false)
  67351. * @param textureType Type of textures used when performing the post process. (default: 0)
  67352. * @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)
  67353. */
  67354. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67355. /** Weight of the bloom to be added to the original input. */
  67356. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67357. }
  67358. }
  67359. declare module "babylonjs/PostProcesses/bloomEffect" {
  67360. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67361. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67362. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67363. import { Camera } from "babylonjs/Cameras/camera";
  67364. import { Scene } from "babylonjs/scene";
  67365. /**
  67366. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67367. */
  67368. export class BloomEffect extends PostProcessRenderEffect {
  67369. private bloomScale;
  67370. /**
  67371. * @hidden Internal
  67372. */
  67373. _effects: Array<PostProcess>;
  67374. /**
  67375. * @hidden Internal
  67376. */
  67377. _downscale: ExtractHighlightsPostProcess;
  67378. private _blurX;
  67379. private _blurY;
  67380. private _merge;
  67381. /**
  67382. * The luminance threshold to find bright areas of the image to bloom.
  67383. */
  67384. get threshold(): number;
  67385. set threshold(value: number);
  67386. /**
  67387. * The strength of the bloom.
  67388. */
  67389. get weight(): number;
  67390. set weight(value: number);
  67391. /**
  67392. * Specifies the size of the bloom blur kernel, relative to the final output size
  67393. */
  67394. get kernel(): number;
  67395. set kernel(value: number);
  67396. /**
  67397. * Creates a new instance of @see BloomEffect
  67398. * @param scene The scene the effect belongs to.
  67399. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67400. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67401. * @param bloomWeight The the strength of bloom.
  67402. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67403. * @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)
  67404. */
  67405. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67406. /**
  67407. * Disposes each of the internal effects for a given camera.
  67408. * @param camera The camera to dispose the effect on.
  67409. */
  67410. disposeEffects(camera: Camera): void;
  67411. /**
  67412. * @hidden Internal
  67413. */
  67414. _updateEffects(): void;
  67415. /**
  67416. * Internal
  67417. * @returns if all the contained post processes are ready.
  67418. * @hidden
  67419. */
  67420. _isReady(): boolean;
  67421. }
  67422. }
  67423. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67424. /** @hidden */
  67425. export var chromaticAberrationPixelShader: {
  67426. name: string;
  67427. shader: string;
  67428. };
  67429. }
  67430. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67431. import { Vector2 } from "babylonjs/Maths/math.vector";
  67432. import { Nullable } from "babylonjs/types";
  67433. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67434. import { Camera } from "babylonjs/Cameras/camera";
  67435. import { Engine } from "babylonjs/Engines/engine";
  67436. import "babylonjs/Shaders/chromaticAberration.fragment";
  67437. /**
  67438. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67439. */
  67440. export class ChromaticAberrationPostProcess extends PostProcess {
  67441. /**
  67442. * The amount of seperation of rgb channels (default: 30)
  67443. */
  67444. aberrationAmount: number;
  67445. /**
  67446. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67447. */
  67448. radialIntensity: number;
  67449. /**
  67450. * 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))
  67451. */
  67452. direction: Vector2;
  67453. /**
  67454. * 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))
  67455. */
  67456. centerPosition: Vector2;
  67457. /**
  67458. * Creates a new instance ChromaticAberrationPostProcess
  67459. * @param name The name of the effect.
  67460. * @param screenWidth The width of the screen to apply the effect on.
  67461. * @param screenHeight The height of the screen to apply the effect on.
  67462. * @param options The required width/height ratio to downsize to before computing the render pass.
  67463. * @param camera The camera to apply the render pass to.
  67464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67465. * @param engine The engine which the post process will be applied. (default: current engine)
  67466. * @param reusable If the post process can be reused on the same frame. (default: false)
  67467. * @param textureType Type of textures used when performing the post process. (default: 0)
  67468. * @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)
  67469. */
  67470. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67471. }
  67472. }
  67473. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67474. /** @hidden */
  67475. export var circleOfConfusionPixelShader: {
  67476. name: string;
  67477. shader: string;
  67478. };
  67479. }
  67480. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67481. import { Nullable } from "babylonjs/types";
  67482. import { Engine } from "babylonjs/Engines/engine";
  67483. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67484. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67485. import { Camera } from "babylonjs/Cameras/camera";
  67486. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67487. /**
  67488. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67489. */
  67490. export class CircleOfConfusionPostProcess extends PostProcess {
  67491. /**
  67492. * 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.
  67493. */
  67494. lensSize: number;
  67495. /**
  67496. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67497. */
  67498. fStop: number;
  67499. /**
  67500. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67501. */
  67502. focusDistance: number;
  67503. /**
  67504. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67505. */
  67506. focalLength: number;
  67507. private _depthTexture;
  67508. /**
  67509. * Creates a new instance CircleOfConfusionPostProcess
  67510. * @param name The name of the effect.
  67511. * @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.
  67512. * @param options The required width/height ratio to downsize to before computing the render pass.
  67513. * @param camera The camera to apply the render pass to.
  67514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67515. * @param engine The engine which the post process will be applied. (default: current engine)
  67516. * @param reusable If the post process can be reused on the same frame. (default: false)
  67517. * @param textureType Type of textures used when performing the post process. (default: 0)
  67518. * @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)
  67519. */
  67520. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67521. /**
  67522. * 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.
  67523. */
  67524. set depthTexture(value: RenderTargetTexture);
  67525. }
  67526. }
  67527. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67528. /** @hidden */
  67529. export var colorCorrectionPixelShader: {
  67530. name: string;
  67531. shader: string;
  67532. };
  67533. }
  67534. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67535. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67536. import { Engine } from "babylonjs/Engines/engine";
  67537. import { Camera } from "babylonjs/Cameras/camera";
  67538. import "babylonjs/Shaders/colorCorrection.fragment";
  67539. /**
  67540. *
  67541. * This post-process allows the modification of rendered colors by using
  67542. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67543. *
  67544. * The object needs to be provided an url to a texture containing the color
  67545. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67546. * Use an image editing software to tweak the LUT to match your needs.
  67547. *
  67548. * For an example of a color LUT, see here:
  67549. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67550. * For explanations on color grading, see here:
  67551. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67552. *
  67553. */
  67554. export class ColorCorrectionPostProcess extends PostProcess {
  67555. private _colorTableTexture;
  67556. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67557. }
  67558. }
  67559. declare module "babylonjs/Shaders/convolution.fragment" {
  67560. /** @hidden */
  67561. export var convolutionPixelShader: {
  67562. name: string;
  67563. shader: string;
  67564. };
  67565. }
  67566. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67568. import { Nullable } from "babylonjs/types";
  67569. import { Camera } from "babylonjs/Cameras/camera";
  67570. import { Engine } from "babylonjs/Engines/engine";
  67571. import "babylonjs/Shaders/convolution.fragment";
  67572. /**
  67573. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67574. * input texture to perform effects such as edge detection or sharpening
  67575. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67576. */
  67577. export class ConvolutionPostProcess extends PostProcess {
  67578. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67579. kernel: number[];
  67580. /**
  67581. * Creates a new instance ConvolutionPostProcess
  67582. * @param name The name of the effect.
  67583. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67584. * @param options The required width/height ratio to downsize to before computing the render pass.
  67585. * @param camera The camera to apply the render pass to.
  67586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67587. * @param engine The engine which the post process will be applied. (default: current engine)
  67588. * @param reusable If the post process can be reused on the same frame. (default: false)
  67589. * @param textureType Type of textures used when performing the post process. (default: 0)
  67590. */
  67591. constructor(name: string,
  67592. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67593. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67594. /**
  67595. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67596. */
  67597. static EdgeDetect0Kernel: number[];
  67598. /**
  67599. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67600. */
  67601. static EdgeDetect1Kernel: number[];
  67602. /**
  67603. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67604. */
  67605. static EdgeDetect2Kernel: number[];
  67606. /**
  67607. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67608. */
  67609. static SharpenKernel: number[];
  67610. /**
  67611. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67612. */
  67613. static EmbossKernel: number[];
  67614. /**
  67615. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67616. */
  67617. static GaussianKernel: number[];
  67618. }
  67619. }
  67620. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67621. import { Nullable } from "babylonjs/types";
  67622. import { Vector2 } from "babylonjs/Maths/math.vector";
  67623. import { Camera } from "babylonjs/Cameras/camera";
  67624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67625. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67626. import { Engine } from "babylonjs/Engines/engine";
  67627. import { Scene } from "babylonjs/scene";
  67628. /**
  67629. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67630. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67631. * based on samples that have a large difference in distance than the center pixel.
  67632. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67633. */
  67634. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67635. direction: Vector2;
  67636. /**
  67637. * Creates a new instance CircleOfConfusionPostProcess
  67638. * @param name The name of the effect.
  67639. * @param scene The scene the effect belongs to.
  67640. * @param direction The direction the blur should be applied.
  67641. * @param kernel The size of the kernel used to blur.
  67642. * @param options The required width/height ratio to downsize to before computing the render pass.
  67643. * @param camera The camera to apply the render pass to.
  67644. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67645. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67647. * @param engine The engine which the post process will be applied. (default: current engine)
  67648. * @param reusable If the post process can be reused on the same frame. (default: false)
  67649. * @param textureType Type of textures used when performing the post process. (default: 0)
  67650. * @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)
  67651. */
  67652. 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);
  67653. }
  67654. }
  67655. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67656. /** @hidden */
  67657. export var depthOfFieldMergePixelShader: {
  67658. name: string;
  67659. shader: string;
  67660. };
  67661. }
  67662. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67663. import { Nullable } from "babylonjs/types";
  67664. import { Camera } from "babylonjs/Cameras/camera";
  67665. import { Effect } from "babylonjs/Materials/effect";
  67666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67667. import { Engine } from "babylonjs/Engines/engine";
  67668. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67669. /**
  67670. * Options to be set when merging outputs from the default pipeline.
  67671. */
  67672. export class DepthOfFieldMergePostProcessOptions {
  67673. /**
  67674. * The original image to merge on top of
  67675. */
  67676. originalFromInput: PostProcess;
  67677. /**
  67678. * Parameters to perform the merge of the depth of field effect
  67679. */
  67680. depthOfField?: {
  67681. circleOfConfusion: PostProcess;
  67682. blurSteps: Array<PostProcess>;
  67683. };
  67684. /**
  67685. * Parameters to perform the merge of bloom effect
  67686. */
  67687. bloom?: {
  67688. blurred: PostProcess;
  67689. weight: number;
  67690. };
  67691. }
  67692. /**
  67693. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67694. */
  67695. export class DepthOfFieldMergePostProcess extends PostProcess {
  67696. private blurSteps;
  67697. /**
  67698. * Creates a new instance of DepthOfFieldMergePostProcess
  67699. * @param name The name of the effect.
  67700. * @param originalFromInput Post process which's input will be used for the merge.
  67701. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67702. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67703. * @param options The required width/height ratio to downsize to before computing the render pass.
  67704. * @param camera The camera to apply the render pass to.
  67705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67706. * @param engine The engine which the post process will be applied. (default: current engine)
  67707. * @param reusable If the post process can be reused on the same frame. (default: false)
  67708. * @param textureType Type of textures used when performing the post process. (default: 0)
  67709. * @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)
  67710. */
  67711. 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);
  67712. /**
  67713. * Updates the effect with the current post process compile time values and recompiles the shader.
  67714. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67715. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67716. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67717. * @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
  67718. * @param onCompiled Called when the shader has been compiled.
  67719. * @param onError Called if there is an error when compiling a shader.
  67720. */
  67721. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67722. }
  67723. }
  67724. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67725. import { Nullable } from "babylonjs/types";
  67726. import { Camera } from "babylonjs/Cameras/camera";
  67727. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67728. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67729. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67730. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67731. import { Scene } from "babylonjs/scene";
  67732. /**
  67733. * Specifies the level of max blur that should be applied when using the depth of field effect
  67734. */
  67735. export enum DepthOfFieldEffectBlurLevel {
  67736. /**
  67737. * Subtle blur
  67738. */
  67739. Low = 0,
  67740. /**
  67741. * Medium blur
  67742. */
  67743. Medium = 1,
  67744. /**
  67745. * Large blur
  67746. */
  67747. High = 2
  67748. }
  67749. /**
  67750. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67751. */
  67752. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67753. private _circleOfConfusion;
  67754. /**
  67755. * @hidden Internal, blurs from high to low
  67756. */
  67757. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67758. private _depthOfFieldBlurY;
  67759. private _dofMerge;
  67760. /**
  67761. * @hidden Internal post processes in depth of field effect
  67762. */
  67763. _effects: Array<PostProcess>;
  67764. /**
  67765. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67766. */
  67767. set focalLength(value: number);
  67768. get focalLength(): number;
  67769. /**
  67770. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67771. */
  67772. set fStop(value: number);
  67773. get fStop(): number;
  67774. /**
  67775. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67776. */
  67777. set focusDistance(value: number);
  67778. get focusDistance(): number;
  67779. /**
  67780. * 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.
  67781. */
  67782. set lensSize(value: number);
  67783. get lensSize(): number;
  67784. /**
  67785. * Creates a new instance DepthOfFieldEffect
  67786. * @param scene The scene the effect belongs to.
  67787. * @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.
  67788. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67789. * @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)
  67790. */
  67791. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67792. /**
  67793. * Get the current class name of the current effet
  67794. * @returns "DepthOfFieldEffect"
  67795. */
  67796. getClassName(): string;
  67797. /**
  67798. * 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.
  67799. */
  67800. set depthTexture(value: RenderTargetTexture);
  67801. /**
  67802. * Disposes each of the internal effects for a given camera.
  67803. * @param camera The camera to dispose the effect on.
  67804. */
  67805. disposeEffects(camera: Camera): void;
  67806. /**
  67807. * @hidden Internal
  67808. */
  67809. _updateEffects(): void;
  67810. /**
  67811. * Internal
  67812. * @returns if all the contained post processes are ready.
  67813. * @hidden
  67814. */
  67815. _isReady(): boolean;
  67816. }
  67817. }
  67818. declare module "babylonjs/Shaders/displayPass.fragment" {
  67819. /** @hidden */
  67820. export var displayPassPixelShader: {
  67821. name: string;
  67822. shader: string;
  67823. };
  67824. }
  67825. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67826. import { Nullable } from "babylonjs/types";
  67827. import { Camera } from "babylonjs/Cameras/camera";
  67828. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67829. import { Engine } from "babylonjs/Engines/engine";
  67830. import "babylonjs/Shaders/displayPass.fragment";
  67831. /**
  67832. * DisplayPassPostProcess which produces an output the same as it's input
  67833. */
  67834. export class DisplayPassPostProcess extends PostProcess {
  67835. /**
  67836. * Creates the DisplayPassPostProcess
  67837. * @param name The name of the effect.
  67838. * @param options The required width/height ratio to downsize to before computing the render pass.
  67839. * @param camera The camera to apply the render pass to.
  67840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67841. * @param engine The engine which the post process will be applied. (default: current engine)
  67842. * @param reusable If the post process can be reused on the same frame. (default: false)
  67843. */
  67844. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67845. }
  67846. }
  67847. declare module "babylonjs/Shaders/filter.fragment" {
  67848. /** @hidden */
  67849. export var filterPixelShader: {
  67850. name: string;
  67851. shader: string;
  67852. };
  67853. }
  67854. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67855. import { Nullable } from "babylonjs/types";
  67856. import { Matrix } from "babylonjs/Maths/math.vector";
  67857. import { Camera } from "babylonjs/Cameras/camera";
  67858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67859. import { Engine } from "babylonjs/Engines/engine";
  67860. import "babylonjs/Shaders/filter.fragment";
  67861. /**
  67862. * Applies a kernel filter to the image
  67863. */
  67864. export class FilterPostProcess extends PostProcess {
  67865. /** The matrix to be applied to the image */
  67866. kernelMatrix: Matrix;
  67867. /**
  67868. *
  67869. * @param name The name of the effect.
  67870. * @param kernelMatrix The matrix to be applied to the image
  67871. * @param options The required width/height ratio to downsize to before computing the render pass.
  67872. * @param camera The camera to apply the render pass to.
  67873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67874. * @param engine The engine which the post process will be applied. (default: current engine)
  67875. * @param reusable If the post process can be reused on the same frame. (default: false)
  67876. */
  67877. constructor(name: string,
  67878. /** The matrix to be applied to the image */
  67879. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67880. }
  67881. }
  67882. declare module "babylonjs/Shaders/fxaa.fragment" {
  67883. /** @hidden */
  67884. export var fxaaPixelShader: {
  67885. name: string;
  67886. shader: string;
  67887. };
  67888. }
  67889. declare module "babylonjs/Shaders/fxaa.vertex" {
  67890. /** @hidden */
  67891. export var fxaaVertexShader: {
  67892. name: string;
  67893. shader: string;
  67894. };
  67895. }
  67896. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67897. import { Nullable } from "babylonjs/types";
  67898. import { Camera } from "babylonjs/Cameras/camera";
  67899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67900. import { Engine } from "babylonjs/Engines/engine";
  67901. import "babylonjs/Shaders/fxaa.fragment";
  67902. import "babylonjs/Shaders/fxaa.vertex";
  67903. /**
  67904. * Fxaa post process
  67905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67906. */
  67907. export class FxaaPostProcess extends PostProcess {
  67908. /** @hidden */
  67909. texelWidth: number;
  67910. /** @hidden */
  67911. texelHeight: number;
  67912. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67913. private _getDefines;
  67914. }
  67915. }
  67916. declare module "babylonjs/Shaders/grain.fragment" {
  67917. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67918. /** @hidden */
  67919. export var grainPixelShader: {
  67920. name: string;
  67921. shader: string;
  67922. };
  67923. }
  67924. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67925. import { Nullable } from "babylonjs/types";
  67926. import { Camera } from "babylonjs/Cameras/camera";
  67927. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67928. import { Engine } from "babylonjs/Engines/engine";
  67929. import "babylonjs/Shaders/grain.fragment";
  67930. /**
  67931. * The GrainPostProcess adds noise to the image at mid luminance levels
  67932. */
  67933. export class GrainPostProcess extends PostProcess {
  67934. /**
  67935. * The intensity of the grain added (default: 30)
  67936. */
  67937. intensity: number;
  67938. /**
  67939. * If the grain should be randomized on every frame
  67940. */
  67941. animated: boolean;
  67942. /**
  67943. * Creates a new instance of @see GrainPostProcess
  67944. * @param name The name of the effect.
  67945. * @param options The required width/height ratio to downsize to before computing the render pass.
  67946. * @param camera The camera to apply the render pass to.
  67947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67948. * @param engine The engine which the post process will be applied. (default: current engine)
  67949. * @param reusable If the post process can be reused on the same frame. (default: false)
  67950. * @param textureType Type of textures used when performing the post process. (default: 0)
  67951. * @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)
  67952. */
  67953. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67954. }
  67955. }
  67956. declare module "babylonjs/Shaders/highlights.fragment" {
  67957. /** @hidden */
  67958. export var highlightsPixelShader: {
  67959. name: string;
  67960. shader: string;
  67961. };
  67962. }
  67963. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67964. import { Nullable } from "babylonjs/types";
  67965. import { Camera } from "babylonjs/Cameras/camera";
  67966. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67967. import { Engine } from "babylonjs/Engines/engine";
  67968. import "babylonjs/Shaders/highlights.fragment";
  67969. /**
  67970. * Extracts highlights from the image
  67971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67972. */
  67973. export class HighlightsPostProcess extends PostProcess {
  67974. /**
  67975. * Extracts highlights from the image
  67976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67977. * @param name The name of the effect.
  67978. * @param options The required width/height ratio to downsize to before computing the render pass.
  67979. * @param camera The camera to apply the render pass to.
  67980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67981. * @param engine The engine which the post process will be applied. (default: current engine)
  67982. * @param reusable If the post process can be reused on the same frame. (default: false)
  67983. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67984. */
  67985. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67986. }
  67987. }
  67988. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67989. /** @hidden */
  67990. export var mrtFragmentDeclaration: {
  67991. name: string;
  67992. shader: string;
  67993. };
  67994. }
  67995. declare module "babylonjs/Shaders/geometry.fragment" {
  67996. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67997. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67998. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67999. /** @hidden */
  68000. export var geometryPixelShader: {
  68001. name: string;
  68002. shader: string;
  68003. };
  68004. }
  68005. declare module "babylonjs/Shaders/geometry.vertex" {
  68006. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68009. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68010. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68013. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68014. /** @hidden */
  68015. export var geometryVertexShader: {
  68016. name: string;
  68017. shader: string;
  68018. };
  68019. }
  68020. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68021. import { Matrix } from "babylonjs/Maths/math.vector";
  68022. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68023. import { Mesh } from "babylonjs/Meshes/mesh";
  68024. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68025. import { Effect } from "babylonjs/Materials/effect";
  68026. import { Scene } from "babylonjs/scene";
  68027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68028. import "babylonjs/Shaders/geometry.fragment";
  68029. import "babylonjs/Shaders/geometry.vertex";
  68030. /** @hidden */
  68031. interface ISavedTransformationMatrix {
  68032. world: Matrix;
  68033. viewProjection: Matrix;
  68034. }
  68035. /**
  68036. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68037. */
  68038. export class GeometryBufferRenderer {
  68039. /**
  68040. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68041. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68042. */
  68043. static readonly POSITION_TEXTURE_TYPE: number;
  68044. /**
  68045. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68046. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68047. */
  68048. static readonly VELOCITY_TEXTURE_TYPE: number;
  68049. /**
  68050. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68051. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68052. */
  68053. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68054. /**
  68055. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68056. * in order to compute objects velocities when enableVelocity is set to "true"
  68057. * @hidden
  68058. */
  68059. _previousTransformationMatrices: {
  68060. [index: number]: ISavedTransformationMatrix;
  68061. };
  68062. /**
  68063. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68064. * in order to compute objects velocities when enableVelocity is set to "true"
  68065. * @hidden
  68066. */
  68067. _previousBonesTransformationMatrices: {
  68068. [index: number]: Float32Array;
  68069. };
  68070. /**
  68071. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68072. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68073. */
  68074. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68075. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68076. renderTransparentMeshes: boolean;
  68077. private _scene;
  68078. private _multiRenderTarget;
  68079. private _ratio;
  68080. private _enablePosition;
  68081. private _enableVelocity;
  68082. private _enableReflectivity;
  68083. private _positionIndex;
  68084. private _velocityIndex;
  68085. private _reflectivityIndex;
  68086. protected _effect: Effect;
  68087. protected _cachedDefines: string;
  68088. /**
  68089. * Set the render list (meshes to be rendered) used in the G buffer.
  68090. */
  68091. set renderList(meshes: Mesh[]);
  68092. /**
  68093. * Gets wether or not G buffer are supported by the running hardware.
  68094. * This requires draw buffer supports
  68095. */
  68096. get isSupported(): boolean;
  68097. /**
  68098. * Returns the index of the given texture type in the G-Buffer textures array
  68099. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68100. * @returns the index of the given texture type in the G-Buffer textures array
  68101. */
  68102. getTextureIndex(textureType: number): number;
  68103. /**
  68104. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68105. */
  68106. get enablePosition(): boolean;
  68107. /**
  68108. * Sets whether or not objects positions are enabled for the G buffer.
  68109. */
  68110. set enablePosition(enable: boolean);
  68111. /**
  68112. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68113. */
  68114. get enableVelocity(): boolean;
  68115. /**
  68116. * Sets wether or not objects velocities are enabled for the G buffer.
  68117. */
  68118. set enableVelocity(enable: boolean);
  68119. /**
  68120. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68121. */
  68122. get enableReflectivity(): boolean;
  68123. /**
  68124. * Sets wether or not objects roughness are enabled for the G buffer.
  68125. */
  68126. set enableReflectivity(enable: boolean);
  68127. /**
  68128. * Gets the scene associated with the buffer.
  68129. */
  68130. get scene(): Scene;
  68131. /**
  68132. * Gets the ratio used by the buffer during its creation.
  68133. * How big is the buffer related to the main canvas.
  68134. */
  68135. get ratio(): number;
  68136. /** @hidden */
  68137. static _SceneComponentInitialization: (scene: Scene) => void;
  68138. /**
  68139. * Creates a new G Buffer for the scene
  68140. * @param scene The scene the buffer belongs to
  68141. * @param ratio How big is the buffer related to the main canvas.
  68142. */
  68143. constructor(scene: Scene, ratio?: number);
  68144. /**
  68145. * Checks wether everything is ready to render a submesh to the G buffer.
  68146. * @param subMesh the submesh to check readiness for
  68147. * @param useInstances is the mesh drawn using instance or not
  68148. * @returns true if ready otherwise false
  68149. */
  68150. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68151. /**
  68152. * Gets the current underlying G Buffer.
  68153. * @returns the buffer
  68154. */
  68155. getGBuffer(): MultiRenderTarget;
  68156. /**
  68157. * Gets the number of samples used to render the buffer (anti aliasing).
  68158. */
  68159. get samples(): number;
  68160. /**
  68161. * Sets the number of samples used to render the buffer (anti aliasing).
  68162. */
  68163. set samples(value: number);
  68164. /**
  68165. * Disposes the renderer and frees up associated resources.
  68166. */
  68167. dispose(): void;
  68168. protected _createRenderTargets(): void;
  68169. private _copyBonesTransformationMatrices;
  68170. }
  68171. }
  68172. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68173. import { Nullable } from "babylonjs/types";
  68174. import { Scene } from "babylonjs/scene";
  68175. import { ISceneComponent } from "babylonjs/sceneComponent";
  68176. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68177. module "babylonjs/scene" {
  68178. interface Scene {
  68179. /** @hidden (Backing field) */
  68180. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68181. /**
  68182. * Gets or Sets the current geometry buffer associated to the scene.
  68183. */
  68184. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68185. /**
  68186. * Enables a GeometryBufferRender and associates it with the scene
  68187. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68188. * @returns the GeometryBufferRenderer
  68189. */
  68190. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68191. /**
  68192. * Disables the GeometryBufferRender associated with the scene
  68193. */
  68194. disableGeometryBufferRenderer(): void;
  68195. }
  68196. }
  68197. /**
  68198. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68199. * in several rendering techniques.
  68200. */
  68201. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68202. /**
  68203. * The component name helpful to identify the component in the list of scene components.
  68204. */
  68205. readonly name: string;
  68206. /**
  68207. * The scene the component belongs to.
  68208. */
  68209. scene: Scene;
  68210. /**
  68211. * Creates a new instance of the component for the given scene
  68212. * @param scene Defines the scene to register the component in
  68213. */
  68214. constructor(scene: Scene);
  68215. /**
  68216. * Registers the component in a given scene
  68217. */
  68218. register(): void;
  68219. /**
  68220. * Rebuilds the elements related to this component in case of
  68221. * context lost for instance.
  68222. */
  68223. rebuild(): void;
  68224. /**
  68225. * Disposes the component and the associated ressources
  68226. */
  68227. dispose(): void;
  68228. private _gatherRenderTargets;
  68229. }
  68230. }
  68231. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68232. /** @hidden */
  68233. export var motionBlurPixelShader: {
  68234. name: string;
  68235. shader: string;
  68236. };
  68237. }
  68238. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68239. import { Nullable } from "babylonjs/types";
  68240. import { Camera } from "babylonjs/Cameras/camera";
  68241. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68242. import { Scene } from "babylonjs/scene";
  68243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68244. import "babylonjs/Animations/animatable";
  68245. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68246. import "babylonjs/Shaders/motionBlur.fragment";
  68247. import { Engine } from "babylonjs/Engines/engine";
  68248. /**
  68249. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68250. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68251. * As an example, all you have to do is to create the post-process:
  68252. * var mb = new BABYLON.MotionBlurPostProcess(
  68253. * 'mb', // The name of the effect.
  68254. * scene, // The scene containing the objects to blur according to their velocity.
  68255. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68256. * camera // The camera to apply the render pass to.
  68257. * );
  68258. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68259. */
  68260. export class MotionBlurPostProcess extends PostProcess {
  68261. /**
  68262. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68263. */
  68264. motionStrength: number;
  68265. /**
  68266. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68267. */
  68268. get motionBlurSamples(): number;
  68269. /**
  68270. * Sets the number of iterations to be used for motion blur quality
  68271. */
  68272. set motionBlurSamples(samples: number);
  68273. private _motionBlurSamples;
  68274. private _geometryBufferRenderer;
  68275. /**
  68276. * Creates a new instance MotionBlurPostProcess
  68277. * @param name The name of the effect.
  68278. * @param scene The scene containing the objects to blur according to their velocity.
  68279. * @param options The required width/height ratio to downsize to before computing the render pass.
  68280. * @param camera The camera to apply the render pass to.
  68281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68282. * @param engine The engine which the post process will be applied. (default: current engine)
  68283. * @param reusable If the post process can be reused on the same frame. (default: false)
  68284. * @param textureType Type of textures used when performing the post process. (default: 0)
  68285. * @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)
  68286. */
  68287. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68288. /**
  68289. * Excludes the given skinned mesh from computing bones velocities.
  68290. * 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.
  68291. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68292. */
  68293. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68294. /**
  68295. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68296. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68297. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68298. */
  68299. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68300. /**
  68301. * Disposes the post process.
  68302. * @param camera The camera to dispose the post process on.
  68303. */
  68304. dispose(camera?: Camera): void;
  68305. }
  68306. }
  68307. declare module "babylonjs/Shaders/refraction.fragment" {
  68308. /** @hidden */
  68309. export var refractionPixelShader: {
  68310. name: string;
  68311. shader: string;
  68312. };
  68313. }
  68314. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68315. import { Color3 } from "babylonjs/Maths/math.color";
  68316. import { Camera } from "babylonjs/Cameras/camera";
  68317. import { Texture } from "babylonjs/Materials/Textures/texture";
  68318. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68319. import { Engine } from "babylonjs/Engines/engine";
  68320. import "babylonjs/Shaders/refraction.fragment";
  68321. /**
  68322. * Post process which applies a refractin texture
  68323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68324. */
  68325. export class RefractionPostProcess extends PostProcess {
  68326. /** the base color of the refraction (used to taint the rendering) */
  68327. color: Color3;
  68328. /** simulated refraction depth */
  68329. depth: number;
  68330. /** the coefficient of the base color (0 to remove base color tainting) */
  68331. colorLevel: number;
  68332. private _refTexture;
  68333. private _ownRefractionTexture;
  68334. /**
  68335. * Gets or sets the refraction texture
  68336. * Please note that you are responsible for disposing the texture if you set it manually
  68337. */
  68338. get refractionTexture(): Texture;
  68339. set refractionTexture(value: Texture);
  68340. /**
  68341. * Initializes the RefractionPostProcess
  68342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68343. * @param name The name of the effect.
  68344. * @param refractionTextureUrl Url of the refraction texture to use
  68345. * @param color the base color of the refraction (used to taint the rendering)
  68346. * @param depth simulated refraction depth
  68347. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68348. * @param camera The camera to apply the render pass to.
  68349. * @param options The required width/height ratio to downsize to before computing the render pass.
  68350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68351. * @param engine The engine which the post process will be applied. (default: current engine)
  68352. * @param reusable If the post process can be reused on the same frame. (default: false)
  68353. */
  68354. constructor(name: string, refractionTextureUrl: string,
  68355. /** the base color of the refraction (used to taint the rendering) */
  68356. color: Color3,
  68357. /** simulated refraction depth */
  68358. depth: number,
  68359. /** the coefficient of the base color (0 to remove base color tainting) */
  68360. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68361. /**
  68362. * Disposes of the post process
  68363. * @param camera Camera to dispose post process on
  68364. */
  68365. dispose(camera: Camera): void;
  68366. }
  68367. }
  68368. declare module "babylonjs/Shaders/sharpen.fragment" {
  68369. /** @hidden */
  68370. export var sharpenPixelShader: {
  68371. name: string;
  68372. shader: string;
  68373. };
  68374. }
  68375. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68376. import { Nullable } from "babylonjs/types";
  68377. import { Camera } from "babylonjs/Cameras/camera";
  68378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68379. import "babylonjs/Shaders/sharpen.fragment";
  68380. import { Engine } from "babylonjs/Engines/engine";
  68381. /**
  68382. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68383. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68384. */
  68385. export class SharpenPostProcess extends PostProcess {
  68386. /**
  68387. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68388. */
  68389. colorAmount: number;
  68390. /**
  68391. * How much sharpness should be applied (default: 0.3)
  68392. */
  68393. edgeAmount: number;
  68394. /**
  68395. * Creates a new instance ConvolutionPostProcess
  68396. * @param name The name of the effect.
  68397. * @param options The required width/height ratio to downsize to before computing the render pass.
  68398. * @param camera The camera to apply the render pass to.
  68399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68400. * @param engine The engine which the post process will be applied. (default: current engine)
  68401. * @param reusable If the post process can be reused on the same frame. (default: false)
  68402. * @param textureType Type of textures used when performing the post process. (default: 0)
  68403. * @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)
  68404. */
  68405. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68406. }
  68407. }
  68408. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68409. import { Nullable } from "babylonjs/types";
  68410. import { Camera } from "babylonjs/Cameras/camera";
  68411. import { Engine } from "babylonjs/Engines/engine";
  68412. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68413. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68414. /**
  68415. * PostProcessRenderPipeline
  68416. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68417. */
  68418. export class PostProcessRenderPipeline {
  68419. private engine;
  68420. private _renderEffects;
  68421. private _renderEffectsForIsolatedPass;
  68422. /**
  68423. * List of inspectable custom properties (used by the Inspector)
  68424. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68425. */
  68426. inspectableCustomProperties: IInspectable[];
  68427. /**
  68428. * @hidden
  68429. */
  68430. protected _cameras: Camera[];
  68431. /** @hidden */
  68432. _name: string;
  68433. /**
  68434. * Gets pipeline name
  68435. */
  68436. get name(): string;
  68437. /** Gets the list of attached cameras */
  68438. get cameras(): Camera[];
  68439. /**
  68440. * Initializes a PostProcessRenderPipeline
  68441. * @param engine engine to add the pipeline to
  68442. * @param name name of the pipeline
  68443. */
  68444. constructor(engine: Engine, name: string);
  68445. /**
  68446. * Gets the class name
  68447. * @returns "PostProcessRenderPipeline"
  68448. */
  68449. getClassName(): string;
  68450. /**
  68451. * If all the render effects in the pipeline are supported
  68452. */
  68453. get isSupported(): boolean;
  68454. /**
  68455. * Adds an effect to the pipeline
  68456. * @param renderEffect the effect to add
  68457. */
  68458. addEffect(renderEffect: PostProcessRenderEffect): void;
  68459. /** @hidden */
  68460. _rebuild(): void;
  68461. /** @hidden */
  68462. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68463. /** @hidden */
  68464. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68465. /** @hidden */
  68466. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68467. /** @hidden */
  68468. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68469. /** @hidden */
  68470. _attachCameras(cameras: Camera, unique: boolean): void;
  68471. /** @hidden */
  68472. _attachCameras(cameras: Camera[], unique: boolean): void;
  68473. /** @hidden */
  68474. _detachCameras(cameras: Camera): void;
  68475. /** @hidden */
  68476. _detachCameras(cameras: Nullable<Camera[]>): void;
  68477. /** @hidden */
  68478. _update(): void;
  68479. /** @hidden */
  68480. _reset(): void;
  68481. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68482. /**
  68483. * Disposes of the pipeline
  68484. */
  68485. dispose(): void;
  68486. }
  68487. }
  68488. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68489. import { Camera } from "babylonjs/Cameras/camera";
  68490. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68491. /**
  68492. * PostProcessRenderPipelineManager class
  68493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68494. */
  68495. export class PostProcessRenderPipelineManager {
  68496. private _renderPipelines;
  68497. /**
  68498. * Initializes a PostProcessRenderPipelineManager
  68499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68500. */
  68501. constructor();
  68502. /**
  68503. * Gets the list of supported render pipelines
  68504. */
  68505. get supportedPipelines(): PostProcessRenderPipeline[];
  68506. /**
  68507. * Adds a pipeline to the manager
  68508. * @param renderPipeline The pipeline to add
  68509. */
  68510. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68511. /**
  68512. * Attaches a camera to the pipeline
  68513. * @param renderPipelineName The name of the pipeline to attach to
  68514. * @param cameras the camera to attach
  68515. * @param unique if the camera can be attached multiple times to the pipeline
  68516. */
  68517. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68518. /**
  68519. * Detaches a camera from the pipeline
  68520. * @param renderPipelineName The name of the pipeline to detach from
  68521. * @param cameras the camera to detach
  68522. */
  68523. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68524. /**
  68525. * Enables an effect by name on a pipeline
  68526. * @param renderPipelineName the name of the pipeline to enable the effect in
  68527. * @param renderEffectName the name of the effect to enable
  68528. * @param cameras the cameras that the effect should be enabled on
  68529. */
  68530. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68531. /**
  68532. * Disables an effect by name on a pipeline
  68533. * @param renderPipelineName the name of the pipeline to disable the effect in
  68534. * @param renderEffectName the name of the effect to disable
  68535. * @param cameras the cameras that the effect should be disabled on
  68536. */
  68537. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68538. /**
  68539. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68540. */
  68541. update(): void;
  68542. /** @hidden */
  68543. _rebuild(): void;
  68544. /**
  68545. * Disposes of the manager and pipelines
  68546. */
  68547. dispose(): void;
  68548. }
  68549. }
  68550. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68551. import { ISceneComponent } from "babylonjs/sceneComponent";
  68552. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68553. import { Scene } from "babylonjs/scene";
  68554. module "babylonjs/scene" {
  68555. interface Scene {
  68556. /** @hidden (Backing field) */
  68557. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68558. /**
  68559. * Gets the postprocess render pipeline manager
  68560. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68561. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68562. */
  68563. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68564. }
  68565. }
  68566. /**
  68567. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68568. */
  68569. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68570. /**
  68571. * The component name helpfull to identify the component in the list of scene components.
  68572. */
  68573. readonly name: string;
  68574. /**
  68575. * The scene the component belongs to.
  68576. */
  68577. scene: Scene;
  68578. /**
  68579. * Creates a new instance of the component for the given scene
  68580. * @param scene Defines the scene to register the component in
  68581. */
  68582. constructor(scene: Scene);
  68583. /**
  68584. * Registers the component in a given scene
  68585. */
  68586. register(): void;
  68587. /**
  68588. * Rebuilds the elements related to this component in case of
  68589. * context lost for instance.
  68590. */
  68591. rebuild(): void;
  68592. /**
  68593. * Disposes the component and the associated ressources
  68594. */
  68595. dispose(): void;
  68596. private _gatherRenderTargets;
  68597. }
  68598. }
  68599. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68600. import { Nullable } from "babylonjs/types";
  68601. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68602. import { Camera } from "babylonjs/Cameras/camera";
  68603. import { IDisposable } from "babylonjs/scene";
  68604. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68605. import { Scene } from "babylonjs/scene";
  68606. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68607. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68608. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68609. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68610. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68611. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68612. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68613. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68614. import { Animation } from "babylonjs/Animations/animation";
  68615. /**
  68616. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68617. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68618. */
  68619. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68620. private _scene;
  68621. private _camerasToBeAttached;
  68622. /**
  68623. * ID of the sharpen post process,
  68624. */
  68625. private readonly SharpenPostProcessId;
  68626. /**
  68627. * @ignore
  68628. * ID of the image processing post process;
  68629. */
  68630. readonly ImageProcessingPostProcessId: string;
  68631. /**
  68632. * @ignore
  68633. * ID of the Fast Approximate Anti-Aliasing post process;
  68634. */
  68635. readonly FxaaPostProcessId: string;
  68636. /**
  68637. * ID of the chromatic aberration post process,
  68638. */
  68639. private readonly ChromaticAberrationPostProcessId;
  68640. /**
  68641. * ID of the grain post process
  68642. */
  68643. private readonly GrainPostProcessId;
  68644. /**
  68645. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68646. */
  68647. sharpen: SharpenPostProcess;
  68648. private _sharpenEffect;
  68649. private bloom;
  68650. /**
  68651. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68652. */
  68653. depthOfField: DepthOfFieldEffect;
  68654. /**
  68655. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68656. */
  68657. fxaa: FxaaPostProcess;
  68658. /**
  68659. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68660. */
  68661. imageProcessing: ImageProcessingPostProcess;
  68662. /**
  68663. * Chromatic aberration post process which will shift rgb colors in the image
  68664. */
  68665. chromaticAberration: ChromaticAberrationPostProcess;
  68666. private _chromaticAberrationEffect;
  68667. /**
  68668. * Grain post process which add noise to the image
  68669. */
  68670. grain: GrainPostProcess;
  68671. private _grainEffect;
  68672. /**
  68673. * Glow post process which adds a glow to emissive areas of the image
  68674. */
  68675. private _glowLayer;
  68676. /**
  68677. * Animations which can be used to tweak settings over a period of time
  68678. */
  68679. animations: Animation[];
  68680. private _imageProcessingConfigurationObserver;
  68681. private _sharpenEnabled;
  68682. private _bloomEnabled;
  68683. private _depthOfFieldEnabled;
  68684. private _depthOfFieldBlurLevel;
  68685. private _fxaaEnabled;
  68686. private _imageProcessingEnabled;
  68687. private _defaultPipelineTextureType;
  68688. private _bloomScale;
  68689. private _chromaticAberrationEnabled;
  68690. private _grainEnabled;
  68691. private _buildAllowed;
  68692. /**
  68693. * Gets active scene
  68694. */
  68695. get scene(): Scene;
  68696. /**
  68697. * Enable or disable the sharpen process from the pipeline
  68698. */
  68699. set sharpenEnabled(enabled: boolean);
  68700. get sharpenEnabled(): boolean;
  68701. private _resizeObserver;
  68702. private _hardwareScaleLevel;
  68703. private _bloomKernel;
  68704. /**
  68705. * Specifies the size of the bloom blur kernel, relative to the final output size
  68706. */
  68707. get bloomKernel(): number;
  68708. set bloomKernel(value: number);
  68709. /**
  68710. * Specifies the weight of the bloom in the final rendering
  68711. */
  68712. private _bloomWeight;
  68713. /**
  68714. * Specifies the luma threshold for the area that will be blurred by the bloom
  68715. */
  68716. private _bloomThreshold;
  68717. private _hdr;
  68718. /**
  68719. * The strength of the bloom.
  68720. */
  68721. set bloomWeight(value: number);
  68722. get bloomWeight(): number;
  68723. /**
  68724. * The strength of the bloom.
  68725. */
  68726. set bloomThreshold(value: number);
  68727. get bloomThreshold(): number;
  68728. /**
  68729. * The scale of the bloom, lower value will provide better performance.
  68730. */
  68731. set bloomScale(value: number);
  68732. get bloomScale(): number;
  68733. /**
  68734. * Enable or disable the bloom from the pipeline
  68735. */
  68736. set bloomEnabled(enabled: boolean);
  68737. get bloomEnabled(): boolean;
  68738. private _rebuildBloom;
  68739. /**
  68740. * If the depth of field is enabled.
  68741. */
  68742. get depthOfFieldEnabled(): boolean;
  68743. set depthOfFieldEnabled(enabled: boolean);
  68744. /**
  68745. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68746. */
  68747. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68748. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68749. /**
  68750. * If the anti aliasing is enabled.
  68751. */
  68752. set fxaaEnabled(enabled: boolean);
  68753. get fxaaEnabled(): boolean;
  68754. private _samples;
  68755. /**
  68756. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68757. */
  68758. set samples(sampleCount: number);
  68759. get samples(): number;
  68760. /**
  68761. * If image processing is enabled.
  68762. */
  68763. set imageProcessingEnabled(enabled: boolean);
  68764. get imageProcessingEnabled(): boolean;
  68765. /**
  68766. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68767. */
  68768. set glowLayerEnabled(enabled: boolean);
  68769. get glowLayerEnabled(): boolean;
  68770. /**
  68771. * Gets the glow layer (or null if not defined)
  68772. */
  68773. get glowLayer(): Nullable<GlowLayer>;
  68774. /**
  68775. * Enable or disable the chromaticAberration process from the pipeline
  68776. */
  68777. set chromaticAberrationEnabled(enabled: boolean);
  68778. get chromaticAberrationEnabled(): boolean;
  68779. /**
  68780. * Enable or disable the grain process from the pipeline
  68781. */
  68782. set grainEnabled(enabled: boolean);
  68783. get grainEnabled(): boolean;
  68784. /**
  68785. * @constructor
  68786. * @param name - The rendering pipeline name (default: "")
  68787. * @param hdr - If high dynamic range textures should be used (default: true)
  68788. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68789. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68790. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68791. */
  68792. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68793. /**
  68794. * Get the class name
  68795. * @returns "DefaultRenderingPipeline"
  68796. */
  68797. getClassName(): string;
  68798. /**
  68799. * Force the compilation of the entire pipeline.
  68800. */
  68801. prepare(): void;
  68802. private _hasCleared;
  68803. private _prevPostProcess;
  68804. private _prevPrevPostProcess;
  68805. private _setAutoClearAndTextureSharing;
  68806. private _depthOfFieldSceneObserver;
  68807. private _buildPipeline;
  68808. private _disposePostProcesses;
  68809. /**
  68810. * Adds a camera to the pipeline
  68811. * @param camera the camera to be added
  68812. */
  68813. addCamera(camera: Camera): void;
  68814. /**
  68815. * Removes a camera from the pipeline
  68816. * @param camera the camera to remove
  68817. */
  68818. removeCamera(camera: Camera): void;
  68819. /**
  68820. * Dispose of the pipeline and stop all post processes
  68821. */
  68822. dispose(): void;
  68823. /**
  68824. * Serialize the rendering pipeline (Used when exporting)
  68825. * @returns the serialized object
  68826. */
  68827. serialize(): any;
  68828. /**
  68829. * Parse the serialized pipeline
  68830. * @param source Source pipeline.
  68831. * @param scene The scene to load the pipeline to.
  68832. * @param rootUrl The URL of the serialized pipeline.
  68833. * @returns An instantiated pipeline from the serialized object.
  68834. */
  68835. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68836. }
  68837. }
  68838. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68839. /** @hidden */
  68840. export var lensHighlightsPixelShader: {
  68841. name: string;
  68842. shader: string;
  68843. };
  68844. }
  68845. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68846. /** @hidden */
  68847. export var depthOfFieldPixelShader: {
  68848. name: string;
  68849. shader: string;
  68850. };
  68851. }
  68852. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68853. import { Camera } from "babylonjs/Cameras/camera";
  68854. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68855. import { Scene } from "babylonjs/scene";
  68856. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68857. import "babylonjs/Shaders/chromaticAberration.fragment";
  68858. import "babylonjs/Shaders/lensHighlights.fragment";
  68859. import "babylonjs/Shaders/depthOfField.fragment";
  68860. /**
  68861. * BABYLON.JS Chromatic Aberration GLSL Shader
  68862. * Author: Olivier Guyot
  68863. * Separates very slightly R, G and B colors on the edges of the screen
  68864. * Inspired by Francois Tarlier & Martins Upitis
  68865. */
  68866. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68867. /**
  68868. * @ignore
  68869. * The chromatic aberration PostProcess id in the pipeline
  68870. */
  68871. LensChromaticAberrationEffect: string;
  68872. /**
  68873. * @ignore
  68874. * The highlights enhancing PostProcess id in the pipeline
  68875. */
  68876. HighlightsEnhancingEffect: string;
  68877. /**
  68878. * @ignore
  68879. * The depth-of-field PostProcess id in the pipeline
  68880. */
  68881. LensDepthOfFieldEffect: string;
  68882. private _scene;
  68883. private _depthTexture;
  68884. private _grainTexture;
  68885. private _chromaticAberrationPostProcess;
  68886. private _highlightsPostProcess;
  68887. private _depthOfFieldPostProcess;
  68888. private _edgeBlur;
  68889. private _grainAmount;
  68890. private _chromaticAberration;
  68891. private _distortion;
  68892. private _highlightsGain;
  68893. private _highlightsThreshold;
  68894. private _dofDistance;
  68895. private _dofAperture;
  68896. private _dofDarken;
  68897. private _dofPentagon;
  68898. private _blurNoise;
  68899. /**
  68900. * @constructor
  68901. *
  68902. * Effect parameters are as follow:
  68903. * {
  68904. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68905. * edge_blur: number; // from 0 to x (1 for realism)
  68906. * distortion: number; // from 0 to x (1 for realism)
  68907. * grain_amount: number; // from 0 to 1
  68908. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68909. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68910. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68911. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68912. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68913. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68914. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68915. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68916. * }
  68917. * Note: if an effect parameter is unset, effect is disabled
  68918. *
  68919. * @param name The rendering pipeline name
  68920. * @param parameters - An object containing all parameters (see above)
  68921. * @param scene The scene linked to this pipeline
  68922. * @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)
  68923. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68924. */
  68925. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68926. /**
  68927. * Get the class name
  68928. * @returns "LensRenderingPipeline"
  68929. */
  68930. getClassName(): string;
  68931. /**
  68932. * Gets associated scene
  68933. */
  68934. get scene(): Scene;
  68935. /**
  68936. * Gets or sets the edge blur
  68937. */
  68938. get edgeBlur(): number;
  68939. set edgeBlur(value: number);
  68940. /**
  68941. * Gets or sets the grain amount
  68942. */
  68943. get grainAmount(): number;
  68944. set grainAmount(value: number);
  68945. /**
  68946. * Gets or sets the chromatic aberration amount
  68947. */
  68948. get chromaticAberration(): number;
  68949. set chromaticAberration(value: number);
  68950. /**
  68951. * Gets or sets the depth of field aperture
  68952. */
  68953. get dofAperture(): number;
  68954. set dofAperture(value: number);
  68955. /**
  68956. * Gets or sets the edge distortion
  68957. */
  68958. get edgeDistortion(): number;
  68959. set edgeDistortion(value: number);
  68960. /**
  68961. * Gets or sets the depth of field distortion
  68962. */
  68963. get dofDistortion(): number;
  68964. set dofDistortion(value: number);
  68965. /**
  68966. * Gets or sets the darken out of focus amount
  68967. */
  68968. get darkenOutOfFocus(): number;
  68969. set darkenOutOfFocus(value: number);
  68970. /**
  68971. * Gets or sets a boolean indicating if blur noise is enabled
  68972. */
  68973. get blurNoise(): boolean;
  68974. set blurNoise(value: boolean);
  68975. /**
  68976. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68977. */
  68978. get pentagonBokeh(): boolean;
  68979. set pentagonBokeh(value: boolean);
  68980. /**
  68981. * Gets or sets the highlight grain amount
  68982. */
  68983. get highlightsGain(): number;
  68984. set highlightsGain(value: number);
  68985. /**
  68986. * Gets or sets the highlight threshold
  68987. */
  68988. get highlightsThreshold(): number;
  68989. set highlightsThreshold(value: number);
  68990. /**
  68991. * Sets the amount of blur at the edges
  68992. * @param amount blur amount
  68993. */
  68994. setEdgeBlur(amount: number): void;
  68995. /**
  68996. * Sets edge blur to 0
  68997. */
  68998. disableEdgeBlur(): void;
  68999. /**
  69000. * Sets the amout of grain
  69001. * @param amount Amount of grain
  69002. */
  69003. setGrainAmount(amount: number): void;
  69004. /**
  69005. * Set grain amount to 0
  69006. */
  69007. disableGrain(): void;
  69008. /**
  69009. * Sets the chromatic aberration amount
  69010. * @param amount amount of chromatic aberration
  69011. */
  69012. setChromaticAberration(amount: number): void;
  69013. /**
  69014. * Sets chromatic aberration amount to 0
  69015. */
  69016. disableChromaticAberration(): void;
  69017. /**
  69018. * Sets the EdgeDistortion amount
  69019. * @param amount amount of EdgeDistortion
  69020. */
  69021. setEdgeDistortion(amount: number): void;
  69022. /**
  69023. * Sets edge distortion to 0
  69024. */
  69025. disableEdgeDistortion(): void;
  69026. /**
  69027. * Sets the FocusDistance amount
  69028. * @param amount amount of FocusDistance
  69029. */
  69030. setFocusDistance(amount: number): void;
  69031. /**
  69032. * Disables depth of field
  69033. */
  69034. disableDepthOfField(): void;
  69035. /**
  69036. * Sets the Aperture amount
  69037. * @param amount amount of Aperture
  69038. */
  69039. setAperture(amount: number): void;
  69040. /**
  69041. * Sets the DarkenOutOfFocus amount
  69042. * @param amount amount of DarkenOutOfFocus
  69043. */
  69044. setDarkenOutOfFocus(amount: number): void;
  69045. private _pentagonBokehIsEnabled;
  69046. /**
  69047. * Creates a pentagon bokeh effect
  69048. */
  69049. enablePentagonBokeh(): void;
  69050. /**
  69051. * Disables the pentagon bokeh effect
  69052. */
  69053. disablePentagonBokeh(): void;
  69054. /**
  69055. * Enables noise blur
  69056. */
  69057. enableNoiseBlur(): void;
  69058. /**
  69059. * Disables noise blur
  69060. */
  69061. disableNoiseBlur(): void;
  69062. /**
  69063. * Sets the HighlightsGain amount
  69064. * @param amount amount of HighlightsGain
  69065. */
  69066. setHighlightsGain(amount: number): void;
  69067. /**
  69068. * Sets the HighlightsThreshold amount
  69069. * @param amount amount of HighlightsThreshold
  69070. */
  69071. setHighlightsThreshold(amount: number): void;
  69072. /**
  69073. * Disables highlights
  69074. */
  69075. disableHighlights(): void;
  69076. /**
  69077. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69078. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69079. */
  69080. dispose(disableDepthRender?: boolean): void;
  69081. private _createChromaticAberrationPostProcess;
  69082. private _createHighlightsPostProcess;
  69083. private _createDepthOfFieldPostProcess;
  69084. private _createGrainTexture;
  69085. }
  69086. }
  69087. declare module "babylonjs/Shaders/ssao2.fragment" {
  69088. /** @hidden */
  69089. export var ssao2PixelShader: {
  69090. name: string;
  69091. shader: string;
  69092. };
  69093. }
  69094. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69095. /** @hidden */
  69096. export var ssaoCombinePixelShader: {
  69097. name: string;
  69098. shader: string;
  69099. };
  69100. }
  69101. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69102. import { Camera } from "babylonjs/Cameras/camera";
  69103. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69104. import { Scene } from "babylonjs/scene";
  69105. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69106. import "babylonjs/Shaders/ssao2.fragment";
  69107. import "babylonjs/Shaders/ssaoCombine.fragment";
  69108. /**
  69109. * Render pipeline to produce ssao effect
  69110. */
  69111. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69112. /**
  69113. * @ignore
  69114. * The PassPostProcess id in the pipeline that contains the original scene color
  69115. */
  69116. SSAOOriginalSceneColorEffect: string;
  69117. /**
  69118. * @ignore
  69119. * The SSAO PostProcess id in the pipeline
  69120. */
  69121. SSAORenderEffect: string;
  69122. /**
  69123. * @ignore
  69124. * The horizontal blur PostProcess id in the pipeline
  69125. */
  69126. SSAOBlurHRenderEffect: string;
  69127. /**
  69128. * @ignore
  69129. * The vertical blur PostProcess id in the pipeline
  69130. */
  69131. SSAOBlurVRenderEffect: string;
  69132. /**
  69133. * @ignore
  69134. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69135. */
  69136. SSAOCombineRenderEffect: string;
  69137. /**
  69138. * The output strength of the SSAO post-process. Default value is 1.0.
  69139. */
  69140. totalStrength: number;
  69141. /**
  69142. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69143. */
  69144. maxZ: number;
  69145. /**
  69146. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69147. */
  69148. minZAspect: number;
  69149. private _samples;
  69150. /**
  69151. * Number of samples used for the SSAO calculations. Default value is 8
  69152. */
  69153. set samples(n: number);
  69154. get samples(): number;
  69155. private _textureSamples;
  69156. /**
  69157. * Number of samples to use for antialiasing
  69158. */
  69159. set textureSamples(n: number);
  69160. get textureSamples(): number;
  69161. /**
  69162. * Ratio object used for SSAO ratio and blur ratio
  69163. */
  69164. private _ratio;
  69165. /**
  69166. * Dynamically generated sphere sampler.
  69167. */
  69168. private _sampleSphere;
  69169. /**
  69170. * Blur filter offsets
  69171. */
  69172. private _samplerOffsets;
  69173. private _expensiveBlur;
  69174. /**
  69175. * If bilateral blur should be used
  69176. */
  69177. set expensiveBlur(b: boolean);
  69178. get expensiveBlur(): boolean;
  69179. /**
  69180. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69181. */
  69182. radius: number;
  69183. /**
  69184. * The base color of the SSAO post-process
  69185. * The final result is "base + ssao" between [0, 1]
  69186. */
  69187. base: number;
  69188. /**
  69189. * Support test.
  69190. */
  69191. static get IsSupported(): boolean;
  69192. private _scene;
  69193. private _depthTexture;
  69194. private _normalTexture;
  69195. private _randomTexture;
  69196. private _originalColorPostProcess;
  69197. private _ssaoPostProcess;
  69198. private _blurHPostProcess;
  69199. private _blurVPostProcess;
  69200. private _ssaoCombinePostProcess;
  69201. /**
  69202. * Gets active scene
  69203. */
  69204. get scene(): Scene;
  69205. /**
  69206. * @constructor
  69207. * @param name The rendering pipeline name
  69208. * @param scene The scene linked to this pipeline
  69209. * @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 }
  69210. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69211. */
  69212. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69213. /**
  69214. * Get the class name
  69215. * @returns "SSAO2RenderingPipeline"
  69216. */
  69217. getClassName(): string;
  69218. /**
  69219. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69220. */
  69221. dispose(disableGeometryBufferRenderer?: boolean): void;
  69222. private _createBlurPostProcess;
  69223. /** @hidden */
  69224. _rebuild(): void;
  69225. private _bits;
  69226. private _radicalInverse_VdC;
  69227. private _hammersley;
  69228. private _hemisphereSample_uniform;
  69229. private _generateHemisphere;
  69230. private _createSSAOPostProcess;
  69231. private _createSSAOCombinePostProcess;
  69232. private _createRandomTexture;
  69233. /**
  69234. * Serialize the rendering pipeline (Used when exporting)
  69235. * @returns the serialized object
  69236. */
  69237. serialize(): any;
  69238. /**
  69239. * Parse the serialized pipeline
  69240. * @param source Source pipeline.
  69241. * @param scene The scene to load the pipeline to.
  69242. * @param rootUrl The URL of the serialized pipeline.
  69243. * @returns An instantiated pipeline from the serialized object.
  69244. */
  69245. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69246. }
  69247. }
  69248. declare module "babylonjs/Shaders/ssao.fragment" {
  69249. /** @hidden */
  69250. export var ssaoPixelShader: {
  69251. name: string;
  69252. shader: string;
  69253. };
  69254. }
  69255. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69256. import { Camera } from "babylonjs/Cameras/camera";
  69257. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69258. import { Scene } from "babylonjs/scene";
  69259. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69260. import "babylonjs/Shaders/ssao.fragment";
  69261. import "babylonjs/Shaders/ssaoCombine.fragment";
  69262. /**
  69263. * Render pipeline to produce ssao effect
  69264. */
  69265. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69266. /**
  69267. * @ignore
  69268. * The PassPostProcess id in the pipeline that contains the original scene color
  69269. */
  69270. SSAOOriginalSceneColorEffect: string;
  69271. /**
  69272. * @ignore
  69273. * The SSAO PostProcess id in the pipeline
  69274. */
  69275. SSAORenderEffect: string;
  69276. /**
  69277. * @ignore
  69278. * The horizontal blur PostProcess id in the pipeline
  69279. */
  69280. SSAOBlurHRenderEffect: string;
  69281. /**
  69282. * @ignore
  69283. * The vertical blur PostProcess id in the pipeline
  69284. */
  69285. SSAOBlurVRenderEffect: string;
  69286. /**
  69287. * @ignore
  69288. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69289. */
  69290. SSAOCombineRenderEffect: string;
  69291. /**
  69292. * The output strength of the SSAO post-process. Default value is 1.0.
  69293. */
  69294. totalStrength: number;
  69295. /**
  69296. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69297. */
  69298. radius: number;
  69299. /**
  69300. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69301. * Must not be equal to fallOff and superior to fallOff.
  69302. * Default value is 0.0075
  69303. */
  69304. area: number;
  69305. /**
  69306. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69307. * Must not be equal to area and inferior to area.
  69308. * Default value is 0.000001
  69309. */
  69310. fallOff: number;
  69311. /**
  69312. * The base color of the SSAO post-process
  69313. * The final result is "base + ssao" between [0, 1]
  69314. */
  69315. base: number;
  69316. private _scene;
  69317. private _depthTexture;
  69318. private _randomTexture;
  69319. private _originalColorPostProcess;
  69320. private _ssaoPostProcess;
  69321. private _blurHPostProcess;
  69322. private _blurVPostProcess;
  69323. private _ssaoCombinePostProcess;
  69324. private _firstUpdate;
  69325. /**
  69326. * Gets active scene
  69327. */
  69328. get scene(): Scene;
  69329. /**
  69330. * @constructor
  69331. * @param name - The rendering pipeline name
  69332. * @param scene - The scene linked to this pipeline
  69333. * @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 }
  69334. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69335. */
  69336. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69337. /**
  69338. * Get the class name
  69339. * @returns "SSAORenderingPipeline"
  69340. */
  69341. getClassName(): string;
  69342. /**
  69343. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69344. */
  69345. dispose(disableDepthRender?: boolean): void;
  69346. private _createBlurPostProcess;
  69347. /** @hidden */
  69348. _rebuild(): void;
  69349. private _createSSAOPostProcess;
  69350. private _createSSAOCombinePostProcess;
  69351. private _createRandomTexture;
  69352. }
  69353. }
  69354. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69355. /** @hidden */
  69356. export var screenSpaceReflectionPixelShader: {
  69357. name: string;
  69358. shader: string;
  69359. };
  69360. }
  69361. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69362. import { Nullable } from "babylonjs/types";
  69363. import { Camera } from "babylonjs/Cameras/camera";
  69364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69365. import { Scene } from "babylonjs/scene";
  69366. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69367. import { Engine } from "babylonjs/Engines/engine";
  69368. /**
  69369. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69370. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69371. */
  69372. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69373. /**
  69374. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69375. */
  69376. threshold: number;
  69377. /**
  69378. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69379. */
  69380. strength: number;
  69381. /**
  69382. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69383. */
  69384. reflectionSpecularFalloffExponent: number;
  69385. /**
  69386. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  69387. */
  69388. step: number;
  69389. /**
  69390. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69391. */
  69392. roughnessFactor: number;
  69393. private _geometryBufferRenderer;
  69394. private _enableSmoothReflections;
  69395. private _reflectionSamples;
  69396. private _smoothSteps;
  69397. /**
  69398. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69399. * @param name The name of the effect.
  69400. * @param scene The scene containing the objects to calculate reflections.
  69401. * @param options The required width/height ratio to downsize to before computing the render pass.
  69402. * @param camera The camera to apply the render pass to.
  69403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69404. * @param engine The engine which the post process will be applied. (default: current engine)
  69405. * @param reusable If the post process can be reused on the same frame. (default: false)
  69406. * @param textureType Type of textures used when performing the post process. (default: 0)
  69407. * @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)
  69408. */
  69409. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69410. /**
  69411. * Gets wether or not smoothing reflections is enabled.
  69412. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69413. */
  69414. get enableSmoothReflections(): boolean;
  69415. /**
  69416. * Sets wether or not smoothing reflections is enabled.
  69417. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69418. */
  69419. set enableSmoothReflections(enabled: boolean);
  69420. /**
  69421. * Gets the number of samples taken while computing reflections. More samples count is high,
  69422. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69423. */
  69424. get reflectionSamples(): number;
  69425. /**
  69426. * Sets the number of samples taken while computing reflections. More samples count is high,
  69427. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69428. */
  69429. set reflectionSamples(samples: number);
  69430. /**
  69431. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69432. * more the post-process will require GPU power and can generate a drop in FPS.
  69433. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69434. */
  69435. get smoothSteps(): number;
  69436. set smoothSteps(steps: number);
  69437. private _updateEffectDefines;
  69438. }
  69439. }
  69440. declare module "babylonjs/Shaders/standard.fragment" {
  69441. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69442. /** @hidden */
  69443. export var standardPixelShader: {
  69444. name: string;
  69445. shader: string;
  69446. };
  69447. }
  69448. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69449. import { Nullable } from "babylonjs/types";
  69450. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69451. import { Camera } from "babylonjs/Cameras/camera";
  69452. import { Texture } from "babylonjs/Materials/Textures/texture";
  69453. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69454. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69455. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69456. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69457. import { IDisposable } from "babylonjs/scene";
  69458. import { SpotLight } from "babylonjs/Lights/spotLight";
  69459. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69460. import { Scene } from "babylonjs/scene";
  69461. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69462. import { Animation } from "babylonjs/Animations/animation";
  69463. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69464. import "babylonjs/Shaders/standard.fragment";
  69465. /**
  69466. * Standard rendering pipeline
  69467. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69468. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69469. */
  69470. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69471. /**
  69472. * Public members
  69473. */
  69474. /**
  69475. * Post-process which contains the original scene color before the pipeline applies all the effects
  69476. */
  69477. originalPostProcess: Nullable<PostProcess>;
  69478. /**
  69479. * Post-process used to down scale an image x4
  69480. */
  69481. downSampleX4PostProcess: Nullable<PostProcess>;
  69482. /**
  69483. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69484. */
  69485. brightPassPostProcess: Nullable<PostProcess>;
  69486. /**
  69487. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69488. */
  69489. blurHPostProcesses: PostProcess[];
  69490. /**
  69491. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69492. */
  69493. blurVPostProcesses: PostProcess[];
  69494. /**
  69495. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69496. */
  69497. textureAdderPostProcess: Nullable<PostProcess>;
  69498. /**
  69499. * Post-process used to create volumetric lighting effect
  69500. */
  69501. volumetricLightPostProcess: Nullable<PostProcess>;
  69502. /**
  69503. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69504. */
  69505. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69506. /**
  69507. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69508. */
  69509. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69510. /**
  69511. * Post-process used to merge the volumetric light effect and the real scene color
  69512. */
  69513. volumetricLightMergePostProces: Nullable<PostProcess>;
  69514. /**
  69515. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69516. */
  69517. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69518. /**
  69519. * Base post-process used to calculate the average luminance of the final image for HDR
  69520. */
  69521. luminancePostProcess: Nullable<PostProcess>;
  69522. /**
  69523. * Post-processes used to create down sample post-processes in order to get
  69524. * the average luminance of the final image for HDR
  69525. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69526. */
  69527. luminanceDownSamplePostProcesses: PostProcess[];
  69528. /**
  69529. * Post-process used to create a HDR effect (light adaptation)
  69530. */
  69531. hdrPostProcess: Nullable<PostProcess>;
  69532. /**
  69533. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69534. */
  69535. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69536. /**
  69537. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69538. */
  69539. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69540. /**
  69541. * Post-process used to merge the final HDR post-process and the real scene color
  69542. */
  69543. hdrFinalPostProcess: Nullable<PostProcess>;
  69544. /**
  69545. * Post-process used to create a lens flare effect
  69546. */
  69547. lensFlarePostProcess: Nullable<PostProcess>;
  69548. /**
  69549. * Post-process that merges the result of the lens flare post-process and the real scene color
  69550. */
  69551. lensFlareComposePostProcess: Nullable<PostProcess>;
  69552. /**
  69553. * Post-process used to create a motion blur effect
  69554. */
  69555. motionBlurPostProcess: Nullable<PostProcess>;
  69556. /**
  69557. * Post-process used to create a depth of field effect
  69558. */
  69559. depthOfFieldPostProcess: Nullable<PostProcess>;
  69560. /**
  69561. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69562. */
  69563. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69564. /**
  69565. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69566. */
  69567. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69568. /**
  69569. * Represents the brightness threshold in order to configure the illuminated surfaces
  69570. */
  69571. brightThreshold: number;
  69572. /**
  69573. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69574. */
  69575. blurWidth: number;
  69576. /**
  69577. * Sets if the blur for highlighted surfaces must be only horizontal
  69578. */
  69579. horizontalBlur: boolean;
  69580. /**
  69581. * Gets the overall exposure used by the pipeline
  69582. */
  69583. get exposure(): number;
  69584. /**
  69585. * Sets the overall exposure used by the pipeline
  69586. */
  69587. set exposure(value: number);
  69588. /**
  69589. * Texture used typically to simulate "dirty" on camera lens
  69590. */
  69591. lensTexture: Nullable<Texture>;
  69592. /**
  69593. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69594. */
  69595. volumetricLightCoefficient: number;
  69596. /**
  69597. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69598. */
  69599. volumetricLightPower: number;
  69600. /**
  69601. * Used the set the blur intensity to smooth the volumetric lights
  69602. */
  69603. volumetricLightBlurScale: number;
  69604. /**
  69605. * Light (spot or directional) used to generate the volumetric lights rays
  69606. * The source light must have a shadow generate so the pipeline can get its
  69607. * depth map
  69608. */
  69609. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69610. /**
  69611. * For eye adaptation, represents the minimum luminance the eye can see
  69612. */
  69613. hdrMinimumLuminance: number;
  69614. /**
  69615. * For eye adaptation, represents the decrease luminance speed
  69616. */
  69617. hdrDecreaseRate: number;
  69618. /**
  69619. * For eye adaptation, represents the increase luminance speed
  69620. */
  69621. hdrIncreaseRate: number;
  69622. /**
  69623. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69624. */
  69625. get hdrAutoExposure(): boolean;
  69626. /**
  69627. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69628. */
  69629. set hdrAutoExposure(value: boolean);
  69630. /**
  69631. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69632. */
  69633. lensColorTexture: Nullable<Texture>;
  69634. /**
  69635. * The overall strengh for the lens flare effect
  69636. */
  69637. lensFlareStrength: number;
  69638. /**
  69639. * Dispersion coefficient for lens flare ghosts
  69640. */
  69641. lensFlareGhostDispersal: number;
  69642. /**
  69643. * Main lens flare halo width
  69644. */
  69645. lensFlareHaloWidth: number;
  69646. /**
  69647. * Based on the lens distortion effect, defines how much the lens flare result
  69648. * is distorted
  69649. */
  69650. lensFlareDistortionStrength: number;
  69651. /**
  69652. * Configures the blur intensity used for for lens flare (halo)
  69653. */
  69654. lensFlareBlurWidth: number;
  69655. /**
  69656. * Lens star texture must be used to simulate rays on the flares and is available
  69657. * in the documentation
  69658. */
  69659. lensStarTexture: Nullable<Texture>;
  69660. /**
  69661. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69662. * flare effect by taking account of the dirt texture
  69663. */
  69664. lensFlareDirtTexture: Nullable<Texture>;
  69665. /**
  69666. * Represents the focal length for the depth of field effect
  69667. */
  69668. depthOfFieldDistance: number;
  69669. /**
  69670. * Represents the blur intensity for the blurred part of the depth of field effect
  69671. */
  69672. depthOfFieldBlurWidth: number;
  69673. /**
  69674. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69675. */
  69676. get motionStrength(): number;
  69677. /**
  69678. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69679. */
  69680. set motionStrength(strength: number);
  69681. /**
  69682. * Gets wether or not the motion blur post-process is object based or screen based.
  69683. */
  69684. get objectBasedMotionBlur(): boolean;
  69685. /**
  69686. * Sets wether or not the motion blur post-process should be object based or screen based
  69687. */
  69688. set objectBasedMotionBlur(value: boolean);
  69689. /**
  69690. * List of animations for the pipeline (IAnimatable implementation)
  69691. */
  69692. animations: Animation[];
  69693. /**
  69694. * Private members
  69695. */
  69696. private _scene;
  69697. private _currentDepthOfFieldSource;
  69698. private _basePostProcess;
  69699. private _fixedExposure;
  69700. private _currentExposure;
  69701. private _hdrAutoExposure;
  69702. private _hdrCurrentLuminance;
  69703. private _motionStrength;
  69704. private _isObjectBasedMotionBlur;
  69705. private _floatTextureType;
  69706. private _camerasToBeAttached;
  69707. private _ratio;
  69708. private _bloomEnabled;
  69709. private _depthOfFieldEnabled;
  69710. private _vlsEnabled;
  69711. private _lensFlareEnabled;
  69712. private _hdrEnabled;
  69713. private _motionBlurEnabled;
  69714. private _fxaaEnabled;
  69715. private _screenSpaceReflectionsEnabled;
  69716. private _motionBlurSamples;
  69717. private _volumetricLightStepsCount;
  69718. private _samples;
  69719. /**
  69720. * @ignore
  69721. * Specifies if the bloom pipeline is enabled
  69722. */
  69723. get BloomEnabled(): boolean;
  69724. set BloomEnabled(enabled: boolean);
  69725. /**
  69726. * @ignore
  69727. * Specifies if the depth of field pipeline is enabed
  69728. */
  69729. get DepthOfFieldEnabled(): boolean;
  69730. set DepthOfFieldEnabled(enabled: boolean);
  69731. /**
  69732. * @ignore
  69733. * Specifies if the lens flare pipeline is enabed
  69734. */
  69735. get LensFlareEnabled(): boolean;
  69736. set LensFlareEnabled(enabled: boolean);
  69737. /**
  69738. * @ignore
  69739. * Specifies if the HDR pipeline is enabled
  69740. */
  69741. get HDREnabled(): boolean;
  69742. set HDREnabled(enabled: boolean);
  69743. /**
  69744. * @ignore
  69745. * Specifies if the volumetric lights scattering effect is enabled
  69746. */
  69747. get VLSEnabled(): boolean;
  69748. set VLSEnabled(enabled: boolean);
  69749. /**
  69750. * @ignore
  69751. * Specifies if the motion blur effect is enabled
  69752. */
  69753. get MotionBlurEnabled(): boolean;
  69754. set MotionBlurEnabled(enabled: boolean);
  69755. /**
  69756. * Specifies if anti-aliasing is enabled
  69757. */
  69758. get fxaaEnabled(): boolean;
  69759. set fxaaEnabled(enabled: boolean);
  69760. /**
  69761. * Specifies if screen space reflections are enabled.
  69762. */
  69763. get screenSpaceReflectionsEnabled(): boolean;
  69764. set screenSpaceReflectionsEnabled(enabled: boolean);
  69765. /**
  69766. * Specifies the number of steps used to calculate the volumetric lights
  69767. * Typically in interval [50, 200]
  69768. */
  69769. get volumetricLightStepsCount(): number;
  69770. set volumetricLightStepsCount(count: number);
  69771. /**
  69772. * Specifies the number of samples used for the motion blur effect
  69773. * Typically in interval [16, 64]
  69774. */
  69775. get motionBlurSamples(): number;
  69776. set motionBlurSamples(samples: number);
  69777. /**
  69778. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69779. */
  69780. get samples(): number;
  69781. set samples(sampleCount: number);
  69782. /**
  69783. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69784. * @constructor
  69785. * @param name The rendering pipeline name
  69786. * @param scene The scene linked to this pipeline
  69787. * @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)
  69788. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69789. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69790. */
  69791. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69792. private _buildPipeline;
  69793. private _createDownSampleX4PostProcess;
  69794. private _createBrightPassPostProcess;
  69795. private _createBlurPostProcesses;
  69796. private _createTextureAdderPostProcess;
  69797. private _createVolumetricLightPostProcess;
  69798. private _createLuminancePostProcesses;
  69799. private _createHdrPostProcess;
  69800. private _createLensFlarePostProcess;
  69801. private _createDepthOfFieldPostProcess;
  69802. private _createMotionBlurPostProcess;
  69803. private _getDepthTexture;
  69804. private _disposePostProcesses;
  69805. /**
  69806. * Dispose of the pipeline and stop all post processes
  69807. */
  69808. dispose(): void;
  69809. /**
  69810. * Serialize the rendering pipeline (Used when exporting)
  69811. * @returns the serialized object
  69812. */
  69813. serialize(): any;
  69814. /**
  69815. * Parse the serialized pipeline
  69816. * @param source Source pipeline.
  69817. * @param scene The scene to load the pipeline to.
  69818. * @param rootUrl The URL of the serialized pipeline.
  69819. * @returns An instantiated pipeline from the serialized object.
  69820. */
  69821. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69822. /**
  69823. * Luminance steps
  69824. */
  69825. static LuminanceSteps: number;
  69826. }
  69827. }
  69828. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69829. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69830. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69831. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69832. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69833. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69834. }
  69835. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69836. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69837. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69838. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69839. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69840. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69841. }
  69842. declare module "babylonjs/Shaders/tonemap.fragment" {
  69843. /** @hidden */
  69844. export var tonemapPixelShader: {
  69845. name: string;
  69846. shader: string;
  69847. };
  69848. }
  69849. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69850. import { Camera } from "babylonjs/Cameras/camera";
  69851. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69852. import "babylonjs/Shaders/tonemap.fragment";
  69853. import { Engine } from "babylonjs/Engines/engine";
  69854. /** Defines operator used for tonemapping */
  69855. export enum TonemappingOperator {
  69856. /** Hable */
  69857. Hable = 0,
  69858. /** Reinhard */
  69859. Reinhard = 1,
  69860. /** HejiDawson */
  69861. HejiDawson = 2,
  69862. /** Photographic */
  69863. Photographic = 3
  69864. }
  69865. /**
  69866. * Defines a post process to apply tone mapping
  69867. */
  69868. export class TonemapPostProcess extends PostProcess {
  69869. private _operator;
  69870. /** Defines the required exposure adjustement */
  69871. exposureAdjustment: number;
  69872. /**
  69873. * Creates a new TonemapPostProcess
  69874. * @param name defines the name of the postprocess
  69875. * @param _operator defines the operator to use
  69876. * @param exposureAdjustment defines the required exposure adjustement
  69877. * @param camera defines the camera to use (can be null)
  69878. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69879. * @param engine defines the hosting engine (can be ignore if camera is set)
  69880. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69881. */
  69882. constructor(name: string, _operator: TonemappingOperator,
  69883. /** Defines the required exposure adjustement */
  69884. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69885. }
  69886. }
  69887. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69888. /** @hidden */
  69889. export var volumetricLightScatteringPixelShader: {
  69890. name: string;
  69891. shader: string;
  69892. };
  69893. }
  69894. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69895. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69896. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69897. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69898. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69899. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69900. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69901. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69902. /** @hidden */
  69903. export var volumetricLightScatteringPassVertexShader: {
  69904. name: string;
  69905. shader: string;
  69906. };
  69907. }
  69908. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69909. /** @hidden */
  69910. export var volumetricLightScatteringPassPixelShader: {
  69911. name: string;
  69912. shader: string;
  69913. };
  69914. }
  69915. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69916. import { Vector3 } from "babylonjs/Maths/math.vector";
  69917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69918. import { Mesh } from "babylonjs/Meshes/mesh";
  69919. import { Camera } from "babylonjs/Cameras/camera";
  69920. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69921. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69922. import { Scene } from "babylonjs/scene";
  69923. import "babylonjs/Meshes/Builders/planeBuilder";
  69924. import "babylonjs/Shaders/depth.vertex";
  69925. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69926. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69927. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69928. import { Engine } from "babylonjs/Engines/engine";
  69929. /**
  69930. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69931. */
  69932. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69933. private _volumetricLightScatteringPass;
  69934. private _volumetricLightScatteringRTT;
  69935. private _viewPort;
  69936. private _screenCoordinates;
  69937. private _cachedDefines;
  69938. /**
  69939. * If not undefined, the mesh position is computed from the attached node position
  69940. */
  69941. attachedNode: {
  69942. position: Vector3;
  69943. };
  69944. /**
  69945. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69946. */
  69947. customMeshPosition: Vector3;
  69948. /**
  69949. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69950. */
  69951. useCustomMeshPosition: boolean;
  69952. /**
  69953. * If the post-process should inverse the light scattering direction
  69954. */
  69955. invert: boolean;
  69956. /**
  69957. * The internal mesh used by the post-process
  69958. */
  69959. mesh: Mesh;
  69960. /**
  69961. * @hidden
  69962. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69963. */
  69964. get useDiffuseColor(): boolean;
  69965. set useDiffuseColor(useDiffuseColor: boolean);
  69966. /**
  69967. * Array containing the excluded meshes not rendered in the internal pass
  69968. */
  69969. excludedMeshes: AbstractMesh[];
  69970. /**
  69971. * Controls the overall intensity of the post-process
  69972. */
  69973. exposure: number;
  69974. /**
  69975. * Dissipates each sample's contribution in range [0, 1]
  69976. */
  69977. decay: number;
  69978. /**
  69979. * Controls the overall intensity of each sample
  69980. */
  69981. weight: number;
  69982. /**
  69983. * Controls the density of each sample
  69984. */
  69985. density: number;
  69986. /**
  69987. * @constructor
  69988. * @param name The post-process name
  69989. * @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)
  69990. * @param camera The camera that the post-process will be attached to
  69991. * @param mesh The mesh used to create the light scattering
  69992. * @param samples The post-process quality, default 100
  69993. * @param samplingModeThe post-process filtering mode
  69994. * @param engine The babylon engine
  69995. * @param reusable If the post-process is reusable
  69996. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69997. */
  69998. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69999. /**
  70000. * Returns the string "VolumetricLightScatteringPostProcess"
  70001. * @returns "VolumetricLightScatteringPostProcess"
  70002. */
  70003. getClassName(): string;
  70004. private _isReady;
  70005. /**
  70006. * Sets the new light position for light scattering effect
  70007. * @param position The new custom light position
  70008. */
  70009. setCustomMeshPosition(position: Vector3): void;
  70010. /**
  70011. * Returns the light position for light scattering effect
  70012. * @return Vector3 The custom light position
  70013. */
  70014. getCustomMeshPosition(): Vector3;
  70015. /**
  70016. * Disposes the internal assets and detaches the post-process from the camera
  70017. */
  70018. dispose(camera: Camera): void;
  70019. /**
  70020. * Returns the render target texture used by the post-process
  70021. * @return the render target texture used by the post-process
  70022. */
  70023. getPass(): RenderTargetTexture;
  70024. private _meshExcluded;
  70025. private _createPass;
  70026. private _updateMeshScreenCoordinates;
  70027. /**
  70028. * Creates a default mesh for the Volumeric Light Scattering post-process
  70029. * @param name The mesh name
  70030. * @param scene The scene where to create the mesh
  70031. * @return the default mesh
  70032. */
  70033. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70034. }
  70035. }
  70036. declare module "babylonjs/PostProcesses/index" {
  70037. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70038. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70039. export * from "babylonjs/PostProcesses/bloomEffect";
  70040. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70041. export * from "babylonjs/PostProcesses/blurPostProcess";
  70042. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70043. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70044. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70045. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70046. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70047. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70048. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70049. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70050. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70051. export * from "babylonjs/PostProcesses/filterPostProcess";
  70052. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70053. export * from "babylonjs/PostProcesses/grainPostProcess";
  70054. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70055. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70056. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70057. export * from "babylonjs/PostProcesses/passPostProcess";
  70058. export * from "babylonjs/PostProcesses/postProcess";
  70059. export * from "babylonjs/PostProcesses/postProcessManager";
  70060. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70061. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70062. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70063. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70064. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70065. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70066. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70067. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70068. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70069. }
  70070. declare module "babylonjs/Probes/index" {
  70071. export * from "babylonjs/Probes/reflectionProbe";
  70072. }
  70073. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70074. import { Scene } from "babylonjs/scene";
  70075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70076. import { SmartArray } from "babylonjs/Misc/smartArray";
  70077. import { ISceneComponent } from "babylonjs/sceneComponent";
  70078. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70079. import "babylonjs/Meshes/Builders/boxBuilder";
  70080. import "babylonjs/Shaders/color.fragment";
  70081. import "babylonjs/Shaders/color.vertex";
  70082. import { Color3 } from "babylonjs/Maths/math.color";
  70083. module "babylonjs/scene" {
  70084. interface Scene {
  70085. /** @hidden (Backing field) */
  70086. _boundingBoxRenderer: BoundingBoxRenderer;
  70087. /** @hidden (Backing field) */
  70088. _forceShowBoundingBoxes: boolean;
  70089. /**
  70090. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70091. */
  70092. forceShowBoundingBoxes: boolean;
  70093. /**
  70094. * Gets the bounding box renderer associated with the scene
  70095. * @returns a BoundingBoxRenderer
  70096. */
  70097. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70098. }
  70099. }
  70100. module "babylonjs/Meshes/abstractMesh" {
  70101. interface AbstractMesh {
  70102. /** @hidden (Backing field) */
  70103. _showBoundingBox: boolean;
  70104. /**
  70105. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70106. */
  70107. showBoundingBox: boolean;
  70108. }
  70109. }
  70110. /**
  70111. * Component responsible of rendering the bounding box of the meshes in a scene.
  70112. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70113. */
  70114. export class BoundingBoxRenderer implements ISceneComponent {
  70115. /**
  70116. * The component name helpfull to identify the component in the list of scene components.
  70117. */
  70118. readonly name: string;
  70119. /**
  70120. * The scene the component belongs to.
  70121. */
  70122. scene: Scene;
  70123. /**
  70124. * Color of the bounding box lines placed in front of an object
  70125. */
  70126. frontColor: Color3;
  70127. /**
  70128. * Color of the bounding box lines placed behind an object
  70129. */
  70130. backColor: Color3;
  70131. /**
  70132. * Defines if the renderer should show the back lines or not
  70133. */
  70134. showBackLines: boolean;
  70135. /**
  70136. * @hidden
  70137. */
  70138. renderList: SmartArray<BoundingBox>;
  70139. private _colorShader;
  70140. private _vertexBuffers;
  70141. private _indexBuffer;
  70142. private _fillIndexBuffer;
  70143. private _fillIndexData;
  70144. /**
  70145. * Instantiates a new bounding box renderer in a scene.
  70146. * @param scene the scene the renderer renders in
  70147. */
  70148. constructor(scene: Scene);
  70149. /**
  70150. * Registers the component in a given scene
  70151. */
  70152. register(): void;
  70153. private _evaluateSubMesh;
  70154. private _activeMesh;
  70155. private _prepareRessources;
  70156. private _createIndexBuffer;
  70157. /**
  70158. * Rebuilds the elements related to this component in case of
  70159. * context lost for instance.
  70160. */
  70161. rebuild(): void;
  70162. /**
  70163. * @hidden
  70164. */
  70165. reset(): void;
  70166. /**
  70167. * Render the bounding boxes of a specific rendering group
  70168. * @param renderingGroupId defines the rendering group to render
  70169. */
  70170. render(renderingGroupId: number): void;
  70171. /**
  70172. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70173. * @param mesh Define the mesh to render the occlusion bounding box for
  70174. */
  70175. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70176. /**
  70177. * Dispose and release the resources attached to this renderer.
  70178. */
  70179. dispose(): void;
  70180. }
  70181. }
  70182. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70183. import { Nullable } from "babylonjs/types";
  70184. import { Scene } from "babylonjs/scene";
  70185. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70186. import { Camera } from "babylonjs/Cameras/camera";
  70187. import { ISceneComponent } from "babylonjs/sceneComponent";
  70188. module "babylonjs/scene" {
  70189. interface Scene {
  70190. /** @hidden (Backing field) */
  70191. _depthRenderer: {
  70192. [id: string]: DepthRenderer;
  70193. };
  70194. /**
  70195. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70196. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70197. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70198. * @returns the created depth renderer
  70199. */
  70200. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70201. /**
  70202. * Disables a depth renderer for a given camera
  70203. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70204. */
  70205. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70206. }
  70207. }
  70208. /**
  70209. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70210. * in several rendering techniques.
  70211. */
  70212. export class DepthRendererSceneComponent implements ISceneComponent {
  70213. /**
  70214. * The component name helpfull to identify the component in the list of scene components.
  70215. */
  70216. readonly name: string;
  70217. /**
  70218. * The scene the component belongs to.
  70219. */
  70220. scene: Scene;
  70221. /**
  70222. * Creates a new instance of the component for the given scene
  70223. * @param scene Defines the scene to register the component in
  70224. */
  70225. constructor(scene: Scene);
  70226. /**
  70227. * Registers the component in a given scene
  70228. */
  70229. register(): void;
  70230. /**
  70231. * Rebuilds the elements related to this component in case of
  70232. * context lost for instance.
  70233. */
  70234. rebuild(): void;
  70235. /**
  70236. * Disposes the component and the associated ressources
  70237. */
  70238. dispose(): void;
  70239. private _gatherRenderTargets;
  70240. private _gatherActiveCameraRenderTargets;
  70241. }
  70242. }
  70243. declare module "babylonjs/Shaders/outline.fragment" {
  70244. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70245. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70246. /** @hidden */
  70247. export var outlinePixelShader: {
  70248. name: string;
  70249. shader: string;
  70250. };
  70251. }
  70252. declare module "babylonjs/Shaders/outline.vertex" {
  70253. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70257. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70258. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70259. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70260. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70261. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70262. /** @hidden */
  70263. export var outlineVertexShader: {
  70264. name: string;
  70265. shader: string;
  70266. };
  70267. }
  70268. declare module "babylonjs/Rendering/outlineRenderer" {
  70269. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70270. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70271. import { Scene } from "babylonjs/scene";
  70272. import { ISceneComponent } from "babylonjs/sceneComponent";
  70273. import "babylonjs/Shaders/outline.fragment";
  70274. import "babylonjs/Shaders/outline.vertex";
  70275. module "babylonjs/scene" {
  70276. interface Scene {
  70277. /** @hidden */
  70278. _outlineRenderer: OutlineRenderer;
  70279. /**
  70280. * Gets the outline renderer associated with the scene
  70281. * @returns a OutlineRenderer
  70282. */
  70283. getOutlineRenderer(): OutlineRenderer;
  70284. }
  70285. }
  70286. module "babylonjs/Meshes/abstractMesh" {
  70287. interface AbstractMesh {
  70288. /** @hidden (Backing field) */
  70289. _renderOutline: boolean;
  70290. /**
  70291. * Gets or sets a boolean indicating if the outline must be rendered as well
  70292. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70293. */
  70294. renderOutline: boolean;
  70295. /** @hidden (Backing field) */
  70296. _renderOverlay: boolean;
  70297. /**
  70298. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70299. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70300. */
  70301. renderOverlay: boolean;
  70302. }
  70303. }
  70304. /**
  70305. * This class is responsible to draw bothe outline/overlay of meshes.
  70306. * It should not be used directly but through the available method on mesh.
  70307. */
  70308. export class OutlineRenderer implements ISceneComponent {
  70309. /**
  70310. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70311. */
  70312. private static _StencilReference;
  70313. /**
  70314. * The name of the component. Each component must have a unique name.
  70315. */
  70316. name: string;
  70317. /**
  70318. * The scene the component belongs to.
  70319. */
  70320. scene: Scene;
  70321. /**
  70322. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70323. */
  70324. zOffset: number;
  70325. private _engine;
  70326. private _effect;
  70327. private _cachedDefines;
  70328. private _savedDepthWrite;
  70329. /**
  70330. * Instantiates a new outline renderer. (There could be only one per scene).
  70331. * @param scene Defines the scene it belongs to
  70332. */
  70333. constructor(scene: Scene);
  70334. /**
  70335. * Register the component to one instance of a scene.
  70336. */
  70337. register(): void;
  70338. /**
  70339. * Rebuilds the elements related to this component in case of
  70340. * context lost for instance.
  70341. */
  70342. rebuild(): void;
  70343. /**
  70344. * Disposes the component and the associated ressources.
  70345. */
  70346. dispose(): void;
  70347. /**
  70348. * Renders the outline in the canvas.
  70349. * @param subMesh Defines the sumesh to render
  70350. * @param batch Defines the batch of meshes in case of instances
  70351. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70352. */
  70353. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70354. /**
  70355. * Returns whether or not the outline renderer is ready for a given submesh.
  70356. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70357. * @param subMesh Defines the submesh to check readyness for
  70358. * @param useInstances Defines wheter wee are trying to render instances or not
  70359. * @returns true if ready otherwise false
  70360. */
  70361. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70362. private _beforeRenderingMesh;
  70363. private _afterRenderingMesh;
  70364. }
  70365. }
  70366. declare module "babylonjs/Rendering/index" {
  70367. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70368. export * from "babylonjs/Rendering/depthRenderer";
  70369. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70370. export * from "babylonjs/Rendering/edgesRenderer";
  70371. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70372. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70373. export * from "babylonjs/Rendering/outlineRenderer";
  70374. export * from "babylonjs/Rendering/renderingGroup";
  70375. export * from "babylonjs/Rendering/renderingManager";
  70376. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70377. }
  70378. declare module "babylonjs/Sprites/ISprites" {
  70379. /**
  70380. * Defines the basic options interface of a Sprite Frame Source Size.
  70381. */
  70382. export interface ISpriteJSONSpriteSourceSize {
  70383. /**
  70384. * number of the original width of the Frame
  70385. */
  70386. w: number;
  70387. /**
  70388. * number of the original height of the Frame
  70389. */
  70390. h: number;
  70391. }
  70392. /**
  70393. * Defines the basic options interface of a Sprite Frame Data.
  70394. */
  70395. export interface ISpriteJSONSpriteFrameData {
  70396. /**
  70397. * number of the x offset of the Frame
  70398. */
  70399. x: number;
  70400. /**
  70401. * number of the y offset of the Frame
  70402. */
  70403. y: number;
  70404. /**
  70405. * number of the width of the Frame
  70406. */
  70407. w: number;
  70408. /**
  70409. * number of the height of the Frame
  70410. */
  70411. h: number;
  70412. }
  70413. /**
  70414. * Defines the basic options interface of a JSON Sprite.
  70415. */
  70416. export interface ISpriteJSONSprite {
  70417. /**
  70418. * string name of the Frame
  70419. */
  70420. filename: string;
  70421. /**
  70422. * ISpriteJSONSpriteFrame basic object of the frame data
  70423. */
  70424. frame: ISpriteJSONSpriteFrameData;
  70425. /**
  70426. * boolean to flag is the frame was rotated.
  70427. */
  70428. rotated: boolean;
  70429. /**
  70430. * boolean to flag is the frame was trimmed.
  70431. */
  70432. trimmed: boolean;
  70433. /**
  70434. * ISpriteJSONSpriteFrame basic object of the source data
  70435. */
  70436. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70437. /**
  70438. * ISpriteJSONSpriteFrame basic object of the source data
  70439. */
  70440. sourceSize: ISpriteJSONSpriteSourceSize;
  70441. }
  70442. /**
  70443. * Defines the basic options interface of a JSON atlas.
  70444. */
  70445. export interface ISpriteJSONAtlas {
  70446. /**
  70447. * Array of objects that contain the frame data.
  70448. */
  70449. frames: Array<ISpriteJSONSprite>;
  70450. /**
  70451. * object basic object containing the sprite meta data.
  70452. */
  70453. meta?: object;
  70454. }
  70455. }
  70456. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70457. /** @hidden */
  70458. export var spriteMapPixelShader: {
  70459. name: string;
  70460. shader: string;
  70461. };
  70462. }
  70463. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70464. /** @hidden */
  70465. export var spriteMapVertexShader: {
  70466. name: string;
  70467. shader: string;
  70468. };
  70469. }
  70470. declare module "babylonjs/Sprites/spriteMap" {
  70471. import { IDisposable, Scene } from "babylonjs/scene";
  70472. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70473. import { Texture } from "babylonjs/Materials/Textures/texture";
  70474. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70475. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70476. import "babylonjs/Meshes/Builders/planeBuilder";
  70477. import "babylonjs/Shaders/spriteMap.fragment";
  70478. import "babylonjs/Shaders/spriteMap.vertex";
  70479. /**
  70480. * Defines the basic options interface of a SpriteMap
  70481. */
  70482. export interface ISpriteMapOptions {
  70483. /**
  70484. * Vector2 of the number of cells in the grid.
  70485. */
  70486. stageSize?: Vector2;
  70487. /**
  70488. * Vector2 of the size of the output plane in World Units.
  70489. */
  70490. outputSize?: Vector2;
  70491. /**
  70492. * Vector3 of the position of the output plane in World Units.
  70493. */
  70494. outputPosition?: Vector3;
  70495. /**
  70496. * Vector3 of the rotation of the output plane.
  70497. */
  70498. outputRotation?: Vector3;
  70499. /**
  70500. * number of layers that the system will reserve in resources.
  70501. */
  70502. layerCount?: number;
  70503. /**
  70504. * number of max animation frames a single cell will reserve in resources.
  70505. */
  70506. maxAnimationFrames?: number;
  70507. /**
  70508. * number cell index of the base tile when the system compiles.
  70509. */
  70510. baseTile?: number;
  70511. /**
  70512. * boolean flip the sprite after its been repositioned by the framing data.
  70513. */
  70514. flipU?: boolean;
  70515. /**
  70516. * Vector3 scalar of the global RGB values of the SpriteMap.
  70517. */
  70518. colorMultiply?: Vector3;
  70519. }
  70520. /**
  70521. * Defines the IDisposable interface in order to be cleanable from resources.
  70522. */
  70523. export interface ISpriteMap extends IDisposable {
  70524. /**
  70525. * String name of the SpriteMap.
  70526. */
  70527. name: string;
  70528. /**
  70529. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70530. */
  70531. atlasJSON: ISpriteJSONAtlas;
  70532. /**
  70533. * Texture of the SpriteMap.
  70534. */
  70535. spriteSheet: Texture;
  70536. /**
  70537. * The parameters to initialize the SpriteMap with.
  70538. */
  70539. options: ISpriteMapOptions;
  70540. }
  70541. /**
  70542. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70543. */
  70544. export class SpriteMap implements ISpriteMap {
  70545. /** The Name of the spriteMap */
  70546. name: string;
  70547. /** The JSON file with the frame and meta data */
  70548. atlasJSON: ISpriteJSONAtlas;
  70549. /** The systems Sprite Sheet Texture */
  70550. spriteSheet: Texture;
  70551. /** Arguments passed with the Constructor */
  70552. options: ISpriteMapOptions;
  70553. /** Public Sprite Storage array, parsed from atlasJSON */
  70554. sprites: Array<ISpriteJSONSprite>;
  70555. /** Returns the Number of Sprites in the System */
  70556. get spriteCount(): number;
  70557. /** Returns the Position of Output Plane*/
  70558. get position(): Vector3;
  70559. /** Returns the Position of Output Plane*/
  70560. set position(v: Vector3);
  70561. /** Returns the Rotation of Output Plane*/
  70562. get rotation(): Vector3;
  70563. /** Returns the Rotation of Output Plane*/
  70564. set rotation(v: Vector3);
  70565. /** Sets the AnimationMap*/
  70566. get animationMap(): RawTexture;
  70567. /** Sets the AnimationMap*/
  70568. set animationMap(v: RawTexture);
  70569. /** Scene that the SpriteMap was created in */
  70570. private _scene;
  70571. /** Texture Buffer of Float32 that holds tile frame data*/
  70572. private _frameMap;
  70573. /** Texture Buffers of Float32 that holds tileMap data*/
  70574. private _tileMaps;
  70575. /** Texture Buffer of Float32 that holds Animation Data*/
  70576. private _animationMap;
  70577. /** Custom ShaderMaterial Central to the System*/
  70578. private _material;
  70579. /** Custom ShaderMaterial Central to the System*/
  70580. private _output;
  70581. /** Systems Time Ticker*/
  70582. private _time;
  70583. /**
  70584. * Creates a new SpriteMap
  70585. * @param name defines the SpriteMaps Name
  70586. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70587. * @param spriteSheet is the Texture that the Sprites are on.
  70588. * @param options a basic deployment configuration
  70589. * @param scene The Scene that the map is deployed on
  70590. */
  70591. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70592. /**
  70593. * Returns tileID location
  70594. * @returns Vector2 the cell position ID
  70595. */
  70596. getTileID(): Vector2;
  70597. /**
  70598. * Gets the UV location of the mouse over the SpriteMap.
  70599. * @returns Vector2 the UV position of the mouse interaction
  70600. */
  70601. getMousePosition(): Vector2;
  70602. /**
  70603. * Creates the "frame" texture Buffer
  70604. * -------------------------------------
  70605. * Structure of frames
  70606. * "filename": "Falling-Water-2.png",
  70607. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70608. * "rotated": true,
  70609. * "trimmed": true,
  70610. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70611. * "sourceSize": {"w":32,"h":32}
  70612. * @returns RawTexture of the frameMap
  70613. */
  70614. private _createFrameBuffer;
  70615. /**
  70616. * Creates the tileMap texture Buffer
  70617. * @param buffer normally and array of numbers, or a false to generate from scratch
  70618. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70619. * @returns RawTexture of the tileMap
  70620. */
  70621. private _createTileBuffer;
  70622. /**
  70623. * Modifies the data of the tileMaps
  70624. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70625. * @param pos is the iVector2 Coordinates of the Tile
  70626. * @param tile The SpriteIndex of the new Tile
  70627. */
  70628. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70629. /**
  70630. * Creates the animationMap texture Buffer
  70631. * @param buffer normally and array of numbers, or a false to generate from scratch
  70632. * @returns RawTexture of the animationMap
  70633. */
  70634. private _createTileAnimationBuffer;
  70635. /**
  70636. * Modifies the data of the animationMap
  70637. * @param cellID is the Index of the Sprite
  70638. * @param _frame is the target Animation frame
  70639. * @param toCell is the Target Index of the next frame of the animation
  70640. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70641. * @param speed is a global scalar of the time variable on the map.
  70642. */
  70643. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70644. /**
  70645. * Exports the .tilemaps file
  70646. */
  70647. saveTileMaps(): void;
  70648. /**
  70649. * Imports the .tilemaps file
  70650. * @param url of the .tilemaps file
  70651. */
  70652. loadTileMaps(url: string): void;
  70653. /**
  70654. * Release associated resources
  70655. */
  70656. dispose(): void;
  70657. }
  70658. }
  70659. declare module "babylonjs/Sprites/spritePackedManager" {
  70660. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70661. import { Scene } from "babylonjs/scene";
  70662. /**
  70663. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70664. * @see http://doc.babylonjs.com/babylon101/sprites
  70665. */
  70666. export class SpritePackedManager extends SpriteManager {
  70667. /** defines the packed manager's name */
  70668. name: string;
  70669. /**
  70670. * Creates a new sprite manager from a packed sprite sheet
  70671. * @param name defines the manager's name
  70672. * @param imgUrl defines the sprite sheet url
  70673. * @param capacity defines the maximum allowed number of sprites
  70674. * @param scene defines the hosting scene
  70675. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70676. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70677. * @param samplingMode defines the smapling mode to use with spritesheet
  70678. * @param fromPacked set to true; do not alter
  70679. */
  70680. constructor(
  70681. /** defines the packed manager's name */
  70682. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70683. }
  70684. }
  70685. declare module "babylonjs/Sprites/index" {
  70686. export * from "babylonjs/Sprites/sprite";
  70687. export * from "babylonjs/Sprites/ISprites";
  70688. export * from "babylonjs/Sprites/spriteManager";
  70689. export * from "babylonjs/Sprites/spriteMap";
  70690. export * from "babylonjs/Sprites/spritePackedManager";
  70691. export * from "babylonjs/Sprites/spriteSceneComponent";
  70692. }
  70693. declare module "babylonjs/States/index" {
  70694. export * from "babylonjs/States/alphaCullingState";
  70695. export * from "babylonjs/States/depthCullingState";
  70696. export * from "babylonjs/States/stencilState";
  70697. }
  70698. declare module "babylonjs/Misc/assetsManager" {
  70699. import { Scene } from "babylonjs/scene";
  70700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70701. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70702. import { Skeleton } from "babylonjs/Bones/skeleton";
  70703. import { Observable } from "babylonjs/Misc/observable";
  70704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70705. import { Texture } from "babylonjs/Materials/Textures/texture";
  70706. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70707. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70708. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70709. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70710. /**
  70711. * Defines the list of states available for a task inside a AssetsManager
  70712. */
  70713. export enum AssetTaskState {
  70714. /**
  70715. * Initialization
  70716. */
  70717. INIT = 0,
  70718. /**
  70719. * Running
  70720. */
  70721. RUNNING = 1,
  70722. /**
  70723. * Done
  70724. */
  70725. DONE = 2,
  70726. /**
  70727. * Error
  70728. */
  70729. ERROR = 3
  70730. }
  70731. /**
  70732. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70733. */
  70734. export abstract class AbstractAssetTask {
  70735. /**
  70736. * Task name
  70737. */ name: string;
  70738. /**
  70739. * Callback called when the task is successful
  70740. */
  70741. onSuccess: (task: any) => void;
  70742. /**
  70743. * Callback called when the task is not successful
  70744. */
  70745. onError: (task: any, message?: string, exception?: any) => void;
  70746. /**
  70747. * Creates a new AssetsManager
  70748. * @param name defines the name of the task
  70749. */
  70750. constructor(
  70751. /**
  70752. * Task name
  70753. */ name: string);
  70754. private _isCompleted;
  70755. private _taskState;
  70756. private _errorObject;
  70757. /**
  70758. * Get if the task is completed
  70759. */
  70760. get isCompleted(): boolean;
  70761. /**
  70762. * Gets the current state of the task
  70763. */
  70764. get taskState(): AssetTaskState;
  70765. /**
  70766. * Gets the current error object (if task is in error)
  70767. */
  70768. get errorObject(): {
  70769. message?: string;
  70770. exception?: any;
  70771. };
  70772. /**
  70773. * Internal only
  70774. * @hidden
  70775. */
  70776. _setErrorObject(message?: string, exception?: any): void;
  70777. /**
  70778. * Execute the current task
  70779. * @param scene defines the scene where you want your assets to be loaded
  70780. * @param onSuccess is a callback called when the task is successfully executed
  70781. * @param onError is a callback called if an error occurs
  70782. */
  70783. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70784. /**
  70785. * Execute the current task
  70786. * @param scene defines the scene where you want your assets to be loaded
  70787. * @param onSuccess is a callback called when the task is successfully executed
  70788. * @param onError is a callback called if an error occurs
  70789. */
  70790. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70791. /**
  70792. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70793. * This can be used with failed tasks that have the reason for failure fixed.
  70794. */
  70795. reset(): void;
  70796. private onErrorCallback;
  70797. private onDoneCallback;
  70798. }
  70799. /**
  70800. * Define the interface used by progress events raised during assets loading
  70801. */
  70802. export interface IAssetsProgressEvent {
  70803. /**
  70804. * Defines the number of remaining tasks to process
  70805. */
  70806. remainingCount: number;
  70807. /**
  70808. * Defines the total number of tasks
  70809. */
  70810. totalCount: number;
  70811. /**
  70812. * Defines the task that was just processed
  70813. */
  70814. task: AbstractAssetTask;
  70815. }
  70816. /**
  70817. * Class used to share progress information about assets loading
  70818. */
  70819. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70820. /**
  70821. * Defines the number of remaining tasks to process
  70822. */
  70823. remainingCount: number;
  70824. /**
  70825. * Defines the total number of tasks
  70826. */
  70827. totalCount: number;
  70828. /**
  70829. * Defines the task that was just processed
  70830. */
  70831. task: AbstractAssetTask;
  70832. /**
  70833. * Creates a AssetsProgressEvent
  70834. * @param remainingCount defines the number of remaining tasks to process
  70835. * @param totalCount defines the total number of tasks
  70836. * @param task defines the task that was just processed
  70837. */
  70838. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70839. }
  70840. /**
  70841. * Define a task used by AssetsManager to load meshes
  70842. */
  70843. export class MeshAssetTask extends AbstractAssetTask {
  70844. /**
  70845. * Defines the name of the task
  70846. */
  70847. name: string;
  70848. /**
  70849. * Defines the list of mesh's names you want to load
  70850. */
  70851. meshesNames: any;
  70852. /**
  70853. * Defines the root url to use as a base to load your meshes and associated resources
  70854. */
  70855. rootUrl: string;
  70856. /**
  70857. * Defines the filename of the scene to load from
  70858. */
  70859. sceneFilename: string;
  70860. /**
  70861. * Gets the list of loaded meshes
  70862. */
  70863. loadedMeshes: Array<AbstractMesh>;
  70864. /**
  70865. * Gets the list of loaded particle systems
  70866. */
  70867. loadedParticleSystems: Array<IParticleSystem>;
  70868. /**
  70869. * Gets the list of loaded skeletons
  70870. */
  70871. loadedSkeletons: Array<Skeleton>;
  70872. /**
  70873. * Gets the list of loaded animation groups
  70874. */
  70875. loadedAnimationGroups: Array<AnimationGroup>;
  70876. /**
  70877. * Callback called when the task is successful
  70878. */
  70879. onSuccess: (task: MeshAssetTask) => void;
  70880. /**
  70881. * Callback called when the task is successful
  70882. */
  70883. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70884. /**
  70885. * Creates a new MeshAssetTask
  70886. * @param name defines the name of the task
  70887. * @param meshesNames defines the list of mesh's names you want to load
  70888. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70889. * @param sceneFilename defines the filename of the scene to load from
  70890. */
  70891. constructor(
  70892. /**
  70893. * Defines the name of the task
  70894. */
  70895. name: string,
  70896. /**
  70897. * Defines the list of mesh's names you want to load
  70898. */
  70899. meshesNames: any,
  70900. /**
  70901. * Defines the root url to use as a base to load your meshes and associated resources
  70902. */
  70903. rootUrl: string,
  70904. /**
  70905. * Defines the filename of the scene to load from
  70906. */
  70907. sceneFilename: string);
  70908. /**
  70909. * Execute the current task
  70910. * @param scene defines the scene where you want your assets to be loaded
  70911. * @param onSuccess is a callback called when the task is successfully executed
  70912. * @param onError is a callback called if an error occurs
  70913. */
  70914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70915. }
  70916. /**
  70917. * Define a task used by AssetsManager to load text content
  70918. */
  70919. export class TextFileAssetTask extends AbstractAssetTask {
  70920. /**
  70921. * Defines the name of the task
  70922. */
  70923. name: string;
  70924. /**
  70925. * Defines the location of the file to load
  70926. */
  70927. url: string;
  70928. /**
  70929. * Gets the loaded text string
  70930. */
  70931. text: string;
  70932. /**
  70933. * Callback called when the task is successful
  70934. */
  70935. onSuccess: (task: TextFileAssetTask) => void;
  70936. /**
  70937. * Callback called when the task is successful
  70938. */
  70939. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70940. /**
  70941. * Creates a new TextFileAssetTask object
  70942. * @param name defines the name of the task
  70943. * @param url defines the location of the file to load
  70944. */
  70945. constructor(
  70946. /**
  70947. * Defines the name of the task
  70948. */
  70949. name: string,
  70950. /**
  70951. * Defines the location of the file to load
  70952. */
  70953. url: string);
  70954. /**
  70955. * Execute the current task
  70956. * @param scene defines the scene where you want your assets to be loaded
  70957. * @param onSuccess is a callback called when the task is successfully executed
  70958. * @param onError is a callback called if an error occurs
  70959. */
  70960. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70961. }
  70962. /**
  70963. * Define a task used by AssetsManager to load binary data
  70964. */
  70965. export class BinaryFileAssetTask extends AbstractAssetTask {
  70966. /**
  70967. * Defines the name of the task
  70968. */
  70969. name: string;
  70970. /**
  70971. * Defines the location of the file to load
  70972. */
  70973. url: string;
  70974. /**
  70975. * Gets the lodaded data (as an array buffer)
  70976. */
  70977. data: ArrayBuffer;
  70978. /**
  70979. * Callback called when the task is successful
  70980. */
  70981. onSuccess: (task: BinaryFileAssetTask) => void;
  70982. /**
  70983. * Callback called when the task is successful
  70984. */
  70985. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70986. /**
  70987. * Creates a new BinaryFileAssetTask object
  70988. * @param name defines the name of the new task
  70989. * @param url defines the location of the file to load
  70990. */
  70991. constructor(
  70992. /**
  70993. * Defines the name of the task
  70994. */
  70995. name: string,
  70996. /**
  70997. * Defines the location of the file to load
  70998. */
  70999. url: string);
  71000. /**
  71001. * Execute the current task
  71002. * @param scene defines the scene where you want your assets to be loaded
  71003. * @param onSuccess is a callback called when the task is successfully executed
  71004. * @param onError is a callback called if an error occurs
  71005. */
  71006. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71007. }
  71008. /**
  71009. * Define a task used by AssetsManager to load images
  71010. */
  71011. export class ImageAssetTask extends AbstractAssetTask {
  71012. /**
  71013. * Defines the name of the task
  71014. */
  71015. name: string;
  71016. /**
  71017. * Defines the location of the image to load
  71018. */
  71019. url: string;
  71020. /**
  71021. * Gets the loaded images
  71022. */
  71023. image: HTMLImageElement;
  71024. /**
  71025. * Callback called when the task is successful
  71026. */
  71027. onSuccess: (task: ImageAssetTask) => void;
  71028. /**
  71029. * Callback called when the task is successful
  71030. */
  71031. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71032. /**
  71033. * Creates a new ImageAssetTask
  71034. * @param name defines the name of the task
  71035. * @param url defines the location of the image to load
  71036. */
  71037. constructor(
  71038. /**
  71039. * Defines the name of the task
  71040. */
  71041. name: string,
  71042. /**
  71043. * Defines the location of the image to load
  71044. */
  71045. url: string);
  71046. /**
  71047. * Execute the current task
  71048. * @param scene defines the scene where you want your assets to be loaded
  71049. * @param onSuccess is a callback called when the task is successfully executed
  71050. * @param onError is a callback called if an error occurs
  71051. */
  71052. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71053. }
  71054. /**
  71055. * Defines the interface used by texture loading tasks
  71056. */
  71057. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71058. /**
  71059. * Gets the loaded texture
  71060. */
  71061. texture: TEX;
  71062. }
  71063. /**
  71064. * Define a task used by AssetsManager to load 2D textures
  71065. */
  71066. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71067. /**
  71068. * Defines the name of the task
  71069. */
  71070. name: string;
  71071. /**
  71072. * Defines the location of the file to load
  71073. */
  71074. url: string;
  71075. /**
  71076. * Defines if mipmap should not be generated (default is false)
  71077. */
  71078. noMipmap?: boolean | undefined;
  71079. /**
  71080. * Defines if texture must be inverted on Y axis (default is false)
  71081. */
  71082. invertY?: boolean | undefined;
  71083. /**
  71084. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71085. */
  71086. samplingMode: number;
  71087. /**
  71088. * Gets the loaded texture
  71089. */
  71090. texture: Texture;
  71091. /**
  71092. * Callback called when the task is successful
  71093. */
  71094. onSuccess: (task: TextureAssetTask) => void;
  71095. /**
  71096. * Callback called when the task is successful
  71097. */
  71098. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71099. /**
  71100. * Creates a new TextureAssetTask object
  71101. * @param name defines the name of the task
  71102. * @param url defines the location of the file to load
  71103. * @param noMipmap defines if mipmap should not be generated (default is false)
  71104. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71105. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71106. */
  71107. constructor(
  71108. /**
  71109. * Defines the name of the task
  71110. */
  71111. name: string,
  71112. /**
  71113. * Defines the location of the file to load
  71114. */
  71115. url: string,
  71116. /**
  71117. * Defines if mipmap should not be generated (default is false)
  71118. */
  71119. noMipmap?: boolean | undefined,
  71120. /**
  71121. * Defines if texture must be inverted on Y axis (default is false)
  71122. */
  71123. invertY?: boolean | undefined,
  71124. /**
  71125. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71126. */
  71127. samplingMode?: number);
  71128. /**
  71129. * Execute the current task
  71130. * @param scene defines the scene where you want your assets to be loaded
  71131. * @param onSuccess is a callback called when the task is successfully executed
  71132. * @param onError is a callback called if an error occurs
  71133. */
  71134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71135. }
  71136. /**
  71137. * Define a task used by AssetsManager to load cube textures
  71138. */
  71139. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71140. /**
  71141. * Defines the name of the task
  71142. */
  71143. name: string;
  71144. /**
  71145. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71146. */
  71147. url: string;
  71148. /**
  71149. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71150. */
  71151. extensions?: string[] | undefined;
  71152. /**
  71153. * Defines if mipmaps should not be generated (default is false)
  71154. */
  71155. noMipmap?: boolean | undefined;
  71156. /**
  71157. * Defines the explicit list of files (undefined by default)
  71158. */
  71159. files?: string[] | undefined;
  71160. /**
  71161. * Gets the loaded texture
  71162. */
  71163. texture: CubeTexture;
  71164. /**
  71165. * Callback called when the task is successful
  71166. */
  71167. onSuccess: (task: CubeTextureAssetTask) => void;
  71168. /**
  71169. * Callback called when the task is successful
  71170. */
  71171. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71172. /**
  71173. * Creates a new CubeTextureAssetTask
  71174. * @param name defines the name of the task
  71175. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71176. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71177. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71178. * @param files defines the explicit list of files (undefined by default)
  71179. */
  71180. constructor(
  71181. /**
  71182. * Defines the name of the task
  71183. */
  71184. name: string,
  71185. /**
  71186. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71187. */
  71188. url: string,
  71189. /**
  71190. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71191. */
  71192. extensions?: string[] | undefined,
  71193. /**
  71194. * Defines if mipmaps should not be generated (default is false)
  71195. */
  71196. noMipmap?: boolean | undefined,
  71197. /**
  71198. * Defines the explicit list of files (undefined by default)
  71199. */
  71200. files?: string[] | undefined);
  71201. /**
  71202. * Execute the current task
  71203. * @param scene defines the scene where you want your assets to be loaded
  71204. * @param onSuccess is a callback called when the task is successfully executed
  71205. * @param onError is a callback called if an error occurs
  71206. */
  71207. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71208. }
  71209. /**
  71210. * Define a task used by AssetsManager to load HDR cube textures
  71211. */
  71212. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71213. /**
  71214. * Defines the name of the task
  71215. */
  71216. name: string;
  71217. /**
  71218. * Defines the location of the file to load
  71219. */
  71220. url: string;
  71221. /**
  71222. * Defines the desired size (the more it increases the longer the generation will be)
  71223. */
  71224. size: number;
  71225. /**
  71226. * Defines if mipmaps should not be generated (default is false)
  71227. */
  71228. noMipmap: boolean;
  71229. /**
  71230. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71231. */
  71232. generateHarmonics: boolean;
  71233. /**
  71234. * 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)
  71235. */
  71236. gammaSpace: boolean;
  71237. /**
  71238. * Internal Use Only
  71239. */
  71240. reserved: boolean;
  71241. /**
  71242. * Gets the loaded texture
  71243. */
  71244. texture: HDRCubeTexture;
  71245. /**
  71246. * Callback called when the task is successful
  71247. */
  71248. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71249. /**
  71250. * Callback called when the task is successful
  71251. */
  71252. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71253. /**
  71254. * Creates a new HDRCubeTextureAssetTask object
  71255. * @param name defines the name of the task
  71256. * @param url defines the location of the file to load
  71257. * @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.
  71258. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71259. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71260. * @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)
  71261. * @param reserved Internal use only
  71262. */
  71263. constructor(
  71264. /**
  71265. * Defines the name of the task
  71266. */
  71267. name: string,
  71268. /**
  71269. * Defines the location of the file to load
  71270. */
  71271. url: string,
  71272. /**
  71273. * Defines the desired size (the more it increases the longer the generation will be)
  71274. */
  71275. size: number,
  71276. /**
  71277. * Defines if mipmaps should not be generated (default is false)
  71278. */
  71279. noMipmap?: boolean,
  71280. /**
  71281. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71282. */
  71283. generateHarmonics?: boolean,
  71284. /**
  71285. * 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)
  71286. */
  71287. gammaSpace?: boolean,
  71288. /**
  71289. * Internal Use Only
  71290. */
  71291. reserved?: boolean);
  71292. /**
  71293. * Execute the current task
  71294. * @param scene defines the scene where you want your assets to be loaded
  71295. * @param onSuccess is a callback called when the task is successfully executed
  71296. * @param onError is a callback called if an error occurs
  71297. */
  71298. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71299. }
  71300. /**
  71301. * Define a task used by AssetsManager to load Equirectangular cube textures
  71302. */
  71303. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71304. /**
  71305. * Defines the name of the task
  71306. */
  71307. name: string;
  71308. /**
  71309. * Defines the location of the file to load
  71310. */
  71311. url: string;
  71312. /**
  71313. * Defines the desired size (the more it increases the longer the generation will be)
  71314. */
  71315. size: number;
  71316. /**
  71317. * Defines if mipmaps should not be generated (default is false)
  71318. */
  71319. noMipmap: boolean;
  71320. /**
  71321. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71322. * but the standard material would require them in Gamma space) (default is true)
  71323. */
  71324. gammaSpace: boolean;
  71325. /**
  71326. * Gets the loaded texture
  71327. */
  71328. texture: EquiRectangularCubeTexture;
  71329. /**
  71330. * Callback called when the task is successful
  71331. */
  71332. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71333. /**
  71334. * Callback called when the task is successful
  71335. */
  71336. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71337. /**
  71338. * Creates a new EquiRectangularCubeTextureAssetTask object
  71339. * @param name defines the name of the task
  71340. * @param url defines the location of the file to load
  71341. * @param size defines the desired size (the more it increases the longer the generation will be)
  71342. * If the size is omitted this implies you are using a preprocessed cubemap.
  71343. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71344. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71345. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71346. * (default is true)
  71347. */
  71348. constructor(
  71349. /**
  71350. * Defines the name of the task
  71351. */
  71352. name: string,
  71353. /**
  71354. * Defines the location of the file to load
  71355. */
  71356. url: string,
  71357. /**
  71358. * Defines the desired size (the more it increases the longer the generation will be)
  71359. */
  71360. size: number,
  71361. /**
  71362. * Defines if mipmaps should not be generated (default is false)
  71363. */
  71364. noMipmap?: boolean,
  71365. /**
  71366. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71367. * but the standard material would require them in Gamma space) (default is true)
  71368. */
  71369. gammaSpace?: boolean);
  71370. /**
  71371. * Execute the current task
  71372. * @param scene defines the scene where you want your assets to be loaded
  71373. * @param onSuccess is a callback called when the task is successfully executed
  71374. * @param onError is a callback called if an error occurs
  71375. */
  71376. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71377. }
  71378. /**
  71379. * This class can be used to easily import assets into a scene
  71380. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71381. */
  71382. export class AssetsManager {
  71383. private _scene;
  71384. private _isLoading;
  71385. protected _tasks: AbstractAssetTask[];
  71386. protected _waitingTasksCount: number;
  71387. protected _totalTasksCount: number;
  71388. /**
  71389. * Callback called when all tasks are processed
  71390. */
  71391. onFinish: (tasks: AbstractAssetTask[]) => void;
  71392. /**
  71393. * Callback called when a task is successful
  71394. */
  71395. onTaskSuccess: (task: AbstractAssetTask) => void;
  71396. /**
  71397. * Callback called when a task had an error
  71398. */
  71399. onTaskError: (task: AbstractAssetTask) => void;
  71400. /**
  71401. * Callback called when a task is done (whatever the result is)
  71402. */
  71403. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71404. /**
  71405. * Observable called when all tasks are processed
  71406. */
  71407. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71408. /**
  71409. * Observable called when a task had an error
  71410. */
  71411. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71412. /**
  71413. * Observable called when all tasks were executed
  71414. */
  71415. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71416. /**
  71417. * Observable called when a task is done (whatever the result is)
  71418. */
  71419. onProgressObservable: Observable<IAssetsProgressEvent>;
  71420. /**
  71421. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71422. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71423. */
  71424. useDefaultLoadingScreen: boolean;
  71425. /**
  71426. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71427. * when all assets have been downloaded.
  71428. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71429. */
  71430. autoHideLoadingUI: boolean;
  71431. /**
  71432. * Creates a new AssetsManager
  71433. * @param scene defines the scene to work on
  71434. */
  71435. constructor(scene: Scene);
  71436. /**
  71437. * Add a MeshAssetTask to the list of active tasks
  71438. * @param taskName defines the name of the new task
  71439. * @param meshesNames defines the name of meshes to load
  71440. * @param rootUrl defines the root url to use to locate files
  71441. * @param sceneFilename defines the filename of the scene file
  71442. * @returns a new MeshAssetTask object
  71443. */
  71444. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71445. /**
  71446. * Add a TextFileAssetTask to the list of active tasks
  71447. * @param taskName defines the name of the new task
  71448. * @param url defines the url of the file to load
  71449. * @returns a new TextFileAssetTask object
  71450. */
  71451. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71452. /**
  71453. * Add a BinaryFileAssetTask to the list of active tasks
  71454. * @param taskName defines the name of the new task
  71455. * @param url defines the url of the file to load
  71456. * @returns a new BinaryFileAssetTask object
  71457. */
  71458. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71459. /**
  71460. * Add a ImageAssetTask to the list of active tasks
  71461. * @param taskName defines the name of the new task
  71462. * @param url defines the url of the file to load
  71463. * @returns a new ImageAssetTask object
  71464. */
  71465. addImageTask(taskName: string, url: string): ImageAssetTask;
  71466. /**
  71467. * Add a TextureAssetTask to the list of active tasks
  71468. * @param taskName defines the name of the new task
  71469. * @param url defines the url of the file to load
  71470. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71471. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71472. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71473. * @returns a new TextureAssetTask object
  71474. */
  71475. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71476. /**
  71477. * Add a CubeTextureAssetTask to the list of active tasks
  71478. * @param taskName defines the name of the new task
  71479. * @param url defines the url of the file to load
  71480. * @param extensions defines the extension to use to load the cube map (can be null)
  71481. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71482. * @param files defines the list of files to load (can be null)
  71483. * @returns a new CubeTextureAssetTask object
  71484. */
  71485. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71486. /**
  71487. *
  71488. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71489. * @param taskName defines the name of the new task
  71490. * @param url defines the url of the file to load
  71491. * @param size defines the size you want for the cubemap (can be null)
  71492. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71493. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71494. * @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)
  71495. * @param reserved Internal use only
  71496. * @returns a new HDRCubeTextureAssetTask object
  71497. */
  71498. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71499. /**
  71500. *
  71501. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71502. * @param taskName defines the name of the new task
  71503. * @param url defines the url of the file to load
  71504. * @param size defines the size you want for the cubemap (can be null)
  71505. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71506. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71507. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71508. * @returns a new EquiRectangularCubeTextureAssetTask object
  71509. */
  71510. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71511. /**
  71512. * Remove a task from the assets manager.
  71513. * @param task the task to remove
  71514. */
  71515. removeTask(task: AbstractAssetTask): void;
  71516. private _decreaseWaitingTasksCount;
  71517. private _runTask;
  71518. /**
  71519. * Reset the AssetsManager and remove all tasks
  71520. * @return the current instance of the AssetsManager
  71521. */
  71522. reset(): AssetsManager;
  71523. /**
  71524. * Start the loading process
  71525. * @return the current instance of the AssetsManager
  71526. */
  71527. load(): AssetsManager;
  71528. /**
  71529. * Start the loading process as an async operation
  71530. * @return a promise returning the list of failed tasks
  71531. */
  71532. loadAsync(): Promise<void>;
  71533. }
  71534. }
  71535. declare module "babylonjs/Misc/deferred" {
  71536. /**
  71537. * Wrapper class for promise with external resolve and reject.
  71538. */
  71539. export class Deferred<T> {
  71540. /**
  71541. * The promise associated with this deferred object.
  71542. */
  71543. readonly promise: Promise<T>;
  71544. private _resolve;
  71545. private _reject;
  71546. /**
  71547. * The resolve method of the promise associated with this deferred object.
  71548. */
  71549. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71550. /**
  71551. * The reject method of the promise associated with this deferred object.
  71552. */
  71553. get reject(): (reason?: any) => void;
  71554. /**
  71555. * Constructor for this deferred object.
  71556. */
  71557. constructor();
  71558. }
  71559. }
  71560. declare module "babylonjs/Misc/meshExploder" {
  71561. import { Mesh } from "babylonjs/Meshes/mesh";
  71562. /**
  71563. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71564. */
  71565. export class MeshExploder {
  71566. private _centerMesh;
  71567. private _meshes;
  71568. private _meshesOrigins;
  71569. private _toCenterVectors;
  71570. private _scaledDirection;
  71571. private _newPosition;
  71572. private _centerPosition;
  71573. /**
  71574. * Explodes meshes from a center mesh.
  71575. * @param meshes The meshes to explode.
  71576. * @param centerMesh The mesh to be center of explosion.
  71577. */
  71578. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71579. private _setCenterMesh;
  71580. /**
  71581. * Get class name
  71582. * @returns "MeshExploder"
  71583. */
  71584. getClassName(): string;
  71585. /**
  71586. * "Exploded meshes"
  71587. * @returns Array of meshes with the centerMesh at index 0.
  71588. */
  71589. getMeshes(): Array<Mesh>;
  71590. /**
  71591. * Explodes meshes giving a specific direction
  71592. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71593. */
  71594. explode(direction?: number): void;
  71595. }
  71596. }
  71597. declare module "babylonjs/Misc/filesInput" {
  71598. import { Engine } from "babylonjs/Engines/engine";
  71599. import { Scene } from "babylonjs/scene";
  71600. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71601. /**
  71602. * Class used to help managing file picking and drag'n'drop
  71603. */
  71604. export class FilesInput {
  71605. /**
  71606. * List of files ready to be loaded
  71607. */
  71608. static get FilesToLoad(): {
  71609. [key: string]: File;
  71610. };
  71611. /**
  71612. * Callback called when a file is processed
  71613. */
  71614. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71615. private _engine;
  71616. private _currentScene;
  71617. private _sceneLoadedCallback;
  71618. private _progressCallback;
  71619. private _additionalRenderLoopLogicCallback;
  71620. private _textureLoadingCallback;
  71621. private _startingProcessingFilesCallback;
  71622. private _onReloadCallback;
  71623. private _errorCallback;
  71624. private _elementToMonitor;
  71625. private _sceneFileToLoad;
  71626. private _filesToLoad;
  71627. /**
  71628. * Creates a new FilesInput
  71629. * @param engine defines the rendering engine
  71630. * @param scene defines the hosting scene
  71631. * @param sceneLoadedCallback callback called when scene is loaded
  71632. * @param progressCallback callback called to track progress
  71633. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71634. * @param textureLoadingCallback callback called when a texture is loading
  71635. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71636. * @param onReloadCallback callback called when a reload is requested
  71637. * @param errorCallback callback call if an error occurs
  71638. */
  71639. 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);
  71640. private _dragEnterHandler;
  71641. private _dragOverHandler;
  71642. private _dropHandler;
  71643. /**
  71644. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71645. * @param elementToMonitor defines the DOM element to track
  71646. */
  71647. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71648. /**
  71649. * Release all associated resources
  71650. */
  71651. dispose(): void;
  71652. private renderFunction;
  71653. private drag;
  71654. private drop;
  71655. private _traverseFolder;
  71656. private _processFiles;
  71657. /**
  71658. * Load files from a drop event
  71659. * @param event defines the drop event to use as source
  71660. */
  71661. loadFiles(event: any): void;
  71662. private _processReload;
  71663. /**
  71664. * Reload the current scene from the loaded files
  71665. */
  71666. reload(): void;
  71667. }
  71668. }
  71669. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71670. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71671. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71672. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71673. }
  71674. declare module "babylonjs/Misc/sceneOptimizer" {
  71675. import { Scene, IDisposable } from "babylonjs/scene";
  71676. import { Observable } from "babylonjs/Misc/observable";
  71677. /**
  71678. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71680. */
  71681. export class SceneOptimization {
  71682. /**
  71683. * Defines the priority of this optimization (0 by default which means first in the list)
  71684. */
  71685. priority: number;
  71686. /**
  71687. * Gets a string describing the action executed by the current optimization
  71688. * @returns description string
  71689. */
  71690. getDescription(): string;
  71691. /**
  71692. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71693. * @param scene defines the current scene where to apply this optimization
  71694. * @param optimizer defines the current optimizer
  71695. * @returns true if everything that can be done was applied
  71696. */
  71697. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71698. /**
  71699. * Creates the SceneOptimization object
  71700. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71701. * @param desc defines the description associated with the optimization
  71702. */
  71703. constructor(
  71704. /**
  71705. * Defines the priority of this optimization (0 by default which means first in the list)
  71706. */
  71707. priority?: number);
  71708. }
  71709. /**
  71710. * Defines an optimization used to reduce the size of render target textures
  71711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71712. */
  71713. export class TextureOptimization extends SceneOptimization {
  71714. /**
  71715. * Defines the priority of this optimization (0 by default which means first in the list)
  71716. */
  71717. priority: number;
  71718. /**
  71719. * 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
  71720. */
  71721. maximumSize: number;
  71722. /**
  71723. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71724. */
  71725. step: number;
  71726. /**
  71727. * Gets a string describing the action executed by the current optimization
  71728. * @returns description string
  71729. */
  71730. getDescription(): string;
  71731. /**
  71732. * Creates the TextureOptimization object
  71733. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71734. * @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
  71735. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71736. */
  71737. constructor(
  71738. /**
  71739. * Defines the priority of this optimization (0 by default which means first in the list)
  71740. */
  71741. priority?: number,
  71742. /**
  71743. * 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
  71744. */
  71745. maximumSize?: number,
  71746. /**
  71747. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71748. */
  71749. step?: number);
  71750. /**
  71751. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71752. * @param scene defines the current scene where to apply this optimization
  71753. * @param optimizer defines the current optimizer
  71754. * @returns true if everything that can be done was applied
  71755. */
  71756. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71757. }
  71758. /**
  71759. * Defines an optimization used to increase or decrease the rendering resolution
  71760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71761. */
  71762. export class HardwareScalingOptimization extends SceneOptimization {
  71763. /**
  71764. * Defines the priority of this optimization (0 by default which means first in the list)
  71765. */
  71766. priority: number;
  71767. /**
  71768. * Defines the maximum scale to use (2 by default)
  71769. */
  71770. maximumScale: number;
  71771. /**
  71772. * Defines the step to use between two passes (0.5 by default)
  71773. */
  71774. step: number;
  71775. private _currentScale;
  71776. private _directionOffset;
  71777. /**
  71778. * Gets a string describing the action executed by the current optimization
  71779. * @return description string
  71780. */
  71781. getDescription(): string;
  71782. /**
  71783. * Creates the HardwareScalingOptimization object
  71784. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71785. * @param maximumScale defines the maximum scale to use (2 by default)
  71786. * @param step defines the step to use between two passes (0.5 by default)
  71787. */
  71788. constructor(
  71789. /**
  71790. * Defines the priority of this optimization (0 by default which means first in the list)
  71791. */
  71792. priority?: number,
  71793. /**
  71794. * Defines the maximum scale to use (2 by default)
  71795. */
  71796. maximumScale?: number,
  71797. /**
  71798. * Defines the step to use between two passes (0.5 by default)
  71799. */
  71800. step?: number);
  71801. /**
  71802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71803. * @param scene defines the current scene where to apply this optimization
  71804. * @param optimizer defines the current optimizer
  71805. * @returns true if everything that can be done was applied
  71806. */
  71807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71808. }
  71809. /**
  71810. * Defines an optimization used to remove shadows
  71811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71812. */
  71813. export class ShadowsOptimization extends SceneOptimization {
  71814. /**
  71815. * Gets a string describing the action executed by the current optimization
  71816. * @return description string
  71817. */
  71818. getDescription(): string;
  71819. /**
  71820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71821. * @param scene defines the current scene where to apply this optimization
  71822. * @param optimizer defines the current optimizer
  71823. * @returns true if everything that can be done was applied
  71824. */
  71825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71826. }
  71827. /**
  71828. * Defines an optimization used to turn post-processes off
  71829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71830. */
  71831. export class PostProcessesOptimization extends SceneOptimization {
  71832. /**
  71833. * Gets a string describing the action executed by the current optimization
  71834. * @return description string
  71835. */
  71836. getDescription(): string;
  71837. /**
  71838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71839. * @param scene defines the current scene where to apply this optimization
  71840. * @param optimizer defines the current optimizer
  71841. * @returns true if everything that can be done was applied
  71842. */
  71843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71844. }
  71845. /**
  71846. * Defines an optimization used to turn lens flares off
  71847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71848. */
  71849. export class LensFlaresOptimization extends SceneOptimization {
  71850. /**
  71851. * Gets a string describing the action executed by the current optimization
  71852. * @return description string
  71853. */
  71854. getDescription(): string;
  71855. /**
  71856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71857. * @param scene defines the current scene where to apply this optimization
  71858. * @param optimizer defines the current optimizer
  71859. * @returns true if everything that can be done was applied
  71860. */
  71861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71862. }
  71863. /**
  71864. * Defines an optimization based on user defined callback.
  71865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71866. */
  71867. export class CustomOptimization extends SceneOptimization {
  71868. /**
  71869. * Callback called to apply the custom optimization.
  71870. */
  71871. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71872. /**
  71873. * Callback called to get custom description
  71874. */
  71875. onGetDescription: () => string;
  71876. /**
  71877. * Gets a string describing the action executed by the current optimization
  71878. * @returns description string
  71879. */
  71880. getDescription(): string;
  71881. /**
  71882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71883. * @param scene defines the current scene where to apply this optimization
  71884. * @param optimizer defines the current optimizer
  71885. * @returns true if everything that can be done was applied
  71886. */
  71887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71888. }
  71889. /**
  71890. * Defines an optimization used to turn particles off
  71891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71892. */
  71893. export class ParticlesOptimization extends SceneOptimization {
  71894. /**
  71895. * Gets a string describing the action executed by the current optimization
  71896. * @return description string
  71897. */
  71898. getDescription(): string;
  71899. /**
  71900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71901. * @param scene defines the current scene where to apply this optimization
  71902. * @param optimizer defines the current optimizer
  71903. * @returns true if everything that can be done was applied
  71904. */
  71905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71906. }
  71907. /**
  71908. * Defines an optimization used to turn render targets off
  71909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71910. */
  71911. export class RenderTargetsOptimization extends SceneOptimization {
  71912. /**
  71913. * Gets a string describing the action executed by the current optimization
  71914. * @return description string
  71915. */
  71916. getDescription(): string;
  71917. /**
  71918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71919. * @param scene defines the current scene where to apply this optimization
  71920. * @param optimizer defines the current optimizer
  71921. * @returns true if everything that can be done was applied
  71922. */
  71923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71924. }
  71925. /**
  71926. * Defines an optimization used to merge meshes with compatible materials
  71927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71928. */
  71929. export class MergeMeshesOptimization extends SceneOptimization {
  71930. private static _UpdateSelectionTree;
  71931. /**
  71932. * Gets or sets a boolean which defines if optimization octree has to be updated
  71933. */
  71934. static get UpdateSelectionTree(): boolean;
  71935. /**
  71936. * Gets or sets a boolean which defines if optimization octree has to be updated
  71937. */
  71938. static set UpdateSelectionTree(value: boolean);
  71939. /**
  71940. * Gets a string describing the action executed by the current optimization
  71941. * @return description string
  71942. */
  71943. getDescription(): string;
  71944. private _canBeMerged;
  71945. /**
  71946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71947. * @param scene defines the current scene where to apply this optimization
  71948. * @param optimizer defines the current optimizer
  71949. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71950. * @returns true if everything that can be done was applied
  71951. */
  71952. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71953. }
  71954. /**
  71955. * Defines a list of options used by SceneOptimizer
  71956. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71957. */
  71958. export class SceneOptimizerOptions {
  71959. /**
  71960. * Defines the target frame rate to reach (60 by default)
  71961. */
  71962. targetFrameRate: number;
  71963. /**
  71964. * Defines the interval between two checkes (2000ms by default)
  71965. */
  71966. trackerDuration: number;
  71967. /**
  71968. * Gets the list of optimizations to apply
  71969. */
  71970. optimizations: SceneOptimization[];
  71971. /**
  71972. * Creates a new list of options used by SceneOptimizer
  71973. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71974. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71975. */
  71976. constructor(
  71977. /**
  71978. * Defines the target frame rate to reach (60 by default)
  71979. */
  71980. targetFrameRate?: number,
  71981. /**
  71982. * Defines the interval between two checkes (2000ms by default)
  71983. */
  71984. trackerDuration?: number);
  71985. /**
  71986. * Add a new optimization
  71987. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71988. * @returns the current SceneOptimizerOptions
  71989. */
  71990. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71991. /**
  71992. * Add a new custom optimization
  71993. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71994. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71995. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71996. * @returns the current SceneOptimizerOptions
  71997. */
  71998. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71999. /**
  72000. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72001. * @param targetFrameRate defines the target frame rate (60 by default)
  72002. * @returns a SceneOptimizerOptions object
  72003. */
  72004. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72005. /**
  72006. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72007. * @param targetFrameRate defines the target frame rate (60 by default)
  72008. * @returns a SceneOptimizerOptions object
  72009. */
  72010. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72011. /**
  72012. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72013. * @param targetFrameRate defines the target frame rate (60 by default)
  72014. * @returns a SceneOptimizerOptions object
  72015. */
  72016. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72017. }
  72018. /**
  72019. * Class used to run optimizations in order to reach a target frame rate
  72020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72021. */
  72022. export class SceneOptimizer implements IDisposable {
  72023. private _isRunning;
  72024. private _options;
  72025. private _scene;
  72026. private _currentPriorityLevel;
  72027. private _targetFrameRate;
  72028. private _trackerDuration;
  72029. private _currentFrameRate;
  72030. private _sceneDisposeObserver;
  72031. private _improvementMode;
  72032. /**
  72033. * Defines an observable called when the optimizer reaches the target frame rate
  72034. */
  72035. onSuccessObservable: Observable<SceneOptimizer>;
  72036. /**
  72037. * Defines an observable called when the optimizer enables an optimization
  72038. */
  72039. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72040. /**
  72041. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72042. */
  72043. onFailureObservable: Observable<SceneOptimizer>;
  72044. /**
  72045. * Gets a boolean indicating if the optimizer is in improvement mode
  72046. */
  72047. get isInImprovementMode(): boolean;
  72048. /**
  72049. * Gets the current priority level (0 at start)
  72050. */
  72051. get currentPriorityLevel(): number;
  72052. /**
  72053. * Gets the current frame rate checked by the SceneOptimizer
  72054. */
  72055. get currentFrameRate(): number;
  72056. /**
  72057. * Gets or sets the current target frame rate (60 by default)
  72058. */
  72059. get targetFrameRate(): number;
  72060. /**
  72061. * Gets or sets the current target frame rate (60 by default)
  72062. */
  72063. set targetFrameRate(value: number);
  72064. /**
  72065. * Gets or sets the current interval between two checks (every 2000ms by default)
  72066. */
  72067. get trackerDuration(): number;
  72068. /**
  72069. * Gets or sets the current interval between two checks (every 2000ms by default)
  72070. */
  72071. set trackerDuration(value: number);
  72072. /**
  72073. * Gets the list of active optimizations
  72074. */
  72075. get optimizations(): SceneOptimization[];
  72076. /**
  72077. * Creates a new SceneOptimizer
  72078. * @param scene defines the scene to work on
  72079. * @param options defines the options to use with the SceneOptimizer
  72080. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72081. * @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)
  72082. */
  72083. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72084. /**
  72085. * Stops the current optimizer
  72086. */
  72087. stop(): void;
  72088. /**
  72089. * Reset the optimizer to initial step (current priority level = 0)
  72090. */
  72091. reset(): void;
  72092. /**
  72093. * Start the optimizer. By default it will try to reach a specific framerate
  72094. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72095. */
  72096. start(): void;
  72097. private _checkCurrentState;
  72098. /**
  72099. * Release all resources
  72100. */
  72101. dispose(): void;
  72102. /**
  72103. * Helper function to create a SceneOptimizer with one single line of code
  72104. * @param scene defines the scene to work on
  72105. * @param options defines the options to use with the SceneOptimizer
  72106. * @param onSuccess defines a callback to call on success
  72107. * @param onFailure defines a callback to call on failure
  72108. * @returns the new SceneOptimizer object
  72109. */
  72110. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72111. }
  72112. }
  72113. declare module "babylonjs/Misc/sceneSerializer" {
  72114. import { Scene } from "babylonjs/scene";
  72115. /**
  72116. * Class used to serialize a scene into a string
  72117. */
  72118. export class SceneSerializer {
  72119. /**
  72120. * Clear cache used by a previous serialization
  72121. */
  72122. static ClearCache(): void;
  72123. /**
  72124. * Serialize a scene into a JSON compatible object
  72125. * @param scene defines the scene to serialize
  72126. * @returns a JSON compatible object
  72127. */
  72128. static Serialize(scene: Scene): any;
  72129. /**
  72130. * Serialize a mesh into a JSON compatible object
  72131. * @param toSerialize defines the mesh to serialize
  72132. * @param withParents defines if parents must be serialized as well
  72133. * @param withChildren defines if children must be serialized as well
  72134. * @returns a JSON compatible object
  72135. */
  72136. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72137. }
  72138. }
  72139. declare module "babylonjs/Misc/textureTools" {
  72140. import { Texture } from "babylonjs/Materials/Textures/texture";
  72141. /**
  72142. * Class used to host texture specific utilities
  72143. */
  72144. export class TextureTools {
  72145. /**
  72146. * Uses the GPU to create a copy texture rescaled at a given size
  72147. * @param texture Texture to copy from
  72148. * @param width defines the desired width
  72149. * @param height defines the desired height
  72150. * @param useBilinearMode defines if bilinear mode has to be used
  72151. * @return the generated texture
  72152. */
  72153. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72154. }
  72155. }
  72156. declare module "babylonjs/Misc/videoRecorder" {
  72157. import { Nullable } from "babylonjs/types";
  72158. import { Engine } from "babylonjs/Engines/engine";
  72159. /**
  72160. * This represents the different options available for the video capture.
  72161. */
  72162. export interface VideoRecorderOptions {
  72163. /** Defines the mime type of the video. */
  72164. mimeType: string;
  72165. /** Defines the FPS the video should be recorded at. */
  72166. fps: number;
  72167. /** Defines the chunk size for the recording data. */
  72168. recordChunckSize: number;
  72169. /** The audio tracks to attach to the recording. */
  72170. audioTracks?: MediaStreamTrack[];
  72171. }
  72172. /**
  72173. * This can help with recording videos from BabylonJS.
  72174. * This is based on the available WebRTC functionalities of the browser.
  72175. *
  72176. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72177. */
  72178. export class VideoRecorder {
  72179. private static readonly _defaultOptions;
  72180. /**
  72181. * Returns whether or not the VideoRecorder is available in your browser.
  72182. * @param engine Defines the Babylon Engine.
  72183. * @returns true if supported otherwise false.
  72184. */
  72185. static IsSupported(engine: Engine): boolean;
  72186. private readonly _options;
  72187. private _canvas;
  72188. private _mediaRecorder;
  72189. private _recordedChunks;
  72190. private _fileName;
  72191. private _resolve;
  72192. private _reject;
  72193. /**
  72194. * True when a recording is already in progress.
  72195. */
  72196. get isRecording(): boolean;
  72197. /**
  72198. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72199. * @param engine Defines the BabylonJS Engine you wish to record.
  72200. * @param options Defines options that can be used to customize the capture.
  72201. */
  72202. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72203. /**
  72204. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72205. */
  72206. stopRecording(): void;
  72207. /**
  72208. * Starts recording the canvas for a max duration specified in parameters.
  72209. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72210. * If null no automatic download will start and you can rely on the promise to get the data back.
  72211. * @param maxDuration Defines the maximum recording time in seconds.
  72212. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72213. * @return A promise callback at the end of the recording with the video data in Blob.
  72214. */
  72215. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72216. /**
  72217. * Releases internal resources used during the recording.
  72218. */
  72219. dispose(): void;
  72220. private _handleDataAvailable;
  72221. private _handleError;
  72222. private _handleStop;
  72223. }
  72224. }
  72225. declare module "babylonjs/Misc/screenshotTools" {
  72226. import { Camera } from "babylonjs/Cameras/camera";
  72227. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72228. import { Engine } from "babylonjs/Engines/engine";
  72229. /**
  72230. * Class containing a set of static utilities functions for screenshots
  72231. */
  72232. export class ScreenshotTools {
  72233. /**
  72234. * Captures a screenshot of the current rendering
  72235. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72236. * @param engine defines the rendering engine
  72237. * @param camera defines the source camera
  72238. * @param size This parameter can be set to a single number or to an object with the
  72239. * following (optional) properties: precision, width, height. If a single number is passed,
  72240. * it will be used for both width and height. If an object is passed, the screenshot size
  72241. * will be derived from the parameters. The precision property is a multiplier allowing
  72242. * rendering at a higher or lower resolution
  72243. * @param successCallback defines the callback receives a single parameter which contains the
  72244. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72245. * src parameter of an <img> to display it
  72246. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72247. * Check your browser for supported MIME types
  72248. */
  72249. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72250. /**
  72251. * Captures a screenshot of the current rendering
  72252. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72253. * @param engine defines the rendering engine
  72254. * @param camera defines the source camera
  72255. * @param size This parameter can be set to a single number or to an object with the
  72256. * following (optional) properties: precision, width, height. If a single number is passed,
  72257. * it will be used for both width and height. If an object is passed, the screenshot size
  72258. * will be derived from the parameters. The precision property is a multiplier allowing
  72259. * rendering at a higher or lower resolution
  72260. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72261. * Check your browser for supported MIME types
  72262. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72263. * to the src parameter of an <img> to display it
  72264. */
  72265. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72266. /**
  72267. * Generates an image screenshot from the specified camera.
  72268. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72269. * @param engine The engine to use for rendering
  72270. * @param camera The camera to use for rendering
  72271. * @param size This parameter can be set to a single number or to an object with the
  72272. * following (optional) properties: precision, width, height. If a single number is passed,
  72273. * it will be used for both width and height. If an object is passed, the screenshot size
  72274. * will be derived from the parameters. The precision property is a multiplier allowing
  72275. * rendering at a higher or lower resolution
  72276. * @param successCallback The callback receives a single parameter which contains the
  72277. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72278. * src parameter of an <img> to display it
  72279. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72280. * Check your browser for supported MIME types
  72281. * @param samples Texture samples (default: 1)
  72282. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72283. * @param fileName A name for for the downloaded file.
  72284. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72285. */
  72286. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72287. /**
  72288. * Generates an image screenshot from the specified camera.
  72289. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72290. * @param engine The engine to use for rendering
  72291. * @param camera The camera to use for rendering
  72292. * @param size This parameter can be set to a single number or to an object with the
  72293. * following (optional) properties: precision, width, height. If a single number is passed,
  72294. * it will be used for both width and height. If an object is passed, the screenshot size
  72295. * will be derived from the parameters. The precision property is a multiplier allowing
  72296. * rendering at a higher or lower resolution
  72297. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72298. * Check your browser for supported MIME types
  72299. * @param samples Texture samples (default: 1)
  72300. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72301. * @param fileName A name for for the downloaded file.
  72302. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72303. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72304. * to the src parameter of an <img> to display it
  72305. */
  72306. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72307. /**
  72308. * Gets height and width for screenshot size
  72309. * @private
  72310. */
  72311. private static _getScreenshotSize;
  72312. }
  72313. }
  72314. declare module "babylonjs/Misc/dataReader" {
  72315. /**
  72316. * Interface for a data buffer
  72317. */
  72318. export interface IDataBuffer {
  72319. /**
  72320. * Reads bytes from the data buffer.
  72321. * @param byteOffset The byte offset to read
  72322. * @param byteLength The byte length to read
  72323. * @returns A promise that resolves when the bytes are read
  72324. */
  72325. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72326. /**
  72327. * The byte length of the buffer.
  72328. */
  72329. readonly byteLength: number;
  72330. }
  72331. /**
  72332. * Utility class for reading from a data buffer
  72333. */
  72334. export class DataReader {
  72335. /**
  72336. * The data buffer associated with this data reader.
  72337. */
  72338. readonly buffer: IDataBuffer;
  72339. /**
  72340. * The current byte offset from the beginning of the data buffer.
  72341. */
  72342. byteOffset: number;
  72343. private _dataView;
  72344. private _dataByteOffset;
  72345. /**
  72346. * Constructor
  72347. * @param buffer The buffer to read
  72348. */
  72349. constructor(buffer: IDataBuffer);
  72350. /**
  72351. * Loads the given byte length.
  72352. * @param byteLength The byte length to load
  72353. * @returns A promise that resolves when the load is complete
  72354. */
  72355. loadAsync(byteLength: number): Promise<void>;
  72356. /**
  72357. * Read a unsigned 32-bit integer from the currently loaded data range.
  72358. * @returns The 32-bit integer read
  72359. */
  72360. readUint32(): number;
  72361. /**
  72362. * Read a byte array from the currently loaded data range.
  72363. * @param byteLength The byte length to read
  72364. * @returns The byte array read
  72365. */
  72366. readUint8Array(byteLength: number): Uint8Array;
  72367. /**
  72368. * Read a string from the currently loaded data range.
  72369. * @param byteLength The byte length to read
  72370. * @returns The string read
  72371. */
  72372. readString(byteLength: number): string;
  72373. /**
  72374. * Skips the given byte length the currently loaded data range.
  72375. * @param byteLength The byte length to skip
  72376. */
  72377. skipBytes(byteLength: number): void;
  72378. }
  72379. }
  72380. declare module "babylonjs/Misc/dataStorage" {
  72381. /**
  72382. * Class for storing data to local storage if available or in-memory storage otherwise
  72383. */
  72384. export class DataStorage {
  72385. private static _Storage;
  72386. private static _GetStorage;
  72387. /**
  72388. * Reads a string from the data storage
  72389. * @param key The key to read
  72390. * @param defaultValue The value if the key doesn't exist
  72391. * @returns The string value
  72392. */
  72393. static ReadString(key: string, defaultValue: string): string;
  72394. /**
  72395. * Writes a string to the data storage
  72396. * @param key The key to write
  72397. * @param value The value to write
  72398. */
  72399. static WriteString(key: string, value: string): void;
  72400. /**
  72401. * Reads a boolean from the data storage
  72402. * @param key The key to read
  72403. * @param defaultValue The value if the key doesn't exist
  72404. * @returns The boolean value
  72405. */
  72406. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72407. /**
  72408. * Writes a boolean to the data storage
  72409. * @param key The key to write
  72410. * @param value The value to write
  72411. */
  72412. static WriteBoolean(key: string, value: boolean): void;
  72413. /**
  72414. * Reads a number from the data storage
  72415. * @param key The key to read
  72416. * @param defaultValue The value if the key doesn't exist
  72417. * @returns The number value
  72418. */
  72419. static ReadNumber(key: string, defaultValue: number): number;
  72420. /**
  72421. * Writes a number to the data storage
  72422. * @param key The key to write
  72423. * @param value The value to write
  72424. */
  72425. static WriteNumber(key: string, value: number): void;
  72426. }
  72427. }
  72428. declare module "babylonjs/Misc/index" {
  72429. export * from "babylonjs/Misc/andOrNotEvaluator";
  72430. export * from "babylonjs/Misc/assetsManager";
  72431. export * from "babylonjs/Misc/basis";
  72432. export * from "babylonjs/Misc/dds";
  72433. export * from "babylonjs/Misc/decorators";
  72434. export * from "babylonjs/Misc/deferred";
  72435. export * from "babylonjs/Misc/environmentTextureTools";
  72436. export * from "babylonjs/Misc/meshExploder";
  72437. export * from "babylonjs/Misc/filesInput";
  72438. export * from "babylonjs/Misc/HighDynamicRange/index";
  72439. export * from "babylonjs/Misc/khronosTextureContainer";
  72440. export * from "babylonjs/Misc/observable";
  72441. export * from "babylonjs/Misc/performanceMonitor";
  72442. export * from "babylonjs/Misc/promise";
  72443. export * from "babylonjs/Misc/sceneOptimizer";
  72444. export * from "babylonjs/Misc/sceneSerializer";
  72445. export * from "babylonjs/Misc/smartArray";
  72446. export * from "babylonjs/Misc/stringDictionary";
  72447. export * from "babylonjs/Misc/tags";
  72448. export * from "babylonjs/Misc/textureTools";
  72449. export * from "babylonjs/Misc/tga";
  72450. export * from "babylonjs/Misc/tools";
  72451. export * from "babylonjs/Misc/videoRecorder";
  72452. export * from "babylonjs/Misc/virtualJoystick";
  72453. export * from "babylonjs/Misc/workerPool";
  72454. export * from "babylonjs/Misc/logger";
  72455. export * from "babylonjs/Misc/typeStore";
  72456. export * from "babylonjs/Misc/filesInputStore";
  72457. export * from "babylonjs/Misc/deepCopier";
  72458. export * from "babylonjs/Misc/pivotTools";
  72459. export * from "babylonjs/Misc/precisionDate";
  72460. export * from "babylonjs/Misc/screenshotTools";
  72461. export * from "babylonjs/Misc/typeStore";
  72462. export * from "babylonjs/Misc/webRequest";
  72463. export * from "babylonjs/Misc/iInspectable";
  72464. export * from "babylonjs/Misc/brdfTextureTools";
  72465. export * from "babylonjs/Misc/rgbdTextureTools";
  72466. export * from "babylonjs/Misc/gradients";
  72467. export * from "babylonjs/Misc/perfCounter";
  72468. export * from "babylonjs/Misc/fileRequest";
  72469. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72470. export * from "babylonjs/Misc/retryStrategy";
  72471. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72472. export * from "babylonjs/Misc/canvasGenerator";
  72473. export * from "babylonjs/Misc/fileTools";
  72474. export * from "babylonjs/Misc/stringTools";
  72475. export * from "babylonjs/Misc/dataReader";
  72476. export * from "babylonjs/Misc/minMaxReducer";
  72477. export * from "babylonjs/Misc/depthReducer";
  72478. export * from "babylonjs/Misc/dataStorage";
  72479. }
  72480. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72481. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72482. import { Observable } from "babylonjs/Misc/observable";
  72483. import { Matrix } from "babylonjs/Maths/math.vector";
  72484. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72485. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72486. /**
  72487. * Options used for hit testing
  72488. */
  72489. export interface IWebXRHitTestOptions {
  72490. /**
  72491. * Only test when user interacted with the scene. Default - hit test every frame
  72492. */
  72493. testOnPointerDownOnly?: boolean;
  72494. /**
  72495. * The node to use to transform the local results to world coordinates
  72496. */
  72497. worldParentNode?: TransformNode;
  72498. }
  72499. /**
  72500. * Interface defining the babylon result of raycasting/hit-test
  72501. */
  72502. export interface IWebXRHitResult {
  72503. /**
  72504. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72505. */
  72506. transformationMatrix: Matrix;
  72507. /**
  72508. * The native hit test result
  72509. */
  72510. xrHitResult: XRHitResult;
  72511. }
  72512. /**
  72513. * The currently-working hit-test module.
  72514. * Hit test (or Ray-casting) is used to interact with the real world.
  72515. * For further information read here - https://github.com/immersive-web/hit-test
  72516. */
  72517. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72518. /**
  72519. * options to use when constructing this feature
  72520. */
  72521. readonly options: IWebXRHitTestOptions;
  72522. private _direction;
  72523. private _mat;
  72524. private _onSelectEnabled;
  72525. private _origin;
  72526. /**
  72527. * The module's name
  72528. */
  72529. static readonly Name: string;
  72530. /**
  72531. * The (Babylon) version of this module.
  72532. * This is an integer representing the implementation version.
  72533. * This number does not correspond to the WebXR specs version
  72534. */
  72535. static readonly Version: number;
  72536. /**
  72537. * Populated with the last native XR Hit Results
  72538. */
  72539. lastNativeXRHitResults: XRHitResult[];
  72540. /**
  72541. * Triggered when new babylon (transformed) hit test results are available
  72542. */
  72543. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72544. /**
  72545. * Creates a new instance of the (legacy version) hit test feature
  72546. * @param _xrSessionManager an instance of WebXRSessionManager
  72547. * @param options options to use when constructing this feature
  72548. */
  72549. constructor(_xrSessionManager: WebXRSessionManager,
  72550. /**
  72551. * options to use when constructing this feature
  72552. */
  72553. options?: IWebXRHitTestOptions);
  72554. /**
  72555. * execute a hit test with an XR Ray
  72556. *
  72557. * @param xrSession a native xrSession that will execute this hit test
  72558. * @param xrRay the ray (position and direction) to use for ray-casting
  72559. * @param referenceSpace native XR reference space to use for the hit-test
  72560. * @param filter filter function that will filter the results
  72561. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72562. */
  72563. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72564. /**
  72565. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72566. * @param event the (select) event to use to select with
  72567. * @param referenceSpace the reference space to use for this hit test
  72568. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72569. */
  72570. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72571. /**
  72572. * attach this feature
  72573. * Will usually be called by the features manager
  72574. *
  72575. * @returns true if successful.
  72576. */
  72577. attach(): boolean;
  72578. /**
  72579. * detach this feature.
  72580. * Will usually be called by the features manager
  72581. *
  72582. * @returns true if successful.
  72583. */
  72584. detach(): boolean;
  72585. /**
  72586. * Dispose this feature and all of the resources attached
  72587. */
  72588. dispose(): void;
  72589. protected _onXRFrame(frame: XRFrame): void;
  72590. private _onHitTestResults;
  72591. private _onSelect;
  72592. }
  72593. }
  72594. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72595. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72596. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72597. import { Observable } from "babylonjs/Misc/observable";
  72598. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72599. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72600. /**
  72601. * Options used in the plane detector module
  72602. */
  72603. export interface IWebXRPlaneDetectorOptions {
  72604. /**
  72605. * The node to use to transform the local results to world coordinates
  72606. */
  72607. worldParentNode?: TransformNode;
  72608. }
  72609. /**
  72610. * A babylon interface for a WebXR plane.
  72611. * A Plane is actually a polygon, built from N points in space
  72612. *
  72613. * Supported in chrome 79, not supported in canary 81 ATM
  72614. */
  72615. export interface IWebXRPlane {
  72616. /**
  72617. * a babylon-assigned ID for this polygon
  72618. */
  72619. id: number;
  72620. /**
  72621. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72622. */
  72623. polygonDefinition: Array<Vector3>;
  72624. /**
  72625. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72626. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72627. */
  72628. transformationMatrix: Matrix;
  72629. /**
  72630. * the native xr-plane object
  72631. */
  72632. xrPlane: XRPlane;
  72633. }
  72634. /**
  72635. * The plane detector is used to detect planes in the real world when in AR
  72636. * For more information see https://github.com/immersive-web/real-world-geometry/
  72637. */
  72638. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72639. private _options;
  72640. private _detectedPlanes;
  72641. private _enabled;
  72642. private _lastFrameDetected;
  72643. /**
  72644. * The module's name
  72645. */
  72646. static readonly Name: string;
  72647. /**
  72648. * The (Babylon) version of this module.
  72649. * This is an integer representing the implementation version.
  72650. * This number does not correspond to the WebXR specs version
  72651. */
  72652. static readonly Version: number;
  72653. /**
  72654. * Observers registered here will be executed when a new plane was added to the session
  72655. */
  72656. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72657. /**
  72658. * Observers registered here will be executed when a plane is no longer detected in the session
  72659. */
  72660. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72661. /**
  72662. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72663. * This can execute N times every frame
  72664. */
  72665. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72666. /**
  72667. * construct a new Plane Detector
  72668. * @param _xrSessionManager an instance of xr Session manager
  72669. * @param _options configuration to use when constructing this feature
  72670. */
  72671. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72672. /**
  72673. * Dispose this feature and all of the resources attached
  72674. */
  72675. dispose(): void;
  72676. protected _onXRFrame(frame: XRFrame): void;
  72677. private _init;
  72678. private _updatePlaneWithXRPlane;
  72679. /**
  72680. * avoiding using Array.find for global support.
  72681. * @param xrPlane the plane to find in the array
  72682. */
  72683. private findIndexInPlaneArray;
  72684. }
  72685. }
  72686. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72687. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72688. import { Observable } from "babylonjs/Misc/observable";
  72689. import { Matrix } from "babylonjs/Maths/math.vector";
  72690. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72691. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72692. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72693. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72694. /**
  72695. * Configuration options of the anchor system
  72696. */
  72697. export interface IWebXRAnchorSystemOptions {
  72698. /**
  72699. * Should a new anchor be added every time a select event is triggered
  72700. */
  72701. addAnchorOnSelect?: boolean;
  72702. /**
  72703. * should the anchor system use plane detection.
  72704. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72705. */
  72706. usePlaneDetection?: boolean;
  72707. /**
  72708. * a node that will be used to convert local to world coordinates
  72709. */
  72710. worldParentNode?: TransformNode;
  72711. }
  72712. /**
  72713. * A babylon container for an XR Anchor
  72714. */
  72715. export interface IWebXRAnchor {
  72716. /**
  72717. * A babylon-assigned ID for this anchor
  72718. */
  72719. id: number;
  72720. /**
  72721. * Transformation matrix to apply to an object attached to this anchor
  72722. */
  72723. transformationMatrix: Matrix;
  72724. /**
  72725. * The native anchor object
  72726. */
  72727. xrAnchor: XRAnchor;
  72728. }
  72729. /**
  72730. * An implementation of the anchor system of WebXR.
  72731. * Note that the current documented implementation is not available in any browser. Future implementations
  72732. * will use the frame to create an anchor and not the session or a detected plane
  72733. * For further information see https://github.com/immersive-web/anchors/
  72734. */
  72735. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72736. private _options;
  72737. private _enabled;
  72738. private _hitTestModule;
  72739. private _lastFrameDetected;
  72740. private _onSelect;
  72741. private _planeDetector;
  72742. private _trackedAnchors;
  72743. /**
  72744. * The module's name
  72745. */
  72746. static readonly Name: string;
  72747. /**
  72748. * The (Babylon) version of this module.
  72749. * This is an integer representing the implementation version.
  72750. * This number does not correspond to the WebXR specs version
  72751. */
  72752. static readonly Version: number;
  72753. /**
  72754. * Observers registered here will be executed when a new anchor was added to the session
  72755. */
  72756. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72757. /**
  72758. * Observers registered here will be executed when an anchor was removed from the session
  72759. */
  72760. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72761. /**
  72762. * Observers registered here will be executed when an existing anchor updates
  72763. * This can execute N times every frame
  72764. */
  72765. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72766. /**
  72767. * constructs a new anchor system
  72768. * @param _xrSessionManager an instance of WebXRSessionManager
  72769. * @param _options configuration object for this feature
  72770. */
  72771. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72772. /**
  72773. * Add anchor at a specific XR point.
  72774. *
  72775. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72776. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72777. * @returns a promise the fulfills when the anchor was created
  72778. */
  72779. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72780. /**
  72781. * attach this feature
  72782. * Will usually be called by the features manager
  72783. *
  72784. * @returns true if successful.
  72785. */
  72786. attach(): boolean;
  72787. /**
  72788. * detach this feature.
  72789. * Will usually be called by the features manager
  72790. *
  72791. * @returns true if successful.
  72792. */
  72793. detach(): boolean;
  72794. /**
  72795. * Dispose this feature and all of the resources attached
  72796. */
  72797. dispose(): void;
  72798. /**
  72799. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72800. * @param hitTestModule the hit-test module to use.
  72801. */
  72802. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72803. /**
  72804. * set the plane detector to use in order to create anchors from frames
  72805. * @param planeDetector the plane-detector module to use
  72806. * @param enable enable plane-anchors. default is true
  72807. */
  72808. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72809. protected _onXRFrame(frame: XRFrame): void;
  72810. /**
  72811. * avoiding using Array.find for global support.
  72812. * @param xrAnchor the plane to find in the array
  72813. */
  72814. private _findIndexInAnchorArray;
  72815. private _updateAnchorWithXRFrame;
  72816. }
  72817. }
  72818. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72819. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72821. import { Observable } from "babylonjs/Misc/observable";
  72822. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72823. /**
  72824. * Options interface for the background remover plugin
  72825. */
  72826. export interface IWebXRBackgroundRemoverOptions {
  72827. /**
  72828. * Further background meshes to disable when entering AR
  72829. */
  72830. backgroundMeshes?: AbstractMesh[];
  72831. /**
  72832. * flags to configure the removal of the environment helper.
  72833. * If not set, the entire background will be removed. If set, flags should be set as well.
  72834. */
  72835. environmentHelperRemovalFlags?: {
  72836. /**
  72837. * Should the skybox be removed (default false)
  72838. */
  72839. skyBox?: boolean;
  72840. /**
  72841. * Should the ground be removed (default false)
  72842. */
  72843. ground?: boolean;
  72844. };
  72845. /**
  72846. * don't disable the environment helper
  72847. */
  72848. ignoreEnvironmentHelper?: boolean;
  72849. }
  72850. /**
  72851. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72852. */
  72853. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72854. /**
  72855. * read-only options to be used in this module
  72856. */
  72857. readonly options: IWebXRBackgroundRemoverOptions;
  72858. /**
  72859. * The module's name
  72860. */
  72861. static readonly Name: string;
  72862. /**
  72863. * The (Babylon) version of this module.
  72864. * This is an integer representing the implementation version.
  72865. * This number does not correspond to the WebXR specs version
  72866. */
  72867. static readonly Version: number;
  72868. /**
  72869. * registered observers will be triggered when the background state changes
  72870. */
  72871. onBackgroundStateChangedObservable: Observable<boolean>;
  72872. /**
  72873. * constructs a new background remover module
  72874. * @param _xrSessionManager the session manager for this module
  72875. * @param options read-only options to be used in this module
  72876. */
  72877. constructor(_xrSessionManager: WebXRSessionManager,
  72878. /**
  72879. * read-only options to be used in this module
  72880. */
  72881. options?: IWebXRBackgroundRemoverOptions);
  72882. /**
  72883. * attach this feature
  72884. * Will usually be called by the features manager
  72885. *
  72886. * @returns true if successful.
  72887. */
  72888. attach(): boolean;
  72889. /**
  72890. * detach this feature.
  72891. * Will usually be called by the features manager
  72892. *
  72893. * @returns true if successful.
  72894. */
  72895. detach(): boolean;
  72896. /**
  72897. * Dispose this feature and all of the resources attached
  72898. */
  72899. dispose(): void;
  72900. protected _onXRFrame(_xrFrame: XRFrame): void;
  72901. private _setBackgroundState;
  72902. }
  72903. }
  72904. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72905. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72906. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72907. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72908. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72909. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72910. import { Nullable } from "babylonjs/types";
  72911. /**
  72912. * Options for the controller physics feature
  72913. */
  72914. export class IWebXRControllerPhysicsOptions {
  72915. /**
  72916. * Should the headset get its own impostor
  72917. */
  72918. enableHeadsetImpostor?: boolean;
  72919. /**
  72920. * Optional parameters for the headset impostor
  72921. */
  72922. headsetImpostorParams?: {
  72923. /**
  72924. * The type of impostor to create. Default is sphere
  72925. */
  72926. impostorType: number;
  72927. /**
  72928. * the size of the impostor. Defaults to 10cm
  72929. */
  72930. impostorSize?: number | {
  72931. width: number;
  72932. height: number;
  72933. depth: number;
  72934. };
  72935. /**
  72936. * Friction definitions
  72937. */
  72938. friction?: number;
  72939. /**
  72940. * Restitution
  72941. */
  72942. restitution?: number;
  72943. };
  72944. /**
  72945. * The physics properties of the future impostors
  72946. */
  72947. physicsProperties?: {
  72948. /**
  72949. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72950. * Note that this requires a physics engine that supports mesh impostors!
  72951. */
  72952. useControllerMesh?: boolean;
  72953. /**
  72954. * The type of impostor to create. Default is sphere
  72955. */
  72956. impostorType?: number;
  72957. /**
  72958. * the size of the impostor. Defaults to 10cm
  72959. */
  72960. impostorSize?: number | {
  72961. width: number;
  72962. height: number;
  72963. depth: number;
  72964. };
  72965. /**
  72966. * Friction definitions
  72967. */
  72968. friction?: number;
  72969. /**
  72970. * Restitution
  72971. */
  72972. restitution?: number;
  72973. };
  72974. /**
  72975. * the xr input to use with this pointer selection
  72976. */
  72977. xrInput: WebXRInput;
  72978. }
  72979. /**
  72980. * Add physics impostor to your webxr controllers,
  72981. * including naive calculation of their linear and angular velocity
  72982. */
  72983. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72984. private readonly _options;
  72985. private _attachController;
  72986. private _controllers;
  72987. private _debugMode;
  72988. private _delta;
  72989. private _headsetImpostor?;
  72990. private _headsetMesh?;
  72991. private _lastTimestamp;
  72992. private _tmpQuaternion;
  72993. private _tmpVector;
  72994. /**
  72995. * The module's name
  72996. */
  72997. static readonly Name: string;
  72998. /**
  72999. * The (Babylon) version of this module.
  73000. * This is an integer representing the implementation version.
  73001. * This number does not correspond to the webxr specs version
  73002. */
  73003. static readonly Version: number;
  73004. /**
  73005. * Construct a new Controller Physics Feature
  73006. * @param _xrSessionManager the corresponding xr session manager
  73007. * @param _options options to create this feature with
  73008. */
  73009. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73010. /**
  73011. * @hidden
  73012. * enable debugging - will show console outputs and the impostor mesh
  73013. */
  73014. _enablePhysicsDebug(): void;
  73015. /**
  73016. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73017. * @param xrController the controller to add
  73018. */
  73019. addController(xrController: WebXRInputSource): void;
  73020. /**
  73021. * attach this feature
  73022. * Will usually be called by the features manager
  73023. *
  73024. * @returns true if successful.
  73025. */
  73026. attach(): boolean;
  73027. /**
  73028. * detach this feature.
  73029. * Will usually be called by the features manager
  73030. *
  73031. * @returns true if successful.
  73032. */
  73033. detach(): boolean;
  73034. /**
  73035. * Get the headset impostor, if enabled
  73036. * @returns the impostor
  73037. */
  73038. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73039. /**
  73040. * Get the physics impostor of a specific controller.
  73041. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73042. * @param controller the controller or the controller id of which to get the impostor
  73043. * @returns the impostor or null
  73044. */
  73045. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73046. /**
  73047. * Update the physics properties provided in the constructor
  73048. * @param newProperties the new properties object
  73049. */
  73050. setPhysicsProperties(newProperties: {
  73051. impostorType?: number;
  73052. impostorSize?: number | {
  73053. width: number;
  73054. height: number;
  73055. depth: number;
  73056. };
  73057. friction?: number;
  73058. restitution?: number;
  73059. }): void;
  73060. protected _onXRFrame(_xrFrame: any): void;
  73061. private _detachController;
  73062. }
  73063. }
  73064. declare module "babylonjs/XR/features/index" {
  73065. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73066. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73067. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73068. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73069. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73070. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73071. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73072. }
  73073. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73074. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73076. import { Scene } from "babylonjs/scene";
  73077. /**
  73078. * The motion controller class for all microsoft mixed reality controllers
  73079. */
  73080. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73081. protected readonly _mapping: {
  73082. defaultButton: {
  73083. "valueNodeName": string;
  73084. "unpressedNodeName": string;
  73085. "pressedNodeName": string;
  73086. };
  73087. defaultAxis: {
  73088. "valueNodeName": string;
  73089. "minNodeName": string;
  73090. "maxNodeName": string;
  73091. };
  73092. buttons: {
  73093. "xr-standard-trigger": {
  73094. "rootNodeName": string;
  73095. "componentProperty": string;
  73096. "states": string[];
  73097. };
  73098. "xr-standard-squeeze": {
  73099. "rootNodeName": string;
  73100. "componentProperty": string;
  73101. "states": string[];
  73102. };
  73103. "xr-standard-touchpad": {
  73104. "rootNodeName": string;
  73105. "labelAnchorNodeName": string;
  73106. "touchPointNodeName": string;
  73107. };
  73108. "xr-standard-thumbstick": {
  73109. "rootNodeName": string;
  73110. "componentProperty": string;
  73111. "states": string[];
  73112. };
  73113. };
  73114. axes: {
  73115. "xr-standard-touchpad": {
  73116. "x-axis": {
  73117. "rootNodeName": string;
  73118. };
  73119. "y-axis": {
  73120. "rootNodeName": string;
  73121. };
  73122. };
  73123. "xr-standard-thumbstick": {
  73124. "x-axis": {
  73125. "rootNodeName": string;
  73126. };
  73127. "y-axis": {
  73128. "rootNodeName": string;
  73129. };
  73130. };
  73131. };
  73132. };
  73133. /**
  73134. * The base url used to load the left and right controller models
  73135. */
  73136. static MODEL_BASE_URL: string;
  73137. /**
  73138. * The name of the left controller model file
  73139. */
  73140. static MODEL_LEFT_FILENAME: string;
  73141. /**
  73142. * The name of the right controller model file
  73143. */
  73144. static MODEL_RIGHT_FILENAME: string;
  73145. profileId: string;
  73146. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73147. protected _getFilenameAndPath(): {
  73148. filename: string;
  73149. path: string;
  73150. };
  73151. protected _getModelLoadingConstraints(): boolean;
  73152. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73153. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73154. protected _updateModel(): void;
  73155. }
  73156. }
  73157. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73158. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73160. import { Scene } from "babylonjs/scene";
  73161. /**
  73162. * The motion controller class for oculus touch (quest, rift).
  73163. * This class supports legacy mapping as well the standard xr mapping
  73164. */
  73165. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73166. private _forceLegacyControllers;
  73167. private _modelRootNode;
  73168. /**
  73169. * The base url used to load the left and right controller models
  73170. */
  73171. static MODEL_BASE_URL: string;
  73172. /**
  73173. * The name of the left controller model file
  73174. */
  73175. static MODEL_LEFT_FILENAME: string;
  73176. /**
  73177. * The name of the right controller model file
  73178. */
  73179. static MODEL_RIGHT_FILENAME: string;
  73180. /**
  73181. * Base Url for the Quest controller model.
  73182. */
  73183. static QUEST_MODEL_BASE_URL: string;
  73184. profileId: string;
  73185. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73186. protected _getFilenameAndPath(): {
  73187. filename: string;
  73188. path: string;
  73189. };
  73190. protected _getModelLoadingConstraints(): boolean;
  73191. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73192. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73193. protected _updateModel(): void;
  73194. /**
  73195. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73196. * between the touch and touch 2.
  73197. */
  73198. private _isQuest;
  73199. }
  73200. }
  73201. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73202. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73203. import { Scene } from "babylonjs/scene";
  73204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73205. /**
  73206. * The motion controller class for the standard HTC-Vive controllers
  73207. */
  73208. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73209. private _modelRootNode;
  73210. /**
  73211. * The base url used to load the left and right controller models
  73212. */
  73213. static MODEL_BASE_URL: string;
  73214. /**
  73215. * File name for the controller model.
  73216. */
  73217. static MODEL_FILENAME: string;
  73218. profileId: string;
  73219. /**
  73220. * Create a new Vive motion controller object
  73221. * @param scene the scene to use to create this controller
  73222. * @param gamepadObject the corresponding gamepad object
  73223. * @param handness the handness of the controller
  73224. */
  73225. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73226. protected _getFilenameAndPath(): {
  73227. filename: string;
  73228. path: string;
  73229. };
  73230. protected _getModelLoadingConstraints(): boolean;
  73231. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73232. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73233. protected _updateModel(): void;
  73234. }
  73235. }
  73236. declare module "babylonjs/XR/motionController/index" {
  73237. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73238. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73239. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73240. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73241. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73242. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73243. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73244. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73245. }
  73246. declare module "babylonjs/XR/index" {
  73247. export * from "babylonjs/XR/webXRCamera";
  73248. export * from "babylonjs/XR/webXREnterExitUI";
  73249. export * from "babylonjs/XR/webXRExperienceHelper";
  73250. export * from "babylonjs/XR/webXRInput";
  73251. export * from "babylonjs/XR/webXRInputSource";
  73252. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73253. export * from "babylonjs/XR/webXRTypes";
  73254. export * from "babylonjs/XR/webXRSessionManager";
  73255. export * from "babylonjs/XR/webXRDefaultExperience";
  73256. export * from "babylonjs/XR/webXRFeaturesManager";
  73257. export * from "babylonjs/XR/features/index";
  73258. export * from "babylonjs/XR/motionController/index";
  73259. }
  73260. declare module "babylonjs/index" {
  73261. export * from "babylonjs/abstractScene";
  73262. export * from "babylonjs/Actions/index";
  73263. export * from "babylonjs/Animations/index";
  73264. export * from "babylonjs/assetContainer";
  73265. export * from "babylonjs/Audio/index";
  73266. export * from "babylonjs/Behaviors/index";
  73267. export * from "babylonjs/Bones/index";
  73268. export * from "babylonjs/Cameras/index";
  73269. export * from "babylonjs/Collisions/index";
  73270. export * from "babylonjs/Culling/index";
  73271. export * from "babylonjs/Debug/index";
  73272. export * from "babylonjs/Engines/index";
  73273. export * from "babylonjs/Events/index";
  73274. export * from "babylonjs/Gamepads/index";
  73275. export * from "babylonjs/Gizmos/index";
  73276. export * from "babylonjs/Helpers/index";
  73277. export * from "babylonjs/Instrumentation/index";
  73278. export * from "babylonjs/Layers/index";
  73279. export * from "babylonjs/LensFlares/index";
  73280. export * from "babylonjs/Lights/index";
  73281. export * from "babylonjs/Loading/index";
  73282. export * from "babylonjs/Materials/index";
  73283. export * from "babylonjs/Maths/index";
  73284. export * from "babylonjs/Meshes/index";
  73285. export * from "babylonjs/Morph/index";
  73286. export * from "babylonjs/Navigation/index";
  73287. export * from "babylonjs/node";
  73288. export * from "babylonjs/Offline/index";
  73289. export * from "babylonjs/Particles/index";
  73290. export * from "babylonjs/Physics/index";
  73291. export * from "babylonjs/PostProcesses/index";
  73292. export * from "babylonjs/Probes/index";
  73293. export * from "babylonjs/Rendering/index";
  73294. export * from "babylonjs/scene";
  73295. export * from "babylonjs/sceneComponent";
  73296. export * from "babylonjs/Sprites/index";
  73297. export * from "babylonjs/States/index";
  73298. export * from "babylonjs/Misc/index";
  73299. export * from "babylonjs/XR/index";
  73300. export * from "babylonjs/types";
  73301. }
  73302. declare module "babylonjs/Animations/pathCursor" {
  73303. import { Vector3 } from "babylonjs/Maths/math.vector";
  73304. import { Path2 } from "babylonjs/Maths/math.path";
  73305. /**
  73306. * A cursor which tracks a point on a path
  73307. */
  73308. export class PathCursor {
  73309. private path;
  73310. /**
  73311. * Stores path cursor callbacks for when an onchange event is triggered
  73312. */
  73313. private _onchange;
  73314. /**
  73315. * The value of the path cursor
  73316. */
  73317. value: number;
  73318. /**
  73319. * The animation array of the path cursor
  73320. */
  73321. animations: Animation[];
  73322. /**
  73323. * Initializes the path cursor
  73324. * @param path The path to track
  73325. */
  73326. constructor(path: Path2);
  73327. /**
  73328. * Gets the cursor point on the path
  73329. * @returns A point on the path cursor at the cursor location
  73330. */
  73331. getPoint(): Vector3;
  73332. /**
  73333. * Moves the cursor ahead by the step amount
  73334. * @param step The amount to move the cursor forward
  73335. * @returns This path cursor
  73336. */
  73337. moveAhead(step?: number): PathCursor;
  73338. /**
  73339. * Moves the cursor behind by the step amount
  73340. * @param step The amount to move the cursor back
  73341. * @returns This path cursor
  73342. */
  73343. moveBack(step?: number): PathCursor;
  73344. /**
  73345. * Moves the cursor by the step amount
  73346. * If the step amount is greater than one, an exception is thrown
  73347. * @param step The amount to move the cursor
  73348. * @returns This path cursor
  73349. */
  73350. move(step: number): PathCursor;
  73351. /**
  73352. * Ensures that the value is limited between zero and one
  73353. * @returns This path cursor
  73354. */
  73355. private ensureLimits;
  73356. /**
  73357. * Runs onchange callbacks on change (used by the animation engine)
  73358. * @returns This path cursor
  73359. */
  73360. private raiseOnChange;
  73361. /**
  73362. * Executes a function on change
  73363. * @param f A path cursor onchange callback
  73364. * @returns This path cursor
  73365. */
  73366. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73367. }
  73368. }
  73369. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73370. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73371. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73372. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73373. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73374. }
  73375. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73376. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73377. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73378. }
  73379. declare module "babylonjs/Engines/Processors/index" {
  73380. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73381. export * from "babylonjs/Engines/Processors/Expressions/index";
  73382. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73383. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73384. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73385. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73386. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73387. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73388. }
  73389. declare module "babylonjs/Legacy/legacy" {
  73390. import * as Babylon from "babylonjs/index";
  73391. export * from "babylonjs/index";
  73392. }
  73393. declare module "babylonjs/Shaders/blur.fragment" {
  73394. /** @hidden */
  73395. export var blurPixelShader: {
  73396. name: string;
  73397. shader: string;
  73398. };
  73399. }
  73400. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73401. /** @hidden */
  73402. export var pointCloudVertexDeclaration: {
  73403. name: string;
  73404. shader: string;
  73405. };
  73406. }
  73407. declare module "babylonjs" {
  73408. export * from "babylonjs/Legacy/legacy";
  73409. }
  73410. declare module BABYLON {
  73411. /** Alias type for value that can be null */
  73412. export type Nullable<T> = T | null;
  73413. /**
  73414. * Alias type for number that are floats
  73415. * @ignorenaming
  73416. */
  73417. export type float = number;
  73418. /**
  73419. * Alias type for number that are doubles.
  73420. * @ignorenaming
  73421. */
  73422. export type double = number;
  73423. /**
  73424. * Alias type for number that are integer
  73425. * @ignorenaming
  73426. */
  73427. export type int = number;
  73428. /** Alias type for number array or Float32Array */
  73429. export type FloatArray = number[] | Float32Array;
  73430. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73431. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73432. /**
  73433. * Alias for types that can be used by a Buffer or VertexBuffer.
  73434. */
  73435. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73436. /**
  73437. * Alias type for primitive types
  73438. * @ignorenaming
  73439. */
  73440. type Primitive = undefined | null | boolean | string | number | Function;
  73441. /**
  73442. * Type modifier to make all the properties of an object Readonly
  73443. */
  73444. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73445. /**
  73446. * Type modifier to make all the properties of an object Readonly recursively
  73447. */
  73448. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73449. /**
  73450. * Type modifier to make object properties readonly.
  73451. */
  73452. export type DeepImmutableObject<T> = {
  73453. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73454. };
  73455. /** @hidden */
  73456. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73457. }
  73458. }
  73459. declare module BABYLON {
  73460. /**
  73461. * A class serves as a medium between the observable and its observers
  73462. */
  73463. export class EventState {
  73464. /**
  73465. * Create a new EventState
  73466. * @param mask defines the mask associated with this state
  73467. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73468. * @param target defines the original target of the state
  73469. * @param currentTarget defines the current target of the state
  73470. */
  73471. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73472. /**
  73473. * Initialize the current event state
  73474. * @param mask defines the mask associated with this state
  73475. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73476. * @param target defines the original target of the state
  73477. * @param currentTarget defines the current target of the state
  73478. * @returns the current event state
  73479. */
  73480. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73481. /**
  73482. * An Observer can set this property to true to prevent subsequent observers of being notified
  73483. */
  73484. skipNextObservers: boolean;
  73485. /**
  73486. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73487. */
  73488. mask: number;
  73489. /**
  73490. * The object that originally notified the event
  73491. */
  73492. target?: any;
  73493. /**
  73494. * The current object in the bubbling phase
  73495. */
  73496. currentTarget?: any;
  73497. /**
  73498. * This will be populated with the return value of the last function that was executed.
  73499. * If it is the first function in the callback chain it will be the event data.
  73500. */
  73501. lastReturnValue?: any;
  73502. }
  73503. /**
  73504. * Represent an Observer registered to a given Observable object.
  73505. */
  73506. export class Observer<T> {
  73507. /**
  73508. * Defines the callback to call when the observer is notified
  73509. */
  73510. callback: (eventData: T, eventState: EventState) => void;
  73511. /**
  73512. * Defines the mask of the observer (used to filter notifications)
  73513. */
  73514. mask: number;
  73515. /**
  73516. * Defines the current scope used to restore the JS context
  73517. */
  73518. scope: any;
  73519. /** @hidden */
  73520. _willBeUnregistered: boolean;
  73521. /**
  73522. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73523. */
  73524. unregisterOnNextCall: boolean;
  73525. /**
  73526. * Creates a new observer
  73527. * @param callback defines the callback to call when the observer is notified
  73528. * @param mask defines the mask of the observer (used to filter notifications)
  73529. * @param scope defines the current scope used to restore the JS context
  73530. */
  73531. constructor(
  73532. /**
  73533. * Defines the callback to call when the observer is notified
  73534. */
  73535. callback: (eventData: T, eventState: EventState) => void,
  73536. /**
  73537. * Defines the mask of the observer (used to filter notifications)
  73538. */
  73539. mask: number,
  73540. /**
  73541. * Defines the current scope used to restore the JS context
  73542. */
  73543. scope?: any);
  73544. }
  73545. /**
  73546. * Represent a list of observers registered to multiple Observables object.
  73547. */
  73548. export class MultiObserver<T> {
  73549. private _observers;
  73550. private _observables;
  73551. /**
  73552. * Release associated resources
  73553. */
  73554. dispose(): void;
  73555. /**
  73556. * Raise a callback when one of the observable will notify
  73557. * @param observables defines a list of observables to watch
  73558. * @param callback defines the callback to call on notification
  73559. * @param mask defines the mask used to filter notifications
  73560. * @param scope defines the current scope used to restore the JS context
  73561. * @returns the new MultiObserver
  73562. */
  73563. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73564. }
  73565. /**
  73566. * The Observable class is a simple implementation of the Observable pattern.
  73567. *
  73568. * 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.
  73569. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73570. * 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).
  73571. * 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.
  73572. */
  73573. export class Observable<T> {
  73574. private _observers;
  73575. private _eventState;
  73576. private _onObserverAdded;
  73577. /**
  73578. * Gets the list of observers
  73579. */
  73580. get observers(): Array<Observer<T>>;
  73581. /**
  73582. * Creates a new observable
  73583. * @param onObserverAdded defines a callback to call when a new observer is added
  73584. */
  73585. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73586. /**
  73587. * Create a new Observer with the specified callback
  73588. * @param callback the callback that will be executed for that Observer
  73589. * @param mask the mask used to filter observers
  73590. * @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.
  73591. * @param scope optional scope for the callback to be called from
  73592. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73593. * @returns the new observer created for the callback
  73594. */
  73595. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73596. /**
  73597. * Create a new Observer with the specified callback and unregisters after the next notification
  73598. * @param callback the callback that will be executed for that Observer
  73599. * @returns the new observer created for the callback
  73600. */
  73601. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73602. /**
  73603. * Remove an Observer from the Observable object
  73604. * @param observer the instance of the Observer to remove
  73605. * @returns false if it doesn't belong to this Observable
  73606. */
  73607. remove(observer: Nullable<Observer<T>>): boolean;
  73608. /**
  73609. * Remove a callback from the Observable object
  73610. * @param callback the callback to remove
  73611. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73612. * @returns false if it doesn't belong to this Observable
  73613. */
  73614. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73615. private _deferUnregister;
  73616. private _remove;
  73617. /**
  73618. * Moves the observable to the top of the observer list making it get called first when notified
  73619. * @param observer the observer to move
  73620. */
  73621. makeObserverTopPriority(observer: Observer<T>): void;
  73622. /**
  73623. * Moves the observable to the bottom of the observer list making it get called last when notified
  73624. * @param observer the observer to move
  73625. */
  73626. makeObserverBottomPriority(observer: Observer<T>): void;
  73627. /**
  73628. * Notify all Observers by calling their respective callback with the given data
  73629. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73630. * @param eventData defines the data to send to all observers
  73631. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73632. * @param target defines the original target of the state
  73633. * @param currentTarget defines the current target of the state
  73634. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73635. */
  73636. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73637. /**
  73638. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73639. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73640. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73641. * and it is crucial that all callbacks will be executed.
  73642. * The order of the callbacks is kept, callbacks are not executed parallel.
  73643. *
  73644. * @param eventData The data to be sent to each callback
  73645. * @param mask is used to filter observers defaults to -1
  73646. * @param target defines the callback target (see EventState)
  73647. * @param currentTarget defines he current object in the bubbling phase
  73648. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73649. */
  73650. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73651. /**
  73652. * Notify a specific observer
  73653. * @param observer defines the observer to notify
  73654. * @param eventData defines the data to be sent to each callback
  73655. * @param mask is used to filter observers defaults to -1
  73656. */
  73657. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73658. /**
  73659. * Gets a boolean indicating if the observable has at least one observer
  73660. * @returns true is the Observable has at least one Observer registered
  73661. */
  73662. hasObservers(): boolean;
  73663. /**
  73664. * Clear the list of observers
  73665. */
  73666. clear(): void;
  73667. /**
  73668. * Clone the current observable
  73669. * @returns a new observable
  73670. */
  73671. clone(): Observable<T>;
  73672. /**
  73673. * Does this observable handles observer registered with a given mask
  73674. * @param mask defines the mask to be tested
  73675. * @return whether or not one observer registered with the given mask is handeled
  73676. **/
  73677. hasSpecificMask(mask?: number): boolean;
  73678. }
  73679. }
  73680. declare module BABYLON {
  73681. /**
  73682. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73683. * Babylon.js
  73684. */
  73685. export class DomManagement {
  73686. /**
  73687. * Checks if the window object exists
  73688. * @returns true if the window object exists
  73689. */
  73690. static IsWindowObjectExist(): boolean;
  73691. /**
  73692. * Checks if the navigator object exists
  73693. * @returns true if the navigator object exists
  73694. */
  73695. static IsNavigatorAvailable(): boolean;
  73696. /**
  73697. * Extracts text content from a DOM element hierarchy
  73698. * @param element defines the root element
  73699. * @returns a string
  73700. */
  73701. static GetDOMTextContent(element: HTMLElement): string;
  73702. }
  73703. }
  73704. declare module BABYLON {
  73705. /**
  73706. * Logger used througouht the application to allow configuration of
  73707. * the log level required for the messages.
  73708. */
  73709. export class Logger {
  73710. /**
  73711. * No log
  73712. */
  73713. static readonly NoneLogLevel: number;
  73714. /**
  73715. * Only message logs
  73716. */
  73717. static readonly MessageLogLevel: number;
  73718. /**
  73719. * Only warning logs
  73720. */
  73721. static readonly WarningLogLevel: number;
  73722. /**
  73723. * Only error logs
  73724. */
  73725. static readonly ErrorLogLevel: number;
  73726. /**
  73727. * All logs
  73728. */
  73729. static readonly AllLogLevel: number;
  73730. private static _LogCache;
  73731. /**
  73732. * Gets a value indicating the number of loading errors
  73733. * @ignorenaming
  73734. */
  73735. static errorsCount: number;
  73736. /**
  73737. * Callback called when a new log is added
  73738. */
  73739. static OnNewCacheEntry: (entry: string) => void;
  73740. private static _AddLogEntry;
  73741. private static _FormatMessage;
  73742. private static _LogDisabled;
  73743. private static _LogEnabled;
  73744. private static _WarnDisabled;
  73745. private static _WarnEnabled;
  73746. private static _ErrorDisabled;
  73747. private static _ErrorEnabled;
  73748. /**
  73749. * Log a message to the console
  73750. */
  73751. static Log: (message: string) => void;
  73752. /**
  73753. * Write a warning message to the console
  73754. */
  73755. static Warn: (message: string) => void;
  73756. /**
  73757. * Write an error message to the console
  73758. */
  73759. static Error: (message: string) => void;
  73760. /**
  73761. * Gets current log cache (list of logs)
  73762. */
  73763. static get LogCache(): string;
  73764. /**
  73765. * Clears the log cache
  73766. */
  73767. static ClearLogCache(): void;
  73768. /**
  73769. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73770. */
  73771. static set LogLevels(level: number);
  73772. }
  73773. }
  73774. declare module BABYLON {
  73775. /** @hidden */
  73776. export class _TypeStore {
  73777. /** @hidden */
  73778. static RegisteredTypes: {
  73779. [key: string]: Object;
  73780. };
  73781. /** @hidden */
  73782. static GetClass(fqdn: string): any;
  73783. }
  73784. }
  73785. declare module BABYLON {
  73786. /**
  73787. * Helper to manipulate strings
  73788. */
  73789. export class StringTools {
  73790. /**
  73791. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73792. * @param str Source string
  73793. * @param suffix Suffix to search for in the source string
  73794. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73795. */
  73796. static EndsWith(str: string, suffix: string): boolean;
  73797. /**
  73798. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73799. * @param str Source string
  73800. * @param suffix Suffix to search for in the source string
  73801. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73802. */
  73803. static StartsWith(str: string, suffix: string): boolean;
  73804. /**
  73805. * Decodes a buffer into a string
  73806. * @param buffer The buffer to decode
  73807. * @returns The decoded string
  73808. */
  73809. static Decode(buffer: Uint8Array | Uint16Array): string;
  73810. /**
  73811. * Encode a buffer to a base64 string
  73812. * @param buffer defines the buffer to encode
  73813. * @returns the encoded string
  73814. */
  73815. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73816. }
  73817. }
  73818. declare module BABYLON {
  73819. /**
  73820. * Class containing a set of static utilities functions for deep copy.
  73821. */
  73822. export class DeepCopier {
  73823. /**
  73824. * Tries to copy an object by duplicating every property
  73825. * @param source defines the source object
  73826. * @param destination defines the target object
  73827. * @param doNotCopyList defines a list of properties to avoid
  73828. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73829. */
  73830. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73831. }
  73832. }
  73833. declare module BABYLON {
  73834. /**
  73835. * Class containing a set of static utilities functions for precision date
  73836. */
  73837. export class PrecisionDate {
  73838. /**
  73839. * Gets either window.performance.now() if supported or Date.now() else
  73840. */
  73841. static get Now(): number;
  73842. }
  73843. }
  73844. declare module BABYLON {
  73845. /** @hidden */
  73846. export class _DevTools {
  73847. static WarnImport(name: string): string;
  73848. }
  73849. }
  73850. declare module BABYLON {
  73851. /**
  73852. * Interface used to define the mechanism to get data from the network
  73853. */
  73854. export interface IWebRequest {
  73855. /**
  73856. * Returns client's response url
  73857. */
  73858. responseURL: string;
  73859. /**
  73860. * Returns client's status
  73861. */
  73862. status: number;
  73863. /**
  73864. * Returns client's status as a text
  73865. */
  73866. statusText: string;
  73867. }
  73868. }
  73869. declare module BABYLON {
  73870. /**
  73871. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73872. */
  73873. export class WebRequest implements IWebRequest {
  73874. private _xhr;
  73875. /**
  73876. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73877. * i.e. when loading files, where the server/service expects an Authorization header
  73878. */
  73879. static CustomRequestHeaders: {
  73880. [key: string]: string;
  73881. };
  73882. /**
  73883. * Add callback functions in this array to update all the requests before they get sent to the network
  73884. */
  73885. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73886. private _injectCustomRequestHeaders;
  73887. /**
  73888. * Gets or sets a function to be called when loading progress changes
  73889. */
  73890. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73891. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73892. /**
  73893. * Returns client's state
  73894. */
  73895. get readyState(): number;
  73896. /**
  73897. * Returns client's status
  73898. */
  73899. get status(): number;
  73900. /**
  73901. * Returns client's status as a text
  73902. */
  73903. get statusText(): string;
  73904. /**
  73905. * Returns client's response
  73906. */
  73907. get response(): any;
  73908. /**
  73909. * Returns client's response url
  73910. */
  73911. get responseURL(): string;
  73912. /**
  73913. * Returns client's response as text
  73914. */
  73915. get responseText(): string;
  73916. /**
  73917. * Gets or sets the expected response type
  73918. */
  73919. get responseType(): XMLHttpRequestResponseType;
  73920. set responseType(value: XMLHttpRequestResponseType);
  73921. /** @hidden */
  73922. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73923. /** @hidden */
  73924. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73925. /**
  73926. * Cancels any network activity
  73927. */
  73928. abort(): void;
  73929. /**
  73930. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73931. * @param body defines an optional request body
  73932. */
  73933. send(body?: Document | BodyInit | null): void;
  73934. /**
  73935. * Sets the request method, request URL
  73936. * @param method defines the method to use (GET, POST, etc..)
  73937. * @param url defines the url to connect with
  73938. */
  73939. open(method: string, url: string): void;
  73940. /**
  73941. * Sets the value of a request header.
  73942. * @param name The name of the header whose value is to be set
  73943. * @param value The value to set as the body of the header
  73944. */
  73945. setRequestHeader(name: string, value: string): void;
  73946. /**
  73947. * Get the string containing the text of a particular header's value.
  73948. * @param name The name of the header
  73949. * @returns The string containing the text of the given header name
  73950. */
  73951. getResponseHeader(name: string): Nullable<string>;
  73952. }
  73953. }
  73954. declare module BABYLON {
  73955. /**
  73956. * File request interface
  73957. */
  73958. export interface IFileRequest {
  73959. /**
  73960. * Raised when the request is complete (success or error).
  73961. */
  73962. onCompleteObservable: Observable<IFileRequest>;
  73963. /**
  73964. * Aborts the request for a file.
  73965. */
  73966. abort: () => void;
  73967. }
  73968. }
  73969. declare module BABYLON {
  73970. /**
  73971. * Define options used to create a render target texture
  73972. */
  73973. export class RenderTargetCreationOptions {
  73974. /**
  73975. * Specifies is mipmaps must be generated
  73976. */
  73977. generateMipMaps?: boolean;
  73978. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73979. generateDepthBuffer?: boolean;
  73980. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73981. generateStencilBuffer?: boolean;
  73982. /** Defines texture type (int by default) */
  73983. type?: number;
  73984. /** Defines sampling mode (trilinear by default) */
  73985. samplingMode?: number;
  73986. /** Defines format (RGBA by default) */
  73987. format?: number;
  73988. }
  73989. }
  73990. declare module BABYLON {
  73991. /** Defines the cross module used constants to avoid circular dependncies */
  73992. export class Constants {
  73993. /** Defines that alpha blending is disabled */
  73994. static readonly ALPHA_DISABLE: number;
  73995. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73996. static readonly ALPHA_ADD: number;
  73997. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73998. static readonly ALPHA_COMBINE: number;
  73999. /** Defines that alpha blending is DEST - SRC * DEST */
  74000. static readonly ALPHA_SUBTRACT: number;
  74001. /** Defines that alpha blending is SRC * DEST */
  74002. static readonly ALPHA_MULTIPLY: number;
  74003. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74004. static readonly ALPHA_MAXIMIZED: number;
  74005. /** Defines that alpha blending is SRC + DEST */
  74006. static readonly ALPHA_ONEONE: number;
  74007. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74008. static readonly ALPHA_PREMULTIPLIED: number;
  74009. /**
  74010. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74011. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74012. */
  74013. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74014. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74015. static readonly ALPHA_INTERPOLATE: number;
  74016. /**
  74017. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74018. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74019. */
  74020. static readonly ALPHA_SCREENMODE: number;
  74021. /**
  74022. * Defines that alpha blending is SRC + DST
  74023. * Alpha will be set to SRC ALPHA + DST ALPHA
  74024. */
  74025. static readonly ALPHA_ONEONE_ONEONE: number;
  74026. /**
  74027. * Defines that alpha blending is SRC * DST ALPHA + DST
  74028. * Alpha will be set to 0
  74029. */
  74030. static readonly ALPHA_ALPHATOCOLOR: number;
  74031. /**
  74032. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74033. */
  74034. static readonly ALPHA_REVERSEONEMINUS: number;
  74035. /**
  74036. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74037. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74038. */
  74039. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74040. /**
  74041. * Defines that alpha blending is SRC + DST
  74042. * Alpha will be set to SRC ALPHA
  74043. */
  74044. static readonly ALPHA_ONEONE_ONEZERO: number;
  74045. /**
  74046. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74047. * Alpha will be set to DST ALPHA
  74048. */
  74049. static readonly ALPHA_EXCLUSION: number;
  74050. /** Defines that alpha blending equation a SUM */
  74051. static readonly ALPHA_EQUATION_ADD: number;
  74052. /** Defines that alpha blending equation a SUBSTRACTION */
  74053. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74054. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74055. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74056. /** Defines that alpha blending equation a MAX operation */
  74057. static readonly ALPHA_EQUATION_MAX: number;
  74058. /** Defines that alpha blending equation a MIN operation */
  74059. static readonly ALPHA_EQUATION_MIN: number;
  74060. /**
  74061. * Defines that alpha blending equation a DARKEN operation:
  74062. * It takes the min of the src and sums the alpha channels.
  74063. */
  74064. static readonly ALPHA_EQUATION_DARKEN: number;
  74065. /** Defines that the ressource is not delayed*/
  74066. static readonly DELAYLOADSTATE_NONE: number;
  74067. /** Defines that the ressource was successfully delay loaded */
  74068. static readonly DELAYLOADSTATE_LOADED: number;
  74069. /** Defines that the ressource is currently delay loading */
  74070. static readonly DELAYLOADSTATE_LOADING: number;
  74071. /** Defines that the ressource is delayed and has not started loading */
  74072. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74073. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74074. static readonly NEVER: number;
  74075. /** 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 */
  74076. static readonly ALWAYS: number;
  74077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74078. static readonly LESS: number;
  74079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74080. static readonly EQUAL: number;
  74081. /** 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 */
  74082. static readonly LEQUAL: number;
  74083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74084. static readonly GREATER: number;
  74085. /** 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 */
  74086. static readonly GEQUAL: number;
  74087. /** 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 */
  74088. static readonly NOTEQUAL: number;
  74089. /** Passed to stencilOperation to specify that stencil value must be kept */
  74090. static readonly KEEP: number;
  74091. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74092. static readonly REPLACE: number;
  74093. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74094. static readonly INCR: number;
  74095. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74096. static readonly DECR: number;
  74097. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74098. static readonly INVERT: number;
  74099. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74100. static readonly INCR_WRAP: number;
  74101. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74102. static readonly DECR_WRAP: number;
  74103. /** Texture is not repeating outside of 0..1 UVs */
  74104. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74105. /** Texture is repeating outside of 0..1 UVs */
  74106. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74107. /** Texture is repeating and mirrored */
  74108. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74109. /** ALPHA */
  74110. static readonly TEXTUREFORMAT_ALPHA: number;
  74111. /** LUMINANCE */
  74112. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74113. /** LUMINANCE_ALPHA */
  74114. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74115. /** RGB */
  74116. static readonly TEXTUREFORMAT_RGB: number;
  74117. /** RGBA */
  74118. static readonly TEXTUREFORMAT_RGBA: number;
  74119. /** RED */
  74120. static readonly TEXTUREFORMAT_RED: number;
  74121. /** RED (2nd reference) */
  74122. static readonly TEXTUREFORMAT_R: number;
  74123. /** RG */
  74124. static readonly TEXTUREFORMAT_RG: number;
  74125. /** RED_INTEGER */
  74126. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74127. /** RED_INTEGER (2nd reference) */
  74128. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74129. /** RG_INTEGER */
  74130. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74131. /** RGB_INTEGER */
  74132. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74133. /** RGBA_INTEGER */
  74134. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74135. /** UNSIGNED_BYTE */
  74136. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74137. /** UNSIGNED_BYTE (2nd reference) */
  74138. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74139. /** FLOAT */
  74140. static readonly TEXTURETYPE_FLOAT: number;
  74141. /** HALF_FLOAT */
  74142. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74143. /** BYTE */
  74144. static readonly TEXTURETYPE_BYTE: number;
  74145. /** SHORT */
  74146. static readonly TEXTURETYPE_SHORT: number;
  74147. /** UNSIGNED_SHORT */
  74148. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74149. /** INT */
  74150. static readonly TEXTURETYPE_INT: number;
  74151. /** UNSIGNED_INT */
  74152. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74153. /** UNSIGNED_SHORT_4_4_4_4 */
  74154. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74155. /** UNSIGNED_SHORT_5_5_5_1 */
  74156. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74157. /** UNSIGNED_SHORT_5_6_5 */
  74158. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74159. /** UNSIGNED_INT_2_10_10_10_REV */
  74160. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74161. /** UNSIGNED_INT_24_8 */
  74162. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74163. /** UNSIGNED_INT_10F_11F_11F_REV */
  74164. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74165. /** UNSIGNED_INT_5_9_9_9_REV */
  74166. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74167. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74168. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74169. /** nearest is mag = nearest and min = nearest and no mip */
  74170. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74171. /** mag = nearest and min = nearest and mip = none */
  74172. static readonly TEXTURE_NEAREST_NEAREST: number;
  74173. /** Bilinear is mag = linear and min = linear and no mip */
  74174. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74175. /** mag = linear and min = linear and mip = none */
  74176. static readonly TEXTURE_LINEAR_LINEAR: number;
  74177. /** Trilinear is mag = linear and min = linear and mip = linear */
  74178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74179. /** Trilinear is mag = linear and min = linear and mip = linear */
  74180. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74181. /** mag = nearest and min = nearest and mip = nearest */
  74182. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74183. /** mag = nearest and min = linear and mip = nearest */
  74184. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74185. /** mag = nearest and min = linear and mip = linear */
  74186. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74187. /** mag = nearest and min = linear and mip = none */
  74188. static readonly TEXTURE_NEAREST_LINEAR: number;
  74189. /** nearest is mag = nearest and min = nearest and mip = linear */
  74190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74191. /** mag = linear and min = nearest and mip = nearest */
  74192. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74193. /** mag = linear and min = nearest and mip = linear */
  74194. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74196. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74197. /** mag = linear and min = nearest and mip = none */
  74198. static readonly TEXTURE_LINEAR_NEAREST: number;
  74199. /** Explicit coordinates mode */
  74200. static readonly TEXTURE_EXPLICIT_MODE: number;
  74201. /** Spherical coordinates mode */
  74202. static readonly TEXTURE_SPHERICAL_MODE: number;
  74203. /** Planar coordinates mode */
  74204. static readonly TEXTURE_PLANAR_MODE: number;
  74205. /** Cubic coordinates mode */
  74206. static readonly TEXTURE_CUBIC_MODE: number;
  74207. /** Projection coordinates mode */
  74208. static readonly TEXTURE_PROJECTION_MODE: number;
  74209. /** Skybox coordinates mode */
  74210. static readonly TEXTURE_SKYBOX_MODE: number;
  74211. /** Inverse Cubic coordinates mode */
  74212. static readonly TEXTURE_INVCUBIC_MODE: number;
  74213. /** Equirectangular coordinates mode */
  74214. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74215. /** Equirectangular Fixed coordinates mode */
  74216. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74217. /** Equirectangular Fixed Mirrored coordinates mode */
  74218. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74219. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74220. static readonly SCALEMODE_FLOOR: number;
  74221. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74222. static readonly SCALEMODE_NEAREST: number;
  74223. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74224. static readonly SCALEMODE_CEILING: number;
  74225. /**
  74226. * The dirty texture flag value
  74227. */
  74228. static readonly MATERIAL_TextureDirtyFlag: number;
  74229. /**
  74230. * The dirty light flag value
  74231. */
  74232. static readonly MATERIAL_LightDirtyFlag: number;
  74233. /**
  74234. * The dirty fresnel flag value
  74235. */
  74236. static readonly MATERIAL_FresnelDirtyFlag: number;
  74237. /**
  74238. * The dirty attribute flag value
  74239. */
  74240. static readonly MATERIAL_AttributesDirtyFlag: number;
  74241. /**
  74242. * The dirty misc flag value
  74243. */
  74244. static readonly MATERIAL_MiscDirtyFlag: number;
  74245. /**
  74246. * The all dirty flag value
  74247. */
  74248. static readonly MATERIAL_AllDirtyFlag: number;
  74249. /**
  74250. * Returns the triangle fill mode
  74251. */
  74252. static readonly MATERIAL_TriangleFillMode: number;
  74253. /**
  74254. * Returns the wireframe mode
  74255. */
  74256. static readonly MATERIAL_WireFrameFillMode: number;
  74257. /**
  74258. * Returns the point fill mode
  74259. */
  74260. static readonly MATERIAL_PointFillMode: number;
  74261. /**
  74262. * Returns the point list draw mode
  74263. */
  74264. static readonly MATERIAL_PointListDrawMode: number;
  74265. /**
  74266. * Returns the line list draw mode
  74267. */
  74268. static readonly MATERIAL_LineListDrawMode: number;
  74269. /**
  74270. * Returns the line loop draw mode
  74271. */
  74272. static readonly MATERIAL_LineLoopDrawMode: number;
  74273. /**
  74274. * Returns the line strip draw mode
  74275. */
  74276. static readonly MATERIAL_LineStripDrawMode: number;
  74277. /**
  74278. * Returns the triangle strip draw mode
  74279. */
  74280. static readonly MATERIAL_TriangleStripDrawMode: number;
  74281. /**
  74282. * Returns the triangle fan draw mode
  74283. */
  74284. static readonly MATERIAL_TriangleFanDrawMode: number;
  74285. /**
  74286. * Stores the clock-wise side orientation
  74287. */
  74288. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74289. /**
  74290. * Stores the counter clock-wise side orientation
  74291. */
  74292. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74293. /**
  74294. * Nothing
  74295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74296. */
  74297. static readonly ACTION_NothingTrigger: number;
  74298. /**
  74299. * On pick
  74300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74301. */
  74302. static readonly ACTION_OnPickTrigger: number;
  74303. /**
  74304. * On left pick
  74305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74306. */
  74307. static readonly ACTION_OnLeftPickTrigger: number;
  74308. /**
  74309. * On right pick
  74310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74311. */
  74312. static readonly ACTION_OnRightPickTrigger: number;
  74313. /**
  74314. * On center pick
  74315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74316. */
  74317. static readonly ACTION_OnCenterPickTrigger: number;
  74318. /**
  74319. * On pick down
  74320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74321. */
  74322. static readonly ACTION_OnPickDownTrigger: number;
  74323. /**
  74324. * On double pick
  74325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74326. */
  74327. static readonly ACTION_OnDoublePickTrigger: number;
  74328. /**
  74329. * On pick up
  74330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74331. */
  74332. static readonly ACTION_OnPickUpTrigger: number;
  74333. /**
  74334. * On pick out.
  74335. * This trigger will only be raised if you also declared a OnPickDown
  74336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74337. */
  74338. static readonly ACTION_OnPickOutTrigger: number;
  74339. /**
  74340. * On long press
  74341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74342. */
  74343. static readonly ACTION_OnLongPressTrigger: number;
  74344. /**
  74345. * On pointer over
  74346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74347. */
  74348. static readonly ACTION_OnPointerOverTrigger: number;
  74349. /**
  74350. * On pointer out
  74351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74352. */
  74353. static readonly ACTION_OnPointerOutTrigger: number;
  74354. /**
  74355. * On every frame
  74356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74357. */
  74358. static readonly ACTION_OnEveryFrameTrigger: number;
  74359. /**
  74360. * On intersection enter
  74361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74362. */
  74363. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74364. /**
  74365. * On intersection exit
  74366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74367. */
  74368. static readonly ACTION_OnIntersectionExitTrigger: number;
  74369. /**
  74370. * On key down
  74371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74372. */
  74373. static readonly ACTION_OnKeyDownTrigger: number;
  74374. /**
  74375. * On key up
  74376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74377. */
  74378. static readonly ACTION_OnKeyUpTrigger: number;
  74379. /**
  74380. * Billboard mode will only apply to Y axis
  74381. */
  74382. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74383. /**
  74384. * Billboard mode will apply to all axes
  74385. */
  74386. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74387. /**
  74388. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74389. */
  74390. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74391. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74392. * Test order :
  74393. * Is the bounding sphere outside the frustum ?
  74394. * If not, are the bounding box vertices outside the frustum ?
  74395. * It not, then the cullable object is in the frustum.
  74396. */
  74397. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74398. /** Culling strategy : Bounding Sphere Only.
  74399. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74400. * It's also less accurate than the standard because some not visible objects can still be selected.
  74401. * Test : is the bounding sphere outside the frustum ?
  74402. * If not, then the cullable object is in the frustum.
  74403. */
  74404. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74405. /** Culling strategy : Optimistic Inclusion.
  74406. * This in an inclusion test first, then the standard exclusion test.
  74407. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74408. * 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.
  74409. * Anyway, it's as accurate as the standard strategy.
  74410. * Test :
  74411. * Is the cullable object bounding sphere center in the frustum ?
  74412. * If not, apply the default culling strategy.
  74413. */
  74414. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74415. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74416. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74417. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74418. * 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.
  74419. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74420. * Test :
  74421. * Is the cullable object bounding sphere center in the frustum ?
  74422. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74423. */
  74424. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74425. /**
  74426. * No logging while loading
  74427. */
  74428. static readonly SCENELOADER_NO_LOGGING: number;
  74429. /**
  74430. * Minimal logging while loading
  74431. */
  74432. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74433. /**
  74434. * Summary logging while loading
  74435. */
  74436. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74437. /**
  74438. * Detailled logging while loading
  74439. */
  74440. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74441. }
  74442. }
  74443. declare module BABYLON {
  74444. /**
  74445. * This represents the required contract to create a new type of texture loader.
  74446. */
  74447. export interface IInternalTextureLoader {
  74448. /**
  74449. * Defines wether the loader supports cascade loading the different faces.
  74450. */
  74451. supportCascades: boolean;
  74452. /**
  74453. * This returns if the loader support the current file information.
  74454. * @param extension defines the file extension of the file being loaded
  74455. * @returns true if the loader can load the specified file
  74456. */
  74457. canLoad(extension: string): boolean;
  74458. /**
  74459. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74460. * @param data contains the texture data
  74461. * @param texture defines the BabylonJS internal texture
  74462. * @param createPolynomials will be true if polynomials have been requested
  74463. * @param onLoad defines the callback to trigger once the texture is ready
  74464. * @param onError defines the callback to trigger in case of error
  74465. */
  74466. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74467. /**
  74468. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74469. * @param data contains the texture data
  74470. * @param texture defines the BabylonJS internal texture
  74471. * @param callback defines the method to call once ready to upload
  74472. */
  74473. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74474. }
  74475. }
  74476. declare module BABYLON {
  74477. /**
  74478. * Class used to store and describe the pipeline context associated with an effect
  74479. */
  74480. export interface IPipelineContext {
  74481. /**
  74482. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74483. */
  74484. isAsync: boolean;
  74485. /**
  74486. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74487. */
  74488. isReady: boolean;
  74489. /** @hidden */
  74490. _getVertexShaderCode(): string | null;
  74491. /** @hidden */
  74492. _getFragmentShaderCode(): string | null;
  74493. /** @hidden */
  74494. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74495. }
  74496. }
  74497. declare module BABYLON {
  74498. /**
  74499. * Class used to store gfx data (like WebGLBuffer)
  74500. */
  74501. export class DataBuffer {
  74502. /**
  74503. * Gets or sets the number of objects referencing this buffer
  74504. */
  74505. references: number;
  74506. /** Gets or sets the size of the underlying buffer */
  74507. capacity: number;
  74508. /**
  74509. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74510. */
  74511. is32Bits: boolean;
  74512. /**
  74513. * Gets the underlying buffer
  74514. */
  74515. get underlyingResource(): any;
  74516. }
  74517. }
  74518. declare module BABYLON {
  74519. /** @hidden */
  74520. export interface IShaderProcessor {
  74521. attributeProcessor?: (attribute: string) => string;
  74522. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74523. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74524. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74525. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74526. lineProcessor?: (line: string, isFragment: boolean) => string;
  74527. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74528. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74529. }
  74530. }
  74531. declare module BABYLON {
  74532. /** @hidden */
  74533. export interface ProcessingOptions {
  74534. defines: string[];
  74535. indexParameters: any;
  74536. isFragment: boolean;
  74537. shouldUseHighPrecisionShader: boolean;
  74538. supportsUniformBuffers: boolean;
  74539. shadersRepository: string;
  74540. includesShadersStore: {
  74541. [key: string]: string;
  74542. };
  74543. processor?: IShaderProcessor;
  74544. version: string;
  74545. platformName: string;
  74546. lookForClosingBracketForUniformBuffer?: boolean;
  74547. }
  74548. }
  74549. declare module BABYLON {
  74550. /** @hidden */
  74551. export class ShaderCodeNode {
  74552. line: string;
  74553. children: ShaderCodeNode[];
  74554. additionalDefineKey?: string;
  74555. additionalDefineValue?: string;
  74556. isValid(preprocessors: {
  74557. [key: string]: string;
  74558. }): boolean;
  74559. process(preprocessors: {
  74560. [key: string]: string;
  74561. }, options: ProcessingOptions): string;
  74562. }
  74563. }
  74564. declare module BABYLON {
  74565. /** @hidden */
  74566. export class ShaderCodeCursor {
  74567. private _lines;
  74568. lineIndex: number;
  74569. get currentLine(): string;
  74570. get canRead(): boolean;
  74571. set lines(value: string[]);
  74572. }
  74573. }
  74574. declare module BABYLON {
  74575. /** @hidden */
  74576. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74577. process(preprocessors: {
  74578. [key: string]: string;
  74579. }, options: ProcessingOptions): string;
  74580. }
  74581. }
  74582. declare module BABYLON {
  74583. /** @hidden */
  74584. export class ShaderDefineExpression {
  74585. isTrue(preprocessors: {
  74586. [key: string]: string;
  74587. }): boolean;
  74588. }
  74589. }
  74590. declare module BABYLON {
  74591. /** @hidden */
  74592. export class ShaderCodeTestNode extends ShaderCodeNode {
  74593. testExpression: ShaderDefineExpression;
  74594. isValid(preprocessors: {
  74595. [key: string]: string;
  74596. }): boolean;
  74597. }
  74598. }
  74599. declare module BABYLON {
  74600. /** @hidden */
  74601. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74602. define: string;
  74603. not: boolean;
  74604. constructor(define: string, not?: boolean);
  74605. isTrue(preprocessors: {
  74606. [key: string]: string;
  74607. }): boolean;
  74608. }
  74609. }
  74610. declare module BABYLON {
  74611. /** @hidden */
  74612. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74613. leftOperand: ShaderDefineExpression;
  74614. rightOperand: ShaderDefineExpression;
  74615. isTrue(preprocessors: {
  74616. [key: string]: string;
  74617. }): boolean;
  74618. }
  74619. }
  74620. declare module BABYLON {
  74621. /** @hidden */
  74622. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74623. leftOperand: ShaderDefineExpression;
  74624. rightOperand: ShaderDefineExpression;
  74625. isTrue(preprocessors: {
  74626. [key: string]: string;
  74627. }): boolean;
  74628. }
  74629. }
  74630. declare module BABYLON {
  74631. /** @hidden */
  74632. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74633. define: string;
  74634. operand: string;
  74635. testValue: string;
  74636. constructor(define: string, operand: string, testValue: string);
  74637. isTrue(preprocessors: {
  74638. [key: string]: string;
  74639. }): boolean;
  74640. }
  74641. }
  74642. declare module BABYLON {
  74643. /**
  74644. * Class used to enable access to offline support
  74645. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74646. */
  74647. export interface IOfflineProvider {
  74648. /**
  74649. * Gets a boolean indicating if scene must be saved in the database
  74650. */
  74651. enableSceneOffline: boolean;
  74652. /**
  74653. * Gets a boolean indicating if textures must be saved in the database
  74654. */
  74655. enableTexturesOffline: boolean;
  74656. /**
  74657. * Open the offline support and make it available
  74658. * @param successCallback defines the callback to call on success
  74659. * @param errorCallback defines the callback to call on error
  74660. */
  74661. open(successCallback: () => void, errorCallback: () => void): void;
  74662. /**
  74663. * Loads an image from the offline support
  74664. * @param url defines the url to load from
  74665. * @param image defines the target DOM image
  74666. */
  74667. loadImage(url: string, image: HTMLImageElement): void;
  74668. /**
  74669. * Loads a file from offline support
  74670. * @param url defines the URL to load from
  74671. * @param sceneLoaded defines a callback to call on success
  74672. * @param progressCallBack defines a callback to call when progress changed
  74673. * @param errorCallback defines a callback to call on error
  74674. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74675. */
  74676. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74677. }
  74678. }
  74679. declare module BABYLON {
  74680. /**
  74681. * Class used to help managing file picking and drag'n'drop
  74682. * File Storage
  74683. */
  74684. export class FilesInputStore {
  74685. /**
  74686. * List of files ready to be loaded
  74687. */
  74688. static FilesToLoad: {
  74689. [key: string]: File;
  74690. };
  74691. }
  74692. }
  74693. declare module BABYLON {
  74694. /**
  74695. * Class used to define a retry strategy when error happens while loading assets
  74696. */
  74697. export class RetryStrategy {
  74698. /**
  74699. * Function used to defines an exponential back off strategy
  74700. * @param maxRetries defines the maximum number of retries (3 by default)
  74701. * @param baseInterval defines the interval between retries
  74702. * @returns the strategy function to use
  74703. */
  74704. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74705. }
  74706. }
  74707. declare module BABYLON {
  74708. /**
  74709. * @ignore
  74710. * Application error to support additional information when loading a file
  74711. */
  74712. export abstract class BaseError extends Error {
  74713. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74714. }
  74715. }
  74716. declare module BABYLON {
  74717. /** @ignore */
  74718. export class LoadFileError extends BaseError {
  74719. request?: WebRequest;
  74720. file?: File;
  74721. /**
  74722. * Creates a new LoadFileError
  74723. * @param message defines the message of the error
  74724. * @param request defines the optional web request
  74725. * @param file defines the optional file
  74726. */
  74727. constructor(message: string, object?: WebRequest | File);
  74728. }
  74729. /** @ignore */
  74730. export class RequestFileError extends BaseError {
  74731. request: WebRequest;
  74732. /**
  74733. * Creates a new LoadFileError
  74734. * @param message defines the message of the error
  74735. * @param request defines the optional web request
  74736. */
  74737. constructor(message: string, request: WebRequest);
  74738. }
  74739. /** @ignore */
  74740. export class ReadFileError extends BaseError {
  74741. file: File;
  74742. /**
  74743. * Creates a new ReadFileError
  74744. * @param message defines the message of the error
  74745. * @param file defines the optional file
  74746. */
  74747. constructor(message: string, file: File);
  74748. }
  74749. /**
  74750. * @hidden
  74751. */
  74752. export class FileTools {
  74753. /**
  74754. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74755. */
  74756. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74757. /**
  74758. * Gets or sets the base URL to use to load assets
  74759. */
  74760. static BaseUrl: string;
  74761. /**
  74762. * Default behaviour for cors in the application.
  74763. * It can be a string if the expected behavior is identical in the entire app.
  74764. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74765. */
  74766. static CorsBehavior: string | ((url: string | string[]) => string);
  74767. /**
  74768. * Gets or sets a function used to pre-process url before using them to load assets
  74769. */
  74770. static PreprocessUrl: (url: string) => string;
  74771. /**
  74772. * Removes unwanted characters from an url
  74773. * @param url defines the url to clean
  74774. * @returns the cleaned url
  74775. */
  74776. private static _CleanUrl;
  74777. /**
  74778. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74779. * @param url define the url we are trying
  74780. * @param element define the dom element where to configure the cors policy
  74781. */
  74782. static SetCorsBehavior(url: string | string[], element: {
  74783. crossOrigin: string | null;
  74784. }): void;
  74785. /**
  74786. * Loads an image as an HTMLImageElement.
  74787. * @param input url string, ArrayBuffer, or Blob to load
  74788. * @param onLoad callback called when the image successfully loads
  74789. * @param onError callback called when the image fails to load
  74790. * @param offlineProvider offline provider for caching
  74791. * @param mimeType optional mime type
  74792. * @returns the HTMLImageElement of the loaded image
  74793. */
  74794. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  74795. /**
  74796. * Reads a file from a File object
  74797. * @param file defines the file to load
  74798. * @param onSuccess defines the callback to call when data is loaded
  74799. * @param onProgress defines the callback to call during loading process
  74800. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74801. * @param onError defines the callback to call when an error occurs
  74802. * @returns a file request object
  74803. */
  74804. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74805. /**
  74806. * Loads a file from a url
  74807. * @param url url to load
  74808. * @param onSuccess callback called when the file successfully loads
  74809. * @param onProgress callback called while file is loading (if the server supports this mode)
  74810. * @param offlineProvider defines the offline provider for caching
  74811. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74812. * @param onError callback called when the file fails to load
  74813. * @returns a file request object
  74814. */
  74815. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  74816. /**
  74817. * Loads a file
  74818. * @param url url to load
  74819. * @param onSuccess callback called when the file successfully loads
  74820. * @param onProgress callback called while file is loading (if the server supports this mode)
  74821. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74822. * @param onError callback called when the file fails to load
  74823. * @param onOpened callback called when the web request is opened
  74824. * @returns a file request object
  74825. */
  74826. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  74827. /**
  74828. * Checks if the loaded document was accessed via `file:`-Protocol.
  74829. * @returns boolean
  74830. */
  74831. static IsFileURL(): boolean;
  74832. }
  74833. }
  74834. declare module BABYLON {
  74835. /** @hidden */
  74836. export class ShaderProcessor {
  74837. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74838. private static _ProcessPrecision;
  74839. private static _ExtractOperation;
  74840. private static _BuildSubExpression;
  74841. private static _BuildExpression;
  74842. private static _MoveCursorWithinIf;
  74843. private static _MoveCursor;
  74844. private static _EvaluatePreProcessors;
  74845. private static _PreparePreProcessors;
  74846. private static _ProcessShaderConversion;
  74847. private static _ProcessIncludes;
  74848. /**
  74849. * Loads a file from a url
  74850. * @param url url to load
  74851. * @param onSuccess callback called when the file successfully loads
  74852. * @param onProgress callback called while file is loading (if the server supports this mode)
  74853. * @param offlineProvider defines the offline provider for caching
  74854. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74855. * @param onError callback called when the file fails to load
  74856. * @returns a file request object
  74857. * @hidden
  74858. */
  74859. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  74860. }
  74861. }
  74862. declare module BABYLON {
  74863. /**
  74864. * @hidden
  74865. */
  74866. export interface IColor4Like {
  74867. r: float;
  74868. g: float;
  74869. b: float;
  74870. a: float;
  74871. }
  74872. /**
  74873. * @hidden
  74874. */
  74875. export interface IColor3Like {
  74876. r: float;
  74877. g: float;
  74878. b: float;
  74879. }
  74880. /**
  74881. * @hidden
  74882. */
  74883. export interface IVector4Like {
  74884. x: float;
  74885. y: float;
  74886. z: float;
  74887. w: float;
  74888. }
  74889. /**
  74890. * @hidden
  74891. */
  74892. export interface IVector3Like {
  74893. x: float;
  74894. y: float;
  74895. z: float;
  74896. }
  74897. /**
  74898. * @hidden
  74899. */
  74900. export interface IVector2Like {
  74901. x: float;
  74902. y: float;
  74903. }
  74904. /**
  74905. * @hidden
  74906. */
  74907. export interface IMatrixLike {
  74908. toArray(): DeepImmutable<Float32Array>;
  74909. updateFlag: int;
  74910. }
  74911. /**
  74912. * @hidden
  74913. */
  74914. export interface IViewportLike {
  74915. x: float;
  74916. y: float;
  74917. width: float;
  74918. height: float;
  74919. }
  74920. /**
  74921. * @hidden
  74922. */
  74923. export interface IPlaneLike {
  74924. normal: IVector3Like;
  74925. d: float;
  74926. normalize(): void;
  74927. }
  74928. }
  74929. declare module BABYLON {
  74930. /**
  74931. * Interface used to define common properties for effect fallbacks
  74932. */
  74933. export interface IEffectFallbacks {
  74934. /**
  74935. * Removes the defines that should be removed when falling back.
  74936. * @param currentDefines defines the current define statements for the shader.
  74937. * @param effect defines the current effect we try to compile
  74938. * @returns The resulting defines with defines of the current rank removed.
  74939. */
  74940. reduce(currentDefines: string, effect: Effect): string;
  74941. /**
  74942. * Removes the fallback from the bound mesh.
  74943. */
  74944. unBindMesh(): void;
  74945. /**
  74946. * Checks to see if more fallbacks are still availible.
  74947. */
  74948. hasMoreFallbacks: boolean;
  74949. }
  74950. }
  74951. declare module BABYLON {
  74952. /**
  74953. * Class used to evalaute queries containing `and` and `or` operators
  74954. */
  74955. export class AndOrNotEvaluator {
  74956. /**
  74957. * Evaluate a query
  74958. * @param query defines the query to evaluate
  74959. * @param evaluateCallback defines the callback used to filter result
  74960. * @returns true if the query matches
  74961. */
  74962. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74963. private static _HandleParenthesisContent;
  74964. private static _SimplifyNegation;
  74965. }
  74966. }
  74967. declare module BABYLON {
  74968. /**
  74969. * Class used to store custom tags
  74970. */
  74971. export class Tags {
  74972. /**
  74973. * Adds support for tags on the given object
  74974. * @param obj defines the object to use
  74975. */
  74976. static EnableFor(obj: any): void;
  74977. /**
  74978. * Removes tags support
  74979. * @param obj defines the object to use
  74980. */
  74981. static DisableFor(obj: any): void;
  74982. /**
  74983. * Gets a boolean indicating if the given object has tags
  74984. * @param obj defines the object to use
  74985. * @returns a boolean
  74986. */
  74987. static HasTags(obj: any): boolean;
  74988. /**
  74989. * Gets the tags available on a given object
  74990. * @param obj defines the object to use
  74991. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74992. * @returns the tags
  74993. */
  74994. static GetTags(obj: any, asString?: boolean): any;
  74995. /**
  74996. * Adds tags to an object
  74997. * @param obj defines the object to use
  74998. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74999. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75000. */
  75001. static AddTagsTo(obj: any, tagsString: string): void;
  75002. /**
  75003. * @hidden
  75004. */
  75005. static _AddTagTo(obj: any, tag: string): void;
  75006. /**
  75007. * Removes specific tags from a specific object
  75008. * @param obj defines the object to use
  75009. * @param tagsString defines the tags to remove
  75010. */
  75011. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75012. /**
  75013. * @hidden
  75014. */
  75015. static _RemoveTagFrom(obj: any, tag: string): void;
  75016. /**
  75017. * Defines if tags hosted on an object match a given query
  75018. * @param obj defines the object to use
  75019. * @param tagsQuery defines the tag query
  75020. * @returns a boolean
  75021. */
  75022. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75023. }
  75024. }
  75025. declare module BABYLON {
  75026. /**
  75027. * Scalar computation library
  75028. */
  75029. export class Scalar {
  75030. /**
  75031. * Two pi constants convenient for computation.
  75032. */
  75033. static TwoPi: number;
  75034. /**
  75035. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75036. * @param a number
  75037. * @param b number
  75038. * @param epsilon (default = 1.401298E-45)
  75039. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75040. */
  75041. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75042. /**
  75043. * Returns a string : the upper case translation of the number i to hexadecimal.
  75044. * @param i number
  75045. * @returns the upper case translation of the number i to hexadecimal.
  75046. */
  75047. static ToHex(i: number): string;
  75048. /**
  75049. * Returns -1 if value is negative and +1 is value is positive.
  75050. * @param value the value
  75051. * @returns the value itself if it's equal to zero.
  75052. */
  75053. static Sign(value: number): number;
  75054. /**
  75055. * Returns the value itself if it's between min and max.
  75056. * Returns min if the value is lower than min.
  75057. * Returns max if the value is greater than max.
  75058. * @param value the value to clmap
  75059. * @param min the min value to clamp to (default: 0)
  75060. * @param max the max value to clamp to (default: 1)
  75061. * @returns the clamped value
  75062. */
  75063. static Clamp(value: number, min?: number, max?: number): number;
  75064. /**
  75065. * the log2 of value.
  75066. * @param value the value to compute log2 of
  75067. * @returns the log2 of value.
  75068. */
  75069. static Log2(value: number): number;
  75070. /**
  75071. * Loops the value, so that it is never larger than length and never smaller than 0.
  75072. *
  75073. * This is similar to the modulo operator but it works with floating point numbers.
  75074. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75075. * With t = 5 and length = 2.5, the result would be 0.0.
  75076. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75077. * @param value the value
  75078. * @param length the length
  75079. * @returns the looped value
  75080. */
  75081. static Repeat(value: number, length: number): number;
  75082. /**
  75083. * Normalize the value between 0.0 and 1.0 using min and max values
  75084. * @param value value to normalize
  75085. * @param min max to normalize between
  75086. * @param max min to normalize between
  75087. * @returns the normalized value
  75088. */
  75089. static Normalize(value: number, min: number, max: number): number;
  75090. /**
  75091. * Denormalize the value from 0.0 and 1.0 using min and max values
  75092. * @param normalized value to denormalize
  75093. * @param min max to denormalize between
  75094. * @param max min to denormalize between
  75095. * @returns the denormalized value
  75096. */
  75097. static Denormalize(normalized: number, min: number, max: number): number;
  75098. /**
  75099. * Calculates the shortest difference between two given angles given in degrees.
  75100. * @param current current angle in degrees
  75101. * @param target target angle in degrees
  75102. * @returns the delta
  75103. */
  75104. static DeltaAngle(current: number, target: number): number;
  75105. /**
  75106. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75107. * @param tx value
  75108. * @param length length
  75109. * @returns The returned value will move back and forth between 0 and length
  75110. */
  75111. static PingPong(tx: number, length: number): number;
  75112. /**
  75113. * Interpolates between min and max with smoothing at the limits.
  75114. *
  75115. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75116. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75117. * @param from from
  75118. * @param to to
  75119. * @param tx value
  75120. * @returns the smooth stepped value
  75121. */
  75122. static SmoothStep(from: number, to: number, tx: number): number;
  75123. /**
  75124. * Moves a value current towards target.
  75125. *
  75126. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75127. * Negative values of maxDelta pushes the value away from target.
  75128. * @param current current value
  75129. * @param target target value
  75130. * @param maxDelta max distance to move
  75131. * @returns resulting value
  75132. */
  75133. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75134. /**
  75135. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75136. *
  75137. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75138. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75139. * @param current current value
  75140. * @param target target value
  75141. * @param maxDelta max distance to move
  75142. * @returns resulting angle
  75143. */
  75144. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75145. /**
  75146. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75147. * @param start start value
  75148. * @param end target value
  75149. * @param amount amount to lerp between
  75150. * @returns the lerped value
  75151. */
  75152. static Lerp(start: number, end: number, amount: number): number;
  75153. /**
  75154. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75155. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75156. * @param start start value
  75157. * @param end target value
  75158. * @param amount amount to lerp between
  75159. * @returns the lerped value
  75160. */
  75161. static LerpAngle(start: number, end: number, amount: number): number;
  75162. /**
  75163. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75164. * @param a start value
  75165. * @param b target value
  75166. * @param value value between a and b
  75167. * @returns the inverseLerp value
  75168. */
  75169. static InverseLerp(a: number, b: number, value: number): number;
  75170. /**
  75171. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75172. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75173. * @param value1 spline value
  75174. * @param tangent1 spline value
  75175. * @param value2 spline value
  75176. * @param tangent2 spline value
  75177. * @param amount input value
  75178. * @returns hermite result
  75179. */
  75180. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75181. /**
  75182. * Returns a random float number between and min and max values
  75183. * @param min min value of random
  75184. * @param max max value of random
  75185. * @returns random value
  75186. */
  75187. static RandomRange(min: number, max: number): number;
  75188. /**
  75189. * This function returns percentage of a number in a given range.
  75190. *
  75191. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75192. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75193. * @param number to convert to percentage
  75194. * @param min min range
  75195. * @param max max range
  75196. * @returns the percentage
  75197. */
  75198. static RangeToPercent(number: number, min: number, max: number): number;
  75199. /**
  75200. * This function returns number that corresponds to the percentage in a given range.
  75201. *
  75202. * PercentToRange(0.34,0,100) will return 34.
  75203. * @param percent to convert to number
  75204. * @param min min range
  75205. * @param max max range
  75206. * @returns the number
  75207. */
  75208. static PercentToRange(percent: number, min: number, max: number): number;
  75209. /**
  75210. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75211. * @param angle The angle to normalize in radian.
  75212. * @return The converted angle.
  75213. */
  75214. static NormalizeRadians(angle: number): number;
  75215. }
  75216. }
  75217. declare module BABYLON {
  75218. /**
  75219. * Constant used to convert a value to gamma space
  75220. * @ignorenaming
  75221. */
  75222. export const ToGammaSpace: number;
  75223. /**
  75224. * Constant used to convert a value to linear space
  75225. * @ignorenaming
  75226. */
  75227. export const ToLinearSpace = 2.2;
  75228. /**
  75229. * Constant used to define the minimal number value in Babylon.js
  75230. * @ignorenaming
  75231. */
  75232. let Epsilon: number;
  75233. }
  75234. declare module BABYLON {
  75235. /**
  75236. * Class used to represent a viewport on screen
  75237. */
  75238. export class Viewport {
  75239. /** viewport left coordinate */
  75240. x: number;
  75241. /** viewport top coordinate */
  75242. y: number;
  75243. /**viewport width */
  75244. width: number;
  75245. /** viewport height */
  75246. height: number;
  75247. /**
  75248. * Creates a Viewport object located at (x, y) and sized (width, height)
  75249. * @param x defines viewport left coordinate
  75250. * @param y defines viewport top coordinate
  75251. * @param width defines the viewport width
  75252. * @param height defines the viewport height
  75253. */
  75254. constructor(
  75255. /** viewport left coordinate */
  75256. x: number,
  75257. /** viewport top coordinate */
  75258. y: number,
  75259. /**viewport width */
  75260. width: number,
  75261. /** viewport height */
  75262. height: number);
  75263. /**
  75264. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75265. * @param renderWidth defines the rendering width
  75266. * @param renderHeight defines the rendering height
  75267. * @returns a new Viewport
  75268. */
  75269. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75270. /**
  75271. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75272. * @param renderWidth defines the rendering width
  75273. * @param renderHeight defines the rendering height
  75274. * @param ref defines the target viewport
  75275. * @returns the current viewport
  75276. */
  75277. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75278. /**
  75279. * Returns a new Viewport copied from the current one
  75280. * @returns a new Viewport
  75281. */
  75282. clone(): Viewport;
  75283. }
  75284. }
  75285. declare module BABYLON {
  75286. /**
  75287. * Class containing a set of static utilities functions for arrays.
  75288. */
  75289. export class ArrayTools {
  75290. /**
  75291. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75292. * @param size the number of element to construct and put in the array
  75293. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75294. * @returns a new array filled with new objects
  75295. */
  75296. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75297. }
  75298. }
  75299. declare module BABYLON {
  75300. /**
  75301. * Class representing a vector containing 2 coordinates
  75302. */
  75303. export class Vector2 {
  75304. /** defines the first coordinate */
  75305. x: number;
  75306. /** defines the second coordinate */
  75307. y: number;
  75308. /**
  75309. * Creates a new Vector2 from the given x and y coordinates
  75310. * @param x defines the first coordinate
  75311. * @param y defines the second coordinate
  75312. */
  75313. constructor(
  75314. /** defines the first coordinate */
  75315. x?: number,
  75316. /** defines the second coordinate */
  75317. y?: number);
  75318. /**
  75319. * Gets a string with the Vector2 coordinates
  75320. * @returns a string with the Vector2 coordinates
  75321. */
  75322. toString(): string;
  75323. /**
  75324. * Gets class name
  75325. * @returns the string "Vector2"
  75326. */
  75327. getClassName(): string;
  75328. /**
  75329. * Gets current vector hash code
  75330. * @returns the Vector2 hash code as a number
  75331. */
  75332. getHashCode(): number;
  75333. /**
  75334. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75335. * @param array defines the source array
  75336. * @param index defines the offset in source array
  75337. * @returns the current Vector2
  75338. */
  75339. toArray(array: FloatArray, index?: number): Vector2;
  75340. /**
  75341. * Copy the current vector to an array
  75342. * @returns a new array with 2 elements: the Vector2 coordinates.
  75343. */
  75344. asArray(): number[];
  75345. /**
  75346. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75347. * @param source defines the source Vector2
  75348. * @returns the current updated Vector2
  75349. */
  75350. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75351. /**
  75352. * Sets the Vector2 coordinates with the given floats
  75353. * @param x defines the first coordinate
  75354. * @param y defines the second coordinate
  75355. * @returns the current updated Vector2
  75356. */
  75357. copyFromFloats(x: number, y: number): Vector2;
  75358. /**
  75359. * Sets the Vector2 coordinates with the given floats
  75360. * @param x defines the first coordinate
  75361. * @param y defines the second coordinate
  75362. * @returns the current updated Vector2
  75363. */
  75364. set(x: number, y: number): Vector2;
  75365. /**
  75366. * Add another vector with the current one
  75367. * @param otherVector defines the other vector
  75368. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75369. */
  75370. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75371. /**
  75372. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75373. * @param otherVector defines the other vector
  75374. * @param result defines the target vector
  75375. * @returns the unmodified current Vector2
  75376. */
  75377. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75378. /**
  75379. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75380. * @param otherVector defines the other vector
  75381. * @returns the current updated Vector2
  75382. */
  75383. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75384. /**
  75385. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75386. * @param otherVector defines the other vector
  75387. * @returns a new Vector2
  75388. */
  75389. addVector3(otherVector: Vector3): Vector2;
  75390. /**
  75391. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75392. * @param otherVector defines the other vector
  75393. * @returns a new Vector2
  75394. */
  75395. subtract(otherVector: Vector2): Vector2;
  75396. /**
  75397. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75398. * @param otherVector defines the other vector
  75399. * @param result defines the target vector
  75400. * @returns the unmodified current Vector2
  75401. */
  75402. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75403. /**
  75404. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75405. * @param otherVector defines the other vector
  75406. * @returns the current updated Vector2
  75407. */
  75408. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75409. /**
  75410. * Multiplies in place the current Vector2 coordinates by the given ones
  75411. * @param otherVector defines the other vector
  75412. * @returns the current updated Vector2
  75413. */
  75414. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75415. /**
  75416. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75417. * @param otherVector defines the other vector
  75418. * @returns a new Vector2
  75419. */
  75420. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75421. /**
  75422. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75423. * @param otherVector defines the other vector
  75424. * @param result defines the target vector
  75425. * @returns the unmodified current Vector2
  75426. */
  75427. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75428. /**
  75429. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75430. * @param x defines the first coordinate
  75431. * @param y defines the second coordinate
  75432. * @returns a new Vector2
  75433. */
  75434. multiplyByFloats(x: number, y: number): Vector2;
  75435. /**
  75436. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75437. * @param otherVector defines the other vector
  75438. * @returns a new Vector2
  75439. */
  75440. divide(otherVector: Vector2): Vector2;
  75441. /**
  75442. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75443. * @param otherVector defines the other vector
  75444. * @param result defines the target vector
  75445. * @returns the unmodified current Vector2
  75446. */
  75447. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75448. /**
  75449. * Divides the current Vector2 coordinates by the given ones
  75450. * @param otherVector defines the other vector
  75451. * @returns the current updated Vector2
  75452. */
  75453. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75454. /**
  75455. * Gets a new Vector2 with current Vector2 negated coordinates
  75456. * @returns a new Vector2
  75457. */
  75458. negate(): Vector2;
  75459. /**
  75460. * Negate this vector in place
  75461. * @returns this
  75462. */
  75463. negateInPlace(): Vector2;
  75464. /**
  75465. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75466. * @param result defines the Vector3 object where to store the result
  75467. * @returns the current Vector2
  75468. */
  75469. negateToRef(result: Vector2): Vector2;
  75470. /**
  75471. * Multiply the Vector2 coordinates by scale
  75472. * @param scale defines the scaling factor
  75473. * @returns the current updated Vector2
  75474. */
  75475. scaleInPlace(scale: number): Vector2;
  75476. /**
  75477. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75478. * @param scale defines the scaling factor
  75479. * @returns a new Vector2
  75480. */
  75481. scale(scale: number): Vector2;
  75482. /**
  75483. * Scale the current Vector2 values by a factor to a given Vector2
  75484. * @param scale defines the scale factor
  75485. * @param result defines the Vector2 object where to store the result
  75486. * @returns the unmodified current Vector2
  75487. */
  75488. scaleToRef(scale: number, result: Vector2): Vector2;
  75489. /**
  75490. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75491. * @param scale defines the scale factor
  75492. * @param result defines the Vector2 object where to store the result
  75493. * @returns the unmodified current Vector2
  75494. */
  75495. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75496. /**
  75497. * Gets a boolean if two vectors are equals
  75498. * @param otherVector defines the other vector
  75499. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75500. */
  75501. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75502. /**
  75503. * Gets a boolean if two vectors are equals (using an epsilon value)
  75504. * @param otherVector defines the other vector
  75505. * @param epsilon defines the minimal distance to consider equality
  75506. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75507. */
  75508. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75509. /**
  75510. * Gets a new Vector2 from current Vector2 floored values
  75511. * @returns a new Vector2
  75512. */
  75513. floor(): Vector2;
  75514. /**
  75515. * Gets a new Vector2 from current Vector2 floored values
  75516. * @returns a new Vector2
  75517. */
  75518. fract(): Vector2;
  75519. /**
  75520. * Gets the length of the vector
  75521. * @returns the vector length (float)
  75522. */
  75523. length(): number;
  75524. /**
  75525. * Gets the vector squared length
  75526. * @returns the vector squared length (float)
  75527. */
  75528. lengthSquared(): number;
  75529. /**
  75530. * Normalize the vector
  75531. * @returns the current updated Vector2
  75532. */
  75533. normalize(): Vector2;
  75534. /**
  75535. * Gets a new Vector2 copied from the Vector2
  75536. * @returns a new Vector2
  75537. */
  75538. clone(): Vector2;
  75539. /**
  75540. * Gets a new Vector2(0, 0)
  75541. * @returns a new Vector2
  75542. */
  75543. static Zero(): Vector2;
  75544. /**
  75545. * Gets a new Vector2(1, 1)
  75546. * @returns a new Vector2
  75547. */
  75548. static One(): Vector2;
  75549. /**
  75550. * Gets a new Vector2 set from the given index element of the given array
  75551. * @param array defines the data source
  75552. * @param offset defines the offset in the data source
  75553. * @returns a new Vector2
  75554. */
  75555. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75556. /**
  75557. * Sets "result" from the given index element of the given array
  75558. * @param array defines the data source
  75559. * @param offset defines the offset in the data source
  75560. * @param result defines the target vector
  75561. */
  75562. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75563. /**
  75564. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75565. * @param value1 defines 1st point of control
  75566. * @param value2 defines 2nd point of control
  75567. * @param value3 defines 3rd point of control
  75568. * @param value4 defines 4th point of control
  75569. * @param amount defines the interpolation factor
  75570. * @returns a new Vector2
  75571. */
  75572. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75573. /**
  75574. * 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".
  75575. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75576. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75577. * @param value defines the value to clamp
  75578. * @param min defines the lower limit
  75579. * @param max defines the upper limit
  75580. * @returns a new Vector2
  75581. */
  75582. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75583. /**
  75584. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75585. * @param value1 defines the 1st control point
  75586. * @param tangent1 defines the outgoing tangent
  75587. * @param value2 defines the 2nd control point
  75588. * @param tangent2 defines the incoming tangent
  75589. * @param amount defines the interpolation factor
  75590. * @returns a new Vector2
  75591. */
  75592. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75593. /**
  75594. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75595. * @param start defines the start vector
  75596. * @param end defines the end vector
  75597. * @param amount defines the interpolation factor
  75598. * @returns a new Vector2
  75599. */
  75600. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75601. /**
  75602. * Gets the dot product of the vector "left" and the vector "right"
  75603. * @param left defines first vector
  75604. * @param right defines second vector
  75605. * @returns the dot product (float)
  75606. */
  75607. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75608. /**
  75609. * Returns a new Vector2 equal to the normalized given vector
  75610. * @param vector defines the vector to normalize
  75611. * @returns a new Vector2
  75612. */
  75613. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75614. /**
  75615. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75616. * @param left defines 1st vector
  75617. * @param right defines 2nd vector
  75618. * @returns a new Vector2
  75619. */
  75620. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75621. /**
  75622. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75623. * @param left defines 1st vector
  75624. * @param right defines 2nd vector
  75625. * @returns a new Vector2
  75626. */
  75627. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75628. /**
  75629. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75630. * @param vector defines the vector to transform
  75631. * @param transformation defines the matrix to apply
  75632. * @returns a new Vector2
  75633. */
  75634. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75635. /**
  75636. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75637. * @param vector defines the vector to transform
  75638. * @param transformation defines the matrix to apply
  75639. * @param result defines the target vector
  75640. */
  75641. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75642. /**
  75643. * Determines if a given vector is included in a triangle
  75644. * @param p defines the vector to test
  75645. * @param p0 defines 1st triangle point
  75646. * @param p1 defines 2nd triangle point
  75647. * @param p2 defines 3rd triangle point
  75648. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75649. */
  75650. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75651. /**
  75652. * Gets the distance between the vectors "value1" and "value2"
  75653. * @param value1 defines first vector
  75654. * @param value2 defines second vector
  75655. * @returns the distance between vectors
  75656. */
  75657. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75658. /**
  75659. * Returns the squared distance between the vectors "value1" and "value2"
  75660. * @param value1 defines first vector
  75661. * @param value2 defines second vector
  75662. * @returns the squared distance between vectors
  75663. */
  75664. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75665. /**
  75666. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75667. * @param value1 defines first vector
  75668. * @param value2 defines second vector
  75669. * @returns a new Vector2
  75670. */
  75671. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75672. /**
  75673. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75674. * @param p defines the middle point
  75675. * @param segA defines one point of the segment
  75676. * @param segB defines the other point of the segment
  75677. * @returns the shortest distance
  75678. */
  75679. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75680. }
  75681. /**
  75682. * Class used to store (x,y,z) vector representation
  75683. * A Vector3 is the main object used in 3D geometry
  75684. * It can represent etiher the coordinates of a point the space, either a direction
  75685. * Reminder: js uses a left handed forward facing system
  75686. */
  75687. export class Vector3 {
  75688. /**
  75689. * Defines the first coordinates (on X axis)
  75690. */
  75691. x: number;
  75692. /**
  75693. * Defines the second coordinates (on Y axis)
  75694. */
  75695. y: number;
  75696. /**
  75697. * Defines the third coordinates (on Z axis)
  75698. */
  75699. z: number;
  75700. private static _UpReadOnly;
  75701. private static _ZeroReadOnly;
  75702. /**
  75703. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75704. * @param x defines the first coordinates (on X axis)
  75705. * @param y defines the second coordinates (on Y axis)
  75706. * @param z defines the third coordinates (on Z axis)
  75707. */
  75708. constructor(
  75709. /**
  75710. * Defines the first coordinates (on X axis)
  75711. */
  75712. x?: number,
  75713. /**
  75714. * Defines the second coordinates (on Y axis)
  75715. */
  75716. y?: number,
  75717. /**
  75718. * Defines the third coordinates (on Z axis)
  75719. */
  75720. z?: number);
  75721. /**
  75722. * Creates a string representation of the Vector3
  75723. * @returns a string with the Vector3 coordinates.
  75724. */
  75725. toString(): string;
  75726. /**
  75727. * Gets the class name
  75728. * @returns the string "Vector3"
  75729. */
  75730. getClassName(): string;
  75731. /**
  75732. * Creates the Vector3 hash code
  75733. * @returns a number which tends to be unique between Vector3 instances
  75734. */
  75735. getHashCode(): number;
  75736. /**
  75737. * Creates an array containing three elements : the coordinates of the Vector3
  75738. * @returns a new array of numbers
  75739. */
  75740. asArray(): number[];
  75741. /**
  75742. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75743. * @param array defines the destination array
  75744. * @param index defines the offset in the destination array
  75745. * @returns the current Vector3
  75746. */
  75747. toArray(array: FloatArray, index?: number): Vector3;
  75748. /**
  75749. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75750. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75751. */
  75752. toQuaternion(): Quaternion;
  75753. /**
  75754. * Adds the given vector to the current Vector3
  75755. * @param otherVector defines the second operand
  75756. * @returns the current updated Vector3
  75757. */
  75758. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75759. /**
  75760. * Adds the given coordinates to the current Vector3
  75761. * @param x defines the x coordinate of the operand
  75762. * @param y defines the y coordinate of the operand
  75763. * @param z defines the z coordinate of the operand
  75764. * @returns the current updated Vector3
  75765. */
  75766. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75767. /**
  75768. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75769. * @param otherVector defines the second operand
  75770. * @returns the resulting Vector3
  75771. */
  75772. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75773. /**
  75774. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75775. * @param otherVector defines the second operand
  75776. * @param result defines the Vector3 object where to store the result
  75777. * @returns the current Vector3
  75778. */
  75779. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75780. /**
  75781. * Subtract the given vector from the current Vector3
  75782. * @param otherVector defines the second operand
  75783. * @returns the current updated Vector3
  75784. */
  75785. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75786. /**
  75787. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75788. * @param otherVector defines the second operand
  75789. * @returns the resulting Vector3
  75790. */
  75791. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75792. /**
  75793. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75794. * @param otherVector defines the second operand
  75795. * @param result defines the Vector3 object where to store the result
  75796. * @returns the current Vector3
  75797. */
  75798. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75799. /**
  75800. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75801. * @param x defines the x coordinate of the operand
  75802. * @param y defines the y coordinate of the operand
  75803. * @param z defines the z coordinate of the operand
  75804. * @returns the resulting Vector3
  75805. */
  75806. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75807. /**
  75808. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75809. * @param x defines the x coordinate of the operand
  75810. * @param y defines the y coordinate of the operand
  75811. * @param z defines the z coordinate of the operand
  75812. * @param result defines the Vector3 object where to store the result
  75813. * @returns the current Vector3
  75814. */
  75815. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75816. /**
  75817. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75818. * @returns a new Vector3
  75819. */
  75820. negate(): Vector3;
  75821. /**
  75822. * Negate this vector in place
  75823. * @returns this
  75824. */
  75825. negateInPlace(): Vector3;
  75826. /**
  75827. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75828. * @param result defines the Vector3 object where to store the result
  75829. * @returns the current Vector3
  75830. */
  75831. negateToRef(result: Vector3): Vector3;
  75832. /**
  75833. * Multiplies the Vector3 coordinates by the float "scale"
  75834. * @param scale defines the multiplier factor
  75835. * @returns the current updated Vector3
  75836. */
  75837. scaleInPlace(scale: number): Vector3;
  75838. /**
  75839. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75840. * @param scale defines the multiplier factor
  75841. * @returns a new Vector3
  75842. */
  75843. scale(scale: number): Vector3;
  75844. /**
  75845. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75846. * @param scale defines the multiplier factor
  75847. * @param result defines the Vector3 object where to store the result
  75848. * @returns the current Vector3
  75849. */
  75850. scaleToRef(scale: number, result: Vector3): Vector3;
  75851. /**
  75852. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75853. * @param scale defines the scale factor
  75854. * @param result defines the Vector3 object where to store the result
  75855. * @returns the unmodified current Vector3
  75856. */
  75857. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75858. /**
  75859. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75860. * @param otherVector defines the second operand
  75861. * @returns true if both vectors are equals
  75862. */
  75863. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75864. /**
  75865. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75866. * @param otherVector defines the second operand
  75867. * @param epsilon defines the minimal distance to define values as equals
  75868. * @returns true if both vectors are distant less than epsilon
  75869. */
  75870. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75871. /**
  75872. * Returns true if the current Vector3 coordinates equals the given floats
  75873. * @param x defines the x coordinate of the operand
  75874. * @param y defines the y coordinate of the operand
  75875. * @param z defines the z coordinate of the operand
  75876. * @returns true if both vectors are equals
  75877. */
  75878. equalsToFloats(x: number, y: number, z: number): boolean;
  75879. /**
  75880. * Multiplies the current Vector3 coordinates by the given ones
  75881. * @param otherVector defines the second operand
  75882. * @returns the current updated Vector3
  75883. */
  75884. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75885. /**
  75886. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75887. * @param otherVector defines the second operand
  75888. * @returns the new Vector3
  75889. */
  75890. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75891. /**
  75892. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75893. * @param otherVector defines the second operand
  75894. * @param result defines the Vector3 object where to store the result
  75895. * @returns the current Vector3
  75896. */
  75897. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75898. /**
  75899. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75900. * @param x defines the x coordinate of the operand
  75901. * @param y defines the y coordinate of the operand
  75902. * @param z defines the z coordinate of the operand
  75903. * @returns the new Vector3
  75904. */
  75905. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75906. /**
  75907. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75908. * @param otherVector defines the second operand
  75909. * @returns the new Vector3
  75910. */
  75911. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75912. /**
  75913. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75914. * @param otherVector defines the second operand
  75915. * @param result defines the Vector3 object where to store the result
  75916. * @returns the current Vector3
  75917. */
  75918. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75919. /**
  75920. * Divides the current Vector3 coordinates by the given ones.
  75921. * @param otherVector defines the second operand
  75922. * @returns the current updated Vector3
  75923. */
  75924. divideInPlace(otherVector: Vector3): Vector3;
  75925. /**
  75926. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75927. * @param other defines the second operand
  75928. * @returns the current updated Vector3
  75929. */
  75930. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75931. /**
  75932. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75933. * @param other defines the second operand
  75934. * @returns the current updated Vector3
  75935. */
  75936. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75937. /**
  75938. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75939. * @param x defines the x coordinate of the operand
  75940. * @param y defines the y coordinate of the operand
  75941. * @param z defines the z coordinate of the operand
  75942. * @returns the current updated Vector3
  75943. */
  75944. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75945. /**
  75946. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75947. * @param x defines the x coordinate of the operand
  75948. * @param y defines the y coordinate of the operand
  75949. * @param z defines the z coordinate of the operand
  75950. * @returns the current updated Vector3
  75951. */
  75952. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75953. /**
  75954. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75955. * Check if is non uniform within a certain amount of decimal places to account for this
  75956. * @param epsilon the amount the values can differ
  75957. * @returns if the the vector is non uniform to a certain number of decimal places
  75958. */
  75959. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75960. /**
  75961. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75962. */
  75963. get isNonUniform(): boolean;
  75964. /**
  75965. * Gets a new Vector3 from current Vector3 floored values
  75966. * @returns a new Vector3
  75967. */
  75968. floor(): Vector3;
  75969. /**
  75970. * Gets a new Vector3 from current Vector3 floored values
  75971. * @returns a new Vector3
  75972. */
  75973. fract(): Vector3;
  75974. /**
  75975. * Gets the length of the Vector3
  75976. * @returns the length of the Vector3
  75977. */
  75978. length(): number;
  75979. /**
  75980. * Gets the squared length of the Vector3
  75981. * @returns squared length of the Vector3
  75982. */
  75983. lengthSquared(): number;
  75984. /**
  75985. * Normalize the current Vector3.
  75986. * Please note that this is an in place operation.
  75987. * @returns the current updated Vector3
  75988. */
  75989. normalize(): Vector3;
  75990. /**
  75991. * Reorders the x y z properties of the vector in place
  75992. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75993. * @returns the current updated vector
  75994. */
  75995. reorderInPlace(order: string): this;
  75996. /**
  75997. * Rotates the vector around 0,0,0 by a quaternion
  75998. * @param quaternion the rotation quaternion
  75999. * @param result vector to store the result
  76000. * @returns the resulting vector
  76001. */
  76002. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76003. /**
  76004. * Rotates a vector around a given point
  76005. * @param quaternion the rotation quaternion
  76006. * @param point the point to rotate around
  76007. * @param result vector to store the result
  76008. * @returns the resulting vector
  76009. */
  76010. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76011. /**
  76012. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76013. * The cross product is then orthogonal to both current and "other"
  76014. * @param other defines the right operand
  76015. * @returns the cross product
  76016. */
  76017. cross(other: Vector3): Vector3;
  76018. /**
  76019. * Normalize the current Vector3 with the given input length.
  76020. * Please note that this is an in place operation.
  76021. * @param len the length of the vector
  76022. * @returns the current updated Vector3
  76023. */
  76024. normalizeFromLength(len: number): Vector3;
  76025. /**
  76026. * Normalize the current Vector3 to a new vector
  76027. * @returns the new Vector3
  76028. */
  76029. normalizeToNew(): Vector3;
  76030. /**
  76031. * Normalize the current Vector3 to the reference
  76032. * @param reference define the Vector3 to update
  76033. * @returns the updated Vector3
  76034. */
  76035. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76036. /**
  76037. * Creates a new Vector3 copied from the current Vector3
  76038. * @returns the new Vector3
  76039. */
  76040. clone(): Vector3;
  76041. /**
  76042. * Copies the given vector coordinates to the current Vector3 ones
  76043. * @param source defines the source Vector3
  76044. * @returns the current updated Vector3
  76045. */
  76046. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76047. /**
  76048. * Copies the given floats to the current Vector3 coordinates
  76049. * @param x defines the x coordinate of the operand
  76050. * @param y defines the y coordinate of the operand
  76051. * @param z defines the z coordinate of the operand
  76052. * @returns the current updated Vector3
  76053. */
  76054. copyFromFloats(x: number, y: number, z: number): Vector3;
  76055. /**
  76056. * Copies the given floats to the current Vector3 coordinates
  76057. * @param x defines the x coordinate of the operand
  76058. * @param y defines the y coordinate of the operand
  76059. * @param z defines the z coordinate of the operand
  76060. * @returns the current updated Vector3
  76061. */
  76062. set(x: number, y: number, z: number): Vector3;
  76063. /**
  76064. * Copies the given float to the current Vector3 coordinates
  76065. * @param v defines the x, y and z coordinates of the operand
  76066. * @returns the current updated Vector3
  76067. */
  76068. setAll(v: number): Vector3;
  76069. /**
  76070. * Get the clip factor between two vectors
  76071. * @param vector0 defines the first operand
  76072. * @param vector1 defines the second operand
  76073. * @param axis defines the axis to use
  76074. * @param size defines the size along the axis
  76075. * @returns the clip factor
  76076. */
  76077. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76078. /**
  76079. * Get angle between two vectors
  76080. * @param vector0 angle between vector0 and vector1
  76081. * @param vector1 angle between vector0 and vector1
  76082. * @param normal direction of the normal
  76083. * @return the angle between vector0 and vector1
  76084. */
  76085. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76086. /**
  76087. * Returns a new Vector3 set from the index "offset" of the given array
  76088. * @param array defines the source array
  76089. * @param offset defines the offset in the source array
  76090. * @returns the new Vector3
  76091. */
  76092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76093. /**
  76094. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76095. * @param array defines the source array
  76096. * @param offset defines the offset in the source array
  76097. * @returns the new Vector3
  76098. * @deprecated Please use FromArray instead.
  76099. */
  76100. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76101. /**
  76102. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76103. * @param array defines the source array
  76104. * @param offset defines the offset in the source array
  76105. * @param result defines the Vector3 where to store the result
  76106. */
  76107. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76108. /**
  76109. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76110. * @param array defines the source array
  76111. * @param offset defines the offset in the source array
  76112. * @param result defines the Vector3 where to store the result
  76113. * @deprecated Please use FromArrayToRef instead.
  76114. */
  76115. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76116. /**
  76117. * Sets the given vector "result" with the given floats.
  76118. * @param x defines the x coordinate of the source
  76119. * @param y defines the y coordinate of the source
  76120. * @param z defines the z coordinate of the source
  76121. * @param result defines the Vector3 where to store the result
  76122. */
  76123. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76124. /**
  76125. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76126. * @returns a new empty Vector3
  76127. */
  76128. static Zero(): Vector3;
  76129. /**
  76130. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76131. * @returns a new unit Vector3
  76132. */
  76133. static One(): Vector3;
  76134. /**
  76135. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76136. * @returns a new up Vector3
  76137. */
  76138. static Up(): Vector3;
  76139. /**
  76140. * Gets a up Vector3 that must not be updated
  76141. */
  76142. static get UpReadOnly(): DeepImmutable<Vector3>;
  76143. /**
  76144. * Gets a zero Vector3 that must not be updated
  76145. */
  76146. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76147. /**
  76148. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76149. * @returns a new down Vector3
  76150. */
  76151. static Down(): Vector3;
  76152. /**
  76153. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76154. * @returns a new forward Vector3
  76155. */
  76156. static Forward(): Vector3;
  76157. /**
  76158. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76159. * @returns a new forward Vector3
  76160. */
  76161. static Backward(): Vector3;
  76162. /**
  76163. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76164. * @returns a new right Vector3
  76165. */
  76166. static Right(): Vector3;
  76167. /**
  76168. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76169. * @returns a new left Vector3
  76170. */
  76171. static Left(): Vector3;
  76172. /**
  76173. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76174. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76175. * @param vector defines the Vector3 to transform
  76176. * @param transformation defines the transformation matrix
  76177. * @returns the transformed Vector3
  76178. */
  76179. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76180. /**
  76181. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76182. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76183. * @param vector defines the Vector3 to transform
  76184. * @param transformation defines the transformation matrix
  76185. * @param result defines the Vector3 where to store the result
  76186. */
  76187. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76188. /**
  76189. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76190. * This method computes tranformed coordinates only, not transformed direction vectors
  76191. * @param x define the x coordinate of the source vector
  76192. * @param y define the y coordinate of the source vector
  76193. * @param z define the z coordinate of the source vector
  76194. * @param transformation defines the transformation matrix
  76195. * @param result defines the Vector3 where to store the result
  76196. */
  76197. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76198. /**
  76199. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76200. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76201. * @param vector defines the Vector3 to transform
  76202. * @param transformation defines the transformation matrix
  76203. * @returns the new Vector3
  76204. */
  76205. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76206. /**
  76207. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76208. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76209. * @param vector defines the Vector3 to transform
  76210. * @param transformation defines the transformation matrix
  76211. * @param result defines the Vector3 where to store the result
  76212. */
  76213. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76214. /**
  76215. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76216. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76217. * @param x define the x coordinate of the source vector
  76218. * @param y define the y coordinate of the source vector
  76219. * @param z define the z coordinate of the source vector
  76220. * @param transformation defines the transformation matrix
  76221. * @param result defines the Vector3 where to store the result
  76222. */
  76223. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76224. /**
  76225. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76226. * @param value1 defines the first control point
  76227. * @param value2 defines the second control point
  76228. * @param value3 defines the third control point
  76229. * @param value4 defines the fourth control point
  76230. * @param amount defines the amount on the spline to use
  76231. * @returns the new Vector3
  76232. */
  76233. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76234. /**
  76235. * 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"
  76236. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76237. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76238. * @param value defines the current value
  76239. * @param min defines the lower range value
  76240. * @param max defines the upper range value
  76241. * @returns the new Vector3
  76242. */
  76243. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76244. /**
  76245. * 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"
  76246. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76247. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76248. * @param value defines the current value
  76249. * @param min defines the lower range value
  76250. * @param max defines the upper range value
  76251. * @param result defines the Vector3 where to store the result
  76252. */
  76253. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76254. /**
  76255. * Checks if a given vector is inside a specific range
  76256. * @param v defines the vector to test
  76257. * @param min defines the minimum range
  76258. * @param max defines the maximum range
  76259. */
  76260. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76261. /**
  76262. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76263. * @param value1 defines the first control point
  76264. * @param tangent1 defines the first tangent vector
  76265. * @param value2 defines the second control point
  76266. * @param tangent2 defines the second tangent vector
  76267. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76268. * @returns the new Vector3
  76269. */
  76270. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76271. /**
  76272. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76273. * @param start defines the start value
  76274. * @param end defines the end value
  76275. * @param amount max defines amount between both (between 0 and 1)
  76276. * @returns the new Vector3
  76277. */
  76278. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76279. /**
  76280. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76281. * @param start defines the start value
  76282. * @param end defines the end value
  76283. * @param amount max defines amount between both (between 0 and 1)
  76284. * @param result defines the Vector3 where to store the result
  76285. */
  76286. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76287. /**
  76288. * Returns the dot product (float) between the vectors "left" and "right"
  76289. * @param left defines the left operand
  76290. * @param right defines the right operand
  76291. * @returns the dot product
  76292. */
  76293. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76294. /**
  76295. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76296. * The cross product is then orthogonal to both "left" and "right"
  76297. * @param left defines the left operand
  76298. * @param right defines the right operand
  76299. * @returns the cross product
  76300. */
  76301. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76302. /**
  76303. * Sets the given vector "result" with the cross product of "left" and "right"
  76304. * The cross product is then orthogonal to both "left" and "right"
  76305. * @param left defines the left operand
  76306. * @param right defines the right operand
  76307. * @param result defines the Vector3 where to store the result
  76308. */
  76309. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76310. /**
  76311. * Returns a new Vector3 as the normalization of the given vector
  76312. * @param vector defines the Vector3 to normalize
  76313. * @returns the new Vector3
  76314. */
  76315. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76316. /**
  76317. * Sets the given vector "result" with the normalization of the given first vector
  76318. * @param vector defines the Vector3 to normalize
  76319. * @param result defines the Vector3 where to store the result
  76320. */
  76321. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76322. /**
  76323. * Project a Vector3 onto screen space
  76324. * @param vector defines the Vector3 to project
  76325. * @param world defines the world matrix to use
  76326. * @param transform defines the transform (view x projection) matrix to use
  76327. * @param viewport defines the screen viewport to use
  76328. * @returns the new Vector3
  76329. */
  76330. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76331. /** @hidden */
  76332. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76333. /**
  76334. * Unproject from screen space to object space
  76335. * @param source defines the screen space Vector3 to use
  76336. * @param viewportWidth defines the current width of the viewport
  76337. * @param viewportHeight defines the current height of the viewport
  76338. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76339. * @param transform defines the transform (view x projection) matrix to use
  76340. * @returns the new Vector3
  76341. */
  76342. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76343. /**
  76344. * Unproject from screen space to object space
  76345. * @param source defines the screen space Vector3 to use
  76346. * @param viewportWidth defines the current width of the viewport
  76347. * @param viewportHeight defines the current height of the viewport
  76348. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76349. * @param view defines the view matrix to use
  76350. * @param projection defines the projection matrix to use
  76351. * @returns the new Vector3
  76352. */
  76353. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76354. /**
  76355. * Unproject from screen space to object space
  76356. * @param source defines the screen space Vector3 to use
  76357. * @param viewportWidth defines the current width of the viewport
  76358. * @param viewportHeight defines the current height of the viewport
  76359. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76360. * @param view defines the view matrix to use
  76361. * @param projection defines the projection matrix to use
  76362. * @param result defines the Vector3 where to store the result
  76363. */
  76364. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76365. /**
  76366. * Unproject from screen space to object space
  76367. * @param sourceX defines the screen space x coordinate to use
  76368. * @param sourceY defines the screen space y coordinate to use
  76369. * @param sourceZ defines the screen space z coordinate to use
  76370. * @param viewportWidth defines the current width of the viewport
  76371. * @param viewportHeight defines the current height of the viewport
  76372. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76373. * @param view defines the view matrix to use
  76374. * @param projection defines the projection matrix to use
  76375. * @param result defines the Vector3 where to store the result
  76376. */
  76377. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76378. /**
  76379. * Gets the minimal coordinate values between two Vector3
  76380. * @param left defines the first operand
  76381. * @param right defines the second operand
  76382. * @returns the new Vector3
  76383. */
  76384. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76385. /**
  76386. * Gets the maximal coordinate values between two Vector3
  76387. * @param left defines the first operand
  76388. * @param right defines the second operand
  76389. * @returns the new Vector3
  76390. */
  76391. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76392. /**
  76393. * Returns the distance between the vectors "value1" and "value2"
  76394. * @param value1 defines the first operand
  76395. * @param value2 defines the second operand
  76396. * @returns the distance
  76397. */
  76398. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76399. /**
  76400. * Returns the squared distance between the vectors "value1" and "value2"
  76401. * @param value1 defines the first operand
  76402. * @param value2 defines the second operand
  76403. * @returns the squared distance
  76404. */
  76405. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76406. /**
  76407. * Returns a new Vector3 located at the center between "value1" and "value2"
  76408. * @param value1 defines the first operand
  76409. * @param value2 defines the second operand
  76410. * @returns the new Vector3
  76411. */
  76412. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76413. /**
  76414. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76415. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76416. * to something in order to rotate it from its local system to the given target system
  76417. * Note: axis1, axis2 and axis3 are normalized during this operation
  76418. * @param axis1 defines the first axis
  76419. * @param axis2 defines the second axis
  76420. * @param axis3 defines the third axis
  76421. * @returns a new Vector3
  76422. */
  76423. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76424. /**
  76425. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76426. * @param axis1 defines the first axis
  76427. * @param axis2 defines the second axis
  76428. * @param axis3 defines the third axis
  76429. * @param ref defines the Vector3 where to store the result
  76430. */
  76431. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76432. }
  76433. /**
  76434. * Vector4 class created for EulerAngle class conversion to Quaternion
  76435. */
  76436. export class Vector4 {
  76437. /** x value of the vector */
  76438. x: number;
  76439. /** y value of the vector */
  76440. y: number;
  76441. /** z value of the vector */
  76442. z: number;
  76443. /** w value of the vector */
  76444. w: number;
  76445. /**
  76446. * Creates a Vector4 object from the given floats.
  76447. * @param x x value of the vector
  76448. * @param y y value of the vector
  76449. * @param z z value of the vector
  76450. * @param w w value of the vector
  76451. */
  76452. constructor(
  76453. /** x value of the vector */
  76454. x: number,
  76455. /** y value of the vector */
  76456. y: number,
  76457. /** z value of the vector */
  76458. z: number,
  76459. /** w value of the vector */
  76460. w: number);
  76461. /**
  76462. * Returns the string with the Vector4 coordinates.
  76463. * @returns a string containing all the vector values
  76464. */
  76465. toString(): string;
  76466. /**
  76467. * Returns the string "Vector4".
  76468. * @returns "Vector4"
  76469. */
  76470. getClassName(): string;
  76471. /**
  76472. * Returns the Vector4 hash code.
  76473. * @returns a unique hash code
  76474. */
  76475. getHashCode(): number;
  76476. /**
  76477. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76478. * @returns the resulting array
  76479. */
  76480. asArray(): number[];
  76481. /**
  76482. * Populates the given array from the given index with the Vector4 coordinates.
  76483. * @param array array to populate
  76484. * @param index index of the array to start at (default: 0)
  76485. * @returns the Vector4.
  76486. */
  76487. toArray(array: FloatArray, index?: number): Vector4;
  76488. /**
  76489. * Adds the given vector to the current Vector4.
  76490. * @param otherVector the vector to add
  76491. * @returns the updated Vector4.
  76492. */
  76493. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76494. /**
  76495. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76496. * @param otherVector the vector to add
  76497. * @returns the resulting vector
  76498. */
  76499. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76500. /**
  76501. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76502. * @param otherVector the vector to add
  76503. * @param result the vector to store the result
  76504. * @returns the current Vector4.
  76505. */
  76506. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76507. /**
  76508. * Subtract in place the given vector from the current Vector4.
  76509. * @param otherVector the vector to subtract
  76510. * @returns the updated Vector4.
  76511. */
  76512. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76513. /**
  76514. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76515. * @param otherVector the vector to add
  76516. * @returns the new vector with the result
  76517. */
  76518. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76519. /**
  76520. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76521. * @param otherVector the vector to subtract
  76522. * @param result the vector to store the result
  76523. * @returns the current Vector4.
  76524. */
  76525. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76526. /**
  76527. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76528. */
  76529. /**
  76530. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76531. * @param x value to subtract
  76532. * @param y value to subtract
  76533. * @param z value to subtract
  76534. * @param w value to subtract
  76535. * @returns new vector containing the result
  76536. */
  76537. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76538. /**
  76539. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76540. * @param x value to subtract
  76541. * @param y value to subtract
  76542. * @param z value to subtract
  76543. * @param w value to subtract
  76544. * @param result the vector to store the result in
  76545. * @returns the current Vector4.
  76546. */
  76547. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76548. /**
  76549. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76550. * @returns a new vector with the negated values
  76551. */
  76552. negate(): Vector4;
  76553. /**
  76554. * Negate this vector in place
  76555. * @returns this
  76556. */
  76557. negateInPlace(): Vector4;
  76558. /**
  76559. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76560. * @param result defines the Vector3 object where to store the result
  76561. * @returns the current Vector4
  76562. */
  76563. negateToRef(result: Vector4): Vector4;
  76564. /**
  76565. * Multiplies the current Vector4 coordinates by scale (float).
  76566. * @param scale the number to scale with
  76567. * @returns the updated Vector4.
  76568. */
  76569. scaleInPlace(scale: number): Vector4;
  76570. /**
  76571. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76572. * @param scale the number to scale with
  76573. * @returns a new vector with the result
  76574. */
  76575. scale(scale: number): Vector4;
  76576. /**
  76577. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76578. * @param scale the number to scale with
  76579. * @param result a vector to store the result in
  76580. * @returns the current Vector4.
  76581. */
  76582. scaleToRef(scale: number, result: Vector4): Vector4;
  76583. /**
  76584. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76585. * @param scale defines the scale factor
  76586. * @param result defines the Vector4 object where to store the result
  76587. * @returns the unmodified current Vector4
  76588. */
  76589. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76590. /**
  76591. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76592. * @param otherVector the vector to compare against
  76593. * @returns true if they are equal
  76594. */
  76595. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76596. /**
  76597. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76598. * @param otherVector vector to compare against
  76599. * @param epsilon (Default: very small number)
  76600. * @returns true if they are equal
  76601. */
  76602. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76603. /**
  76604. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76605. * @param x x value to compare against
  76606. * @param y y value to compare against
  76607. * @param z z value to compare against
  76608. * @param w w value to compare against
  76609. * @returns true if equal
  76610. */
  76611. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76612. /**
  76613. * Multiplies in place the current Vector4 by the given one.
  76614. * @param otherVector vector to multiple with
  76615. * @returns the updated Vector4.
  76616. */
  76617. multiplyInPlace(otherVector: Vector4): Vector4;
  76618. /**
  76619. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76620. * @param otherVector vector to multiple with
  76621. * @returns resulting new vector
  76622. */
  76623. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76624. /**
  76625. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76626. * @param otherVector vector to multiple with
  76627. * @param result vector to store the result
  76628. * @returns the current Vector4.
  76629. */
  76630. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76631. /**
  76632. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76633. * @param x x value multiply with
  76634. * @param y y value multiply with
  76635. * @param z z value multiply with
  76636. * @param w w value multiply with
  76637. * @returns resulting new vector
  76638. */
  76639. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76640. /**
  76641. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76642. * @param otherVector vector to devide with
  76643. * @returns resulting new vector
  76644. */
  76645. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76646. /**
  76647. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76648. * @param otherVector vector to devide with
  76649. * @param result vector to store the result
  76650. * @returns the current Vector4.
  76651. */
  76652. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76653. /**
  76654. * Divides the current Vector3 coordinates by the given ones.
  76655. * @param otherVector vector to devide with
  76656. * @returns the updated Vector3.
  76657. */
  76658. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76659. /**
  76660. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76661. * @param other defines the second operand
  76662. * @returns the current updated Vector4
  76663. */
  76664. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76665. /**
  76666. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76667. * @param other defines the second operand
  76668. * @returns the current updated Vector4
  76669. */
  76670. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76671. /**
  76672. * Gets a new Vector4 from current Vector4 floored values
  76673. * @returns a new Vector4
  76674. */
  76675. floor(): Vector4;
  76676. /**
  76677. * Gets a new Vector4 from current Vector3 floored values
  76678. * @returns a new Vector4
  76679. */
  76680. fract(): Vector4;
  76681. /**
  76682. * Returns the Vector4 length (float).
  76683. * @returns the length
  76684. */
  76685. length(): number;
  76686. /**
  76687. * Returns the Vector4 squared length (float).
  76688. * @returns the length squared
  76689. */
  76690. lengthSquared(): number;
  76691. /**
  76692. * Normalizes in place the Vector4.
  76693. * @returns the updated Vector4.
  76694. */
  76695. normalize(): Vector4;
  76696. /**
  76697. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76698. * @returns this converted to a new vector3
  76699. */
  76700. toVector3(): Vector3;
  76701. /**
  76702. * Returns a new Vector4 copied from the current one.
  76703. * @returns the new cloned vector
  76704. */
  76705. clone(): Vector4;
  76706. /**
  76707. * Updates the current Vector4 with the given one coordinates.
  76708. * @param source the source vector to copy from
  76709. * @returns the updated Vector4.
  76710. */
  76711. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76712. /**
  76713. * Updates the current Vector4 coordinates with the given floats.
  76714. * @param x float to copy from
  76715. * @param y float to copy from
  76716. * @param z float to copy from
  76717. * @param w float to copy from
  76718. * @returns the updated Vector4.
  76719. */
  76720. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76721. /**
  76722. * Updates the current Vector4 coordinates with the given floats.
  76723. * @param x float to set from
  76724. * @param y float to set from
  76725. * @param z float to set from
  76726. * @param w float to set from
  76727. * @returns the updated Vector4.
  76728. */
  76729. set(x: number, y: number, z: number, w: number): Vector4;
  76730. /**
  76731. * Copies the given float to the current Vector3 coordinates
  76732. * @param v defines the x, y, z and w coordinates of the operand
  76733. * @returns the current updated Vector3
  76734. */
  76735. setAll(v: number): Vector4;
  76736. /**
  76737. * Returns a new Vector4 set from the starting index of the given array.
  76738. * @param array the array to pull values from
  76739. * @param offset the offset into the array to start at
  76740. * @returns the new vector
  76741. */
  76742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76743. /**
  76744. * Updates the given vector "result" from the starting index of the given array.
  76745. * @param array the array to pull values from
  76746. * @param offset the offset into the array to start at
  76747. * @param result the vector to store the result in
  76748. */
  76749. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76750. /**
  76751. * Updates the given vector "result" from the starting index of the given Float32Array.
  76752. * @param array the array to pull values from
  76753. * @param offset the offset into the array to start at
  76754. * @param result the vector to store the result in
  76755. */
  76756. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76757. /**
  76758. * Updates the given vector "result" coordinates from the given floats.
  76759. * @param x float to set from
  76760. * @param y float to set from
  76761. * @param z float to set from
  76762. * @param w float to set from
  76763. * @param result the vector to the floats in
  76764. */
  76765. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76766. /**
  76767. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76768. * @returns the new vector
  76769. */
  76770. static Zero(): Vector4;
  76771. /**
  76772. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76773. * @returns the new vector
  76774. */
  76775. static One(): Vector4;
  76776. /**
  76777. * Returns a new normalized Vector4 from the given one.
  76778. * @param vector the vector to normalize
  76779. * @returns the vector
  76780. */
  76781. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76782. /**
  76783. * Updates the given vector "result" from the normalization of the given one.
  76784. * @param vector the vector to normalize
  76785. * @param result the vector to store the result in
  76786. */
  76787. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76788. /**
  76789. * Returns a vector with the minimum values from the left and right vectors
  76790. * @param left left vector to minimize
  76791. * @param right right vector to minimize
  76792. * @returns a new vector with the minimum of the left and right vector values
  76793. */
  76794. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76795. /**
  76796. * Returns a vector with the maximum values from the left and right vectors
  76797. * @param left left vector to maximize
  76798. * @param right right vector to maximize
  76799. * @returns a new vector with the maximum of the left and right vector values
  76800. */
  76801. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76802. /**
  76803. * Returns the distance (float) between the vectors "value1" and "value2".
  76804. * @param value1 value to calulate the distance between
  76805. * @param value2 value to calulate the distance between
  76806. * @return the distance between the two vectors
  76807. */
  76808. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76809. /**
  76810. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76811. * @param value1 value to calulate the distance between
  76812. * @param value2 value to calulate the distance between
  76813. * @return the distance between the two vectors squared
  76814. */
  76815. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76816. /**
  76817. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76818. * @param value1 value to calulate the center between
  76819. * @param value2 value to calulate the center between
  76820. * @return the center between the two vectors
  76821. */
  76822. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76823. /**
  76824. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76825. * This methods computes transformed normalized direction vectors only.
  76826. * @param vector the vector to transform
  76827. * @param transformation the transformation matrix to apply
  76828. * @returns the new vector
  76829. */
  76830. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76831. /**
  76832. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76833. * This methods computes transformed normalized direction vectors only.
  76834. * @param vector the vector to transform
  76835. * @param transformation the transformation matrix to apply
  76836. * @param result the vector to store the result in
  76837. */
  76838. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76839. /**
  76840. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76841. * This methods computes transformed normalized direction vectors only.
  76842. * @param x value to transform
  76843. * @param y value to transform
  76844. * @param z value to transform
  76845. * @param w value to transform
  76846. * @param transformation the transformation matrix to apply
  76847. * @param result the vector to store the results in
  76848. */
  76849. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76850. /**
  76851. * Creates a new Vector4 from a Vector3
  76852. * @param source defines the source data
  76853. * @param w defines the 4th component (default is 0)
  76854. * @returns a new Vector4
  76855. */
  76856. static FromVector3(source: Vector3, w?: number): Vector4;
  76857. }
  76858. /**
  76859. * Class used to store quaternion data
  76860. * @see https://en.wikipedia.org/wiki/Quaternion
  76861. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76862. */
  76863. export class Quaternion {
  76864. /** defines the first component (0 by default) */
  76865. x: number;
  76866. /** defines the second component (0 by default) */
  76867. y: number;
  76868. /** defines the third component (0 by default) */
  76869. z: number;
  76870. /** defines the fourth component (1.0 by default) */
  76871. w: number;
  76872. /**
  76873. * Creates a new Quaternion from the given floats
  76874. * @param x defines the first component (0 by default)
  76875. * @param y defines the second component (0 by default)
  76876. * @param z defines the third component (0 by default)
  76877. * @param w defines the fourth component (1.0 by default)
  76878. */
  76879. constructor(
  76880. /** defines the first component (0 by default) */
  76881. x?: number,
  76882. /** defines the second component (0 by default) */
  76883. y?: number,
  76884. /** defines the third component (0 by default) */
  76885. z?: number,
  76886. /** defines the fourth component (1.0 by default) */
  76887. w?: number);
  76888. /**
  76889. * Gets a string representation for the current quaternion
  76890. * @returns a string with the Quaternion coordinates
  76891. */
  76892. toString(): string;
  76893. /**
  76894. * Gets the class name of the quaternion
  76895. * @returns the string "Quaternion"
  76896. */
  76897. getClassName(): string;
  76898. /**
  76899. * Gets a hash code for this quaternion
  76900. * @returns the quaternion hash code
  76901. */
  76902. getHashCode(): number;
  76903. /**
  76904. * Copy the quaternion to an array
  76905. * @returns a new array populated with 4 elements from the quaternion coordinates
  76906. */
  76907. asArray(): number[];
  76908. /**
  76909. * Check if two quaternions are equals
  76910. * @param otherQuaternion defines the second operand
  76911. * @return true if the current quaternion and the given one coordinates are strictly equals
  76912. */
  76913. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76914. /**
  76915. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76916. * @param otherQuaternion defines the other quaternion
  76917. * @param epsilon defines the minimal distance to consider equality
  76918. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76919. */
  76920. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76921. /**
  76922. * Clone the current quaternion
  76923. * @returns a new quaternion copied from the current one
  76924. */
  76925. clone(): Quaternion;
  76926. /**
  76927. * Copy a quaternion to the current one
  76928. * @param other defines the other quaternion
  76929. * @returns the updated current quaternion
  76930. */
  76931. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76932. /**
  76933. * Updates the current quaternion with the given float coordinates
  76934. * @param x defines the x coordinate
  76935. * @param y defines the y coordinate
  76936. * @param z defines the z coordinate
  76937. * @param w defines the w coordinate
  76938. * @returns the updated current quaternion
  76939. */
  76940. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76941. /**
  76942. * Updates the current quaternion from the given float coordinates
  76943. * @param x defines the x coordinate
  76944. * @param y defines the y coordinate
  76945. * @param z defines the z coordinate
  76946. * @param w defines the w coordinate
  76947. * @returns the updated current quaternion
  76948. */
  76949. set(x: number, y: number, z: number, w: number): Quaternion;
  76950. /**
  76951. * Adds two quaternions
  76952. * @param other defines the second operand
  76953. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76954. */
  76955. add(other: DeepImmutable<Quaternion>): Quaternion;
  76956. /**
  76957. * Add a quaternion to the current one
  76958. * @param other defines the quaternion to add
  76959. * @returns the current quaternion
  76960. */
  76961. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76962. /**
  76963. * Subtract two quaternions
  76964. * @param other defines the second operand
  76965. * @returns a new quaternion as the subtraction result of the given one from the current one
  76966. */
  76967. subtract(other: Quaternion): Quaternion;
  76968. /**
  76969. * Multiplies the current quaternion by a scale factor
  76970. * @param value defines the scale factor
  76971. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76972. */
  76973. scale(value: number): Quaternion;
  76974. /**
  76975. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76976. * @param scale defines the scale factor
  76977. * @param result defines the Quaternion object where to store the result
  76978. * @returns the unmodified current quaternion
  76979. */
  76980. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76981. /**
  76982. * Multiplies in place the current quaternion by a scale factor
  76983. * @param value defines the scale factor
  76984. * @returns the current modified quaternion
  76985. */
  76986. scaleInPlace(value: number): Quaternion;
  76987. /**
  76988. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76989. * @param scale defines the scale factor
  76990. * @param result defines the Quaternion object where to store the result
  76991. * @returns the unmodified current quaternion
  76992. */
  76993. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76994. /**
  76995. * Multiplies two quaternions
  76996. * @param q1 defines the second operand
  76997. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76998. */
  76999. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77000. /**
  77001. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77002. * @param q1 defines the second operand
  77003. * @param result defines the target quaternion
  77004. * @returns the current quaternion
  77005. */
  77006. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77007. /**
  77008. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77009. * @param q1 defines the second operand
  77010. * @returns the currentupdated quaternion
  77011. */
  77012. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77013. /**
  77014. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77015. * @param ref defines the target quaternion
  77016. * @returns the current quaternion
  77017. */
  77018. conjugateToRef(ref: Quaternion): Quaternion;
  77019. /**
  77020. * Conjugates in place (1-q) the current quaternion
  77021. * @returns the current updated quaternion
  77022. */
  77023. conjugateInPlace(): Quaternion;
  77024. /**
  77025. * Conjugates in place (1-q) the current quaternion
  77026. * @returns a new quaternion
  77027. */
  77028. conjugate(): Quaternion;
  77029. /**
  77030. * Gets length of current quaternion
  77031. * @returns the quaternion length (float)
  77032. */
  77033. length(): number;
  77034. /**
  77035. * Normalize in place the current quaternion
  77036. * @returns the current updated quaternion
  77037. */
  77038. normalize(): Quaternion;
  77039. /**
  77040. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77041. * @param order is a reserved parameter and is ignore for now
  77042. * @returns a new Vector3 containing the Euler angles
  77043. */
  77044. toEulerAngles(order?: string): Vector3;
  77045. /**
  77046. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77047. * @param result defines the vector which will be filled with the Euler angles
  77048. * @param order is a reserved parameter and is ignore for now
  77049. * @returns the current unchanged quaternion
  77050. */
  77051. toEulerAnglesToRef(result: Vector3): Quaternion;
  77052. /**
  77053. * Updates the given rotation matrix with the current quaternion values
  77054. * @param result defines the target matrix
  77055. * @returns the current unchanged quaternion
  77056. */
  77057. toRotationMatrix(result: Matrix): Quaternion;
  77058. /**
  77059. * Updates the current quaternion from the given rotation matrix values
  77060. * @param matrix defines the source matrix
  77061. * @returns the current updated quaternion
  77062. */
  77063. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77064. /**
  77065. * Creates a new quaternion from a rotation matrix
  77066. * @param matrix defines the source matrix
  77067. * @returns a new quaternion created from the given rotation matrix values
  77068. */
  77069. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77070. /**
  77071. * Updates the given quaternion with the given rotation matrix values
  77072. * @param matrix defines the source matrix
  77073. * @param result defines the target quaternion
  77074. */
  77075. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77076. /**
  77077. * Returns the dot product (float) between the quaternions "left" and "right"
  77078. * @param left defines the left operand
  77079. * @param right defines the right operand
  77080. * @returns the dot product
  77081. */
  77082. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77083. /**
  77084. * Checks if the two quaternions are close to each other
  77085. * @param quat0 defines the first quaternion to check
  77086. * @param quat1 defines the second quaternion to check
  77087. * @returns true if the two quaternions are close to each other
  77088. */
  77089. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77090. /**
  77091. * Creates an empty quaternion
  77092. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77093. */
  77094. static Zero(): Quaternion;
  77095. /**
  77096. * Inverse a given quaternion
  77097. * @param q defines the source quaternion
  77098. * @returns a new quaternion as the inverted current quaternion
  77099. */
  77100. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77101. /**
  77102. * Inverse a given quaternion
  77103. * @param q defines the source quaternion
  77104. * @param result the quaternion the result will be stored in
  77105. * @returns the result quaternion
  77106. */
  77107. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77108. /**
  77109. * Creates an identity quaternion
  77110. * @returns the identity quaternion
  77111. */
  77112. static Identity(): Quaternion;
  77113. /**
  77114. * Gets a boolean indicating if the given quaternion is identity
  77115. * @param quaternion defines the quaternion to check
  77116. * @returns true if the quaternion is identity
  77117. */
  77118. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77119. /**
  77120. * Creates a quaternion from a rotation around an axis
  77121. * @param axis defines the axis to use
  77122. * @param angle defines the angle to use
  77123. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77124. */
  77125. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77126. /**
  77127. * Creates a rotation around an axis and stores it into the given quaternion
  77128. * @param axis defines the axis to use
  77129. * @param angle defines the angle to use
  77130. * @param result defines the target quaternion
  77131. * @returns the target quaternion
  77132. */
  77133. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77134. /**
  77135. * Creates a new quaternion from data stored into an array
  77136. * @param array defines the data source
  77137. * @param offset defines the offset in the source array where the data starts
  77138. * @returns a new quaternion
  77139. */
  77140. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77141. /**
  77142. * Create a quaternion from Euler rotation angles
  77143. * @param x Pitch
  77144. * @param y Yaw
  77145. * @param z Roll
  77146. * @returns the new Quaternion
  77147. */
  77148. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77149. /**
  77150. * Updates a quaternion from Euler rotation angles
  77151. * @param x Pitch
  77152. * @param y Yaw
  77153. * @param z Roll
  77154. * @param result the quaternion to store the result
  77155. * @returns the updated quaternion
  77156. */
  77157. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77158. /**
  77159. * Create a quaternion from Euler rotation vector
  77160. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77161. * @returns the new Quaternion
  77162. */
  77163. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77164. /**
  77165. * Updates a quaternion from Euler rotation vector
  77166. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77167. * @param result the quaternion to store the result
  77168. * @returns the updated quaternion
  77169. */
  77170. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77171. /**
  77172. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77173. * @param yaw defines the rotation around Y axis
  77174. * @param pitch defines the rotation around X axis
  77175. * @param roll defines the rotation around Z axis
  77176. * @returns the new quaternion
  77177. */
  77178. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77179. /**
  77180. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77181. * @param yaw defines the rotation around Y axis
  77182. * @param pitch defines the rotation around X axis
  77183. * @param roll defines the rotation around Z axis
  77184. * @param result defines the target quaternion
  77185. */
  77186. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77187. /**
  77188. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77189. * @param alpha defines the rotation around first axis
  77190. * @param beta defines the rotation around second axis
  77191. * @param gamma defines the rotation around third axis
  77192. * @returns the new quaternion
  77193. */
  77194. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77195. /**
  77196. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77197. * @param alpha defines the rotation around first axis
  77198. * @param beta defines the rotation around second axis
  77199. * @param gamma defines the rotation around third axis
  77200. * @param result defines the target quaternion
  77201. */
  77202. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77203. /**
  77204. * 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)
  77205. * @param axis1 defines the first axis
  77206. * @param axis2 defines the second axis
  77207. * @param axis3 defines the third axis
  77208. * @returns the new quaternion
  77209. */
  77210. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77211. /**
  77212. * 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
  77213. * @param axis1 defines the first axis
  77214. * @param axis2 defines the second axis
  77215. * @param axis3 defines the third axis
  77216. * @param ref defines the target quaternion
  77217. */
  77218. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77219. /**
  77220. * Interpolates between two quaternions
  77221. * @param left defines first quaternion
  77222. * @param right defines second quaternion
  77223. * @param amount defines the gradient to use
  77224. * @returns the new interpolated quaternion
  77225. */
  77226. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77227. /**
  77228. * Interpolates between two quaternions and stores it into a target quaternion
  77229. * @param left defines first quaternion
  77230. * @param right defines second quaternion
  77231. * @param amount defines the gradient to use
  77232. * @param result defines the target quaternion
  77233. */
  77234. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77235. /**
  77236. * Interpolate between two quaternions using Hermite interpolation
  77237. * @param value1 defines first quaternion
  77238. * @param tangent1 defines the incoming tangent
  77239. * @param value2 defines second quaternion
  77240. * @param tangent2 defines the outgoing tangent
  77241. * @param amount defines the target quaternion
  77242. * @returns the new interpolated quaternion
  77243. */
  77244. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77245. }
  77246. /**
  77247. * Class used to store matrix data (4x4)
  77248. */
  77249. export class Matrix {
  77250. private static _updateFlagSeed;
  77251. private static _identityReadOnly;
  77252. private _isIdentity;
  77253. private _isIdentityDirty;
  77254. private _isIdentity3x2;
  77255. private _isIdentity3x2Dirty;
  77256. /**
  77257. * Gets the update flag of the matrix which is an unique number for the matrix.
  77258. * It will be incremented every time the matrix data change.
  77259. * You can use it to speed the comparison between two versions of the same matrix.
  77260. */
  77261. updateFlag: number;
  77262. private readonly _m;
  77263. /**
  77264. * Gets the internal data of the matrix
  77265. */
  77266. get m(): DeepImmutable<Float32Array>;
  77267. /** @hidden */
  77268. _markAsUpdated(): void;
  77269. /** @hidden */
  77270. private _updateIdentityStatus;
  77271. /**
  77272. * Creates an empty matrix (filled with zeros)
  77273. */
  77274. constructor();
  77275. /**
  77276. * Check if the current matrix is identity
  77277. * @returns true is the matrix is the identity matrix
  77278. */
  77279. isIdentity(): boolean;
  77280. /**
  77281. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77282. * @returns true is the matrix is the identity matrix
  77283. */
  77284. isIdentityAs3x2(): boolean;
  77285. /**
  77286. * Gets the determinant of the matrix
  77287. * @returns the matrix determinant
  77288. */
  77289. determinant(): number;
  77290. /**
  77291. * Returns the matrix as a Float32Array
  77292. * @returns the matrix underlying array
  77293. */
  77294. toArray(): DeepImmutable<Float32Array>;
  77295. /**
  77296. * Returns the matrix as a Float32Array
  77297. * @returns the matrix underlying array.
  77298. */
  77299. asArray(): DeepImmutable<Float32Array>;
  77300. /**
  77301. * Inverts the current matrix in place
  77302. * @returns the current inverted matrix
  77303. */
  77304. invert(): Matrix;
  77305. /**
  77306. * Sets all the matrix elements to zero
  77307. * @returns the current matrix
  77308. */
  77309. reset(): Matrix;
  77310. /**
  77311. * Adds the current matrix with a second one
  77312. * @param other defines the matrix to add
  77313. * @returns a new matrix as the addition of the current matrix and the given one
  77314. */
  77315. add(other: DeepImmutable<Matrix>): Matrix;
  77316. /**
  77317. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77318. * @param other defines the matrix to add
  77319. * @param result defines the target matrix
  77320. * @returns the current matrix
  77321. */
  77322. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77323. /**
  77324. * Adds in place the given matrix to the current matrix
  77325. * @param other defines the second operand
  77326. * @returns the current updated matrix
  77327. */
  77328. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77329. /**
  77330. * Sets the given matrix to the current inverted Matrix
  77331. * @param other defines the target matrix
  77332. * @returns the unmodified current matrix
  77333. */
  77334. invertToRef(other: Matrix): Matrix;
  77335. /**
  77336. * add a value at the specified position in the current Matrix
  77337. * @param index the index of the value within the matrix. between 0 and 15.
  77338. * @param value the value to be added
  77339. * @returns the current updated matrix
  77340. */
  77341. addAtIndex(index: number, value: number): Matrix;
  77342. /**
  77343. * mutiply the specified position in the current Matrix by a value
  77344. * @param index the index of the value within the matrix. between 0 and 15.
  77345. * @param value the value to be added
  77346. * @returns the current updated matrix
  77347. */
  77348. multiplyAtIndex(index: number, value: number): Matrix;
  77349. /**
  77350. * Inserts the translation vector (using 3 floats) in the current matrix
  77351. * @param x defines the 1st component of the translation
  77352. * @param y defines the 2nd component of the translation
  77353. * @param z defines the 3rd component of the translation
  77354. * @returns the current updated matrix
  77355. */
  77356. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77357. /**
  77358. * Adds the translation vector (using 3 floats) in the current matrix
  77359. * @param x defines the 1st component of the translation
  77360. * @param y defines the 2nd component of the translation
  77361. * @param z defines the 3rd component of the translation
  77362. * @returns the current updated matrix
  77363. */
  77364. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77365. /**
  77366. * Inserts the translation vector in the current matrix
  77367. * @param vector3 defines the translation to insert
  77368. * @returns the current updated matrix
  77369. */
  77370. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77371. /**
  77372. * Gets the translation value of the current matrix
  77373. * @returns a new Vector3 as the extracted translation from the matrix
  77374. */
  77375. getTranslation(): Vector3;
  77376. /**
  77377. * Fill a Vector3 with the extracted translation from the matrix
  77378. * @param result defines the Vector3 where to store the translation
  77379. * @returns the current matrix
  77380. */
  77381. getTranslationToRef(result: Vector3): Matrix;
  77382. /**
  77383. * Remove rotation and scaling part from the matrix
  77384. * @returns the updated matrix
  77385. */
  77386. removeRotationAndScaling(): Matrix;
  77387. /**
  77388. * Multiply two matrices
  77389. * @param other defines the second operand
  77390. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77391. */
  77392. multiply(other: DeepImmutable<Matrix>): Matrix;
  77393. /**
  77394. * Copy the current matrix from the given one
  77395. * @param other defines the source matrix
  77396. * @returns the current updated matrix
  77397. */
  77398. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77399. /**
  77400. * Populates the given array from the starting index with the current matrix values
  77401. * @param array defines the target array
  77402. * @param offset defines the offset in the target array where to start storing values
  77403. * @returns the current matrix
  77404. */
  77405. copyToArray(array: Float32Array, offset?: number): Matrix;
  77406. /**
  77407. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77408. * @param other defines the second operand
  77409. * @param result defines the matrix where to store the multiplication
  77410. * @returns the current matrix
  77411. */
  77412. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77413. /**
  77414. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77415. * @param other defines the second operand
  77416. * @param result defines the array where to store the multiplication
  77417. * @param offset defines the offset in the target array where to start storing values
  77418. * @returns the current matrix
  77419. */
  77420. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77421. /**
  77422. * Check equality between this matrix and a second one
  77423. * @param value defines the second matrix to compare
  77424. * @returns true is the current matrix and the given one values are strictly equal
  77425. */
  77426. equals(value: DeepImmutable<Matrix>): boolean;
  77427. /**
  77428. * Clone the current matrix
  77429. * @returns a new matrix from the current matrix
  77430. */
  77431. clone(): Matrix;
  77432. /**
  77433. * Returns the name of the current matrix class
  77434. * @returns the string "Matrix"
  77435. */
  77436. getClassName(): string;
  77437. /**
  77438. * Gets the hash code of the current matrix
  77439. * @returns the hash code
  77440. */
  77441. getHashCode(): number;
  77442. /**
  77443. * Decomposes the current Matrix into a translation, rotation and scaling components
  77444. * @param scale defines the scale vector3 given as a reference to update
  77445. * @param rotation defines the rotation quaternion given as a reference to update
  77446. * @param translation defines the translation vector3 given as a reference to update
  77447. * @returns true if operation was successful
  77448. */
  77449. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77450. /**
  77451. * Gets specific row of the matrix
  77452. * @param index defines the number of the row to get
  77453. * @returns the index-th row of the current matrix as a new Vector4
  77454. */
  77455. getRow(index: number): Nullable<Vector4>;
  77456. /**
  77457. * Sets the index-th row of the current matrix to the vector4 values
  77458. * @param index defines the number of the row to set
  77459. * @param row defines the target vector4
  77460. * @returns the updated current matrix
  77461. */
  77462. setRow(index: number, row: Vector4): Matrix;
  77463. /**
  77464. * Compute the transpose of the matrix
  77465. * @returns the new transposed matrix
  77466. */
  77467. transpose(): Matrix;
  77468. /**
  77469. * Compute the transpose of the matrix and store it in a given matrix
  77470. * @param result defines the target matrix
  77471. * @returns the current matrix
  77472. */
  77473. transposeToRef(result: Matrix): Matrix;
  77474. /**
  77475. * Sets the index-th row of the current matrix with the given 4 x float values
  77476. * @param index defines the row index
  77477. * @param x defines the x component to set
  77478. * @param y defines the y component to set
  77479. * @param z defines the z component to set
  77480. * @param w defines the w component to set
  77481. * @returns the updated current matrix
  77482. */
  77483. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77484. /**
  77485. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77486. * @param scale defines the scale factor
  77487. * @returns a new matrix
  77488. */
  77489. scale(scale: number): Matrix;
  77490. /**
  77491. * Scale the current matrix values by a factor to a given result matrix
  77492. * @param scale defines the scale factor
  77493. * @param result defines the matrix to store the result
  77494. * @returns the current matrix
  77495. */
  77496. scaleToRef(scale: number, result: Matrix): Matrix;
  77497. /**
  77498. * Scale the current matrix values by a factor and add the result to a given matrix
  77499. * @param scale defines the scale factor
  77500. * @param result defines the Matrix to store the result
  77501. * @returns the current matrix
  77502. */
  77503. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77504. /**
  77505. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77506. * @param ref matrix to store the result
  77507. */
  77508. toNormalMatrix(ref: Matrix): void;
  77509. /**
  77510. * Gets only rotation part of the current matrix
  77511. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77512. */
  77513. getRotationMatrix(): Matrix;
  77514. /**
  77515. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77516. * @param result defines the target matrix to store data to
  77517. * @returns the current matrix
  77518. */
  77519. getRotationMatrixToRef(result: Matrix): Matrix;
  77520. /**
  77521. * Toggles model matrix from being right handed to left handed in place and vice versa
  77522. */
  77523. toggleModelMatrixHandInPlace(): void;
  77524. /**
  77525. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77526. */
  77527. toggleProjectionMatrixHandInPlace(): void;
  77528. /**
  77529. * Creates a matrix from an array
  77530. * @param array defines the source array
  77531. * @param offset defines an offset in the source array
  77532. * @returns a new Matrix set from the starting index of the given array
  77533. */
  77534. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77535. /**
  77536. * Copy the content of an array into a given matrix
  77537. * @param array defines the source array
  77538. * @param offset defines an offset in the source array
  77539. * @param result defines the target matrix
  77540. */
  77541. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77542. /**
  77543. * Stores an array into a matrix after having multiplied each component by a given factor
  77544. * @param array defines the source array
  77545. * @param offset defines the offset in the source array
  77546. * @param scale defines the scaling factor
  77547. * @param result defines the target matrix
  77548. */
  77549. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77550. /**
  77551. * Gets an identity matrix that must not be updated
  77552. */
  77553. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77554. /**
  77555. * Stores a list of values (16) inside a given matrix
  77556. * @param initialM11 defines 1st value of 1st row
  77557. * @param initialM12 defines 2nd value of 1st row
  77558. * @param initialM13 defines 3rd value of 1st row
  77559. * @param initialM14 defines 4th value of 1st row
  77560. * @param initialM21 defines 1st value of 2nd row
  77561. * @param initialM22 defines 2nd value of 2nd row
  77562. * @param initialM23 defines 3rd value of 2nd row
  77563. * @param initialM24 defines 4th value of 2nd row
  77564. * @param initialM31 defines 1st value of 3rd row
  77565. * @param initialM32 defines 2nd value of 3rd row
  77566. * @param initialM33 defines 3rd value of 3rd row
  77567. * @param initialM34 defines 4th value of 3rd row
  77568. * @param initialM41 defines 1st value of 4th row
  77569. * @param initialM42 defines 2nd value of 4th row
  77570. * @param initialM43 defines 3rd value of 4th row
  77571. * @param initialM44 defines 4th value of 4th row
  77572. * @param result defines the target matrix
  77573. */
  77574. 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;
  77575. /**
  77576. * Creates new matrix from a list of values (16)
  77577. * @param initialM11 defines 1st value of 1st row
  77578. * @param initialM12 defines 2nd value of 1st row
  77579. * @param initialM13 defines 3rd value of 1st row
  77580. * @param initialM14 defines 4th value of 1st row
  77581. * @param initialM21 defines 1st value of 2nd row
  77582. * @param initialM22 defines 2nd value of 2nd row
  77583. * @param initialM23 defines 3rd value of 2nd row
  77584. * @param initialM24 defines 4th value of 2nd row
  77585. * @param initialM31 defines 1st value of 3rd row
  77586. * @param initialM32 defines 2nd value of 3rd row
  77587. * @param initialM33 defines 3rd value of 3rd row
  77588. * @param initialM34 defines 4th value of 3rd row
  77589. * @param initialM41 defines 1st value of 4th row
  77590. * @param initialM42 defines 2nd value of 4th row
  77591. * @param initialM43 defines 3rd value of 4th row
  77592. * @param initialM44 defines 4th value of 4th row
  77593. * @returns the new matrix
  77594. */
  77595. 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;
  77596. /**
  77597. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77598. * @param scale defines the scale vector3
  77599. * @param rotation defines the rotation quaternion
  77600. * @param translation defines the translation vector3
  77601. * @returns a new matrix
  77602. */
  77603. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77604. /**
  77605. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77606. * @param scale defines the scale vector3
  77607. * @param rotation defines the rotation quaternion
  77608. * @param translation defines the translation vector3
  77609. * @param result defines the target matrix
  77610. */
  77611. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77612. /**
  77613. * Creates a new identity matrix
  77614. * @returns a new identity matrix
  77615. */
  77616. static Identity(): Matrix;
  77617. /**
  77618. * Creates a new identity matrix and stores the result in a given matrix
  77619. * @param result defines the target matrix
  77620. */
  77621. static IdentityToRef(result: Matrix): void;
  77622. /**
  77623. * Creates a new zero matrix
  77624. * @returns a new zero matrix
  77625. */
  77626. static Zero(): Matrix;
  77627. /**
  77628. * Creates a new rotation matrix for "angle" radians around the X axis
  77629. * @param angle defines the angle (in radians) to use
  77630. * @return the new matrix
  77631. */
  77632. static RotationX(angle: number): Matrix;
  77633. /**
  77634. * Creates a new matrix as the invert of a given matrix
  77635. * @param source defines the source matrix
  77636. * @returns the new matrix
  77637. */
  77638. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77639. /**
  77640. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77641. * @param angle defines the angle (in radians) to use
  77642. * @param result defines the target matrix
  77643. */
  77644. static RotationXToRef(angle: number, result: Matrix): void;
  77645. /**
  77646. * Creates a new rotation matrix for "angle" radians around the Y axis
  77647. * @param angle defines the angle (in radians) to use
  77648. * @return the new matrix
  77649. */
  77650. static RotationY(angle: number): Matrix;
  77651. /**
  77652. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77653. * @param angle defines the angle (in radians) to use
  77654. * @param result defines the target matrix
  77655. */
  77656. static RotationYToRef(angle: number, result: Matrix): void;
  77657. /**
  77658. * Creates a new rotation matrix for "angle" radians around the Z axis
  77659. * @param angle defines the angle (in radians) to use
  77660. * @return the new matrix
  77661. */
  77662. static RotationZ(angle: number): Matrix;
  77663. /**
  77664. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77665. * @param angle defines the angle (in radians) to use
  77666. * @param result defines the target matrix
  77667. */
  77668. static RotationZToRef(angle: number, result: Matrix): void;
  77669. /**
  77670. * Creates a new rotation matrix for "angle" radians around the given axis
  77671. * @param axis defines the axis to use
  77672. * @param angle defines the angle (in radians) to use
  77673. * @return the new matrix
  77674. */
  77675. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77676. /**
  77677. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77678. * @param axis defines the axis to use
  77679. * @param angle defines the angle (in radians) to use
  77680. * @param result defines the target matrix
  77681. */
  77682. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77683. /**
  77684. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77685. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77686. * @param from defines the vector to align
  77687. * @param to defines the vector to align to
  77688. * @param result defines the target matrix
  77689. */
  77690. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77691. /**
  77692. * Creates a rotation matrix
  77693. * @param yaw defines the yaw angle in radians (Y axis)
  77694. * @param pitch defines the pitch angle in radians (X axis)
  77695. * @param roll defines the roll angle in radians (X axis)
  77696. * @returns the new rotation matrix
  77697. */
  77698. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77699. /**
  77700. * Creates a rotation matrix and stores it in a given matrix
  77701. * @param yaw defines the yaw angle in radians (Y axis)
  77702. * @param pitch defines the pitch angle in radians (X axis)
  77703. * @param roll defines the roll angle in radians (X axis)
  77704. * @param result defines the target matrix
  77705. */
  77706. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77707. /**
  77708. * Creates a scaling matrix
  77709. * @param x defines the scale factor on X axis
  77710. * @param y defines the scale factor on Y axis
  77711. * @param z defines the scale factor on Z axis
  77712. * @returns the new matrix
  77713. */
  77714. static Scaling(x: number, y: number, z: number): Matrix;
  77715. /**
  77716. * Creates a scaling matrix and stores it in a given matrix
  77717. * @param x defines the scale factor on X axis
  77718. * @param y defines the scale factor on Y axis
  77719. * @param z defines the scale factor on Z axis
  77720. * @param result defines the target matrix
  77721. */
  77722. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77723. /**
  77724. * Creates a translation matrix
  77725. * @param x defines the translation on X axis
  77726. * @param y defines the translation on Y axis
  77727. * @param z defines the translationon Z axis
  77728. * @returns the new matrix
  77729. */
  77730. static Translation(x: number, y: number, z: number): Matrix;
  77731. /**
  77732. * Creates a translation matrix and stores it in a given matrix
  77733. * @param x defines the translation on X axis
  77734. * @param y defines the translation on Y axis
  77735. * @param z defines the translationon Z axis
  77736. * @param result defines the target matrix
  77737. */
  77738. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77739. /**
  77740. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77741. * @param startValue defines the start value
  77742. * @param endValue defines the end value
  77743. * @param gradient defines the gradient factor
  77744. * @returns the new matrix
  77745. */
  77746. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77747. /**
  77748. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77749. * @param startValue defines the start value
  77750. * @param endValue defines the end value
  77751. * @param gradient defines the gradient factor
  77752. * @param result defines the Matrix object where to store data
  77753. */
  77754. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77755. /**
  77756. * Builds a new matrix whose values are computed by:
  77757. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77758. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77759. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77760. * @param startValue defines the first matrix
  77761. * @param endValue defines the second matrix
  77762. * @param gradient defines the gradient between the two matrices
  77763. * @returns the new matrix
  77764. */
  77765. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77766. /**
  77767. * Update a matrix to values which are computed by:
  77768. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77769. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77770. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77771. * @param startValue defines the first matrix
  77772. * @param endValue defines the second matrix
  77773. * @param gradient defines the gradient between the two matrices
  77774. * @param result defines the target matrix
  77775. */
  77776. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77777. /**
  77778. * 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"
  77779. * This function works in left handed mode
  77780. * @param eye defines the final position of the entity
  77781. * @param target defines where the entity should look at
  77782. * @param up defines the up vector for the entity
  77783. * @returns the new matrix
  77784. */
  77785. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77786. /**
  77787. * 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".
  77788. * This function works in left handed mode
  77789. * @param eye defines the final position of the entity
  77790. * @param target defines where the entity should look at
  77791. * @param up defines the up vector for the entity
  77792. * @param result defines the target matrix
  77793. */
  77794. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77795. /**
  77796. * 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"
  77797. * This function works in right handed mode
  77798. * @param eye defines the final position of the entity
  77799. * @param target defines where the entity should look at
  77800. * @param up defines the up vector for the entity
  77801. * @returns the new matrix
  77802. */
  77803. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77804. /**
  77805. * 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".
  77806. * This function works in right handed mode
  77807. * @param eye defines the final position of the entity
  77808. * @param target defines where the entity should look at
  77809. * @param up defines the up vector for the entity
  77810. * @param result defines the target matrix
  77811. */
  77812. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77813. /**
  77814. * Create a left-handed orthographic projection matrix
  77815. * @param width defines the viewport width
  77816. * @param height defines the viewport height
  77817. * @param znear defines the near clip plane
  77818. * @param zfar defines the far clip plane
  77819. * @returns a new matrix as a left-handed orthographic projection matrix
  77820. */
  77821. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77822. /**
  77823. * Store a left-handed orthographic projection to a given matrix
  77824. * @param width defines the viewport width
  77825. * @param height defines the viewport height
  77826. * @param znear defines the near clip plane
  77827. * @param zfar defines the far clip plane
  77828. * @param result defines the target matrix
  77829. */
  77830. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77831. /**
  77832. * Create a left-handed orthographic projection matrix
  77833. * @param left defines the viewport left coordinate
  77834. * @param right defines the viewport right coordinate
  77835. * @param bottom defines the viewport bottom coordinate
  77836. * @param top defines the viewport top coordinate
  77837. * @param znear defines the near clip plane
  77838. * @param zfar defines the far clip plane
  77839. * @returns a new matrix as a left-handed orthographic projection matrix
  77840. */
  77841. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77842. /**
  77843. * Stores a left-handed orthographic projection into a given matrix
  77844. * @param left defines the viewport left coordinate
  77845. * @param right defines the viewport right coordinate
  77846. * @param bottom defines the viewport bottom coordinate
  77847. * @param top defines the viewport top coordinate
  77848. * @param znear defines the near clip plane
  77849. * @param zfar defines the far clip plane
  77850. * @param result defines the target matrix
  77851. */
  77852. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77853. /**
  77854. * Creates a right-handed orthographic projection matrix
  77855. * @param left defines the viewport left coordinate
  77856. * @param right defines the viewport right coordinate
  77857. * @param bottom defines the viewport bottom coordinate
  77858. * @param top defines the viewport top coordinate
  77859. * @param znear defines the near clip plane
  77860. * @param zfar defines the far clip plane
  77861. * @returns a new matrix as a right-handed orthographic projection matrix
  77862. */
  77863. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77864. /**
  77865. * Stores a right-handed orthographic projection into a given matrix
  77866. * @param left defines the viewport left coordinate
  77867. * @param right defines the viewport right coordinate
  77868. * @param bottom defines the viewport bottom coordinate
  77869. * @param top defines the viewport top coordinate
  77870. * @param znear defines the near clip plane
  77871. * @param zfar defines the far clip plane
  77872. * @param result defines the target matrix
  77873. */
  77874. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77875. /**
  77876. * Creates a left-handed perspective projection matrix
  77877. * @param width defines the viewport width
  77878. * @param height defines the viewport height
  77879. * @param znear defines the near clip plane
  77880. * @param zfar defines the far clip plane
  77881. * @returns a new matrix as a left-handed perspective projection matrix
  77882. */
  77883. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77884. /**
  77885. * Creates a left-handed perspective projection matrix
  77886. * @param fov defines the horizontal field of view
  77887. * @param aspect defines the aspect ratio
  77888. * @param znear defines the near clip plane
  77889. * @param zfar defines the far clip plane
  77890. * @returns a new matrix as a left-handed perspective projection matrix
  77891. */
  77892. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77893. /**
  77894. * Stores a left-handed perspective projection into a given matrix
  77895. * @param fov defines the horizontal field of view
  77896. * @param aspect defines the aspect ratio
  77897. * @param znear defines the near clip plane
  77898. * @param zfar defines the far clip plane
  77899. * @param result defines the target matrix
  77900. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77901. */
  77902. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77903. /**
  77904. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77905. * @param fov defines the horizontal field of view
  77906. * @param aspect defines the aspect ratio
  77907. * @param znear defines the near clip plane
  77908. * @param zfar not used as infinity is used as far clip
  77909. * @param result defines the target matrix
  77910. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77911. */
  77912. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77913. /**
  77914. * Creates a right-handed perspective projection matrix
  77915. * @param fov defines the horizontal field of view
  77916. * @param aspect defines the aspect ratio
  77917. * @param znear defines the near clip plane
  77918. * @param zfar defines the far clip plane
  77919. * @returns a new matrix as a right-handed perspective projection matrix
  77920. */
  77921. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77922. /**
  77923. * Stores a right-handed perspective projection into a given matrix
  77924. * @param fov defines the horizontal field of view
  77925. * @param aspect defines the aspect ratio
  77926. * @param znear defines the near clip plane
  77927. * @param zfar defines the far clip plane
  77928. * @param result defines the target matrix
  77929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77930. */
  77931. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77932. /**
  77933. * Stores a right-handed perspective projection into a given matrix
  77934. * @param fov defines the horizontal field of view
  77935. * @param aspect defines the aspect ratio
  77936. * @param znear defines the near clip plane
  77937. * @param zfar not used as infinity is used as far clip
  77938. * @param result defines the target matrix
  77939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77940. */
  77941. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77942. /**
  77943. * Stores a perspective projection for WebVR info a given matrix
  77944. * @param fov defines the field of view
  77945. * @param znear defines the near clip plane
  77946. * @param zfar defines the far clip plane
  77947. * @param result defines the target matrix
  77948. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77949. */
  77950. static PerspectiveFovWebVRToRef(fov: {
  77951. upDegrees: number;
  77952. downDegrees: number;
  77953. leftDegrees: number;
  77954. rightDegrees: number;
  77955. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77956. /**
  77957. * Computes a complete transformation matrix
  77958. * @param viewport defines the viewport to use
  77959. * @param world defines the world matrix
  77960. * @param view defines the view matrix
  77961. * @param projection defines the projection matrix
  77962. * @param zmin defines the near clip plane
  77963. * @param zmax defines the far clip plane
  77964. * @returns the transformation matrix
  77965. */
  77966. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77967. /**
  77968. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77969. * @param matrix defines the matrix to use
  77970. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77971. */
  77972. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77973. /**
  77974. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77975. * @param matrix defines the matrix to use
  77976. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77977. */
  77978. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77979. /**
  77980. * Compute the transpose of a given matrix
  77981. * @param matrix defines the matrix to transpose
  77982. * @returns the new matrix
  77983. */
  77984. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77985. /**
  77986. * Compute the transpose of a matrix and store it in a target matrix
  77987. * @param matrix defines the matrix to transpose
  77988. * @param result defines the target matrix
  77989. */
  77990. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77991. /**
  77992. * Computes a reflection matrix from a plane
  77993. * @param plane defines the reflection plane
  77994. * @returns a new matrix
  77995. */
  77996. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77997. /**
  77998. * Computes a reflection matrix from a plane
  77999. * @param plane defines the reflection plane
  78000. * @param result defines the target matrix
  78001. */
  78002. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78003. /**
  78004. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78005. * @param xaxis defines the value of the 1st axis
  78006. * @param yaxis defines the value of the 2nd axis
  78007. * @param zaxis defines the value of the 3rd axis
  78008. * @param result defines the target matrix
  78009. */
  78010. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78011. /**
  78012. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78013. * @param quat defines the quaternion to use
  78014. * @param result defines the target matrix
  78015. */
  78016. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78017. }
  78018. /**
  78019. * @hidden
  78020. */
  78021. export class TmpVectors {
  78022. static Vector2: Vector2[];
  78023. static Vector3: Vector3[];
  78024. static Vector4: Vector4[];
  78025. static Quaternion: Quaternion[];
  78026. static Matrix: Matrix[];
  78027. }
  78028. }
  78029. declare module BABYLON {
  78030. /**
  78031. * Defines potential orientation for back face culling
  78032. */
  78033. export enum Orientation {
  78034. /**
  78035. * Clockwise
  78036. */
  78037. CW = 0,
  78038. /** Counter clockwise */
  78039. CCW = 1
  78040. }
  78041. /** Class used to represent a Bezier curve */
  78042. export class BezierCurve {
  78043. /**
  78044. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78045. * @param t defines the time
  78046. * @param x1 defines the left coordinate on X axis
  78047. * @param y1 defines the left coordinate on Y axis
  78048. * @param x2 defines the right coordinate on X axis
  78049. * @param y2 defines the right coordinate on Y axis
  78050. * @returns the interpolated value
  78051. */
  78052. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78053. }
  78054. /**
  78055. * Defines angle representation
  78056. */
  78057. export class Angle {
  78058. private _radians;
  78059. /**
  78060. * Creates an Angle object of "radians" radians (float).
  78061. * @param radians the angle in radians
  78062. */
  78063. constructor(radians: number);
  78064. /**
  78065. * Get value in degrees
  78066. * @returns the Angle value in degrees (float)
  78067. */
  78068. degrees(): number;
  78069. /**
  78070. * Get value in radians
  78071. * @returns the Angle value in radians (float)
  78072. */
  78073. radians(): number;
  78074. /**
  78075. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78076. * @param a defines first vector
  78077. * @param b defines second vector
  78078. * @returns a new Angle
  78079. */
  78080. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78081. /**
  78082. * Gets a new Angle object from the given float in radians
  78083. * @param radians defines the angle value in radians
  78084. * @returns a new Angle
  78085. */
  78086. static FromRadians(radians: number): Angle;
  78087. /**
  78088. * Gets a new Angle object from the given float in degrees
  78089. * @param degrees defines the angle value in degrees
  78090. * @returns a new Angle
  78091. */
  78092. static FromDegrees(degrees: number): Angle;
  78093. }
  78094. /**
  78095. * This represents an arc in a 2d space.
  78096. */
  78097. export class Arc2 {
  78098. /** Defines the start point of the arc */
  78099. startPoint: Vector2;
  78100. /** Defines the mid point of the arc */
  78101. midPoint: Vector2;
  78102. /** Defines the end point of the arc */
  78103. endPoint: Vector2;
  78104. /**
  78105. * Defines the center point of the arc.
  78106. */
  78107. centerPoint: Vector2;
  78108. /**
  78109. * Defines the radius of the arc.
  78110. */
  78111. radius: number;
  78112. /**
  78113. * Defines the angle of the arc (from mid point to end point).
  78114. */
  78115. angle: Angle;
  78116. /**
  78117. * Defines the start angle of the arc (from start point to middle point).
  78118. */
  78119. startAngle: Angle;
  78120. /**
  78121. * Defines the orientation of the arc (clock wise/counter clock wise).
  78122. */
  78123. orientation: Orientation;
  78124. /**
  78125. * Creates an Arc object from the three given points : start, middle and end.
  78126. * @param startPoint Defines the start point of the arc
  78127. * @param midPoint Defines the midlle point of the arc
  78128. * @param endPoint Defines the end point of the arc
  78129. */
  78130. constructor(
  78131. /** Defines the start point of the arc */
  78132. startPoint: Vector2,
  78133. /** Defines the mid point of the arc */
  78134. midPoint: Vector2,
  78135. /** Defines the end point of the arc */
  78136. endPoint: Vector2);
  78137. }
  78138. /**
  78139. * Represents a 2D path made up of multiple 2D points
  78140. */
  78141. export class Path2 {
  78142. private _points;
  78143. private _length;
  78144. /**
  78145. * If the path start and end point are the same
  78146. */
  78147. closed: boolean;
  78148. /**
  78149. * Creates a Path2 object from the starting 2D coordinates x and y.
  78150. * @param x the starting points x value
  78151. * @param y the starting points y value
  78152. */
  78153. constructor(x: number, y: number);
  78154. /**
  78155. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78156. * @param x the added points x value
  78157. * @param y the added points y value
  78158. * @returns the updated Path2.
  78159. */
  78160. addLineTo(x: number, y: number): Path2;
  78161. /**
  78162. * 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.
  78163. * @param midX middle point x value
  78164. * @param midY middle point y value
  78165. * @param endX end point x value
  78166. * @param endY end point y value
  78167. * @param numberOfSegments (default: 36)
  78168. * @returns the updated Path2.
  78169. */
  78170. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78171. /**
  78172. * Closes the Path2.
  78173. * @returns the Path2.
  78174. */
  78175. close(): Path2;
  78176. /**
  78177. * Gets the sum of the distance between each sequential point in the path
  78178. * @returns the Path2 total length (float).
  78179. */
  78180. length(): number;
  78181. /**
  78182. * Gets the points which construct the path
  78183. * @returns the Path2 internal array of points.
  78184. */
  78185. getPoints(): Vector2[];
  78186. /**
  78187. * Retreives the point at the distance aways from the starting point
  78188. * @param normalizedLengthPosition the length along the path to retreive the point from
  78189. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78190. */
  78191. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78192. /**
  78193. * Creates a new path starting from an x and y position
  78194. * @param x starting x value
  78195. * @param y starting y value
  78196. * @returns a new Path2 starting at the coordinates (x, y).
  78197. */
  78198. static StartingAt(x: number, y: number): Path2;
  78199. }
  78200. /**
  78201. * Represents a 3D path made up of multiple 3D points
  78202. */
  78203. export class Path3D {
  78204. /**
  78205. * an array of Vector3, the curve axis of the Path3D
  78206. */
  78207. path: Vector3[];
  78208. private _curve;
  78209. private _distances;
  78210. private _tangents;
  78211. private _normals;
  78212. private _binormals;
  78213. private _raw;
  78214. private _alignTangentsWithPath;
  78215. private readonly _pointAtData;
  78216. /**
  78217. * new Path3D(path, normal, raw)
  78218. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78219. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78220. * @param path an array of Vector3, the curve axis of the Path3D
  78221. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78222. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78223. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78224. */
  78225. constructor(
  78226. /**
  78227. * an array of Vector3, the curve axis of the Path3D
  78228. */
  78229. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78230. /**
  78231. * Returns the Path3D array of successive Vector3 designing its curve.
  78232. * @returns the Path3D array of successive Vector3 designing its curve.
  78233. */
  78234. getCurve(): Vector3[];
  78235. /**
  78236. * Returns the Path3D array of successive Vector3 designing its curve.
  78237. * @returns the Path3D array of successive Vector3 designing its curve.
  78238. */
  78239. getPoints(): Vector3[];
  78240. /**
  78241. * @returns the computed length (float) of the path.
  78242. */
  78243. length(): number;
  78244. /**
  78245. * Returns an array populated with tangent vectors on each Path3D curve point.
  78246. * @returns an array populated with tangent vectors on each Path3D curve point.
  78247. */
  78248. getTangents(): Vector3[];
  78249. /**
  78250. * Returns an array populated with normal vectors on each Path3D curve point.
  78251. * @returns an array populated with normal vectors on each Path3D curve point.
  78252. */
  78253. getNormals(): Vector3[];
  78254. /**
  78255. * Returns an array populated with binormal vectors on each Path3D curve point.
  78256. * @returns an array populated with binormal vectors on each Path3D curve point.
  78257. */
  78258. getBinormals(): Vector3[];
  78259. /**
  78260. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78261. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78262. */
  78263. getDistances(): number[];
  78264. /**
  78265. * Returns an interpolated point along this path
  78266. * @param position the position of the point along this path, from 0.0 to 1.0
  78267. * @returns a new Vector3 as the point
  78268. */
  78269. getPointAt(position: number): Vector3;
  78270. /**
  78271. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78272. * @param position the position of the point along this path, from 0.0 to 1.0
  78273. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78274. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78275. */
  78276. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78277. /**
  78278. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78279. * @param position the position of the point along this path, from 0.0 to 1.0
  78280. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78281. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78282. */
  78283. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78284. /**
  78285. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78286. * @param position the position of the point along this path, from 0.0 to 1.0
  78287. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78288. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78289. */
  78290. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78291. /**
  78292. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78293. * @param position the position of the point along this path, from 0.0 to 1.0
  78294. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78295. */
  78296. getDistanceAt(position: number): number;
  78297. /**
  78298. * Returns the array index of the previous point of an interpolated point along this path
  78299. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78300. * @returns the array index
  78301. */
  78302. getPreviousPointIndexAt(position: number): number;
  78303. /**
  78304. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  78305. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78306. * @returns the sub position
  78307. */
  78308. getSubPositionAt(position: number): number;
  78309. /**
  78310. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78311. * @param target the vector of which to get the closest position to
  78312. * @returns the position of the closest virtual point on this path to the target vector
  78313. */
  78314. getClosestPositionTo(target: Vector3): number;
  78315. /**
  78316. * Returns a sub path (slice) of this path
  78317. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  78318. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  78319. * @returns a sub path (slice) of this path
  78320. */
  78321. slice(start?: number, end?: number): Path3D;
  78322. /**
  78323. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78324. * @param path path which all values are copied into the curves points
  78325. * @param firstNormal which should be projected onto the curve
  78326. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78327. * @returns the same object updated.
  78328. */
  78329. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78330. private _compute;
  78331. private _getFirstNonNullVector;
  78332. private _getLastNonNullVector;
  78333. private _normalVector;
  78334. /**
  78335. * Updates the point at data for an interpolated point along this curve
  78336. * @param position the position of the point along this curve, from 0.0 to 1.0
  78337. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78338. * @returns the (updated) point at data
  78339. */
  78340. private _updatePointAtData;
  78341. /**
  78342. * Updates the point at data from the specified parameters
  78343. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78344. * @param point the interpolated point
  78345. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78346. */
  78347. private _setPointAtData;
  78348. /**
  78349. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78350. */
  78351. private _updateInterpolationMatrix;
  78352. }
  78353. /**
  78354. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78355. * A Curve3 is designed from a series of successive Vector3.
  78356. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78357. */
  78358. export class Curve3 {
  78359. private _points;
  78360. private _length;
  78361. /**
  78362. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78363. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78364. * @param v1 (Vector3) the control point
  78365. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78366. * @param nbPoints (integer) the wanted number of points in the curve
  78367. * @returns the created Curve3
  78368. */
  78369. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78370. /**
  78371. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78372. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78373. * @param v1 (Vector3) the first control point
  78374. * @param v2 (Vector3) the second control point
  78375. * @param v3 (Vector3) the end point of the Cubic Bezier
  78376. * @param nbPoints (integer) the wanted number of points in the curve
  78377. * @returns the created Curve3
  78378. */
  78379. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78380. /**
  78381. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78382. * @param p1 (Vector3) the origin point of the Hermite Spline
  78383. * @param t1 (Vector3) the tangent vector at the origin point
  78384. * @param p2 (Vector3) the end point of the Hermite Spline
  78385. * @param t2 (Vector3) the tangent vector at the end point
  78386. * @param nbPoints (integer) the wanted number of points in the curve
  78387. * @returns the created Curve3
  78388. */
  78389. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78390. /**
  78391. * Returns a Curve3 object along a CatmullRom Spline curve :
  78392. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78393. * @param nbPoints (integer) the wanted number of points between each curve control points
  78394. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78395. * @returns the created Curve3
  78396. */
  78397. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78398. /**
  78399. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78400. * A Curve3 is designed from a series of successive Vector3.
  78401. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78402. * @param points points which make up the curve
  78403. */
  78404. constructor(points: Vector3[]);
  78405. /**
  78406. * @returns the Curve3 stored array of successive Vector3
  78407. */
  78408. getPoints(): Vector3[];
  78409. /**
  78410. * @returns the computed length (float) of the curve.
  78411. */
  78412. length(): number;
  78413. /**
  78414. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78415. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78416. * curveA and curveB keep unchanged.
  78417. * @param curve the curve to continue from this curve
  78418. * @returns the newly constructed curve
  78419. */
  78420. continue(curve: DeepImmutable<Curve3>): Curve3;
  78421. private _computeLength;
  78422. }
  78423. }
  78424. declare module BABYLON {
  78425. /**
  78426. * This represents the main contract an easing function should follow.
  78427. * Easing functions are used throughout the animation system.
  78428. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78429. */
  78430. export interface IEasingFunction {
  78431. /**
  78432. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78433. * of the easing function.
  78434. * The link below provides some of the most common examples of easing functions.
  78435. * @see https://easings.net/
  78436. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78437. * @returns the corresponding value on the curve defined by the easing function
  78438. */
  78439. ease(gradient: number): number;
  78440. }
  78441. /**
  78442. * Base class used for every default easing function.
  78443. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78444. */
  78445. export class EasingFunction implements IEasingFunction {
  78446. /**
  78447. * Interpolation follows the mathematical formula associated with the easing function.
  78448. */
  78449. static readonly EASINGMODE_EASEIN: number;
  78450. /**
  78451. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78452. */
  78453. static readonly EASINGMODE_EASEOUT: number;
  78454. /**
  78455. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78456. */
  78457. static readonly EASINGMODE_EASEINOUT: number;
  78458. private _easingMode;
  78459. /**
  78460. * Sets the easing mode of the current function.
  78461. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78462. */
  78463. setEasingMode(easingMode: number): void;
  78464. /**
  78465. * Gets the current easing mode.
  78466. * @returns the easing mode
  78467. */
  78468. getEasingMode(): number;
  78469. /**
  78470. * @hidden
  78471. */
  78472. easeInCore(gradient: number): number;
  78473. /**
  78474. * Given an input gradient between 0 and 1, this returns the corresponding value
  78475. * of the easing function.
  78476. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78477. * @returns the corresponding value on the curve defined by the easing function
  78478. */
  78479. ease(gradient: number): number;
  78480. }
  78481. /**
  78482. * Easing function with a circle shape (see link below).
  78483. * @see https://easings.net/#easeInCirc
  78484. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78485. */
  78486. export class CircleEase extends EasingFunction implements IEasingFunction {
  78487. /** @hidden */
  78488. easeInCore(gradient: number): number;
  78489. }
  78490. /**
  78491. * Easing function with a ease back shape (see link below).
  78492. * @see https://easings.net/#easeInBack
  78493. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78494. */
  78495. export class BackEase extends EasingFunction implements IEasingFunction {
  78496. /** Defines the amplitude of the function */
  78497. amplitude: number;
  78498. /**
  78499. * Instantiates a back ease easing
  78500. * @see https://easings.net/#easeInBack
  78501. * @param amplitude Defines the amplitude of the function
  78502. */
  78503. constructor(
  78504. /** Defines the amplitude of the function */
  78505. amplitude?: number);
  78506. /** @hidden */
  78507. easeInCore(gradient: number): number;
  78508. }
  78509. /**
  78510. * Easing function with a bouncing shape (see link below).
  78511. * @see https://easings.net/#easeInBounce
  78512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78513. */
  78514. export class BounceEase extends EasingFunction implements IEasingFunction {
  78515. /** Defines the number of bounces */
  78516. bounces: number;
  78517. /** Defines the amplitude of the bounce */
  78518. bounciness: number;
  78519. /**
  78520. * Instantiates a bounce easing
  78521. * @see https://easings.net/#easeInBounce
  78522. * @param bounces Defines the number of bounces
  78523. * @param bounciness Defines the amplitude of the bounce
  78524. */
  78525. constructor(
  78526. /** Defines the number of bounces */
  78527. bounces?: number,
  78528. /** Defines the amplitude of the bounce */
  78529. bounciness?: number);
  78530. /** @hidden */
  78531. easeInCore(gradient: number): number;
  78532. }
  78533. /**
  78534. * Easing function with a power of 3 shape (see link below).
  78535. * @see https://easings.net/#easeInCubic
  78536. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78537. */
  78538. export class CubicEase extends EasingFunction implements IEasingFunction {
  78539. /** @hidden */
  78540. easeInCore(gradient: number): number;
  78541. }
  78542. /**
  78543. * Easing function with an elastic shape (see link below).
  78544. * @see https://easings.net/#easeInElastic
  78545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78546. */
  78547. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78548. /** Defines the number of oscillations*/
  78549. oscillations: number;
  78550. /** Defines the amplitude of the oscillations*/
  78551. springiness: number;
  78552. /**
  78553. * Instantiates an elastic easing function
  78554. * @see https://easings.net/#easeInElastic
  78555. * @param oscillations Defines the number of oscillations
  78556. * @param springiness Defines the amplitude of the oscillations
  78557. */
  78558. constructor(
  78559. /** Defines the number of oscillations*/
  78560. oscillations?: number,
  78561. /** Defines the amplitude of the oscillations*/
  78562. springiness?: number);
  78563. /** @hidden */
  78564. easeInCore(gradient: number): number;
  78565. }
  78566. /**
  78567. * Easing function with an exponential shape (see link below).
  78568. * @see https://easings.net/#easeInExpo
  78569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78570. */
  78571. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78572. /** Defines the exponent of the function */
  78573. exponent: number;
  78574. /**
  78575. * Instantiates an exponential easing function
  78576. * @see https://easings.net/#easeInExpo
  78577. * @param exponent Defines the exponent of the function
  78578. */
  78579. constructor(
  78580. /** Defines the exponent of the function */
  78581. exponent?: number);
  78582. /** @hidden */
  78583. easeInCore(gradient: number): number;
  78584. }
  78585. /**
  78586. * Easing function with a power shape (see link below).
  78587. * @see https://easings.net/#easeInQuad
  78588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78589. */
  78590. export class PowerEase extends EasingFunction implements IEasingFunction {
  78591. /** Defines the power of the function */
  78592. power: number;
  78593. /**
  78594. * Instantiates an power base easing function
  78595. * @see https://easings.net/#easeInQuad
  78596. * @param power Defines the power of the function
  78597. */
  78598. constructor(
  78599. /** Defines the power of the function */
  78600. power?: number);
  78601. /** @hidden */
  78602. easeInCore(gradient: number): number;
  78603. }
  78604. /**
  78605. * Easing function with a power of 2 shape (see link below).
  78606. * @see https://easings.net/#easeInQuad
  78607. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78608. */
  78609. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78610. /** @hidden */
  78611. easeInCore(gradient: number): number;
  78612. }
  78613. /**
  78614. * Easing function with a power of 4 shape (see link below).
  78615. * @see https://easings.net/#easeInQuart
  78616. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78617. */
  78618. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78619. /** @hidden */
  78620. easeInCore(gradient: number): number;
  78621. }
  78622. /**
  78623. * Easing function with a power of 5 shape (see link below).
  78624. * @see https://easings.net/#easeInQuint
  78625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78626. */
  78627. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78628. /** @hidden */
  78629. easeInCore(gradient: number): number;
  78630. }
  78631. /**
  78632. * Easing function with a sin shape (see link below).
  78633. * @see https://easings.net/#easeInSine
  78634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78635. */
  78636. export class SineEase extends EasingFunction implements IEasingFunction {
  78637. /** @hidden */
  78638. easeInCore(gradient: number): number;
  78639. }
  78640. /**
  78641. * Easing function with a bezier shape (see link below).
  78642. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78644. */
  78645. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78646. /** Defines the x component of the start tangent in the bezier curve */
  78647. x1: number;
  78648. /** Defines the y component of the start tangent in the bezier curve */
  78649. y1: number;
  78650. /** Defines the x component of the end tangent in the bezier curve */
  78651. x2: number;
  78652. /** Defines the y component of the end tangent in the bezier curve */
  78653. y2: number;
  78654. /**
  78655. * Instantiates a bezier function
  78656. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78657. * @param x1 Defines the x component of the start tangent in the bezier curve
  78658. * @param y1 Defines the y component of the start tangent in the bezier curve
  78659. * @param x2 Defines the x component of the end tangent in the bezier curve
  78660. * @param y2 Defines the y component of the end tangent in the bezier curve
  78661. */
  78662. constructor(
  78663. /** Defines the x component of the start tangent in the bezier curve */
  78664. x1?: number,
  78665. /** Defines the y component of the start tangent in the bezier curve */
  78666. y1?: number,
  78667. /** Defines the x component of the end tangent in the bezier curve */
  78668. x2?: number,
  78669. /** Defines the y component of the end tangent in the bezier curve */
  78670. y2?: number);
  78671. /** @hidden */
  78672. easeInCore(gradient: number): number;
  78673. }
  78674. }
  78675. declare module BABYLON {
  78676. /**
  78677. * Class used to hold a RBG color
  78678. */
  78679. export class Color3 {
  78680. /**
  78681. * Defines the red component (between 0 and 1, default is 0)
  78682. */
  78683. r: number;
  78684. /**
  78685. * Defines the green component (between 0 and 1, default is 0)
  78686. */
  78687. g: number;
  78688. /**
  78689. * Defines the blue component (between 0 and 1, default is 0)
  78690. */
  78691. b: number;
  78692. /**
  78693. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78694. * @param r defines the red component (between 0 and 1, default is 0)
  78695. * @param g defines the green component (between 0 and 1, default is 0)
  78696. * @param b defines the blue component (between 0 and 1, default is 0)
  78697. */
  78698. constructor(
  78699. /**
  78700. * Defines the red component (between 0 and 1, default is 0)
  78701. */
  78702. r?: number,
  78703. /**
  78704. * Defines the green component (between 0 and 1, default is 0)
  78705. */
  78706. g?: number,
  78707. /**
  78708. * Defines the blue component (between 0 and 1, default is 0)
  78709. */
  78710. b?: number);
  78711. /**
  78712. * Creates a string with the Color3 current values
  78713. * @returns the string representation of the Color3 object
  78714. */
  78715. toString(): string;
  78716. /**
  78717. * Returns the string "Color3"
  78718. * @returns "Color3"
  78719. */
  78720. getClassName(): string;
  78721. /**
  78722. * Compute the Color3 hash code
  78723. * @returns an unique number that can be used to hash Color3 objects
  78724. */
  78725. getHashCode(): number;
  78726. /**
  78727. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78728. * @param array defines the array where to store the r,g,b components
  78729. * @param index defines an optional index in the target array to define where to start storing values
  78730. * @returns the current Color3 object
  78731. */
  78732. toArray(array: FloatArray, index?: number): Color3;
  78733. /**
  78734. * Returns a new Color4 object from the current Color3 and the given alpha
  78735. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78736. * @returns a new Color4 object
  78737. */
  78738. toColor4(alpha?: number): Color4;
  78739. /**
  78740. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78741. * @returns the new array
  78742. */
  78743. asArray(): number[];
  78744. /**
  78745. * Returns the luminance value
  78746. * @returns a float value
  78747. */
  78748. toLuminance(): number;
  78749. /**
  78750. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78751. * @param otherColor defines the second operand
  78752. * @returns the new Color3 object
  78753. */
  78754. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78755. /**
  78756. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78757. * @param otherColor defines the second operand
  78758. * @param result defines the Color3 object where to store the result
  78759. * @returns the current Color3
  78760. */
  78761. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78762. /**
  78763. * Determines equality between Color3 objects
  78764. * @param otherColor defines the second operand
  78765. * @returns true if the rgb values are equal to the given ones
  78766. */
  78767. equals(otherColor: DeepImmutable<Color3>): boolean;
  78768. /**
  78769. * Determines equality between the current Color3 object and a set of r,b,g values
  78770. * @param r defines the red component to check
  78771. * @param g defines the green component to check
  78772. * @param b defines the blue component to check
  78773. * @returns true if the rgb values are equal to the given ones
  78774. */
  78775. equalsFloats(r: number, g: number, b: number): boolean;
  78776. /**
  78777. * Multiplies in place each rgb value by scale
  78778. * @param scale defines the scaling factor
  78779. * @returns the updated Color3
  78780. */
  78781. scale(scale: number): Color3;
  78782. /**
  78783. * Multiplies the rgb values by scale and stores the result into "result"
  78784. * @param scale defines the scaling factor
  78785. * @param result defines the Color3 object where to store the result
  78786. * @returns the unmodified current Color3
  78787. */
  78788. scaleToRef(scale: number, result: Color3): Color3;
  78789. /**
  78790. * Scale the current Color3 values by a factor and add the result to a given Color3
  78791. * @param scale defines the scale factor
  78792. * @param result defines color to store the result into
  78793. * @returns the unmodified current Color3
  78794. */
  78795. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78796. /**
  78797. * Clamps the rgb values by the min and max values and stores the result into "result"
  78798. * @param min defines minimum clamping value (default is 0)
  78799. * @param max defines maximum clamping value (default is 1)
  78800. * @param result defines color to store the result into
  78801. * @returns the original Color3
  78802. */
  78803. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78804. /**
  78805. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78806. * @param otherColor defines the second operand
  78807. * @returns the new Color3
  78808. */
  78809. add(otherColor: DeepImmutable<Color3>): Color3;
  78810. /**
  78811. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78812. * @param otherColor defines the second operand
  78813. * @param result defines Color3 object to store the result into
  78814. * @returns the unmodified current Color3
  78815. */
  78816. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78817. /**
  78818. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78819. * @param otherColor defines the second operand
  78820. * @returns the new Color3
  78821. */
  78822. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78823. /**
  78824. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78825. * @param otherColor defines the second operand
  78826. * @param result defines Color3 object to store the result into
  78827. * @returns the unmodified current Color3
  78828. */
  78829. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78830. /**
  78831. * Copy the current object
  78832. * @returns a new Color3 copied the current one
  78833. */
  78834. clone(): Color3;
  78835. /**
  78836. * Copies the rgb values from the source in the current Color3
  78837. * @param source defines the source Color3 object
  78838. * @returns the updated Color3 object
  78839. */
  78840. copyFrom(source: DeepImmutable<Color3>): Color3;
  78841. /**
  78842. * Updates the Color3 rgb values from the given floats
  78843. * @param r defines the red component to read from
  78844. * @param g defines the green component to read from
  78845. * @param b defines the blue component to read from
  78846. * @returns the current Color3 object
  78847. */
  78848. copyFromFloats(r: number, g: number, b: number): Color3;
  78849. /**
  78850. * Updates the Color3 rgb values from the given floats
  78851. * @param r defines the red component to read from
  78852. * @param g defines the green component to read from
  78853. * @param b defines the blue component to read from
  78854. * @returns the current Color3 object
  78855. */
  78856. set(r: number, g: number, b: number): Color3;
  78857. /**
  78858. * Compute the Color3 hexadecimal code as a string
  78859. * @returns a string containing the hexadecimal representation of the Color3 object
  78860. */
  78861. toHexString(): string;
  78862. /**
  78863. * Computes a new Color3 converted from the current one to linear space
  78864. * @returns a new Color3 object
  78865. */
  78866. toLinearSpace(): Color3;
  78867. /**
  78868. * Converts current color in rgb space to HSV values
  78869. * @returns a new color3 representing the HSV values
  78870. */
  78871. toHSV(): Color3;
  78872. /**
  78873. * Converts current color in rgb space to HSV values
  78874. * @param result defines the Color3 where to store the HSV values
  78875. */
  78876. toHSVToRef(result: Color3): void;
  78877. /**
  78878. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78879. * @param convertedColor defines the Color3 object where to store the linear space version
  78880. * @returns the unmodified Color3
  78881. */
  78882. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78883. /**
  78884. * Computes a new Color3 converted from the current one to gamma space
  78885. * @returns a new Color3 object
  78886. */
  78887. toGammaSpace(): Color3;
  78888. /**
  78889. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78890. * @param convertedColor defines the Color3 object where to store the gamma space version
  78891. * @returns the unmodified Color3
  78892. */
  78893. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78894. private static _BlackReadOnly;
  78895. /**
  78896. * Convert Hue, saturation and value to a Color3 (RGB)
  78897. * @param hue defines the hue
  78898. * @param saturation defines the saturation
  78899. * @param value defines the value
  78900. * @param result defines the Color3 where to store the RGB values
  78901. */
  78902. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78903. /**
  78904. * Creates a new Color3 from the string containing valid hexadecimal values
  78905. * @param hex defines a string containing valid hexadecimal values
  78906. * @returns a new Color3 object
  78907. */
  78908. static FromHexString(hex: string): Color3;
  78909. /**
  78910. * Creates a new Color3 from the starting index of the given array
  78911. * @param array defines the source array
  78912. * @param offset defines an offset in the source array
  78913. * @returns a new Color3 object
  78914. */
  78915. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78916. /**
  78917. * Creates a new Color3 from integer values (< 256)
  78918. * @param r defines the red component to read from (value between 0 and 255)
  78919. * @param g defines the green component to read from (value between 0 and 255)
  78920. * @param b defines the blue component to read from (value between 0 and 255)
  78921. * @returns a new Color3 object
  78922. */
  78923. static FromInts(r: number, g: number, b: number): Color3;
  78924. /**
  78925. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78926. * @param start defines the start Color3 value
  78927. * @param end defines the end Color3 value
  78928. * @param amount defines the gradient value between start and end
  78929. * @returns a new Color3 object
  78930. */
  78931. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78932. /**
  78933. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78934. * @param left defines the start value
  78935. * @param right defines the end value
  78936. * @param amount defines the gradient factor
  78937. * @param result defines the Color3 object where to store the result
  78938. */
  78939. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78940. /**
  78941. * Returns a Color3 value containing a red color
  78942. * @returns a new Color3 object
  78943. */
  78944. static Red(): Color3;
  78945. /**
  78946. * Returns a Color3 value containing a green color
  78947. * @returns a new Color3 object
  78948. */
  78949. static Green(): Color3;
  78950. /**
  78951. * Returns a Color3 value containing a blue color
  78952. * @returns a new Color3 object
  78953. */
  78954. static Blue(): Color3;
  78955. /**
  78956. * Returns a Color3 value containing a black color
  78957. * @returns a new Color3 object
  78958. */
  78959. static Black(): Color3;
  78960. /**
  78961. * Gets a Color3 value containing a black color that must not be updated
  78962. */
  78963. static get BlackReadOnly(): DeepImmutable<Color3>;
  78964. /**
  78965. * Returns a Color3 value containing a white color
  78966. * @returns a new Color3 object
  78967. */
  78968. static White(): Color3;
  78969. /**
  78970. * Returns a Color3 value containing a purple color
  78971. * @returns a new Color3 object
  78972. */
  78973. static Purple(): Color3;
  78974. /**
  78975. * Returns a Color3 value containing a magenta color
  78976. * @returns a new Color3 object
  78977. */
  78978. static Magenta(): Color3;
  78979. /**
  78980. * Returns a Color3 value containing a yellow color
  78981. * @returns a new Color3 object
  78982. */
  78983. static Yellow(): Color3;
  78984. /**
  78985. * Returns a Color3 value containing a gray color
  78986. * @returns a new Color3 object
  78987. */
  78988. static Gray(): Color3;
  78989. /**
  78990. * Returns a Color3 value containing a teal color
  78991. * @returns a new Color3 object
  78992. */
  78993. static Teal(): Color3;
  78994. /**
  78995. * Returns a Color3 value containing a random color
  78996. * @returns a new Color3 object
  78997. */
  78998. static Random(): Color3;
  78999. }
  79000. /**
  79001. * Class used to hold a RBGA color
  79002. */
  79003. export class Color4 {
  79004. /**
  79005. * Defines the red component (between 0 and 1, default is 0)
  79006. */
  79007. r: number;
  79008. /**
  79009. * Defines the green component (between 0 and 1, default is 0)
  79010. */
  79011. g: number;
  79012. /**
  79013. * Defines the blue component (between 0 and 1, default is 0)
  79014. */
  79015. b: number;
  79016. /**
  79017. * Defines the alpha component (between 0 and 1, default is 1)
  79018. */
  79019. a: number;
  79020. /**
  79021. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79022. * @param r defines the red component (between 0 and 1, default is 0)
  79023. * @param g defines the green component (between 0 and 1, default is 0)
  79024. * @param b defines the blue component (between 0 and 1, default is 0)
  79025. * @param a defines the alpha component (between 0 and 1, default is 1)
  79026. */
  79027. constructor(
  79028. /**
  79029. * Defines the red component (between 0 and 1, default is 0)
  79030. */
  79031. r?: number,
  79032. /**
  79033. * Defines the green component (between 0 and 1, default is 0)
  79034. */
  79035. g?: number,
  79036. /**
  79037. * Defines the blue component (between 0 and 1, default is 0)
  79038. */
  79039. b?: number,
  79040. /**
  79041. * Defines the alpha component (between 0 and 1, default is 1)
  79042. */
  79043. a?: number);
  79044. /**
  79045. * Adds in place the given Color4 values to the current Color4 object
  79046. * @param right defines the second operand
  79047. * @returns the current updated Color4 object
  79048. */
  79049. addInPlace(right: DeepImmutable<Color4>): Color4;
  79050. /**
  79051. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79052. * @returns the new array
  79053. */
  79054. asArray(): number[];
  79055. /**
  79056. * Stores from the starting index in the given array the Color4 successive values
  79057. * @param array defines the array where to store the r,g,b components
  79058. * @param index defines an optional index in the target array to define where to start storing values
  79059. * @returns the current Color4 object
  79060. */
  79061. toArray(array: number[], index?: number): Color4;
  79062. /**
  79063. * Determines equality between Color4 objects
  79064. * @param otherColor defines the second operand
  79065. * @returns true if the rgba values are equal to the given ones
  79066. */
  79067. equals(otherColor: DeepImmutable<Color4>): boolean;
  79068. /**
  79069. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79070. * @param right defines the second operand
  79071. * @returns a new Color4 object
  79072. */
  79073. add(right: DeepImmutable<Color4>): Color4;
  79074. /**
  79075. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79076. * @param right defines the second operand
  79077. * @returns a new Color4 object
  79078. */
  79079. subtract(right: DeepImmutable<Color4>): Color4;
  79080. /**
  79081. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79082. * @param right defines the second operand
  79083. * @param result defines the Color4 object where to store the result
  79084. * @returns the current Color4 object
  79085. */
  79086. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79087. /**
  79088. * Creates a new Color4 with the current Color4 values multiplied by scale
  79089. * @param scale defines the scaling factor to apply
  79090. * @returns a new Color4 object
  79091. */
  79092. scale(scale: number): Color4;
  79093. /**
  79094. * Multiplies the current Color4 values by scale and stores the result in "result"
  79095. * @param scale defines the scaling factor to apply
  79096. * @param result defines the Color4 object where to store the result
  79097. * @returns the current unmodified Color4
  79098. */
  79099. scaleToRef(scale: number, result: Color4): Color4;
  79100. /**
  79101. * Scale the current Color4 values by a factor and add the result to a given Color4
  79102. * @param scale defines the scale factor
  79103. * @param result defines the Color4 object where to store the result
  79104. * @returns the unmodified current Color4
  79105. */
  79106. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79107. /**
  79108. * Clamps the rgb values by the min and max values and stores the result into "result"
  79109. * @param min defines minimum clamping value (default is 0)
  79110. * @param max defines maximum clamping value (default is 1)
  79111. * @param result defines color to store the result into.
  79112. * @returns the cuurent Color4
  79113. */
  79114. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79115. /**
  79116. * Multipy an Color4 value by another and return a new Color4 object
  79117. * @param color defines the Color4 value to multiply by
  79118. * @returns a new Color4 object
  79119. */
  79120. multiply(color: Color4): Color4;
  79121. /**
  79122. * Multipy a Color4 value by another and push the result in a reference value
  79123. * @param color defines the Color4 value to multiply by
  79124. * @param result defines the Color4 to fill the result in
  79125. * @returns the result Color4
  79126. */
  79127. multiplyToRef(color: Color4, result: Color4): Color4;
  79128. /**
  79129. * Creates a string with the Color4 current values
  79130. * @returns the string representation of the Color4 object
  79131. */
  79132. toString(): string;
  79133. /**
  79134. * Returns the string "Color4"
  79135. * @returns "Color4"
  79136. */
  79137. getClassName(): string;
  79138. /**
  79139. * Compute the Color4 hash code
  79140. * @returns an unique number that can be used to hash Color4 objects
  79141. */
  79142. getHashCode(): number;
  79143. /**
  79144. * Creates a new Color4 copied from the current one
  79145. * @returns a new Color4 object
  79146. */
  79147. clone(): Color4;
  79148. /**
  79149. * Copies the given Color4 values into the current one
  79150. * @param source defines the source Color4 object
  79151. * @returns the current updated Color4 object
  79152. */
  79153. copyFrom(source: Color4): Color4;
  79154. /**
  79155. * Copies the given float values into the current one
  79156. * @param r defines the red component to read from
  79157. * @param g defines the green component to read from
  79158. * @param b defines the blue component to read from
  79159. * @param a defines the alpha component to read from
  79160. * @returns the current updated Color4 object
  79161. */
  79162. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79163. /**
  79164. * Copies the given float values into the current one
  79165. * @param r defines the red component to read from
  79166. * @param g defines the green component to read from
  79167. * @param b defines the blue component to read from
  79168. * @param a defines the alpha component to read from
  79169. * @returns the current updated Color4 object
  79170. */
  79171. set(r: number, g: number, b: number, a: number): Color4;
  79172. /**
  79173. * Compute the Color4 hexadecimal code as a string
  79174. * @returns a string containing the hexadecimal representation of the Color4 object
  79175. */
  79176. toHexString(): string;
  79177. /**
  79178. * Computes a new Color4 converted from the current one to linear space
  79179. * @returns a new Color4 object
  79180. */
  79181. toLinearSpace(): Color4;
  79182. /**
  79183. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79184. * @param convertedColor defines the Color4 object where to store the linear space version
  79185. * @returns the unmodified Color4
  79186. */
  79187. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79188. /**
  79189. * Computes a new Color4 converted from the current one to gamma space
  79190. * @returns a new Color4 object
  79191. */
  79192. toGammaSpace(): Color4;
  79193. /**
  79194. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79195. * @param convertedColor defines the Color4 object where to store the gamma space version
  79196. * @returns the unmodified Color4
  79197. */
  79198. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79199. /**
  79200. * Creates a new Color4 from the string containing valid hexadecimal values
  79201. * @param hex defines a string containing valid hexadecimal values
  79202. * @returns a new Color4 object
  79203. */
  79204. static FromHexString(hex: string): Color4;
  79205. /**
  79206. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79207. * @param left defines the start value
  79208. * @param right defines the end value
  79209. * @param amount defines the gradient factor
  79210. * @returns a new Color4 object
  79211. */
  79212. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79213. /**
  79214. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79215. * @param left defines the start value
  79216. * @param right defines the end value
  79217. * @param amount defines the gradient factor
  79218. * @param result defines the Color4 object where to store data
  79219. */
  79220. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79221. /**
  79222. * Creates a new Color4 from a Color3 and an alpha value
  79223. * @param color3 defines the source Color3 to read from
  79224. * @param alpha defines the alpha component (1.0 by default)
  79225. * @returns a new Color4 object
  79226. */
  79227. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79228. /**
  79229. * Creates a new Color4 from the starting index element of the given array
  79230. * @param array defines the source array to read from
  79231. * @param offset defines the offset in the source array
  79232. * @returns a new Color4 object
  79233. */
  79234. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79235. /**
  79236. * Creates a new Color3 from integer values (< 256)
  79237. * @param r defines the red component to read from (value between 0 and 255)
  79238. * @param g defines the green component to read from (value between 0 and 255)
  79239. * @param b defines the blue component to read from (value between 0 and 255)
  79240. * @param a defines the alpha component to read from (value between 0 and 255)
  79241. * @returns a new Color3 object
  79242. */
  79243. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79244. /**
  79245. * Check the content of a given array and convert it to an array containing RGBA data
  79246. * If the original array was already containing count * 4 values then it is returned directly
  79247. * @param colors defines the array to check
  79248. * @param count defines the number of RGBA data to expect
  79249. * @returns an array containing count * 4 values (RGBA)
  79250. */
  79251. static CheckColors4(colors: number[], count: number): number[];
  79252. }
  79253. /**
  79254. * @hidden
  79255. */
  79256. export class TmpColors {
  79257. static Color3: Color3[];
  79258. static Color4: Color4[];
  79259. }
  79260. }
  79261. declare module BABYLON {
  79262. /**
  79263. * Defines an interface which represents an animation key frame
  79264. */
  79265. export interface IAnimationKey {
  79266. /**
  79267. * Frame of the key frame
  79268. */
  79269. frame: number;
  79270. /**
  79271. * Value at the specifies key frame
  79272. */
  79273. value: any;
  79274. /**
  79275. * The input tangent for the cubic hermite spline
  79276. */
  79277. inTangent?: any;
  79278. /**
  79279. * The output tangent for the cubic hermite spline
  79280. */
  79281. outTangent?: any;
  79282. /**
  79283. * The animation interpolation type
  79284. */
  79285. interpolation?: AnimationKeyInterpolation;
  79286. }
  79287. /**
  79288. * Enum for the animation key frame interpolation type
  79289. */
  79290. export enum AnimationKeyInterpolation {
  79291. /**
  79292. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79293. */
  79294. STEP = 1
  79295. }
  79296. }
  79297. declare module BABYLON {
  79298. /**
  79299. * Represents the range of an animation
  79300. */
  79301. export class AnimationRange {
  79302. /**The name of the animation range**/
  79303. name: string;
  79304. /**The starting frame of the animation */
  79305. from: number;
  79306. /**The ending frame of the animation*/
  79307. to: number;
  79308. /**
  79309. * Initializes the range of an animation
  79310. * @param name The name of the animation range
  79311. * @param from The starting frame of the animation
  79312. * @param to The ending frame of the animation
  79313. */
  79314. constructor(
  79315. /**The name of the animation range**/
  79316. name: string,
  79317. /**The starting frame of the animation */
  79318. from: number,
  79319. /**The ending frame of the animation*/
  79320. to: number);
  79321. /**
  79322. * Makes a copy of the animation range
  79323. * @returns A copy of the animation range
  79324. */
  79325. clone(): AnimationRange;
  79326. }
  79327. }
  79328. declare module BABYLON {
  79329. /**
  79330. * Composed of a frame, and an action function
  79331. */
  79332. export class AnimationEvent {
  79333. /** The frame for which the event is triggered **/
  79334. frame: number;
  79335. /** The event to perform when triggered **/
  79336. action: (currentFrame: number) => void;
  79337. /** Specifies if the event should be triggered only once**/
  79338. onlyOnce?: boolean | undefined;
  79339. /**
  79340. * Specifies if the animation event is done
  79341. */
  79342. isDone: boolean;
  79343. /**
  79344. * Initializes the animation event
  79345. * @param frame The frame for which the event is triggered
  79346. * @param action The event to perform when triggered
  79347. * @param onlyOnce Specifies if the event should be triggered only once
  79348. */
  79349. constructor(
  79350. /** The frame for which the event is triggered **/
  79351. frame: number,
  79352. /** The event to perform when triggered **/
  79353. action: (currentFrame: number) => void,
  79354. /** Specifies if the event should be triggered only once**/
  79355. onlyOnce?: boolean | undefined);
  79356. /** @hidden */
  79357. _clone(): AnimationEvent;
  79358. }
  79359. }
  79360. declare module BABYLON {
  79361. /**
  79362. * Interface used to define a behavior
  79363. */
  79364. export interface Behavior<T> {
  79365. /** gets or sets behavior's name */
  79366. name: string;
  79367. /**
  79368. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79369. */
  79370. init(): void;
  79371. /**
  79372. * Called when the behavior is attached to a target
  79373. * @param target defines the target where the behavior is attached to
  79374. */
  79375. attach(target: T): void;
  79376. /**
  79377. * Called when the behavior is detached from its target
  79378. */
  79379. detach(): void;
  79380. }
  79381. /**
  79382. * Interface implemented by classes supporting behaviors
  79383. */
  79384. export interface IBehaviorAware<T> {
  79385. /**
  79386. * Attach a behavior
  79387. * @param behavior defines the behavior to attach
  79388. * @returns the current host
  79389. */
  79390. addBehavior(behavior: Behavior<T>): T;
  79391. /**
  79392. * Remove a behavior from the current object
  79393. * @param behavior defines the behavior to detach
  79394. * @returns the current host
  79395. */
  79396. removeBehavior(behavior: Behavior<T>): T;
  79397. /**
  79398. * Gets a behavior using its name to search
  79399. * @param name defines the name to search
  79400. * @returns the behavior or null if not found
  79401. */
  79402. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79403. }
  79404. }
  79405. declare module BABYLON {
  79406. /**
  79407. * Defines an array and its length.
  79408. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79409. */
  79410. export interface ISmartArrayLike<T> {
  79411. /**
  79412. * The data of the array.
  79413. */
  79414. data: Array<T>;
  79415. /**
  79416. * The active length of the array.
  79417. */
  79418. length: number;
  79419. }
  79420. /**
  79421. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79422. */
  79423. export class SmartArray<T> implements ISmartArrayLike<T> {
  79424. /**
  79425. * The full set of data from the array.
  79426. */
  79427. data: Array<T>;
  79428. /**
  79429. * The active length of the array.
  79430. */
  79431. length: number;
  79432. protected _id: number;
  79433. /**
  79434. * Instantiates a Smart Array.
  79435. * @param capacity defines the default capacity of the array.
  79436. */
  79437. constructor(capacity: number);
  79438. /**
  79439. * Pushes a value at the end of the active data.
  79440. * @param value defines the object to push in the array.
  79441. */
  79442. push(value: T): void;
  79443. /**
  79444. * Iterates over the active data and apply the lambda to them.
  79445. * @param func defines the action to apply on each value.
  79446. */
  79447. forEach(func: (content: T) => void): void;
  79448. /**
  79449. * Sorts the full sets of data.
  79450. * @param compareFn defines the comparison function to apply.
  79451. */
  79452. sort(compareFn: (a: T, b: T) => number): void;
  79453. /**
  79454. * Resets the active data to an empty array.
  79455. */
  79456. reset(): void;
  79457. /**
  79458. * Releases all the data from the array as well as the array.
  79459. */
  79460. dispose(): void;
  79461. /**
  79462. * Concats the active data with a given array.
  79463. * @param array defines the data to concatenate with.
  79464. */
  79465. concat(array: any): void;
  79466. /**
  79467. * Returns the position of a value in the active data.
  79468. * @param value defines the value to find the index for
  79469. * @returns the index if found in the active data otherwise -1
  79470. */
  79471. indexOf(value: T): number;
  79472. /**
  79473. * Returns whether an element is part of the active data.
  79474. * @param value defines the value to look for
  79475. * @returns true if found in the active data otherwise false
  79476. */
  79477. contains(value: T): boolean;
  79478. private static _GlobalId;
  79479. }
  79480. /**
  79481. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79482. * The data in this array can only be present once
  79483. */
  79484. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79485. private _duplicateId;
  79486. /**
  79487. * Pushes a value at the end of the active data.
  79488. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79489. * @param value defines the object to push in the array.
  79490. */
  79491. push(value: T): void;
  79492. /**
  79493. * Pushes a value at the end of the active data.
  79494. * If the data is already present, it won t be added again
  79495. * @param value defines the object to push in the array.
  79496. * @returns true if added false if it was already present
  79497. */
  79498. pushNoDuplicate(value: T): boolean;
  79499. /**
  79500. * Resets the active data to an empty array.
  79501. */
  79502. reset(): void;
  79503. /**
  79504. * Concats the active data with a given array.
  79505. * This ensures no dupplicate will be present in the result.
  79506. * @param array defines the data to concatenate with.
  79507. */
  79508. concatWithNoDuplicate(array: any): void;
  79509. }
  79510. }
  79511. declare module BABYLON {
  79512. /**
  79513. * @ignore
  79514. * This is a list of all the different input types that are available in the application.
  79515. * Fo instance: ArcRotateCameraGamepadInput...
  79516. */
  79517. export var CameraInputTypes: {};
  79518. /**
  79519. * This is the contract to implement in order to create a new input class.
  79520. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79521. */
  79522. export interface ICameraInput<TCamera extends Camera> {
  79523. /**
  79524. * Defines the camera the input is attached to.
  79525. */
  79526. camera: Nullable<TCamera>;
  79527. /**
  79528. * Gets the class name of the current intput.
  79529. * @returns the class name
  79530. */
  79531. getClassName(): string;
  79532. /**
  79533. * Get the friendly name associated with the input class.
  79534. * @returns the input friendly name
  79535. */
  79536. getSimpleName(): string;
  79537. /**
  79538. * Attach the input controls to a specific dom element to get the input from.
  79539. * @param element Defines the element the controls should be listened from
  79540. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79541. */
  79542. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79543. /**
  79544. * Detach the current controls from the specified dom element.
  79545. * @param element Defines the element to stop listening the inputs from
  79546. */
  79547. detachControl(element: Nullable<HTMLElement>): void;
  79548. /**
  79549. * Update the current camera state depending on the inputs that have been used this frame.
  79550. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79551. */
  79552. checkInputs?: () => void;
  79553. }
  79554. /**
  79555. * Represents a map of input types to input instance or input index to input instance.
  79556. */
  79557. export interface CameraInputsMap<TCamera extends Camera> {
  79558. /**
  79559. * Accessor to the input by input type.
  79560. */
  79561. [name: string]: ICameraInput<TCamera>;
  79562. /**
  79563. * Accessor to the input by input index.
  79564. */
  79565. [idx: number]: ICameraInput<TCamera>;
  79566. }
  79567. /**
  79568. * This represents the input manager used within a camera.
  79569. * It helps dealing with all the different kind of input attached to a camera.
  79570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79571. */
  79572. export class CameraInputsManager<TCamera extends Camera> {
  79573. /**
  79574. * Defines the list of inputs attahed to the camera.
  79575. */
  79576. attached: CameraInputsMap<TCamera>;
  79577. /**
  79578. * Defines the dom element the camera is collecting inputs from.
  79579. * This is null if the controls have not been attached.
  79580. */
  79581. attachedElement: Nullable<HTMLElement>;
  79582. /**
  79583. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79584. */
  79585. noPreventDefault: boolean;
  79586. /**
  79587. * Defined the camera the input manager belongs to.
  79588. */
  79589. camera: TCamera;
  79590. /**
  79591. * Update the current camera state depending on the inputs that have been used this frame.
  79592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79593. */
  79594. checkInputs: () => void;
  79595. /**
  79596. * Instantiate a new Camera Input Manager.
  79597. * @param camera Defines the camera the input manager blongs to
  79598. */
  79599. constructor(camera: TCamera);
  79600. /**
  79601. * Add an input method to a camera
  79602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79603. * @param input camera input method
  79604. */
  79605. add(input: ICameraInput<TCamera>): void;
  79606. /**
  79607. * Remove a specific input method from a camera
  79608. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79609. * @param inputToRemove camera input method
  79610. */
  79611. remove(inputToRemove: ICameraInput<TCamera>): void;
  79612. /**
  79613. * Remove a specific input type from a camera
  79614. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79615. * @param inputType the type of the input to remove
  79616. */
  79617. removeByType(inputType: string): void;
  79618. private _addCheckInputs;
  79619. /**
  79620. * Attach the input controls to the currently attached dom element to listen the events from.
  79621. * @param input Defines the input to attach
  79622. */
  79623. attachInput(input: ICameraInput<TCamera>): void;
  79624. /**
  79625. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79626. * @param element Defines the dom element to collect the events from
  79627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79628. */
  79629. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79630. /**
  79631. * Detach the current manager inputs controls from a specific dom element.
  79632. * @param element Defines the dom element to collect the events from
  79633. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79634. */
  79635. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79636. /**
  79637. * Rebuild the dynamic inputCheck function from the current list of
  79638. * defined inputs in the manager.
  79639. */
  79640. rebuildInputCheck(): void;
  79641. /**
  79642. * Remove all attached input methods from a camera
  79643. */
  79644. clear(): void;
  79645. /**
  79646. * Serialize the current input manager attached to a camera.
  79647. * This ensures than once parsed,
  79648. * the input associated to the camera will be identical to the current ones
  79649. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79650. */
  79651. serialize(serializedCamera: any): void;
  79652. /**
  79653. * Parses an input manager serialized JSON to restore the previous list of inputs
  79654. * and states associated to a camera.
  79655. * @param parsedCamera Defines the JSON to parse
  79656. */
  79657. parse(parsedCamera: any): void;
  79658. }
  79659. }
  79660. declare module BABYLON {
  79661. /**
  79662. * Class used to store data that will be store in GPU memory
  79663. */
  79664. export class Buffer {
  79665. private _engine;
  79666. private _buffer;
  79667. /** @hidden */
  79668. _data: Nullable<DataArray>;
  79669. private _updatable;
  79670. private _instanced;
  79671. private _divisor;
  79672. /**
  79673. * Gets the byte stride.
  79674. */
  79675. readonly byteStride: number;
  79676. /**
  79677. * Constructor
  79678. * @param engine the engine
  79679. * @param data the data to use for this buffer
  79680. * @param updatable whether the data is updatable
  79681. * @param stride the stride (optional)
  79682. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79683. * @param instanced whether the buffer is instanced (optional)
  79684. * @param useBytes set to true if the stride in in bytes (optional)
  79685. * @param divisor sets an optional divisor for instances (1 by default)
  79686. */
  79687. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79688. /**
  79689. * Create a new VertexBuffer based on the current buffer
  79690. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79691. * @param offset defines offset in the buffer (0 by default)
  79692. * @param size defines the size in floats of attributes (position is 3 for instance)
  79693. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79694. * @param instanced defines if the vertex buffer contains indexed data
  79695. * @param useBytes defines if the offset and stride are in bytes *
  79696. * @param divisor sets an optional divisor for instances (1 by default)
  79697. * @returns the new vertex buffer
  79698. */
  79699. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79700. /**
  79701. * Gets a boolean indicating if the Buffer is updatable?
  79702. * @returns true if the buffer is updatable
  79703. */
  79704. isUpdatable(): boolean;
  79705. /**
  79706. * Gets current buffer's data
  79707. * @returns a DataArray or null
  79708. */
  79709. getData(): Nullable<DataArray>;
  79710. /**
  79711. * Gets underlying native buffer
  79712. * @returns underlying native buffer
  79713. */
  79714. getBuffer(): Nullable<DataBuffer>;
  79715. /**
  79716. * Gets the stride in float32 units (i.e. byte stride / 4).
  79717. * May not be an integer if the byte stride is not divisible by 4.
  79718. * @returns the stride in float32 units
  79719. * @deprecated Please use byteStride instead.
  79720. */
  79721. getStrideSize(): number;
  79722. /**
  79723. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79724. * @param data defines the data to store
  79725. */
  79726. create(data?: Nullable<DataArray>): void;
  79727. /** @hidden */
  79728. _rebuild(): void;
  79729. /**
  79730. * Update current buffer data
  79731. * @param data defines the data to store
  79732. */
  79733. update(data: DataArray): void;
  79734. /**
  79735. * Updates the data directly.
  79736. * @param data the new data
  79737. * @param offset the new offset
  79738. * @param vertexCount the vertex count (optional)
  79739. * @param useBytes set to true if the offset is in bytes
  79740. */
  79741. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79742. /**
  79743. * Release all resources
  79744. */
  79745. dispose(): void;
  79746. }
  79747. /**
  79748. * Specialized buffer used to store vertex data
  79749. */
  79750. export class VertexBuffer {
  79751. /** @hidden */
  79752. _buffer: Buffer;
  79753. private _kind;
  79754. private _size;
  79755. private _ownsBuffer;
  79756. private _instanced;
  79757. private _instanceDivisor;
  79758. /**
  79759. * The byte type.
  79760. */
  79761. static readonly BYTE: number;
  79762. /**
  79763. * The unsigned byte type.
  79764. */
  79765. static readonly UNSIGNED_BYTE: number;
  79766. /**
  79767. * The short type.
  79768. */
  79769. static readonly SHORT: number;
  79770. /**
  79771. * The unsigned short type.
  79772. */
  79773. static readonly UNSIGNED_SHORT: number;
  79774. /**
  79775. * The integer type.
  79776. */
  79777. static readonly INT: number;
  79778. /**
  79779. * The unsigned integer type.
  79780. */
  79781. static readonly UNSIGNED_INT: number;
  79782. /**
  79783. * The float type.
  79784. */
  79785. static readonly FLOAT: number;
  79786. /**
  79787. * Gets or sets the instance divisor when in instanced mode
  79788. */
  79789. get instanceDivisor(): number;
  79790. set instanceDivisor(value: number);
  79791. /**
  79792. * Gets the byte stride.
  79793. */
  79794. readonly byteStride: number;
  79795. /**
  79796. * Gets the byte offset.
  79797. */
  79798. readonly byteOffset: number;
  79799. /**
  79800. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79801. */
  79802. readonly normalized: boolean;
  79803. /**
  79804. * Gets the data type of each component in the array.
  79805. */
  79806. readonly type: number;
  79807. /**
  79808. * Constructor
  79809. * @param engine the engine
  79810. * @param data the data to use for this vertex buffer
  79811. * @param kind the vertex buffer kind
  79812. * @param updatable whether the data is updatable
  79813. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79814. * @param stride the stride (optional)
  79815. * @param instanced whether the buffer is instanced (optional)
  79816. * @param offset the offset of the data (optional)
  79817. * @param size the number of components (optional)
  79818. * @param type the type of the component (optional)
  79819. * @param normalized whether the data contains normalized data (optional)
  79820. * @param useBytes set to true if stride and offset are in bytes (optional)
  79821. * @param divisor defines the instance divisor to use (1 by default)
  79822. */
  79823. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  79824. /** @hidden */
  79825. _rebuild(): void;
  79826. /**
  79827. * Returns the kind of the VertexBuffer (string)
  79828. * @returns a string
  79829. */
  79830. getKind(): string;
  79831. /**
  79832. * Gets a boolean indicating if the VertexBuffer is updatable?
  79833. * @returns true if the buffer is updatable
  79834. */
  79835. isUpdatable(): boolean;
  79836. /**
  79837. * Gets current buffer's data
  79838. * @returns a DataArray or null
  79839. */
  79840. getData(): Nullable<DataArray>;
  79841. /**
  79842. * Gets underlying native buffer
  79843. * @returns underlying native buffer
  79844. */
  79845. getBuffer(): Nullable<DataBuffer>;
  79846. /**
  79847. * Gets the stride in float32 units (i.e. byte stride / 4).
  79848. * May not be an integer if the byte stride is not divisible by 4.
  79849. * @returns the stride in float32 units
  79850. * @deprecated Please use byteStride instead.
  79851. */
  79852. getStrideSize(): number;
  79853. /**
  79854. * Returns the offset as a multiple of the type byte length.
  79855. * @returns the offset in bytes
  79856. * @deprecated Please use byteOffset instead.
  79857. */
  79858. getOffset(): number;
  79859. /**
  79860. * Returns the number of components per vertex attribute (integer)
  79861. * @returns the size in float
  79862. */
  79863. getSize(): number;
  79864. /**
  79865. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79866. * @returns true if this buffer is instanced
  79867. */
  79868. getIsInstanced(): boolean;
  79869. /**
  79870. * Returns the instancing divisor, zero for non-instanced (integer).
  79871. * @returns a number
  79872. */
  79873. getInstanceDivisor(): number;
  79874. /**
  79875. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79876. * @param data defines the data to store
  79877. */
  79878. create(data?: DataArray): void;
  79879. /**
  79880. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79881. * This function will create a new buffer if the current one is not updatable
  79882. * @param data defines the data to store
  79883. */
  79884. update(data: DataArray): void;
  79885. /**
  79886. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79887. * Returns the directly updated WebGLBuffer.
  79888. * @param data the new data
  79889. * @param offset the new offset
  79890. * @param useBytes set to true if the offset is in bytes
  79891. */
  79892. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79893. /**
  79894. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79895. */
  79896. dispose(): void;
  79897. /**
  79898. * Enumerates each value of this vertex buffer as numbers.
  79899. * @param count the number of values to enumerate
  79900. * @param callback the callback function called for each value
  79901. */
  79902. forEach(count: number, callback: (value: number, index: number) => void): void;
  79903. /**
  79904. * Positions
  79905. */
  79906. static readonly PositionKind: string;
  79907. /**
  79908. * Normals
  79909. */
  79910. static readonly NormalKind: string;
  79911. /**
  79912. * Tangents
  79913. */
  79914. static readonly TangentKind: string;
  79915. /**
  79916. * Texture coordinates
  79917. */
  79918. static readonly UVKind: string;
  79919. /**
  79920. * Texture coordinates 2
  79921. */
  79922. static readonly UV2Kind: string;
  79923. /**
  79924. * Texture coordinates 3
  79925. */
  79926. static readonly UV3Kind: string;
  79927. /**
  79928. * Texture coordinates 4
  79929. */
  79930. static readonly UV4Kind: string;
  79931. /**
  79932. * Texture coordinates 5
  79933. */
  79934. static readonly UV5Kind: string;
  79935. /**
  79936. * Texture coordinates 6
  79937. */
  79938. static readonly UV6Kind: string;
  79939. /**
  79940. * Colors
  79941. */
  79942. static readonly ColorKind: string;
  79943. /**
  79944. * Matrix indices (for bones)
  79945. */
  79946. static readonly MatricesIndicesKind: string;
  79947. /**
  79948. * Matrix weights (for bones)
  79949. */
  79950. static readonly MatricesWeightsKind: string;
  79951. /**
  79952. * Additional matrix indices (for bones)
  79953. */
  79954. static readonly MatricesIndicesExtraKind: string;
  79955. /**
  79956. * Additional matrix weights (for bones)
  79957. */
  79958. static readonly MatricesWeightsExtraKind: string;
  79959. /**
  79960. * Deduces the stride given a kind.
  79961. * @param kind The kind string to deduce
  79962. * @returns The deduced stride
  79963. */
  79964. static DeduceStride(kind: string): number;
  79965. /**
  79966. * Gets the byte length of the given type.
  79967. * @param type the type
  79968. * @returns the number of bytes
  79969. */
  79970. static GetTypeByteLength(type: number): number;
  79971. /**
  79972. * Enumerates each value of the given parameters as numbers.
  79973. * @param data the data to enumerate
  79974. * @param byteOffset the byte offset of the data
  79975. * @param byteStride the byte stride of the data
  79976. * @param componentCount the number of components per element
  79977. * @param componentType the type of the component
  79978. * @param count the number of values to enumerate
  79979. * @param normalized whether the data is normalized
  79980. * @param callback the callback function called for each value
  79981. */
  79982. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79983. private static _GetFloatValue;
  79984. }
  79985. }
  79986. declare module BABYLON {
  79987. /**
  79988. * @hidden
  79989. */
  79990. export class IntersectionInfo {
  79991. bu: Nullable<number>;
  79992. bv: Nullable<number>;
  79993. distance: number;
  79994. faceId: number;
  79995. subMeshId: number;
  79996. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79997. }
  79998. }
  79999. declare module BABYLON {
  80000. /**
  80001. * Represens a plane by the equation ax + by + cz + d = 0
  80002. */
  80003. export class Plane {
  80004. private static _TmpMatrix;
  80005. /**
  80006. * Normal of the plane (a,b,c)
  80007. */
  80008. normal: Vector3;
  80009. /**
  80010. * d component of the plane
  80011. */
  80012. d: number;
  80013. /**
  80014. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80015. * @param a a component of the plane
  80016. * @param b b component of the plane
  80017. * @param c c component of the plane
  80018. * @param d d component of the plane
  80019. */
  80020. constructor(a: number, b: number, c: number, d: number);
  80021. /**
  80022. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80023. */
  80024. asArray(): number[];
  80025. /**
  80026. * @returns a new plane copied from the current Plane.
  80027. */
  80028. clone(): Plane;
  80029. /**
  80030. * @returns the string "Plane".
  80031. */
  80032. getClassName(): string;
  80033. /**
  80034. * @returns the Plane hash code.
  80035. */
  80036. getHashCode(): number;
  80037. /**
  80038. * Normalize the current Plane in place.
  80039. * @returns the updated Plane.
  80040. */
  80041. normalize(): Plane;
  80042. /**
  80043. * Applies a transformation the plane and returns the result
  80044. * @param transformation the transformation matrix to be applied to the plane
  80045. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80046. */
  80047. transform(transformation: DeepImmutable<Matrix>): Plane;
  80048. /**
  80049. * Calcualtte the dot product between the point and the plane normal
  80050. * @param point point to calculate the dot product with
  80051. * @returns the dot product (float) of the point coordinates and the plane normal.
  80052. */
  80053. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80054. /**
  80055. * Updates the current Plane from the plane defined by the three given points.
  80056. * @param point1 one of the points used to contruct the plane
  80057. * @param point2 one of the points used to contruct the plane
  80058. * @param point3 one of the points used to contruct the plane
  80059. * @returns the updated Plane.
  80060. */
  80061. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80062. /**
  80063. * Checks if the plane is facing a given direction
  80064. * @param direction the direction to check if the plane is facing
  80065. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80066. * @returns True is the vector "direction" is the same side than the plane normal.
  80067. */
  80068. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80069. /**
  80070. * Calculates the distance to a point
  80071. * @param point point to calculate distance to
  80072. * @returns the signed distance (float) from the given point to the Plane.
  80073. */
  80074. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80075. /**
  80076. * Creates a plane from an array
  80077. * @param array the array to create a plane from
  80078. * @returns a new Plane from the given array.
  80079. */
  80080. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80081. /**
  80082. * Creates a plane from three points
  80083. * @param point1 point used to create the plane
  80084. * @param point2 point used to create the plane
  80085. * @param point3 point used to create the plane
  80086. * @returns a new Plane defined by the three given points.
  80087. */
  80088. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80089. /**
  80090. * Creates a plane from an origin point and a normal
  80091. * @param origin origin of the plane to be constructed
  80092. * @param normal normal of the plane to be constructed
  80093. * @returns a new Plane the normal vector to this plane at the given origin point.
  80094. * Note : the vector "normal" is updated because normalized.
  80095. */
  80096. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80097. /**
  80098. * Calculates the distance from a plane and a point
  80099. * @param origin origin of the plane to be constructed
  80100. * @param normal normal of the plane to be constructed
  80101. * @param point point to calculate distance to
  80102. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80103. */
  80104. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80105. }
  80106. }
  80107. declare module BABYLON {
  80108. /**
  80109. * Class used to store bounding sphere information
  80110. */
  80111. export class BoundingSphere {
  80112. /**
  80113. * Gets the center of the bounding sphere in local space
  80114. */
  80115. readonly center: Vector3;
  80116. /**
  80117. * Radius of the bounding sphere in local space
  80118. */
  80119. radius: number;
  80120. /**
  80121. * Gets the center of the bounding sphere in world space
  80122. */
  80123. readonly centerWorld: Vector3;
  80124. /**
  80125. * Radius of the bounding sphere in world space
  80126. */
  80127. radiusWorld: number;
  80128. /**
  80129. * Gets the minimum vector in local space
  80130. */
  80131. readonly minimum: Vector3;
  80132. /**
  80133. * Gets the maximum vector in local space
  80134. */
  80135. readonly maximum: Vector3;
  80136. private _worldMatrix;
  80137. private static readonly TmpVector3;
  80138. /**
  80139. * Creates a new bounding sphere
  80140. * @param min defines the minimum vector (in local space)
  80141. * @param max defines the maximum vector (in local space)
  80142. * @param worldMatrix defines the new world matrix
  80143. */
  80144. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80145. /**
  80146. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80147. * @param min defines the new minimum vector (in local space)
  80148. * @param max defines the new maximum vector (in local space)
  80149. * @param worldMatrix defines the new world matrix
  80150. */
  80151. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80152. /**
  80153. * Scale the current bounding sphere by applying a scale factor
  80154. * @param factor defines the scale factor to apply
  80155. * @returns the current bounding box
  80156. */
  80157. scale(factor: number): BoundingSphere;
  80158. /**
  80159. * Gets the world matrix of the bounding box
  80160. * @returns a matrix
  80161. */
  80162. getWorldMatrix(): DeepImmutable<Matrix>;
  80163. /** @hidden */
  80164. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80165. /**
  80166. * Tests if the bounding sphere is intersecting the frustum planes
  80167. * @param frustumPlanes defines the frustum planes to test
  80168. * @returns true if there is an intersection
  80169. */
  80170. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80171. /**
  80172. * Tests if the bounding sphere center is in between the frustum planes.
  80173. * Used for optimistic fast inclusion.
  80174. * @param frustumPlanes defines the frustum planes to test
  80175. * @returns true if the sphere center is in between the frustum planes
  80176. */
  80177. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80178. /**
  80179. * Tests if a point is inside the bounding sphere
  80180. * @param point defines the point to test
  80181. * @returns true if the point is inside the bounding sphere
  80182. */
  80183. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80184. /**
  80185. * Checks if two sphere intersct
  80186. * @param sphere0 sphere 0
  80187. * @param sphere1 sphere 1
  80188. * @returns true if the speres intersect
  80189. */
  80190. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80191. }
  80192. }
  80193. declare module BABYLON {
  80194. /**
  80195. * Class used to store bounding box information
  80196. */
  80197. export class BoundingBox implements ICullable {
  80198. /**
  80199. * Gets the 8 vectors representing the bounding box in local space
  80200. */
  80201. readonly vectors: Vector3[];
  80202. /**
  80203. * Gets the center of the bounding box in local space
  80204. */
  80205. readonly center: Vector3;
  80206. /**
  80207. * Gets the center of the bounding box in world space
  80208. */
  80209. readonly centerWorld: Vector3;
  80210. /**
  80211. * Gets the extend size in local space
  80212. */
  80213. readonly extendSize: Vector3;
  80214. /**
  80215. * Gets the extend size in world space
  80216. */
  80217. readonly extendSizeWorld: Vector3;
  80218. /**
  80219. * Gets the OBB (object bounding box) directions
  80220. */
  80221. readonly directions: Vector3[];
  80222. /**
  80223. * Gets the 8 vectors representing the bounding box in world space
  80224. */
  80225. readonly vectorsWorld: Vector3[];
  80226. /**
  80227. * Gets the minimum vector in world space
  80228. */
  80229. readonly minimumWorld: Vector3;
  80230. /**
  80231. * Gets the maximum vector in world space
  80232. */
  80233. readonly maximumWorld: Vector3;
  80234. /**
  80235. * Gets the minimum vector in local space
  80236. */
  80237. readonly minimum: Vector3;
  80238. /**
  80239. * Gets the maximum vector in local space
  80240. */
  80241. readonly maximum: Vector3;
  80242. private _worldMatrix;
  80243. private static readonly TmpVector3;
  80244. /**
  80245. * @hidden
  80246. */
  80247. _tag: number;
  80248. /**
  80249. * Creates a new bounding box
  80250. * @param min defines the minimum vector (in local space)
  80251. * @param max defines the maximum vector (in local space)
  80252. * @param worldMatrix defines the new world matrix
  80253. */
  80254. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80255. /**
  80256. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80257. * @param min defines the new minimum vector (in local space)
  80258. * @param max defines the new maximum vector (in local space)
  80259. * @param worldMatrix defines the new world matrix
  80260. */
  80261. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80262. /**
  80263. * Scale the current bounding box by applying a scale factor
  80264. * @param factor defines the scale factor to apply
  80265. * @returns the current bounding box
  80266. */
  80267. scale(factor: number): BoundingBox;
  80268. /**
  80269. * Gets the world matrix of the bounding box
  80270. * @returns a matrix
  80271. */
  80272. getWorldMatrix(): DeepImmutable<Matrix>;
  80273. /** @hidden */
  80274. _update(world: DeepImmutable<Matrix>): void;
  80275. /**
  80276. * Tests if the bounding box is intersecting the frustum planes
  80277. * @param frustumPlanes defines the frustum planes to test
  80278. * @returns true if there is an intersection
  80279. */
  80280. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80281. /**
  80282. * Tests if the bounding box is entirely inside the frustum planes
  80283. * @param frustumPlanes defines the frustum planes to test
  80284. * @returns true if there is an inclusion
  80285. */
  80286. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80287. /**
  80288. * Tests if a point is inside the bounding box
  80289. * @param point defines the point to test
  80290. * @returns true if the point is inside the bounding box
  80291. */
  80292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80293. /**
  80294. * Tests if the bounding box intersects with a bounding sphere
  80295. * @param sphere defines the sphere to test
  80296. * @returns true if there is an intersection
  80297. */
  80298. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80299. /**
  80300. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80301. * @param min defines the min vector to use
  80302. * @param max defines the max vector to use
  80303. * @returns true if there is an intersection
  80304. */
  80305. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80306. /**
  80307. * Tests if two bounding boxes are intersections
  80308. * @param box0 defines the first box to test
  80309. * @param box1 defines the second box to test
  80310. * @returns true if there is an intersection
  80311. */
  80312. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80313. /**
  80314. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80315. * @param minPoint defines the minimum vector of the bounding box
  80316. * @param maxPoint defines the maximum vector of the bounding box
  80317. * @param sphereCenter defines the sphere center
  80318. * @param sphereRadius defines the sphere radius
  80319. * @returns true if there is an intersection
  80320. */
  80321. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80322. /**
  80323. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80325. * @param frustumPlanes defines the frustum planes to test
  80326. * @return true if there is an inclusion
  80327. */
  80328. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80329. /**
  80330. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80331. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80332. * @param frustumPlanes defines the frustum planes to test
  80333. * @return true if there is an intersection
  80334. */
  80335. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80336. }
  80337. }
  80338. declare module BABYLON {
  80339. /** @hidden */
  80340. export class Collider {
  80341. /** Define if a collision was found */
  80342. collisionFound: boolean;
  80343. /**
  80344. * Define last intersection point in local space
  80345. */
  80346. intersectionPoint: Vector3;
  80347. /**
  80348. * Define last collided mesh
  80349. */
  80350. collidedMesh: Nullable<AbstractMesh>;
  80351. private _collisionPoint;
  80352. private _planeIntersectionPoint;
  80353. private _tempVector;
  80354. private _tempVector2;
  80355. private _tempVector3;
  80356. private _tempVector4;
  80357. private _edge;
  80358. private _baseToVertex;
  80359. private _destinationPoint;
  80360. private _slidePlaneNormal;
  80361. private _displacementVector;
  80362. /** @hidden */
  80363. _radius: Vector3;
  80364. /** @hidden */
  80365. _retry: number;
  80366. private _velocity;
  80367. private _basePoint;
  80368. private _epsilon;
  80369. /** @hidden */
  80370. _velocityWorldLength: number;
  80371. /** @hidden */
  80372. _basePointWorld: Vector3;
  80373. private _velocityWorld;
  80374. private _normalizedVelocity;
  80375. /** @hidden */
  80376. _initialVelocity: Vector3;
  80377. /** @hidden */
  80378. _initialPosition: Vector3;
  80379. private _nearestDistance;
  80380. private _collisionMask;
  80381. get collisionMask(): number;
  80382. set collisionMask(mask: number);
  80383. /**
  80384. * Gets the plane normal used to compute the sliding response (in local space)
  80385. */
  80386. get slidePlaneNormal(): Vector3;
  80387. /** @hidden */
  80388. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80389. /** @hidden */
  80390. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80391. /** @hidden */
  80392. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80393. /** @hidden */
  80394. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80395. /** @hidden */
  80396. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80397. /** @hidden */
  80398. _getResponse(pos: Vector3, vel: Vector3): void;
  80399. }
  80400. }
  80401. declare module BABYLON {
  80402. /**
  80403. * Interface for cullable objects
  80404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80405. */
  80406. export interface ICullable {
  80407. /**
  80408. * Checks if the object or part of the object is in the frustum
  80409. * @param frustumPlanes Camera near/planes
  80410. * @returns true if the object is in frustum otherwise false
  80411. */
  80412. isInFrustum(frustumPlanes: Plane[]): boolean;
  80413. /**
  80414. * Checks if a cullable object (mesh...) is in the camera frustum
  80415. * Unlike isInFrustum this cheks the full bounding box
  80416. * @param frustumPlanes Camera near/planes
  80417. * @returns true if the object is in frustum otherwise false
  80418. */
  80419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80420. }
  80421. /**
  80422. * Info for a bounding data of a mesh
  80423. */
  80424. export class BoundingInfo implements ICullable {
  80425. /**
  80426. * Bounding box for the mesh
  80427. */
  80428. readonly boundingBox: BoundingBox;
  80429. /**
  80430. * Bounding sphere for the mesh
  80431. */
  80432. readonly boundingSphere: BoundingSphere;
  80433. private _isLocked;
  80434. private static readonly TmpVector3;
  80435. /**
  80436. * Constructs bounding info
  80437. * @param minimum min vector of the bounding box/sphere
  80438. * @param maximum max vector of the bounding box/sphere
  80439. * @param worldMatrix defines the new world matrix
  80440. */
  80441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80442. /**
  80443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80444. * @param min defines the new minimum vector (in local space)
  80445. * @param max defines the new maximum vector (in local space)
  80446. * @param worldMatrix defines the new world matrix
  80447. */
  80448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80449. /**
  80450. * min vector of the bounding box/sphere
  80451. */
  80452. get minimum(): Vector3;
  80453. /**
  80454. * max vector of the bounding box/sphere
  80455. */
  80456. get maximum(): Vector3;
  80457. /**
  80458. * If the info is locked and won't be updated to avoid perf overhead
  80459. */
  80460. get isLocked(): boolean;
  80461. set isLocked(value: boolean);
  80462. /**
  80463. * Updates the bounding sphere and box
  80464. * @param world world matrix to be used to update
  80465. */
  80466. update(world: DeepImmutable<Matrix>): void;
  80467. /**
  80468. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80469. * @param center New center of the bounding info
  80470. * @param extend New extend of the bounding info
  80471. * @returns the current bounding info
  80472. */
  80473. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80474. /**
  80475. * Scale the current bounding info by applying a scale factor
  80476. * @param factor defines the scale factor to apply
  80477. * @returns the current bounding info
  80478. */
  80479. scale(factor: number): BoundingInfo;
  80480. /**
  80481. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80482. * @param frustumPlanes defines the frustum to test
  80483. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80484. * @returns true if the bounding info is in the frustum planes
  80485. */
  80486. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80487. /**
  80488. * Gets the world distance between the min and max points of the bounding box
  80489. */
  80490. get diagonalLength(): number;
  80491. /**
  80492. * Checks if a cullable object (mesh...) is in the camera frustum
  80493. * Unlike isInFrustum this cheks the full bounding box
  80494. * @param frustumPlanes Camera near/planes
  80495. * @returns true if the object is in frustum otherwise false
  80496. */
  80497. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80498. /** @hidden */
  80499. _checkCollision(collider: Collider): boolean;
  80500. /**
  80501. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80502. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80503. * @param point the point to check intersection with
  80504. * @returns if the point intersects
  80505. */
  80506. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80507. /**
  80508. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80509. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80510. * @param boundingInfo the bounding info to check intersection with
  80511. * @param precise if the intersection should be done using OBB
  80512. * @returns if the bounding info intersects
  80513. */
  80514. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80515. }
  80516. }
  80517. declare module BABYLON {
  80518. /**
  80519. * Extracts minimum and maximum values from a list of indexed positions
  80520. * @param positions defines the positions to use
  80521. * @param indices defines the indices to the positions
  80522. * @param indexStart defines the start index
  80523. * @param indexCount defines the end index
  80524. * @param bias defines bias value to add to the result
  80525. * @return minimum and maximum values
  80526. */
  80527. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80528. minimum: Vector3;
  80529. maximum: Vector3;
  80530. };
  80531. /**
  80532. * Extracts minimum and maximum values from a list of positions
  80533. * @param positions defines the positions to use
  80534. * @param start defines the start index in the positions array
  80535. * @param count defines the number of positions to handle
  80536. * @param bias defines bias value to add to the result
  80537. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80538. * @return minimum and maximum values
  80539. */
  80540. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80541. minimum: Vector3;
  80542. maximum: Vector3;
  80543. };
  80544. }
  80545. declare module BABYLON {
  80546. /** @hidden */
  80547. export class WebGLDataBuffer extends DataBuffer {
  80548. private _buffer;
  80549. constructor(resource: WebGLBuffer);
  80550. get underlyingResource(): any;
  80551. }
  80552. }
  80553. declare module BABYLON {
  80554. /** @hidden */
  80555. export class WebGLPipelineContext implements IPipelineContext {
  80556. engine: ThinEngine;
  80557. program: Nullable<WebGLProgram>;
  80558. context?: WebGLRenderingContext;
  80559. vertexShader?: WebGLShader;
  80560. fragmentShader?: WebGLShader;
  80561. isParallelCompiled: boolean;
  80562. onCompiled?: () => void;
  80563. transformFeedback?: WebGLTransformFeedback | null;
  80564. vertexCompilationError: Nullable<string>;
  80565. fragmentCompilationError: Nullable<string>;
  80566. programLinkError: Nullable<string>;
  80567. programValidationError: Nullable<string>;
  80568. get isAsync(): boolean;
  80569. get isReady(): boolean;
  80570. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80571. _getVertexShaderCode(): string | null;
  80572. _getFragmentShaderCode(): string | null;
  80573. }
  80574. }
  80575. declare module BABYLON {
  80576. interface ThinEngine {
  80577. /**
  80578. * Create an uniform buffer
  80579. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80580. * @param elements defines the content of the uniform buffer
  80581. * @returns the webGL uniform buffer
  80582. */
  80583. createUniformBuffer(elements: FloatArray): DataBuffer;
  80584. /**
  80585. * Create a dynamic uniform buffer
  80586. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80587. * @param elements defines the content of the uniform buffer
  80588. * @returns the webGL uniform buffer
  80589. */
  80590. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80591. /**
  80592. * Update an existing uniform buffer
  80593. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80594. * @param uniformBuffer defines the target uniform buffer
  80595. * @param elements defines the content to update
  80596. * @param offset defines the offset in the uniform buffer where update should start
  80597. * @param count defines the size of the data to update
  80598. */
  80599. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80600. /**
  80601. * Bind an uniform buffer to the current webGL context
  80602. * @param buffer defines the buffer to bind
  80603. */
  80604. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80605. /**
  80606. * Bind a buffer to the current webGL context at a given location
  80607. * @param buffer defines the buffer to bind
  80608. * @param location defines the index where to bind the buffer
  80609. */
  80610. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80611. /**
  80612. * Bind a specific block at a given index in a specific shader program
  80613. * @param pipelineContext defines the pipeline context to use
  80614. * @param blockName defines the block name
  80615. * @param index defines the index where to bind the block
  80616. */
  80617. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80618. }
  80619. }
  80620. declare module BABYLON {
  80621. /**
  80622. * Uniform buffer objects.
  80623. *
  80624. * Handles blocks of uniform on the GPU.
  80625. *
  80626. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80627. *
  80628. * For more information, please refer to :
  80629. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80630. */
  80631. export class UniformBuffer {
  80632. private _engine;
  80633. private _buffer;
  80634. private _data;
  80635. private _bufferData;
  80636. private _dynamic?;
  80637. private _uniformLocations;
  80638. private _uniformSizes;
  80639. private _uniformLocationPointer;
  80640. private _needSync;
  80641. private _noUBO;
  80642. private _currentEffect;
  80643. /** @hidden */
  80644. _alreadyBound: boolean;
  80645. private static _MAX_UNIFORM_SIZE;
  80646. private static _tempBuffer;
  80647. /**
  80648. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80649. * This is dynamic to allow compat with webgl 1 and 2.
  80650. * You will need to pass the name of the uniform as well as the value.
  80651. */
  80652. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80653. /**
  80654. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80655. * This is dynamic to allow compat with webgl 1 and 2.
  80656. * You will need to pass the name of the uniform as well as the value.
  80657. */
  80658. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80659. /**
  80660. * Lambda to Update a single float in a uniform buffer.
  80661. * This is dynamic to allow compat with webgl 1 and 2.
  80662. * You will need to pass the name of the uniform as well as the value.
  80663. */
  80664. updateFloat: (name: string, x: number) => void;
  80665. /**
  80666. * Lambda to Update a vec2 of float in a uniform buffer.
  80667. * This is dynamic to allow compat with webgl 1 and 2.
  80668. * You will need to pass the name of the uniform as well as the value.
  80669. */
  80670. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80671. /**
  80672. * Lambda to Update a vec3 of float in a uniform buffer.
  80673. * This is dynamic to allow compat with webgl 1 and 2.
  80674. * You will need to pass the name of the uniform as well as the value.
  80675. */
  80676. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80677. /**
  80678. * Lambda to Update a vec4 of float in a uniform buffer.
  80679. * This is dynamic to allow compat with webgl 1 and 2.
  80680. * You will need to pass the name of the uniform as well as the value.
  80681. */
  80682. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80683. /**
  80684. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80685. * This is dynamic to allow compat with webgl 1 and 2.
  80686. * You will need to pass the name of the uniform as well as the value.
  80687. */
  80688. updateMatrix: (name: string, mat: Matrix) => void;
  80689. /**
  80690. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80691. * This is dynamic to allow compat with webgl 1 and 2.
  80692. * You will need to pass the name of the uniform as well as the value.
  80693. */
  80694. updateVector3: (name: string, vector: Vector3) => void;
  80695. /**
  80696. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80697. * This is dynamic to allow compat with webgl 1 and 2.
  80698. * You will need to pass the name of the uniform as well as the value.
  80699. */
  80700. updateVector4: (name: string, vector: Vector4) => void;
  80701. /**
  80702. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80703. * This is dynamic to allow compat with webgl 1 and 2.
  80704. * You will need to pass the name of the uniform as well as the value.
  80705. */
  80706. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80707. /**
  80708. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80709. * This is dynamic to allow compat with webgl 1 and 2.
  80710. * You will need to pass the name of the uniform as well as the value.
  80711. */
  80712. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80713. /**
  80714. * Instantiates a new Uniform buffer objects.
  80715. *
  80716. * Handles blocks of uniform on the GPU.
  80717. *
  80718. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80719. *
  80720. * For more information, please refer to :
  80721. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80722. * @param engine Define the engine the buffer is associated with
  80723. * @param data Define the data contained in the buffer
  80724. * @param dynamic Define if the buffer is updatable
  80725. */
  80726. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80727. /**
  80728. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80729. * or just falling back on setUniformXXX calls.
  80730. */
  80731. get useUbo(): boolean;
  80732. /**
  80733. * Indicates if the WebGL underlying uniform buffer is in sync
  80734. * with the javascript cache data.
  80735. */
  80736. get isSync(): boolean;
  80737. /**
  80738. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80739. * Also, a dynamic UniformBuffer will disable cache verification and always
  80740. * update the underlying WebGL uniform buffer to the GPU.
  80741. * @returns if Dynamic, otherwise false
  80742. */
  80743. isDynamic(): boolean;
  80744. /**
  80745. * The data cache on JS side.
  80746. * @returns the underlying data as a float array
  80747. */
  80748. getData(): Float32Array;
  80749. /**
  80750. * The underlying WebGL Uniform buffer.
  80751. * @returns the webgl buffer
  80752. */
  80753. getBuffer(): Nullable<DataBuffer>;
  80754. /**
  80755. * std140 layout specifies how to align data within an UBO structure.
  80756. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80757. * for specs.
  80758. */
  80759. private _fillAlignment;
  80760. /**
  80761. * Adds an uniform in the buffer.
  80762. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80763. * for the layout to be correct !
  80764. * @param name Name of the uniform, as used in the uniform block in the shader.
  80765. * @param size Data size, or data directly.
  80766. */
  80767. addUniform(name: string, size: number | number[]): void;
  80768. /**
  80769. * Adds a Matrix 4x4 to the uniform buffer.
  80770. * @param name Name of the uniform, as used in the uniform block in the shader.
  80771. * @param mat A 4x4 matrix.
  80772. */
  80773. addMatrix(name: string, mat: Matrix): void;
  80774. /**
  80775. * Adds a vec2 to the uniform buffer.
  80776. * @param name Name of the uniform, as used in the uniform block in the shader.
  80777. * @param x Define the x component value of the vec2
  80778. * @param y Define the y component value of the vec2
  80779. */
  80780. addFloat2(name: string, x: number, y: number): void;
  80781. /**
  80782. * Adds a vec3 to the uniform buffer.
  80783. * @param name Name of the uniform, as used in the uniform block in the shader.
  80784. * @param x Define the x component value of the vec3
  80785. * @param y Define the y component value of the vec3
  80786. * @param z Define the z component value of the vec3
  80787. */
  80788. addFloat3(name: string, x: number, y: number, z: number): void;
  80789. /**
  80790. * Adds a vec3 to the uniform buffer.
  80791. * @param name Name of the uniform, as used in the uniform block in the shader.
  80792. * @param color Define the vec3 from a Color
  80793. */
  80794. addColor3(name: string, color: Color3): void;
  80795. /**
  80796. * Adds a vec4 to the uniform buffer.
  80797. * @param name Name of the uniform, as used in the uniform block in the shader.
  80798. * @param color Define the rgb components from a Color
  80799. * @param alpha Define the a component of the vec4
  80800. */
  80801. addColor4(name: string, color: Color3, alpha: number): void;
  80802. /**
  80803. * Adds a vec3 to the uniform buffer.
  80804. * @param name Name of the uniform, as used in the uniform block in the shader.
  80805. * @param vector Define the vec3 components from a Vector
  80806. */
  80807. addVector3(name: string, vector: Vector3): void;
  80808. /**
  80809. * Adds a Matrix 3x3 to the uniform buffer.
  80810. * @param name Name of the uniform, as used in the uniform block in the shader.
  80811. */
  80812. addMatrix3x3(name: string): void;
  80813. /**
  80814. * Adds a Matrix 2x2 to the uniform buffer.
  80815. * @param name Name of the uniform, as used in the uniform block in the shader.
  80816. */
  80817. addMatrix2x2(name: string): void;
  80818. /**
  80819. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80820. */
  80821. create(): void;
  80822. /** @hidden */
  80823. _rebuild(): void;
  80824. /**
  80825. * Updates the WebGL Uniform Buffer on the GPU.
  80826. * If the `dynamic` flag is set to true, no cache comparison is done.
  80827. * Otherwise, the buffer will be updated only if the cache differs.
  80828. */
  80829. update(): void;
  80830. /**
  80831. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80832. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80833. * @param data Define the flattened data
  80834. * @param size Define the size of the data.
  80835. */
  80836. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80837. private _valueCache;
  80838. private _cacheMatrix;
  80839. private _updateMatrix3x3ForUniform;
  80840. private _updateMatrix3x3ForEffect;
  80841. private _updateMatrix2x2ForEffect;
  80842. private _updateMatrix2x2ForUniform;
  80843. private _updateFloatForEffect;
  80844. private _updateFloatForUniform;
  80845. private _updateFloat2ForEffect;
  80846. private _updateFloat2ForUniform;
  80847. private _updateFloat3ForEffect;
  80848. private _updateFloat3ForUniform;
  80849. private _updateFloat4ForEffect;
  80850. private _updateFloat4ForUniform;
  80851. private _updateMatrixForEffect;
  80852. private _updateMatrixForUniform;
  80853. private _updateVector3ForEffect;
  80854. private _updateVector3ForUniform;
  80855. private _updateVector4ForEffect;
  80856. private _updateVector4ForUniform;
  80857. private _updateColor3ForEffect;
  80858. private _updateColor3ForUniform;
  80859. private _updateColor4ForEffect;
  80860. private _updateColor4ForUniform;
  80861. /**
  80862. * Sets a sampler uniform on the effect.
  80863. * @param name Define the name of the sampler.
  80864. * @param texture Define the texture to set in the sampler
  80865. */
  80866. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80867. /**
  80868. * Directly updates the value of the uniform in the cache AND on the GPU.
  80869. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80870. * @param data Define the flattened data
  80871. */
  80872. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80873. /**
  80874. * Binds this uniform buffer to an effect.
  80875. * @param effect Define the effect to bind the buffer to
  80876. * @param name Name of the uniform block in the shader.
  80877. */
  80878. bindToEffect(effect: Effect, name: string): void;
  80879. /**
  80880. * Disposes the uniform buffer.
  80881. */
  80882. dispose(): void;
  80883. }
  80884. }
  80885. declare module BABYLON {
  80886. /**
  80887. * Enum that determines the text-wrapping mode to use.
  80888. */
  80889. export enum InspectableType {
  80890. /**
  80891. * Checkbox for booleans
  80892. */
  80893. Checkbox = 0,
  80894. /**
  80895. * Sliders for numbers
  80896. */
  80897. Slider = 1,
  80898. /**
  80899. * Vector3
  80900. */
  80901. Vector3 = 2,
  80902. /**
  80903. * Quaternions
  80904. */
  80905. Quaternion = 3,
  80906. /**
  80907. * Color3
  80908. */
  80909. Color3 = 4,
  80910. /**
  80911. * String
  80912. */
  80913. String = 5
  80914. }
  80915. /**
  80916. * Interface used to define custom inspectable properties.
  80917. * This interface is used by the inspector to display custom property grids
  80918. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80919. */
  80920. export interface IInspectable {
  80921. /**
  80922. * Gets the label to display
  80923. */
  80924. label: string;
  80925. /**
  80926. * Gets the name of the property to edit
  80927. */
  80928. propertyName: string;
  80929. /**
  80930. * Gets the type of the editor to use
  80931. */
  80932. type: InspectableType;
  80933. /**
  80934. * Gets the minimum value of the property when using in "slider" mode
  80935. */
  80936. min?: number;
  80937. /**
  80938. * Gets the maximum value of the property when using in "slider" mode
  80939. */
  80940. max?: number;
  80941. /**
  80942. * Gets the setp to use when using in "slider" mode
  80943. */
  80944. step?: number;
  80945. }
  80946. }
  80947. declare module BABYLON {
  80948. /**
  80949. * Class used to provide helper for timing
  80950. */
  80951. export class TimingTools {
  80952. /**
  80953. * Polyfill for setImmediate
  80954. * @param action defines the action to execute after the current execution block
  80955. */
  80956. static SetImmediate(action: () => void): void;
  80957. }
  80958. }
  80959. declare module BABYLON {
  80960. /**
  80961. * Class used to enable instatition of objects by class name
  80962. */
  80963. export class InstantiationTools {
  80964. /**
  80965. * Use this object to register external classes like custom textures or material
  80966. * to allow the laoders to instantiate them
  80967. */
  80968. static RegisteredExternalClasses: {
  80969. [key: string]: Object;
  80970. };
  80971. /**
  80972. * Tries to instantiate a new object from a given class name
  80973. * @param className defines the class name to instantiate
  80974. * @returns the new object or null if the system was not able to do the instantiation
  80975. */
  80976. static Instantiate(className: string): any;
  80977. }
  80978. }
  80979. declare module BABYLON {
  80980. /**
  80981. * Define options used to create a depth texture
  80982. */
  80983. export class DepthTextureCreationOptions {
  80984. /** Specifies whether or not a stencil should be allocated in the texture */
  80985. generateStencil?: boolean;
  80986. /** Specifies whether or not bilinear filtering is enable on the texture */
  80987. bilinearFiltering?: boolean;
  80988. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80989. comparisonFunction?: number;
  80990. /** Specifies if the created texture is a cube texture */
  80991. isCube?: boolean;
  80992. }
  80993. }
  80994. declare module BABYLON {
  80995. interface ThinEngine {
  80996. /**
  80997. * Creates a depth stencil cube texture.
  80998. * This is only available in WebGL 2.
  80999. * @param size The size of face edge in the cube texture.
  81000. * @param options The options defining the cube texture.
  81001. * @returns The cube texture
  81002. */
  81003. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81004. /**
  81005. * Creates a cube texture
  81006. * @param rootUrl defines the url where the files to load is located
  81007. * @param scene defines the current scene
  81008. * @param files defines the list of files to load (1 per face)
  81009. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81010. * @param onLoad defines an optional callback raised when the texture is loaded
  81011. * @param onError defines an optional callback raised if there is an issue to load the texture
  81012. * @param format defines the format of the data
  81013. * @param forcedExtension defines the extension to use to pick the right loader
  81014. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81015. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81016. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81017. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81018. * @returns the cube texture as an InternalTexture
  81019. */
  81020. 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>): InternalTexture;
  81021. /**
  81022. * Creates a cube texture
  81023. * @param rootUrl defines the url where the files to load is located
  81024. * @param scene defines the current scene
  81025. * @param files defines the list of files to load (1 per face)
  81026. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81027. * @param onLoad defines an optional callback raised when the texture is loaded
  81028. * @param onError defines an optional callback raised if there is an issue to load the texture
  81029. * @param format defines the format of the data
  81030. * @param forcedExtension defines the extension to use to pick the right loader
  81031. * @returns the cube texture as an InternalTexture
  81032. */
  81033. 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;
  81034. /**
  81035. * Creates a cube texture
  81036. * @param rootUrl defines the url where the files to load is located
  81037. * @param scene defines the current scene
  81038. * @param files defines the list of files to load (1 per face)
  81039. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81040. * @param onLoad defines an optional callback raised when the texture is loaded
  81041. * @param onError defines an optional callback raised if there is an issue to load the texture
  81042. * @param format defines the format of the data
  81043. * @param forcedExtension defines the extension to use to pick the right loader
  81044. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81045. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81046. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81047. * @returns the cube texture as an InternalTexture
  81048. */
  81049. 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;
  81050. /** @hidden */
  81051. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81052. /** @hidden */
  81053. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81054. /** @hidden */
  81055. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81056. /** @hidden */
  81057. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81058. /**
  81059. * @hidden
  81060. */
  81061. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81062. }
  81063. }
  81064. declare module BABYLON {
  81065. /**
  81066. * Class for creating a cube texture
  81067. */
  81068. export class CubeTexture extends BaseTexture {
  81069. private _delayedOnLoad;
  81070. /**
  81071. * Observable triggered once the texture has been loaded.
  81072. */
  81073. onLoadObservable: Observable<CubeTexture>;
  81074. /**
  81075. * The url of the texture
  81076. */
  81077. url: string;
  81078. /**
  81079. * Gets or sets the center of the bounding box associated with the cube texture.
  81080. * It must define where the camera used to render the texture was set
  81081. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81082. */
  81083. boundingBoxPosition: Vector3;
  81084. private _boundingBoxSize;
  81085. /**
  81086. * Gets or sets the size of the bounding box associated with the cube texture
  81087. * When defined, the cubemap will switch to local mode
  81088. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81089. * @example https://www.babylonjs-playground.com/#RNASML
  81090. */
  81091. set boundingBoxSize(value: Vector3);
  81092. /**
  81093. * Returns the bounding box size
  81094. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81095. */
  81096. get boundingBoxSize(): Vector3;
  81097. protected _rotationY: number;
  81098. /**
  81099. * Sets texture matrix rotation angle around Y axis in radians.
  81100. */
  81101. set rotationY(value: number);
  81102. /**
  81103. * Gets texture matrix rotation angle around Y axis radians.
  81104. */
  81105. get rotationY(): number;
  81106. /**
  81107. * Are mip maps generated for this texture or not.
  81108. */
  81109. get noMipmap(): boolean;
  81110. private _noMipmap;
  81111. private _files;
  81112. protected _forcedExtension: Nullable<string>;
  81113. private _extensions;
  81114. private _textureMatrix;
  81115. private _format;
  81116. private _createPolynomials;
  81117. /** @hidden */
  81118. _prefiltered: boolean;
  81119. /**
  81120. * Creates a cube texture from an array of image urls
  81121. * @param files defines an array of image urls
  81122. * @param scene defines the hosting scene
  81123. * @param noMipmap specifies if mip maps are not used
  81124. * @returns a cube texture
  81125. */
  81126. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81127. /**
  81128. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81129. * @param url defines the url of the prefiltered texture
  81130. * @param scene defines the scene the texture is attached to
  81131. * @param forcedExtension defines the extension of the file if different from the url
  81132. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81133. * @return the prefiltered texture
  81134. */
  81135. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81136. /**
  81137. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81138. * as prefiltered data.
  81139. * @param rootUrl defines the url of the texture or the root name of the six images
  81140. * @param scene defines the scene the texture is attached to
  81141. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81142. * @param noMipmap defines if mipmaps should be created or not
  81143. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81144. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81145. * @param onError defines a callback triggered in case of error during load
  81146. * @param format defines the internal format to use for the texture once loaded
  81147. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81148. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81149. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81150. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81151. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81152. * @return the cube texture
  81153. */
  81154. 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);
  81155. /**
  81156. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81157. */
  81158. get isPrefiltered(): boolean;
  81159. /**
  81160. * Get the current class name of the texture useful for serialization or dynamic coding.
  81161. * @returns "CubeTexture"
  81162. */
  81163. getClassName(): string;
  81164. /**
  81165. * Update the url (and optional buffer) of this texture if url was null during construction.
  81166. * @param url the url of the texture
  81167. * @param forcedExtension defines the extension to use
  81168. * @param onLoad callback called when the texture is loaded (defaults to null)
  81169. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81170. */
  81171. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81172. /**
  81173. * Delays loading of the cube texture
  81174. * @param forcedExtension defines the extension to use
  81175. */
  81176. delayLoad(forcedExtension?: string): void;
  81177. /**
  81178. * Returns the reflection texture matrix
  81179. * @returns the reflection texture matrix
  81180. */
  81181. getReflectionTextureMatrix(): Matrix;
  81182. /**
  81183. * Sets the reflection texture matrix
  81184. * @param value Reflection texture matrix
  81185. */
  81186. setReflectionTextureMatrix(value: Matrix): void;
  81187. /**
  81188. * Parses text to create a cube texture
  81189. * @param parsedTexture define the serialized text to read from
  81190. * @param scene defines the hosting scene
  81191. * @param rootUrl defines the root url of the cube texture
  81192. * @returns a cube texture
  81193. */
  81194. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81195. /**
  81196. * Makes a clone, or deep copy, of the cube texture
  81197. * @returns a new cube texture
  81198. */
  81199. clone(): CubeTexture;
  81200. }
  81201. }
  81202. declare module BABYLON {
  81203. /**
  81204. * Manages the defines for the Material
  81205. */
  81206. export class MaterialDefines {
  81207. /** @hidden */
  81208. protected _keys: string[];
  81209. private _isDirty;
  81210. /** @hidden */
  81211. _renderId: number;
  81212. /** @hidden */
  81213. _areLightsDirty: boolean;
  81214. /** @hidden */
  81215. _areLightsDisposed: boolean;
  81216. /** @hidden */
  81217. _areAttributesDirty: boolean;
  81218. /** @hidden */
  81219. _areTexturesDirty: boolean;
  81220. /** @hidden */
  81221. _areFresnelDirty: boolean;
  81222. /** @hidden */
  81223. _areMiscDirty: boolean;
  81224. /** @hidden */
  81225. _areImageProcessingDirty: boolean;
  81226. /** @hidden */
  81227. _normals: boolean;
  81228. /** @hidden */
  81229. _uvs: boolean;
  81230. /** @hidden */
  81231. _needNormals: boolean;
  81232. /** @hidden */
  81233. _needUVs: boolean;
  81234. [id: string]: any;
  81235. /**
  81236. * Specifies if the material needs to be re-calculated
  81237. */
  81238. get isDirty(): boolean;
  81239. /**
  81240. * Marks the material to indicate that it has been re-calculated
  81241. */
  81242. markAsProcessed(): void;
  81243. /**
  81244. * Marks the material to indicate that it needs to be re-calculated
  81245. */
  81246. markAsUnprocessed(): void;
  81247. /**
  81248. * Marks the material to indicate all of its defines need to be re-calculated
  81249. */
  81250. markAllAsDirty(): void;
  81251. /**
  81252. * Marks the material to indicate that image processing needs to be re-calculated
  81253. */
  81254. markAsImageProcessingDirty(): void;
  81255. /**
  81256. * Marks the material to indicate the lights need to be re-calculated
  81257. * @param disposed Defines whether the light is dirty due to dispose or not
  81258. */
  81259. markAsLightDirty(disposed?: boolean): void;
  81260. /**
  81261. * Marks the attribute state as changed
  81262. */
  81263. markAsAttributesDirty(): void;
  81264. /**
  81265. * Marks the texture state as changed
  81266. */
  81267. markAsTexturesDirty(): void;
  81268. /**
  81269. * Marks the fresnel state as changed
  81270. */
  81271. markAsFresnelDirty(): void;
  81272. /**
  81273. * Marks the misc state as changed
  81274. */
  81275. markAsMiscDirty(): void;
  81276. /**
  81277. * Rebuilds the material defines
  81278. */
  81279. rebuild(): void;
  81280. /**
  81281. * Specifies if two material defines are equal
  81282. * @param other - A material define instance to compare to
  81283. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81284. */
  81285. isEqual(other: MaterialDefines): boolean;
  81286. /**
  81287. * Clones this instance's defines to another instance
  81288. * @param other - material defines to clone values to
  81289. */
  81290. cloneTo(other: MaterialDefines): void;
  81291. /**
  81292. * Resets the material define values
  81293. */
  81294. reset(): void;
  81295. /**
  81296. * Converts the material define values to a string
  81297. * @returns - String of material define information
  81298. */
  81299. toString(): string;
  81300. }
  81301. }
  81302. declare module BABYLON {
  81303. /**
  81304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81306. * 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;
  81307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81308. */
  81309. export class ColorCurves {
  81310. private _dirty;
  81311. private _tempColor;
  81312. private _globalCurve;
  81313. private _highlightsCurve;
  81314. private _midtonesCurve;
  81315. private _shadowsCurve;
  81316. private _positiveCurve;
  81317. private _negativeCurve;
  81318. private _globalHue;
  81319. private _globalDensity;
  81320. private _globalSaturation;
  81321. private _globalExposure;
  81322. /**
  81323. * Gets the global Hue value.
  81324. * 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).
  81325. */
  81326. get globalHue(): number;
  81327. /**
  81328. * Sets the global Hue value.
  81329. * 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).
  81330. */
  81331. set globalHue(value: number);
  81332. /**
  81333. * Gets the global Density value.
  81334. * 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.
  81335. * Values less than zero provide a filter of opposite hue.
  81336. */
  81337. get globalDensity(): number;
  81338. /**
  81339. * Sets the global Density value.
  81340. * 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.
  81341. * Values less than zero provide a filter of opposite hue.
  81342. */
  81343. set globalDensity(value: number);
  81344. /**
  81345. * Gets the global Saturation value.
  81346. * 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.
  81347. */
  81348. get globalSaturation(): number;
  81349. /**
  81350. * Sets the global Saturation value.
  81351. * 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.
  81352. */
  81353. set globalSaturation(value: number);
  81354. /**
  81355. * Gets the global Exposure value.
  81356. * 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.
  81357. */
  81358. get globalExposure(): number;
  81359. /**
  81360. * Sets the global Exposure value.
  81361. * 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.
  81362. */
  81363. set globalExposure(value: number);
  81364. private _highlightsHue;
  81365. private _highlightsDensity;
  81366. private _highlightsSaturation;
  81367. private _highlightsExposure;
  81368. /**
  81369. * Gets the highlights Hue value.
  81370. * 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).
  81371. */
  81372. get highlightsHue(): number;
  81373. /**
  81374. * Sets the highlights Hue value.
  81375. * 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).
  81376. */
  81377. set highlightsHue(value: number);
  81378. /**
  81379. * Gets the highlights Density value.
  81380. * 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.
  81381. * Values less than zero provide a filter of opposite hue.
  81382. */
  81383. get highlightsDensity(): number;
  81384. /**
  81385. * Sets the highlights Density value.
  81386. * 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.
  81387. * Values less than zero provide a filter of opposite hue.
  81388. */
  81389. set highlightsDensity(value: number);
  81390. /**
  81391. * Gets the highlights Saturation value.
  81392. * 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.
  81393. */
  81394. get highlightsSaturation(): number;
  81395. /**
  81396. * Sets the highlights Saturation value.
  81397. * 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.
  81398. */
  81399. set highlightsSaturation(value: number);
  81400. /**
  81401. * Gets the highlights Exposure value.
  81402. * 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.
  81403. */
  81404. get highlightsExposure(): number;
  81405. /**
  81406. * Sets the highlights Exposure value.
  81407. * 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.
  81408. */
  81409. set highlightsExposure(value: number);
  81410. private _midtonesHue;
  81411. private _midtonesDensity;
  81412. private _midtonesSaturation;
  81413. private _midtonesExposure;
  81414. /**
  81415. * Gets the midtones Hue value.
  81416. * 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).
  81417. */
  81418. get midtonesHue(): number;
  81419. /**
  81420. * Sets the midtones Hue value.
  81421. * 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).
  81422. */
  81423. set midtonesHue(value: number);
  81424. /**
  81425. * Gets the midtones Density value.
  81426. * 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.
  81427. * Values less than zero provide a filter of opposite hue.
  81428. */
  81429. get midtonesDensity(): number;
  81430. /**
  81431. * Sets the midtones Density value.
  81432. * 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.
  81433. * Values less than zero provide a filter of opposite hue.
  81434. */
  81435. set midtonesDensity(value: number);
  81436. /**
  81437. * Gets the midtones Saturation value.
  81438. * 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.
  81439. */
  81440. get midtonesSaturation(): number;
  81441. /**
  81442. * Sets the midtones Saturation value.
  81443. * 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.
  81444. */
  81445. set midtonesSaturation(value: number);
  81446. /**
  81447. * Gets the midtones Exposure value.
  81448. * 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.
  81449. */
  81450. get midtonesExposure(): number;
  81451. /**
  81452. * Sets the midtones Exposure value.
  81453. * 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.
  81454. */
  81455. set midtonesExposure(value: number);
  81456. private _shadowsHue;
  81457. private _shadowsDensity;
  81458. private _shadowsSaturation;
  81459. private _shadowsExposure;
  81460. /**
  81461. * Gets the shadows Hue value.
  81462. * 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).
  81463. */
  81464. get shadowsHue(): number;
  81465. /**
  81466. * Sets the shadows Hue value.
  81467. * 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).
  81468. */
  81469. set shadowsHue(value: number);
  81470. /**
  81471. * Gets the shadows Density value.
  81472. * 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.
  81473. * Values less than zero provide a filter of opposite hue.
  81474. */
  81475. get shadowsDensity(): number;
  81476. /**
  81477. * Sets the shadows Density value.
  81478. * 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.
  81479. * Values less than zero provide a filter of opposite hue.
  81480. */
  81481. set shadowsDensity(value: number);
  81482. /**
  81483. * Gets the shadows Saturation value.
  81484. * 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.
  81485. */
  81486. get shadowsSaturation(): number;
  81487. /**
  81488. * Sets the shadows Saturation value.
  81489. * 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.
  81490. */
  81491. set shadowsSaturation(value: number);
  81492. /**
  81493. * Gets the shadows Exposure value.
  81494. * 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.
  81495. */
  81496. get shadowsExposure(): number;
  81497. /**
  81498. * Sets the shadows Exposure value.
  81499. * 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.
  81500. */
  81501. set shadowsExposure(value: number);
  81502. /**
  81503. * Returns the class name
  81504. * @returns The class name
  81505. */
  81506. getClassName(): string;
  81507. /**
  81508. * Binds the color curves to the shader.
  81509. * @param colorCurves The color curve to bind
  81510. * @param effect The effect to bind to
  81511. * @param positiveUniform The positive uniform shader parameter
  81512. * @param neutralUniform The neutral uniform shader parameter
  81513. * @param negativeUniform The negative uniform shader parameter
  81514. */
  81515. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81516. /**
  81517. * Prepare the list of uniforms associated with the ColorCurves effects.
  81518. * @param uniformsList The list of uniforms used in the effect
  81519. */
  81520. static PrepareUniforms(uniformsList: string[]): void;
  81521. /**
  81522. * Returns color grading data based on a hue, density, saturation and exposure value.
  81523. * @param filterHue The hue of the color filter.
  81524. * @param filterDensity The density of the color filter.
  81525. * @param saturation The saturation.
  81526. * @param exposure The exposure.
  81527. * @param result The result data container.
  81528. */
  81529. private getColorGradingDataToRef;
  81530. /**
  81531. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81532. * @param value The input slider value in range [-100,100].
  81533. * @returns Adjusted value.
  81534. */
  81535. private static applyColorGradingSliderNonlinear;
  81536. /**
  81537. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81538. * @param hue The hue (H) input.
  81539. * @param saturation The saturation (S) input.
  81540. * @param brightness The brightness (B) input.
  81541. * @result An RGBA color represented as Vector4.
  81542. */
  81543. private static fromHSBToRef;
  81544. /**
  81545. * Returns a value clamped between min and max
  81546. * @param value The value to clamp
  81547. * @param min The minimum of value
  81548. * @param max The maximum of value
  81549. * @returns The clamped value.
  81550. */
  81551. private static clamp;
  81552. /**
  81553. * Clones the current color curve instance.
  81554. * @return The cloned curves
  81555. */
  81556. clone(): ColorCurves;
  81557. /**
  81558. * Serializes the current color curve instance to a json representation.
  81559. * @return a JSON representation
  81560. */
  81561. serialize(): any;
  81562. /**
  81563. * Parses the color curve from a json representation.
  81564. * @param source the JSON source to parse
  81565. * @return The parsed curves
  81566. */
  81567. static Parse(source: any): ColorCurves;
  81568. }
  81569. }
  81570. declare module BABYLON {
  81571. /**
  81572. * Interface to follow in your material defines to integrate easily the
  81573. * Image proccessing functions.
  81574. * @hidden
  81575. */
  81576. export interface IImageProcessingConfigurationDefines {
  81577. IMAGEPROCESSING: boolean;
  81578. VIGNETTE: boolean;
  81579. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81580. VIGNETTEBLENDMODEOPAQUE: boolean;
  81581. TONEMAPPING: boolean;
  81582. TONEMAPPING_ACES: boolean;
  81583. CONTRAST: boolean;
  81584. EXPOSURE: boolean;
  81585. COLORCURVES: boolean;
  81586. COLORGRADING: boolean;
  81587. COLORGRADING3D: boolean;
  81588. SAMPLER3DGREENDEPTH: boolean;
  81589. SAMPLER3DBGRMAP: boolean;
  81590. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81591. }
  81592. /**
  81593. * @hidden
  81594. */
  81595. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81596. IMAGEPROCESSING: boolean;
  81597. VIGNETTE: boolean;
  81598. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81599. VIGNETTEBLENDMODEOPAQUE: boolean;
  81600. TONEMAPPING: boolean;
  81601. TONEMAPPING_ACES: boolean;
  81602. CONTRAST: boolean;
  81603. COLORCURVES: boolean;
  81604. COLORGRADING: boolean;
  81605. COLORGRADING3D: boolean;
  81606. SAMPLER3DGREENDEPTH: boolean;
  81607. SAMPLER3DBGRMAP: boolean;
  81608. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81609. EXPOSURE: boolean;
  81610. constructor();
  81611. }
  81612. /**
  81613. * This groups together the common properties used for image processing either in direct forward pass
  81614. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81615. * or not.
  81616. */
  81617. export class ImageProcessingConfiguration {
  81618. /**
  81619. * Default tone mapping applied in BabylonJS.
  81620. */
  81621. static readonly TONEMAPPING_STANDARD: number;
  81622. /**
  81623. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81624. * to other engines rendering to increase portability.
  81625. */
  81626. static readonly TONEMAPPING_ACES: number;
  81627. /**
  81628. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81629. */
  81630. colorCurves: Nullable<ColorCurves>;
  81631. private _colorCurvesEnabled;
  81632. /**
  81633. * Gets wether the color curves effect is enabled.
  81634. */
  81635. get colorCurvesEnabled(): boolean;
  81636. /**
  81637. * Sets wether the color curves effect is enabled.
  81638. */
  81639. set colorCurvesEnabled(value: boolean);
  81640. private _colorGradingTexture;
  81641. /**
  81642. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81643. */
  81644. get colorGradingTexture(): Nullable<BaseTexture>;
  81645. /**
  81646. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81647. */
  81648. set colorGradingTexture(value: Nullable<BaseTexture>);
  81649. private _colorGradingEnabled;
  81650. /**
  81651. * Gets wether the color grading effect is enabled.
  81652. */
  81653. get colorGradingEnabled(): boolean;
  81654. /**
  81655. * Sets wether the color grading effect is enabled.
  81656. */
  81657. set colorGradingEnabled(value: boolean);
  81658. private _colorGradingWithGreenDepth;
  81659. /**
  81660. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81661. */
  81662. get colorGradingWithGreenDepth(): boolean;
  81663. /**
  81664. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81665. */
  81666. set colorGradingWithGreenDepth(value: boolean);
  81667. private _colorGradingBGR;
  81668. /**
  81669. * Gets wether the color grading texture contains BGR values.
  81670. */
  81671. get colorGradingBGR(): boolean;
  81672. /**
  81673. * Sets wether the color grading texture contains BGR values.
  81674. */
  81675. set colorGradingBGR(value: boolean);
  81676. /** @hidden */
  81677. _exposure: number;
  81678. /**
  81679. * Gets the Exposure used in the effect.
  81680. */
  81681. get exposure(): number;
  81682. /**
  81683. * Sets the Exposure used in the effect.
  81684. */
  81685. set exposure(value: number);
  81686. private _toneMappingEnabled;
  81687. /**
  81688. * Gets wether the tone mapping effect is enabled.
  81689. */
  81690. get toneMappingEnabled(): boolean;
  81691. /**
  81692. * Sets wether the tone mapping effect is enabled.
  81693. */
  81694. set toneMappingEnabled(value: boolean);
  81695. private _toneMappingType;
  81696. /**
  81697. * Gets the type of tone mapping effect.
  81698. */
  81699. get toneMappingType(): number;
  81700. /**
  81701. * Sets the type of tone mapping effect used in BabylonJS.
  81702. */
  81703. set toneMappingType(value: number);
  81704. protected _contrast: number;
  81705. /**
  81706. * Gets the contrast used in the effect.
  81707. */
  81708. get contrast(): number;
  81709. /**
  81710. * Sets the contrast used in the effect.
  81711. */
  81712. set contrast(value: number);
  81713. /**
  81714. * Vignette stretch size.
  81715. */
  81716. vignetteStretch: number;
  81717. /**
  81718. * Vignette centre X Offset.
  81719. */
  81720. vignetteCentreX: number;
  81721. /**
  81722. * Vignette centre Y Offset.
  81723. */
  81724. vignetteCentreY: number;
  81725. /**
  81726. * Vignette weight or intensity of the vignette effect.
  81727. */
  81728. vignetteWeight: number;
  81729. /**
  81730. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81731. * if vignetteEnabled is set to true.
  81732. */
  81733. vignetteColor: Color4;
  81734. /**
  81735. * Camera field of view used by the Vignette effect.
  81736. */
  81737. vignetteCameraFov: number;
  81738. private _vignetteBlendMode;
  81739. /**
  81740. * Gets the vignette blend mode allowing different kind of effect.
  81741. */
  81742. get vignetteBlendMode(): number;
  81743. /**
  81744. * Sets the vignette blend mode allowing different kind of effect.
  81745. */
  81746. set vignetteBlendMode(value: number);
  81747. private _vignetteEnabled;
  81748. /**
  81749. * Gets wether the vignette effect is enabled.
  81750. */
  81751. get vignetteEnabled(): boolean;
  81752. /**
  81753. * Sets wether the vignette effect is enabled.
  81754. */
  81755. set vignetteEnabled(value: boolean);
  81756. private _applyByPostProcess;
  81757. /**
  81758. * Gets wether the image processing is applied through a post process or not.
  81759. */
  81760. get applyByPostProcess(): boolean;
  81761. /**
  81762. * Sets wether the image processing is applied through a post process or not.
  81763. */
  81764. set applyByPostProcess(value: boolean);
  81765. private _isEnabled;
  81766. /**
  81767. * Gets wether the image processing is enabled or not.
  81768. */
  81769. get isEnabled(): boolean;
  81770. /**
  81771. * Sets wether the image processing is enabled or not.
  81772. */
  81773. set isEnabled(value: boolean);
  81774. /**
  81775. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81776. */
  81777. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81778. /**
  81779. * Method called each time the image processing information changes requires to recompile the effect.
  81780. */
  81781. protected _updateParameters(): void;
  81782. /**
  81783. * Gets the current class name.
  81784. * @return "ImageProcessingConfiguration"
  81785. */
  81786. getClassName(): string;
  81787. /**
  81788. * Prepare the list of uniforms associated with the Image Processing effects.
  81789. * @param uniforms The list of uniforms used in the effect
  81790. * @param defines the list of defines currently in use
  81791. */
  81792. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81793. /**
  81794. * Prepare the list of samplers associated with the Image Processing effects.
  81795. * @param samplersList The list of uniforms used in the effect
  81796. * @param defines the list of defines currently in use
  81797. */
  81798. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81799. /**
  81800. * Prepare the list of defines associated to the shader.
  81801. * @param defines the list of defines to complete
  81802. * @param forPostProcess Define if we are currently in post process mode or not
  81803. */
  81804. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81805. /**
  81806. * Returns true if all the image processing information are ready.
  81807. * @returns True if ready, otherwise, false
  81808. */
  81809. isReady(): boolean;
  81810. /**
  81811. * Binds the image processing to the shader.
  81812. * @param effect The effect to bind to
  81813. * @param overrideAspectRatio Override the aspect ratio of the effect
  81814. */
  81815. bind(effect: Effect, overrideAspectRatio?: number): void;
  81816. /**
  81817. * Clones the current image processing instance.
  81818. * @return The cloned image processing
  81819. */
  81820. clone(): ImageProcessingConfiguration;
  81821. /**
  81822. * Serializes the current image processing instance to a json representation.
  81823. * @return a JSON representation
  81824. */
  81825. serialize(): any;
  81826. /**
  81827. * Parses the image processing from a json representation.
  81828. * @param source the JSON source to parse
  81829. * @return The parsed image processing
  81830. */
  81831. static Parse(source: any): ImageProcessingConfiguration;
  81832. private static _VIGNETTEMODE_MULTIPLY;
  81833. private static _VIGNETTEMODE_OPAQUE;
  81834. /**
  81835. * Used to apply the vignette as a mix with the pixel color.
  81836. */
  81837. static get VIGNETTEMODE_MULTIPLY(): number;
  81838. /**
  81839. * Used to apply the vignette as a replacement of the pixel color.
  81840. */
  81841. static get VIGNETTEMODE_OPAQUE(): number;
  81842. }
  81843. }
  81844. declare module BABYLON {
  81845. /** @hidden */
  81846. export var postprocessVertexShader: {
  81847. name: string;
  81848. shader: string;
  81849. };
  81850. }
  81851. declare module BABYLON {
  81852. interface ThinEngine {
  81853. /**
  81854. * Creates a new render target texture
  81855. * @param size defines the size of the texture
  81856. * @param options defines the options used to create the texture
  81857. * @returns a new render target texture stored in an InternalTexture
  81858. */
  81859. createRenderTargetTexture(size: number | {
  81860. width: number;
  81861. height: number;
  81862. layers?: number;
  81863. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81864. /**
  81865. * Creates a depth stencil texture.
  81866. * This is only available in WebGL 2 or with the depth texture extension available.
  81867. * @param size The size of face edge in the texture.
  81868. * @param options The options defining the texture.
  81869. * @returns The texture
  81870. */
  81871. createDepthStencilTexture(size: number | {
  81872. width: number;
  81873. height: number;
  81874. layers?: number;
  81875. }, options: DepthTextureCreationOptions): InternalTexture;
  81876. /** @hidden */
  81877. _createDepthStencilTexture(size: number | {
  81878. width: number;
  81879. height: number;
  81880. layers?: number;
  81881. }, options: DepthTextureCreationOptions): InternalTexture;
  81882. }
  81883. }
  81884. declare module BABYLON {
  81885. /** Defines supported spaces */
  81886. export enum Space {
  81887. /** Local (object) space */
  81888. LOCAL = 0,
  81889. /** World space */
  81890. WORLD = 1,
  81891. /** Bone space */
  81892. BONE = 2
  81893. }
  81894. /** Defines the 3 main axes */
  81895. export class Axis {
  81896. /** X axis */
  81897. static X: Vector3;
  81898. /** Y axis */
  81899. static Y: Vector3;
  81900. /** Z axis */
  81901. static Z: Vector3;
  81902. }
  81903. }
  81904. declare module BABYLON {
  81905. /**
  81906. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81907. * This is the base of the follow, arc rotate cameras and Free camera
  81908. * @see http://doc.babylonjs.com/features/cameras
  81909. */
  81910. export class TargetCamera extends Camera {
  81911. private static _RigCamTransformMatrix;
  81912. private static _TargetTransformMatrix;
  81913. private static _TargetFocalPoint;
  81914. /**
  81915. * Define the current direction the camera is moving to
  81916. */
  81917. cameraDirection: Vector3;
  81918. /**
  81919. * Define the current rotation the camera is rotating to
  81920. */
  81921. cameraRotation: Vector2;
  81922. /**
  81923. * When set, the up vector of the camera will be updated by the rotation of the camera
  81924. */
  81925. updateUpVectorFromRotation: boolean;
  81926. private _tmpQuaternion;
  81927. /**
  81928. * Define the current rotation of the camera
  81929. */
  81930. rotation: Vector3;
  81931. /**
  81932. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81933. */
  81934. rotationQuaternion: Quaternion;
  81935. /**
  81936. * Define the current speed of the camera
  81937. */
  81938. speed: number;
  81939. /**
  81940. * Add constraint to the camera to prevent it to move freely in all directions and
  81941. * around all axis.
  81942. */
  81943. noRotationConstraint: boolean;
  81944. /**
  81945. * Define the current target of the camera as an object or a position.
  81946. */
  81947. lockedTarget: any;
  81948. /** @hidden */
  81949. _currentTarget: Vector3;
  81950. /** @hidden */
  81951. _initialFocalDistance: number;
  81952. /** @hidden */
  81953. _viewMatrix: Matrix;
  81954. /** @hidden */
  81955. _camMatrix: Matrix;
  81956. /** @hidden */
  81957. _cameraTransformMatrix: Matrix;
  81958. /** @hidden */
  81959. _cameraRotationMatrix: Matrix;
  81960. /** @hidden */
  81961. _referencePoint: Vector3;
  81962. /** @hidden */
  81963. _transformedReferencePoint: Vector3;
  81964. protected _globalCurrentTarget: Vector3;
  81965. protected _globalCurrentUpVector: Vector3;
  81966. /** @hidden */
  81967. _reset: () => void;
  81968. private _defaultUp;
  81969. /**
  81970. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81971. * This is the base of the follow, arc rotate cameras and Free camera
  81972. * @see http://doc.babylonjs.com/features/cameras
  81973. * @param name Defines the name of the camera in the scene
  81974. * @param position Defines the start position of the camera in the scene
  81975. * @param scene Defines the scene the camera belongs to
  81976. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81977. */
  81978. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81979. /**
  81980. * Gets the position in front of the camera at a given distance.
  81981. * @param distance The distance from the camera we want the position to be
  81982. * @returns the position
  81983. */
  81984. getFrontPosition(distance: number): Vector3;
  81985. /** @hidden */
  81986. _getLockedTargetPosition(): Nullable<Vector3>;
  81987. private _storedPosition;
  81988. private _storedRotation;
  81989. private _storedRotationQuaternion;
  81990. /**
  81991. * Store current camera state of the camera (fov, position, rotation, etc..)
  81992. * @returns the camera
  81993. */
  81994. storeState(): Camera;
  81995. /**
  81996. * Restored camera state. You must call storeState() first
  81997. * @returns whether it was successful or not
  81998. * @hidden
  81999. */
  82000. _restoreStateValues(): boolean;
  82001. /** @hidden */
  82002. _initCache(): void;
  82003. /** @hidden */
  82004. _updateCache(ignoreParentClass?: boolean): void;
  82005. /** @hidden */
  82006. _isSynchronizedViewMatrix(): boolean;
  82007. /** @hidden */
  82008. _computeLocalCameraSpeed(): number;
  82009. /**
  82010. * Defines the target the camera should look at.
  82011. * @param target Defines the new target as a Vector or a mesh
  82012. */
  82013. setTarget(target: Vector3): void;
  82014. /**
  82015. * Return the current target position of the camera. This value is expressed in local space.
  82016. * @returns the target position
  82017. */
  82018. getTarget(): Vector3;
  82019. /** @hidden */
  82020. _decideIfNeedsToMove(): boolean;
  82021. /** @hidden */
  82022. _updatePosition(): void;
  82023. /** @hidden */
  82024. _checkInputs(): void;
  82025. protected _updateCameraRotationMatrix(): void;
  82026. /**
  82027. * 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)
  82028. * @returns the current camera
  82029. */
  82030. private _rotateUpVectorWithCameraRotationMatrix;
  82031. private _cachedRotationZ;
  82032. private _cachedQuaternionRotationZ;
  82033. /** @hidden */
  82034. _getViewMatrix(): Matrix;
  82035. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82036. /**
  82037. * @hidden
  82038. */
  82039. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82040. /**
  82041. * @hidden
  82042. */
  82043. _updateRigCameras(): void;
  82044. private _getRigCamPositionAndTarget;
  82045. /**
  82046. * Gets the current object class name.
  82047. * @return the class name
  82048. */
  82049. getClassName(): string;
  82050. }
  82051. }
  82052. declare module BABYLON {
  82053. /**
  82054. * Gather the list of keyboard event types as constants.
  82055. */
  82056. export class KeyboardEventTypes {
  82057. /**
  82058. * The keydown event is fired when a key becomes active (pressed).
  82059. */
  82060. static readonly KEYDOWN: number;
  82061. /**
  82062. * The keyup event is fired when a key has been released.
  82063. */
  82064. static readonly KEYUP: number;
  82065. }
  82066. /**
  82067. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82068. */
  82069. export class KeyboardInfo {
  82070. /**
  82071. * Defines the type of event (KeyboardEventTypes)
  82072. */
  82073. type: number;
  82074. /**
  82075. * Defines the related dom event
  82076. */
  82077. event: KeyboardEvent;
  82078. /**
  82079. * Instantiates a new keyboard info.
  82080. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82081. * @param type Defines the type of event (KeyboardEventTypes)
  82082. * @param event Defines the related dom event
  82083. */
  82084. constructor(
  82085. /**
  82086. * Defines the type of event (KeyboardEventTypes)
  82087. */
  82088. type: number,
  82089. /**
  82090. * Defines the related dom event
  82091. */
  82092. event: KeyboardEvent);
  82093. }
  82094. /**
  82095. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82096. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82097. */
  82098. export class KeyboardInfoPre extends KeyboardInfo {
  82099. /**
  82100. * Defines the type of event (KeyboardEventTypes)
  82101. */
  82102. type: number;
  82103. /**
  82104. * Defines the related dom event
  82105. */
  82106. event: KeyboardEvent;
  82107. /**
  82108. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82109. */
  82110. skipOnPointerObservable: boolean;
  82111. /**
  82112. * Instantiates a new keyboard pre info.
  82113. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82114. * @param type Defines the type of event (KeyboardEventTypes)
  82115. * @param event Defines the related dom event
  82116. */
  82117. constructor(
  82118. /**
  82119. * Defines the type of event (KeyboardEventTypes)
  82120. */
  82121. type: number,
  82122. /**
  82123. * Defines the related dom event
  82124. */
  82125. event: KeyboardEvent);
  82126. }
  82127. }
  82128. declare module BABYLON {
  82129. /**
  82130. * Manage the keyboard inputs to control the movement of a free camera.
  82131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82132. */
  82133. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82134. /**
  82135. * Defines the camera the input is attached to.
  82136. */
  82137. camera: FreeCamera;
  82138. /**
  82139. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82140. */
  82141. keysUp: number[];
  82142. /**
  82143. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82144. */
  82145. keysDown: number[];
  82146. /**
  82147. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82148. */
  82149. keysLeft: number[];
  82150. /**
  82151. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82152. */
  82153. keysRight: number[];
  82154. private _keys;
  82155. private _onCanvasBlurObserver;
  82156. private _onKeyboardObserver;
  82157. private _engine;
  82158. private _scene;
  82159. /**
  82160. * Attach the input controls to a specific dom element to get the input from.
  82161. * @param element Defines the element the controls should be listened from
  82162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82163. */
  82164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82165. /**
  82166. * Detach the current controls from the specified dom element.
  82167. * @param element Defines the element to stop listening the inputs from
  82168. */
  82169. detachControl(element: Nullable<HTMLElement>): void;
  82170. /**
  82171. * Update the current camera state depending on the inputs that have been used this frame.
  82172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82173. */
  82174. checkInputs(): void;
  82175. /**
  82176. * Gets the class name of the current intput.
  82177. * @returns the class name
  82178. */
  82179. getClassName(): string;
  82180. /** @hidden */
  82181. _onLostFocus(): void;
  82182. /**
  82183. * Get the friendly name associated with the input class.
  82184. * @returns the input friendly name
  82185. */
  82186. getSimpleName(): string;
  82187. }
  82188. }
  82189. declare module BABYLON {
  82190. /**
  82191. * Interface describing all the common properties and methods a shadow light needs to implement.
  82192. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82193. * as well as binding the different shadow properties to the effects.
  82194. */
  82195. export interface IShadowLight extends Light {
  82196. /**
  82197. * The light id in the scene (used in scene.findLighById for instance)
  82198. */
  82199. id: string;
  82200. /**
  82201. * The position the shdow will be casted from.
  82202. */
  82203. position: Vector3;
  82204. /**
  82205. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82206. */
  82207. direction: Vector3;
  82208. /**
  82209. * The transformed position. Position of the light in world space taking parenting in account.
  82210. */
  82211. transformedPosition: Vector3;
  82212. /**
  82213. * The transformed direction. Direction of the light in world space taking parenting in account.
  82214. */
  82215. transformedDirection: Vector3;
  82216. /**
  82217. * The friendly name of the light in the scene.
  82218. */
  82219. name: string;
  82220. /**
  82221. * Defines the shadow projection clipping minimum z value.
  82222. */
  82223. shadowMinZ: number;
  82224. /**
  82225. * Defines the shadow projection clipping maximum z value.
  82226. */
  82227. shadowMaxZ: number;
  82228. /**
  82229. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82230. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82231. */
  82232. computeTransformedInformation(): boolean;
  82233. /**
  82234. * Gets the scene the light belongs to.
  82235. * @returns The scene
  82236. */
  82237. getScene(): Scene;
  82238. /**
  82239. * Callback defining a custom Projection Matrix Builder.
  82240. * This can be used to override the default projection matrix computation.
  82241. */
  82242. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82243. /**
  82244. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82245. * @param matrix The materix to updated with the projection information
  82246. * @param viewMatrix The transform matrix of the light
  82247. * @param renderList The list of mesh to render in the map
  82248. * @returns The current light
  82249. */
  82250. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82251. /**
  82252. * Gets the current depth scale used in ESM.
  82253. * @returns The scale
  82254. */
  82255. getDepthScale(): number;
  82256. /**
  82257. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82258. * @returns true if a cube texture needs to be use
  82259. */
  82260. needCube(): boolean;
  82261. /**
  82262. * Detects if the projection matrix requires to be recomputed this frame.
  82263. * @returns true if it requires to be recomputed otherwise, false.
  82264. */
  82265. needProjectionMatrixCompute(): boolean;
  82266. /**
  82267. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82268. */
  82269. forceProjectionMatrixCompute(): void;
  82270. /**
  82271. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82272. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82273. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82274. */
  82275. getShadowDirection(faceIndex?: number): Vector3;
  82276. /**
  82277. * Gets the minZ used for shadow according to both the scene and the light.
  82278. * @param activeCamera The camera we are returning the min for
  82279. * @returns the depth min z
  82280. */
  82281. getDepthMinZ(activeCamera: Camera): number;
  82282. /**
  82283. * Gets the maxZ used for shadow according to both the scene and the light.
  82284. * @param activeCamera The camera we are returning the max for
  82285. * @returns the depth max z
  82286. */
  82287. getDepthMaxZ(activeCamera: Camera): number;
  82288. }
  82289. /**
  82290. * Base implementation IShadowLight
  82291. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82292. */
  82293. export abstract class ShadowLight extends Light implements IShadowLight {
  82294. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82295. protected _position: Vector3;
  82296. protected _setPosition(value: Vector3): void;
  82297. /**
  82298. * Sets the position the shadow will be casted from. Also use as the light position for both
  82299. * point and spot lights.
  82300. */
  82301. get position(): Vector3;
  82302. /**
  82303. * Sets the position the shadow will be casted from. Also use as the light position for both
  82304. * point and spot lights.
  82305. */
  82306. set position(value: Vector3);
  82307. protected _direction: Vector3;
  82308. protected _setDirection(value: Vector3): void;
  82309. /**
  82310. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82311. * Also use as the light direction on spot and directional lights.
  82312. */
  82313. get direction(): Vector3;
  82314. /**
  82315. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82316. * Also use as the light direction on spot and directional lights.
  82317. */
  82318. set direction(value: Vector3);
  82319. protected _shadowMinZ: number;
  82320. /**
  82321. * Gets the shadow projection clipping minimum z value.
  82322. */
  82323. get shadowMinZ(): number;
  82324. /**
  82325. * Sets the shadow projection clipping minimum z value.
  82326. */
  82327. set shadowMinZ(value: number);
  82328. protected _shadowMaxZ: number;
  82329. /**
  82330. * Sets the shadow projection clipping maximum z value.
  82331. */
  82332. get shadowMaxZ(): number;
  82333. /**
  82334. * Gets the shadow projection clipping maximum z value.
  82335. */
  82336. set shadowMaxZ(value: number);
  82337. /**
  82338. * Callback defining a custom Projection Matrix Builder.
  82339. * This can be used to override the default projection matrix computation.
  82340. */
  82341. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82342. /**
  82343. * The transformed position. Position of the light in world space taking parenting in account.
  82344. */
  82345. transformedPosition: Vector3;
  82346. /**
  82347. * The transformed direction. Direction of the light in world space taking parenting in account.
  82348. */
  82349. transformedDirection: Vector3;
  82350. private _needProjectionMatrixCompute;
  82351. /**
  82352. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82353. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82354. */
  82355. computeTransformedInformation(): boolean;
  82356. /**
  82357. * Return the depth scale used for the shadow map.
  82358. * @returns the depth scale.
  82359. */
  82360. getDepthScale(): number;
  82361. /**
  82362. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82363. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82364. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82365. */
  82366. getShadowDirection(faceIndex?: number): Vector3;
  82367. /**
  82368. * Returns the ShadowLight absolute position in the World.
  82369. * @returns the position vector in world space
  82370. */
  82371. getAbsolutePosition(): Vector3;
  82372. /**
  82373. * Sets the ShadowLight direction toward the passed target.
  82374. * @param target The point to target in local space
  82375. * @returns the updated ShadowLight direction
  82376. */
  82377. setDirectionToTarget(target: Vector3): Vector3;
  82378. /**
  82379. * Returns the light rotation in euler definition.
  82380. * @returns the x y z rotation in local space.
  82381. */
  82382. getRotation(): Vector3;
  82383. /**
  82384. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82385. * @returns true if a cube texture needs to be use
  82386. */
  82387. needCube(): boolean;
  82388. /**
  82389. * Detects if the projection matrix requires to be recomputed this frame.
  82390. * @returns true if it requires to be recomputed otherwise, false.
  82391. */
  82392. needProjectionMatrixCompute(): boolean;
  82393. /**
  82394. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82395. */
  82396. forceProjectionMatrixCompute(): void;
  82397. /** @hidden */
  82398. _initCache(): void;
  82399. /** @hidden */
  82400. _isSynchronized(): boolean;
  82401. /**
  82402. * Computes the world matrix of the node
  82403. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82404. * @returns the world matrix
  82405. */
  82406. computeWorldMatrix(force?: boolean): Matrix;
  82407. /**
  82408. * Gets the minZ used for shadow according to both the scene and the light.
  82409. * @param activeCamera The camera we are returning the min for
  82410. * @returns the depth min z
  82411. */
  82412. getDepthMinZ(activeCamera: Camera): number;
  82413. /**
  82414. * Gets the maxZ used for shadow according to both the scene and the light.
  82415. * @param activeCamera The camera we are returning the max for
  82416. * @returns the depth max z
  82417. */
  82418. getDepthMaxZ(activeCamera: Camera): number;
  82419. /**
  82420. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82421. * @param matrix The materix to updated with the projection information
  82422. * @param viewMatrix The transform matrix of the light
  82423. * @param renderList The list of mesh to render in the map
  82424. * @returns The current light
  82425. */
  82426. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82427. }
  82428. }
  82429. declare module BABYLON {
  82430. /**
  82431. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82432. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82433. */
  82434. export class EffectFallbacks implements IEffectFallbacks {
  82435. private _defines;
  82436. private _currentRank;
  82437. private _maxRank;
  82438. private _mesh;
  82439. /**
  82440. * Removes the fallback from the bound mesh.
  82441. */
  82442. unBindMesh(): void;
  82443. /**
  82444. * Adds a fallback on the specified property.
  82445. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82446. * @param define The name of the define in the shader
  82447. */
  82448. addFallback(rank: number, define: string): void;
  82449. /**
  82450. * Sets the mesh to use CPU skinning when needing to fallback.
  82451. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82452. * @param mesh The mesh to use the fallbacks.
  82453. */
  82454. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82455. /**
  82456. * Checks to see if more fallbacks are still availible.
  82457. */
  82458. get hasMoreFallbacks(): boolean;
  82459. /**
  82460. * Removes the defines that should be removed when falling back.
  82461. * @param currentDefines defines the current define statements for the shader.
  82462. * @param effect defines the current effect we try to compile
  82463. * @returns The resulting defines with defines of the current rank removed.
  82464. */
  82465. reduce(currentDefines: string, effect: Effect): string;
  82466. }
  82467. }
  82468. declare module BABYLON {
  82469. /**
  82470. * "Static Class" containing the most commonly used helper while dealing with material for
  82471. * rendering purpose.
  82472. *
  82473. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82474. *
  82475. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82476. */
  82477. export class MaterialHelper {
  82478. /**
  82479. * Bind the current view position to an effect.
  82480. * @param effect The effect to be bound
  82481. * @param scene The scene the eyes position is used from
  82482. */
  82483. static BindEyePosition(effect: Effect, scene: Scene): void;
  82484. /**
  82485. * Helps preparing the defines values about the UVs in used in the effect.
  82486. * UVs are shared as much as we can accross channels in the shaders.
  82487. * @param texture The texture we are preparing the UVs for
  82488. * @param defines The defines to update
  82489. * @param key The channel key "diffuse", "specular"... used in the shader
  82490. */
  82491. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82492. /**
  82493. * Binds a texture matrix value to its corrsponding uniform
  82494. * @param texture The texture to bind the matrix for
  82495. * @param uniformBuffer The uniform buffer receivin the data
  82496. * @param key The channel key "diffuse", "specular"... used in the shader
  82497. */
  82498. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82499. /**
  82500. * Gets the current status of the fog (should it be enabled?)
  82501. * @param mesh defines the mesh to evaluate for fog support
  82502. * @param scene defines the hosting scene
  82503. * @returns true if fog must be enabled
  82504. */
  82505. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82506. /**
  82507. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82508. * @param mesh defines the current mesh
  82509. * @param scene defines the current scene
  82510. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82511. * @param pointsCloud defines if point cloud rendering has to be turned on
  82512. * @param fogEnabled defines if fog has to be turned on
  82513. * @param alphaTest defines if alpha testing has to be turned on
  82514. * @param defines defines the current list of defines
  82515. */
  82516. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82517. /**
  82518. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82519. * @param scene defines the current scene
  82520. * @param engine defines the current engine
  82521. * @param defines specifies the list of active defines
  82522. * @param useInstances defines if instances have to be turned on
  82523. * @param useClipPlane defines if clip plane have to be turned on
  82524. */
  82525. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82526. /**
  82527. * Prepares the defines for bones
  82528. * @param mesh The mesh containing the geometry data we will draw
  82529. * @param defines The defines to update
  82530. */
  82531. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82532. /**
  82533. * Prepares the defines for morph targets
  82534. * @param mesh The mesh containing the geometry data we will draw
  82535. * @param defines The defines to update
  82536. */
  82537. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82538. /**
  82539. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82540. * @param mesh The mesh containing the geometry data we will draw
  82541. * @param defines The defines to update
  82542. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82543. * @param useBones Precise whether bones should be used or not (override mesh info)
  82544. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82545. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82546. * @returns false if defines are considered not dirty and have not been checked
  82547. */
  82548. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82549. /**
  82550. * Prepares the defines related to multiview
  82551. * @param scene The scene we are intending to draw
  82552. * @param defines The defines to update
  82553. */
  82554. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82555. /**
  82556. * Prepares the defines related to the light information passed in parameter
  82557. * @param scene The scene we are intending to draw
  82558. * @param mesh The mesh the effect is compiling for
  82559. * @param light The light the effect is compiling for
  82560. * @param lightIndex The index of the light
  82561. * @param defines The defines to update
  82562. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82563. * @param state Defines the current state regarding what is needed (normals, etc...)
  82564. */
  82565. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82566. needNormals: boolean;
  82567. needRebuild: boolean;
  82568. shadowEnabled: boolean;
  82569. specularEnabled: boolean;
  82570. lightmapMode: boolean;
  82571. }): void;
  82572. /**
  82573. * Prepares the defines related to the light information passed in parameter
  82574. * @param scene The scene we are intending to draw
  82575. * @param mesh The mesh the effect is compiling for
  82576. * @param defines The defines to update
  82577. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82578. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82579. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82580. * @returns true if normals will be required for the rest of the effect
  82581. */
  82582. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82583. /**
  82584. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82585. * @param lightIndex defines the light index
  82586. * @param uniformsList The uniform list
  82587. * @param samplersList The sampler list
  82588. * @param projectedLightTexture defines if projected texture must be used
  82589. * @param uniformBuffersList defines an optional list of uniform buffers
  82590. */
  82591. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82592. /**
  82593. * Prepares the uniforms and samplers list to be used in the effect
  82594. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82595. * @param samplersList The sampler list
  82596. * @param defines The defines helping in the list generation
  82597. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82598. */
  82599. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82600. /**
  82601. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82602. * @param defines The defines to update while falling back
  82603. * @param fallbacks The authorized effect fallbacks
  82604. * @param maxSimultaneousLights The maximum number of lights allowed
  82605. * @param rank the current rank of the Effect
  82606. * @returns The newly affected rank
  82607. */
  82608. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82609. private static _TmpMorphInfluencers;
  82610. /**
  82611. * Prepares the list of attributes required for morph targets according to the effect defines.
  82612. * @param attribs The current list of supported attribs
  82613. * @param mesh The mesh to prepare the morph targets attributes for
  82614. * @param influencers The number of influencers
  82615. */
  82616. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82617. /**
  82618. * Prepares the list of attributes required for morph targets according to the effect defines.
  82619. * @param attribs The current list of supported attribs
  82620. * @param mesh The mesh to prepare the morph targets attributes for
  82621. * @param defines The current Defines of the effect
  82622. */
  82623. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82624. /**
  82625. * Prepares the list of attributes required for bones according to the effect defines.
  82626. * @param attribs The current list of supported attribs
  82627. * @param mesh The mesh to prepare the bones attributes for
  82628. * @param defines The current Defines of the effect
  82629. * @param fallbacks The current efffect fallback strategy
  82630. */
  82631. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82632. /**
  82633. * Check and prepare the list of attributes required for instances according to the effect defines.
  82634. * @param attribs The current list of supported attribs
  82635. * @param defines The current MaterialDefines of the effect
  82636. */
  82637. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82638. /**
  82639. * Add the list of attributes required for instances to the attribs array.
  82640. * @param attribs The current list of supported attribs
  82641. */
  82642. static PushAttributesForInstances(attribs: string[]): void;
  82643. /**
  82644. * Binds the light information to the effect.
  82645. * @param light The light containing the generator
  82646. * @param effect The effect we are binding the data to
  82647. * @param lightIndex The light index in the effect used to render
  82648. */
  82649. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82650. /**
  82651. * Binds the lights information from the scene to the effect for the given mesh.
  82652. * @param light Light to bind
  82653. * @param lightIndex Light index
  82654. * @param scene The scene where the light belongs to
  82655. * @param effect The effect we are binding the data to
  82656. * @param useSpecular Defines if specular is supported
  82657. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82658. */
  82659. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82660. /**
  82661. * Binds the lights information from the scene to the effect for the given mesh.
  82662. * @param scene The scene the lights belongs to
  82663. * @param mesh The mesh we are binding the information to render
  82664. * @param effect The effect we are binding the data to
  82665. * @param defines The generated defines for the effect
  82666. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82667. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82668. */
  82669. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82670. private static _tempFogColor;
  82671. /**
  82672. * Binds the fog information from the scene to the effect for the given mesh.
  82673. * @param scene The scene the lights belongs to
  82674. * @param mesh The mesh we are binding the information to render
  82675. * @param effect The effect we are binding the data to
  82676. * @param linearSpace Defines if the fog effect is applied in linear space
  82677. */
  82678. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82679. /**
  82680. * Binds the bones information from the mesh to the effect.
  82681. * @param mesh The mesh we are binding the information to render
  82682. * @param effect The effect we are binding the data to
  82683. */
  82684. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82685. /**
  82686. * Binds the morph targets information from the mesh to the effect.
  82687. * @param abstractMesh The mesh we are binding the information to render
  82688. * @param effect The effect we are binding the data to
  82689. */
  82690. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82691. /**
  82692. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82693. * @param defines The generated defines used in the effect
  82694. * @param effect The effect we are binding the data to
  82695. * @param scene The scene we are willing to render with logarithmic scale for
  82696. */
  82697. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82698. /**
  82699. * Binds the clip plane information from the scene to the effect.
  82700. * @param scene The scene the clip plane information are extracted from
  82701. * @param effect The effect we are binding the data to
  82702. */
  82703. static BindClipPlane(effect: Effect, scene: Scene): void;
  82704. }
  82705. }
  82706. declare module BABYLON {
  82707. /** @hidden */
  82708. export var packingFunctions: {
  82709. name: string;
  82710. shader: string;
  82711. };
  82712. }
  82713. declare module BABYLON {
  82714. /** @hidden */
  82715. export var clipPlaneFragmentDeclaration: {
  82716. name: string;
  82717. shader: string;
  82718. };
  82719. }
  82720. declare module BABYLON {
  82721. /** @hidden */
  82722. export var clipPlaneFragment: {
  82723. name: string;
  82724. shader: string;
  82725. };
  82726. }
  82727. declare module BABYLON {
  82728. /** @hidden */
  82729. export var shadowMapPixelShader: {
  82730. name: string;
  82731. shader: string;
  82732. };
  82733. }
  82734. declare module BABYLON {
  82735. /** @hidden */
  82736. export var bonesDeclaration: {
  82737. name: string;
  82738. shader: string;
  82739. };
  82740. }
  82741. declare module BABYLON {
  82742. /** @hidden */
  82743. export var morphTargetsVertexGlobalDeclaration: {
  82744. name: string;
  82745. shader: string;
  82746. };
  82747. }
  82748. declare module BABYLON {
  82749. /** @hidden */
  82750. export var morphTargetsVertexDeclaration: {
  82751. name: string;
  82752. shader: string;
  82753. };
  82754. }
  82755. declare module BABYLON {
  82756. /** @hidden */
  82757. export var instancesDeclaration: {
  82758. name: string;
  82759. shader: string;
  82760. };
  82761. }
  82762. declare module BABYLON {
  82763. /** @hidden */
  82764. export var helperFunctions: {
  82765. name: string;
  82766. shader: string;
  82767. };
  82768. }
  82769. declare module BABYLON {
  82770. /** @hidden */
  82771. export var clipPlaneVertexDeclaration: {
  82772. name: string;
  82773. shader: string;
  82774. };
  82775. }
  82776. declare module BABYLON {
  82777. /** @hidden */
  82778. export var morphTargetsVertex: {
  82779. name: string;
  82780. shader: string;
  82781. };
  82782. }
  82783. declare module BABYLON {
  82784. /** @hidden */
  82785. export var instancesVertex: {
  82786. name: string;
  82787. shader: string;
  82788. };
  82789. }
  82790. declare module BABYLON {
  82791. /** @hidden */
  82792. export var bonesVertex: {
  82793. name: string;
  82794. shader: string;
  82795. };
  82796. }
  82797. declare module BABYLON {
  82798. /** @hidden */
  82799. export var clipPlaneVertex: {
  82800. name: string;
  82801. shader: string;
  82802. };
  82803. }
  82804. declare module BABYLON {
  82805. /** @hidden */
  82806. export var shadowMapVertexShader: {
  82807. name: string;
  82808. shader: string;
  82809. };
  82810. }
  82811. declare module BABYLON {
  82812. /** @hidden */
  82813. export var depthBoxBlurPixelShader: {
  82814. name: string;
  82815. shader: string;
  82816. };
  82817. }
  82818. declare module BABYLON {
  82819. /**
  82820. * Class representing a ray with position and direction
  82821. */
  82822. export class Ray {
  82823. /** origin point */
  82824. origin: Vector3;
  82825. /** direction */
  82826. direction: Vector3;
  82827. /** length of the ray */
  82828. length: number;
  82829. private static readonly TmpVector3;
  82830. private _tmpRay;
  82831. /**
  82832. * Creates a new ray
  82833. * @param origin origin point
  82834. * @param direction direction
  82835. * @param length length of the ray
  82836. */
  82837. constructor(
  82838. /** origin point */
  82839. origin: Vector3,
  82840. /** direction */
  82841. direction: Vector3,
  82842. /** length of the ray */
  82843. length?: number);
  82844. /**
  82845. * Checks if the ray intersects a box
  82846. * @param minimum bound of the box
  82847. * @param maximum bound of the box
  82848. * @param intersectionTreshold extra extend to be added to the box in all direction
  82849. * @returns if the box was hit
  82850. */
  82851. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82852. /**
  82853. * Checks if the ray intersects a box
  82854. * @param box the bounding box to check
  82855. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82856. * @returns if the box was hit
  82857. */
  82858. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82859. /**
  82860. * If the ray hits a sphere
  82861. * @param sphere the bounding sphere to check
  82862. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82863. * @returns true if it hits the sphere
  82864. */
  82865. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82866. /**
  82867. * If the ray hits a triange
  82868. * @param vertex0 triangle vertex
  82869. * @param vertex1 triangle vertex
  82870. * @param vertex2 triangle vertex
  82871. * @returns intersection information if hit
  82872. */
  82873. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82874. /**
  82875. * Checks if ray intersects a plane
  82876. * @param plane the plane to check
  82877. * @returns the distance away it was hit
  82878. */
  82879. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82880. /**
  82881. * Calculate the intercept of a ray on a given axis
  82882. * @param axis to check 'x' | 'y' | 'z'
  82883. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82884. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82885. */
  82886. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82887. /**
  82888. * Checks if ray intersects a mesh
  82889. * @param mesh the mesh to check
  82890. * @param fastCheck if only the bounding box should checked
  82891. * @returns picking info of the intersecton
  82892. */
  82893. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82894. /**
  82895. * Checks if ray intersects a mesh
  82896. * @param meshes the meshes to check
  82897. * @param fastCheck if only the bounding box should checked
  82898. * @param results array to store result in
  82899. * @returns Array of picking infos
  82900. */
  82901. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82902. private _comparePickingInfo;
  82903. private static smallnum;
  82904. private static rayl;
  82905. /**
  82906. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82907. * @param sega the first point of the segment to test the intersection against
  82908. * @param segb the second point of the segment to test the intersection against
  82909. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82910. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82911. */
  82912. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82913. /**
  82914. * Update the ray from viewport position
  82915. * @param x position
  82916. * @param y y position
  82917. * @param viewportWidth viewport width
  82918. * @param viewportHeight viewport height
  82919. * @param world world matrix
  82920. * @param view view matrix
  82921. * @param projection projection matrix
  82922. * @returns this ray updated
  82923. */
  82924. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82925. /**
  82926. * Creates a ray with origin and direction of 0,0,0
  82927. * @returns the new ray
  82928. */
  82929. static Zero(): Ray;
  82930. /**
  82931. * Creates a new ray from screen space and viewport
  82932. * @param x position
  82933. * @param y y position
  82934. * @param viewportWidth viewport width
  82935. * @param viewportHeight viewport height
  82936. * @param world world matrix
  82937. * @param view view matrix
  82938. * @param projection projection matrix
  82939. * @returns new ray
  82940. */
  82941. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82942. /**
  82943. * 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
  82944. * transformed to the given world matrix.
  82945. * @param origin The origin point
  82946. * @param end The end point
  82947. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82948. * @returns the new ray
  82949. */
  82950. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82951. /**
  82952. * Transforms a ray by a matrix
  82953. * @param ray ray to transform
  82954. * @param matrix matrix to apply
  82955. * @returns the resulting new ray
  82956. */
  82957. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82958. /**
  82959. * Transforms a ray by a matrix
  82960. * @param ray ray to transform
  82961. * @param matrix matrix to apply
  82962. * @param result ray to store result in
  82963. */
  82964. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82965. /**
  82966. * Unproject a ray from screen space to object space
  82967. * @param sourceX defines the screen space x coordinate to use
  82968. * @param sourceY defines the screen space y coordinate to use
  82969. * @param viewportWidth defines the current width of the viewport
  82970. * @param viewportHeight defines the current height of the viewport
  82971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82972. * @param view defines the view matrix to use
  82973. * @param projection defines the projection matrix to use
  82974. */
  82975. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82976. }
  82977. /**
  82978. * Type used to define predicate used to select faces when a mesh intersection is detected
  82979. */
  82980. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82981. interface Scene {
  82982. /** @hidden */
  82983. _tempPickingRay: Nullable<Ray>;
  82984. /** @hidden */
  82985. _cachedRayForTransform: Ray;
  82986. /** @hidden */
  82987. _pickWithRayInverseMatrix: Matrix;
  82988. /** @hidden */
  82989. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82990. /** @hidden */
  82991. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82992. }
  82993. }
  82994. declare module BABYLON {
  82995. /**
  82996. * Groups all the scene component constants in one place to ease maintenance.
  82997. * @hidden
  82998. */
  82999. export class SceneComponentConstants {
  83000. static readonly NAME_EFFECTLAYER: string;
  83001. static readonly NAME_LAYER: string;
  83002. static readonly NAME_LENSFLARESYSTEM: string;
  83003. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83004. static readonly NAME_PARTICLESYSTEM: string;
  83005. static readonly NAME_GAMEPAD: string;
  83006. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83007. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83008. static readonly NAME_DEPTHRENDERER: string;
  83009. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83010. static readonly NAME_SPRITE: string;
  83011. static readonly NAME_OUTLINERENDERER: string;
  83012. static readonly NAME_PROCEDURALTEXTURE: string;
  83013. static readonly NAME_SHADOWGENERATOR: string;
  83014. static readonly NAME_OCTREE: string;
  83015. static readonly NAME_PHYSICSENGINE: string;
  83016. static readonly NAME_AUDIO: string;
  83017. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83018. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83019. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83020. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83021. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83022. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83023. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83024. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83025. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83026. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83027. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83028. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83029. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83030. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83031. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83032. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83033. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83034. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83035. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83036. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83037. static readonly STEP_AFTERRENDER_AUDIO: number;
  83038. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83039. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83040. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83041. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83042. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83043. static readonly STEP_POINTERMOVE_SPRITE: number;
  83044. static readonly STEP_POINTERDOWN_SPRITE: number;
  83045. static readonly STEP_POINTERUP_SPRITE: number;
  83046. }
  83047. /**
  83048. * This represents a scene component.
  83049. *
  83050. * This is used to decouple the dependency the scene is having on the different workloads like
  83051. * layers, post processes...
  83052. */
  83053. export interface ISceneComponent {
  83054. /**
  83055. * The name of the component. Each component must have a unique name.
  83056. */
  83057. name: string;
  83058. /**
  83059. * The scene the component belongs to.
  83060. */
  83061. scene: Scene;
  83062. /**
  83063. * Register the component to one instance of a scene.
  83064. */
  83065. register(): void;
  83066. /**
  83067. * Rebuilds the elements related to this component in case of
  83068. * context lost for instance.
  83069. */
  83070. rebuild(): void;
  83071. /**
  83072. * Disposes the component and the associated ressources.
  83073. */
  83074. dispose(): void;
  83075. }
  83076. /**
  83077. * This represents a SERIALIZABLE scene component.
  83078. *
  83079. * This extends Scene Component to add Serialization methods on top.
  83080. */
  83081. export interface ISceneSerializableComponent extends ISceneComponent {
  83082. /**
  83083. * Adds all the elements from the container to the scene
  83084. * @param container the container holding the elements
  83085. */
  83086. addFromContainer(container: AbstractScene): void;
  83087. /**
  83088. * Removes all the elements in the container from the scene
  83089. * @param container contains the elements to remove
  83090. * @param dispose if the removed element should be disposed (default: false)
  83091. */
  83092. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83093. /**
  83094. * Serializes the component data to the specified json object
  83095. * @param serializationObject The object to serialize to
  83096. */
  83097. serialize(serializationObject: any): void;
  83098. }
  83099. /**
  83100. * Strong typing of a Mesh related stage step action
  83101. */
  83102. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83103. /**
  83104. * Strong typing of a Evaluate Sub Mesh related stage step action
  83105. */
  83106. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83107. /**
  83108. * Strong typing of a Active Mesh related stage step action
  83109. */
  83110. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83111. /**
  83112. * Strong typing of a Camera related stage step action
  83113. */
  83114. export type CameraStageAction = (camera: Camera) => void;
  83115. /**
  83116. * Strong typing of a Camera Frame buffer related stage step action
  83117. */
  83118. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83119. /**
  83120. * Strong typing of a Render Target related stage step action
  83121. */
  83122. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83123. /**
  83124. * Strong typing of a RenderingGroup related stage step action
  83125. */
  83126. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83127. /**
  83128. * Strong typing of a Mesh Render related stage step action
  83129. */
  83130. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83131. /**
  83132. * Strong typing of a simple stage step action
  83133. */
  83134. export type SimpleStageAction = () => void;
  83135. /**
  83136. * Strong typing of a render target action.
  83137. */
  83138. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83139. /**
  83140. * Strong typing of a pointer move action.
  83141. */
  83142. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83143. /**
  83144. * Strong typing of a pointer up/down action.
  83145. */
  83146. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83147. /**
  83148. * Representation of a stage in the scene (Basically a list of ordered steps)
  83149. * @hidden
  83150. */
  83151. export class Stage<T extends Function> extends Array<{
  83152. index: number;
  83153. component: ISceneComponent;
  83154. action: T;
  83155. }> {
  83156. /**
  83157. * Hide ctor from the rest of the world.
  83158. * @param items The items to add.
  83159. */
  83160. private constructor();
  83161. /**
  83162. * Creates a new Stage.
  83163. * @returns A new instance of a Stage
  83164. */
  83165. static Create<T extends Function>(): Stage<T>;
  83166. /**
  83167. * Registers a step in an ordered way in the targeted stage.
  83168. * @param index Defines the position to register the step in
  83169. * @param component Defines the component attached to the step
  83170. * @param action Defines the action to launch during the step
  83171. */
  83172. registerStep(index: number, component: ISceneComponent, action: T): void;
  83173. /**
  83174. * Clears all the steps from the stage.
  83175. */
  83176. clear(): void;
  83177. }
  83178. }
  83179. declare module BABYLON {
  83180. interface Scene {
  83181. /** @hidden */
  83182. _pointerOverSprite: Nullable<Sprite>;
  83183. /** @hidden */
  83184. _pickedDownSprite: Nullable<Sprite>;
  83185. /** @hidden */
  83186. _tempSpritePickingRay: Nullable<Ray>;
  83187. /**
  83188. * All of the sprite managers added to this scene
  83189. * @see http://doc.babylonjs.com/babylon101/sprites
  83190. */
  83191. spriteManagers: Array<ISpriteManager>;
  83192. /**
  83193. * An event triggered when sprites rendering is about to start
  83194. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83195. */
  83196. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83197. /**
  83198. * An event triggered when sprites rendering is done
  83199. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83200. */
  83201. onAfterSpritesRenderingObservable: Observable<Scene>;
  83202. /** @hidden */
  83203. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83204. /** Launch a ray to try to pick a sprite in the scene
  83205. * @param x position on screen
  83206. * @param y position on screen
  83207. * @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
  83208. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83209. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83210. * @returns a PickingInfo
  83211. */
  83212. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83213. /** Use the given ray to pick a sprite in the scene
  83214. * @param ray The ray (in world space) to use to pick meshes
  83215. * @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
  83216. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83217. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83218. * @returns a PickingInfo
  83219. */
  83220. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83221. /** @hidden */
  83222. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83223. /** Launch a ray to try to pick sprites in the scene
  83224. * @param x position on screen
  83225. * @param y position on screen
  83226. * @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
  83227. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83228. * @returns a PickingInfo array
  83229. */
  83230. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83231. /** Use the given ray to pick sprites in the scene
  83232. * @param ray The ray (in world space) to use to pick meshes
  83233. * @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
  83234. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83235. * @returns a PickingInfo array
  83236. */
  83237. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83238. /**
  83239. * Force the sprite under the pointer
  83240. * @param sprite defines the sprite to use
  83241. */
  83242. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83243. /**
  83244. * Gets the sprite under the pointer
  83245. * @returns a Sprite or null if no sprite is under the pointer
  83246. */
  83247. getPointerOverSprite(): Nullable<Sprite>;
  83248. }
  83249. /**
  83250. * Defines the sprite scene component responsible to manage sprites
  83251. * in a given scene.
  83252. */
  83253. export class SpriteSceneComponent implements ISceneComponent {
  83254. /**
  83255. * The component name helpfull to identify the component in the list of scene components.
  83256. */
  83257. readonly name: string;
  83258. /**
  83259. * The scene the component belongs to.
  83260. */
  83261. scene: Scene;
  83262. /** @hidden */
  83263. private _spritePredicate;
  83264. /**
  83265. * Creates a new instance of the component for the given scene
  83266. * @param scene Defines the scene to register the component in
  83267. */
  83268. constructor(scene: Scene);
  83269. /**
  83270. * Registers the component in a given scene
  83271. */
  83272. register(): void;
  83273. /**
  83274. * Rebuilds the elements related to this component in case of
  83275. * context lost for instance.
  83276. */
  83277. rebuild(): void;
  83278. /**
  83279. * Disposes the component and the associated ressources.
  83280. */
  83281. dispose(): void;
  83282. private _pickSpriteButKeepRay;
  83283. private _pointerMove;
  83284. private _pointerDown;
  83285. private _pointerUp;
  83286. }
  83287. }
  83288. declare module BABYLON {
  83289. /** @hidden */
  83290. export var fogFragmentDeclaration: {
  83291. name: string;
  83292. shader: string;
  83293. };
  83294. }
  83295. declare module BABYLON {
  83296. /** @hidden */
  83297. export var fogFragment: {
  83298. name: string;
  83299. shader: string;
  83300. };
  83301. }
  83302. declare module BABYLON {
  83303. /** @hidden */
  83304. export var spritesPixelShader: {
  83305. name: string;
  83306. shader: string;
  83307. };
  83308. }
  83309. declare module BABYLON {
  83310. /** @hidden */
  83311. export var fogVertexDeclaration: {
  83312. name: string;
  83313. shader: string;
  83314. };
  83315. }
  83316. declare module BABYLON {
  83317. /** @hidden */
  83318. export var spritesVertexShader: {
  83319. name: string;
  83320. shader: string;
  83321. };
  83322. }
  83323. declare module BABYLON {
  83324. /**
  83325. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83326. */
  83327. export interface ISpriteManager extends IDisposable {
  83328. /**
  83329. * Restricts the camera to viewing objects with the same layerMask.
  83330. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83331. */
  83332. layerMask: number;
  83333. /**
  83334. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83335. */
  83336. isPickable: boolean;
  83337. /**
  83338. * Specifies the rendering group id for this mesh (0 by default)
  83339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83340. */
  83341. renderingGroupId: number;
  83342. /**
  83343. * Defines the list of sprites managed by the manager.
  83344. */
  83345. sprites: Array<Sprite>;
  83346. /**
  83347. * Tests the intersection of a sprite with a specific ray.
  83348. * @param ray The ray we are sending to test the collision
  83349. * @param camera The camera space we are sending rays in
  83350. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83351. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83352. * @returns picking info or null.
  83353. */
  83354. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83355. /**
  83356. * Intersects the sprites with a ray
  83357. * @param ray defines the ray to intersect with
  83358. * @param camera defines the current active camera
  83359. * @param predicate defines a predicate used to select candidate sprites
  83360. * @returns null if no hit or a PickingInfo array
  83361. */
  83362. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83363. /**
  83364. * Renders the list of sprites on screen.
  83365. */
  83366. render(): void;
  83367. }
  83368. /**
  83369. * Class used to manage multiple sprites on the same spritesheet
  83370. * @see http://doc.babylonjs.com/babylon101/sprites
  83371. */
  83372. export class SpriteManager implements ISpriteManager {
  83373. /** defines the manager's name */
  83374. name: string;
  83375. /** Gets the list of sprites */
  83376. sprites: Sprite[];
  83377. /** Gets or sets the rendering group id (0 by default) */
  83378. renderingGroupId: number;
  83379. /** Gets or sets camera layer mask */
  83380. layerMask: number;
  83381. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83382. fogEnabled: boolean;
  83383. /** Gets or sets a boolean indicating if the sprites are pickable */
  83384. isPickable: boolean;
  83385. /** Defines the default width of a cell in the spritesheet */
  83386. cellWidth: number;
  83387. /** Defines the default height of a cell in the spritesheet */
  83388. cellHeight: number;
  83389. /** Associative array from JSON sprite data file */
  83390. private _cellData;
  83391. /** Array of sprite names from JSON sprite data file */
  83392. private _spriteMap;
  83393. /** True when packed cell data from JSON file is ready*/
  83394. private _packedAndReady;
  83395. /**
  83396. * An event triggered when the manager is disposed.
  83397. */
  83398. onDisposeObservable: Observable<SpriteManager>;
  83399. private _onDisposeObserver;
  83400. /**
  83401. * Callback called when the manager is disposed
  83402. */
  83403. set onDispose(callback: () => void);
  83404. private _capacity;
  83405. private _fromPacked;
  83406. private _spriteTexture;
  83407. private _epsilon;
  83408. private _scene;
  83409. private _vertexData;
  83410. private _buffer;
  83411. private _vertexBuffers;
  83412. private _indexBuffer;
  83413. private _effectBase;
  83414. private _effectFog;
  83415. /**
  83416. * Gets or sets the spritesheet texture
  83417. */
  83418. get texture(): Texture;
  83419. set texture(value: Texture);
  83420. private _blendMode;
  83421. /**
  83422. * Blend mode use to render the particle, it can be any of
  83423. * the static Constants.ALPHA_x properties provided in this class.
  83424. * Default value is Constants.ALPHA_COMBINE
  83425. */
  83426. get blendMode(): number;
  83427. set blendMode(blendMode: number);
  83428. /** Disables writing to the depth buffer when rendering the sprites.
  83429. * It can be handy to disable depth writing when using textures without alpha channel
  83430. * and setting some specific blend modes.
  83431. */
  83432. disableDepthWrite: boolean;
  83433. /**
  83434. * Creates a new sprite manager
  83435. * @param name defines the manager's name
  83436. * @param imgUrl defines the sprite sheet url
  83437. * @param capacity defines the maximum allowed number of sprites
  83438. * @param cellSize defines the size of a sprite cell
  83439. * @param scene defines the hosting scene
  83440. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83441. * @param samplingMode defines the smapling mode to use with spritesheet
  83442. * @param fromPacked set to false; do not alter
  83443. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83444. */
  83445. constructor(
  83446. /** defines the manager's name */
  83447. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83448. private _makePacked;
  83449. private _appendSpriteVertex;
  83450. /**
  83451. * Intersects the sprites with a ray
  83452. * @param ray defines the ray to intersect with
  83453. * @param camera defines the current active camera
  83454. * @param predicate defines a predicate used to select candidate sprites
  83455. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83456. * @returns null if no hit or a PickingInfo
  83457. */
  83458. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83459. /**
  83460. * Intersects the sprites with a ray
  83461. * @param ray defines the ray to intersect with
  83462. * @param camera defines the current active camera
  83463. * @param predicate defines a predicate used to select candidate sprites
  83464. * @returns null if no hit or a PickingInfo array
  83465. */
  83466. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83467. /**
  83468. * Render all child sprites
  83469. */
  83470. render(): void;
  83471. /**
  83472. * Release associated resources
  83473. */
  83474. dispose(): void;
  83475. }
  83476. }
  83477. declare module BABYLON {
  83478. /** Interface used by value gradients (color, factor, ...) */
  83479. export interface IValueGradient {
  83480. /**
  83481. * Gets or sets the gradient value (between 0 and 1)
  83482. */
  83483. gradient: number;
  83484. }
  83485. /** Class used to store color4 gradient */
  83486. export class ColorGradient implements IValueGradient {
  83487. /**
  83488. * Gets or sets the gradient value (between 0 and 1)
  83489. */
  83490. gradient: number;
  83491. /**
  83492. * Gets or sets first associated color
  83493. */
  83494. color1: Color4;
  83495. /**
  83496. * Gets or sets second associated color
  83497. */
  83498. color2?: Color4;
  83499. /**
  83500. * Will get a color picked randomly between color1 and color2.
  83501. * If color2 is undefined then color1 will be used
  83502. * @param result defines the target Color4 to store the result in
  83503. */
  83504. getColorToRef(result: Color4): void;
  83505. }
  83506. /** Class used to store color 3 gradient */
  83507. export class Color3Gradient implements IValueGradient {
  83508. /**
  83509. * Gets or sets the gradient value (between 0 and 1)
  83510. */
  83511. gradient: number;
  83512. /**
  83513. * Gets or sets the associated color
  83514. */
  83515. color: Color3;
  83516. }
  83517. /** Class used to store factor gradient */
  83518. export class FactorGradient implements IValueGradient {
  83519. /**
  83520. * Gets or sets the gradient value (between 0 and 1)
  83521. */
  83522. gradient: number;
  83523. /**
  83524. * Gets or sets first associated factor
  83525. */
  83526. factor1: number;
  83527. /**
  83528. * Gets or sets second associated factor
  83529. */
  83530. factor2?: number;
  83531. /**
  83532. * Will get a number picked randomly between factor1 and factor2.
  83533. * If factor2 is undefined then factor1 will be used
  83534. * @returns the picked number
  83535. */
  83536. getFactor(): number;
  83537. }
  83538. /**
  83539. * Helper used to simplify some generic gradient tasks
  83540. */
  83541. export class GradientHelper {
  83542. /**
  83543. * Gets the current gradient from an array of IValueGradient
  83544. * @param ratio defines the current ratio to get
  83545. * @param gradients defines the array of IValueGradient
  83546. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83547. */
  83548. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83549. }
  83550. }
  83551. declare module BABYLON {
  83552. /**
  83553. * Interface for the size containing width and height
  83554. */
  83555. export interface ISize {
  83556. /**
  83557. * Width
  83558. */
  83559. width: number;
  83560. /**
  83561. * Heighht
  83562. */
  83563. height: number;
  83564. }
  83565. /**
  83566. * Size containing widht and height
  83567. */
  83568. export class Size implements ISize {
  83569. /**
  83570. * Width
  83571. */
  83572. width: number;
  83573. /**
  83574. * Height
  83575. */
  83576. height: number;
  83577. /**
  83578. * Creates a Size object from the given width and height (floats).
  83579. * @param width width of the new size
  83580. * @param height height of the new size
  83581. */
  83582. constructor(width: number, height: number);
  83583. /**
  83584. * Returns a string with the Size width and height
  83585. * @returns a string with the Size width and height
  83586. */
  83587. toString(): string;
  83588. /**
  83589. * "Size"
  83590. * @returns the string "Size"
  83591. */
  83592. getClassName(): string;
  83593. /**
  83594. * Returns the Size hash code.
  83595. * @returns a hash code for a unique width and height
  83596. */
  83597. getHashCode(): number;
  83598. /**
  83599. * Updates the current size from the given one.
  83600. * @param src the given size
  83601. */
  83602. copyFrom(src: Size): void;
  83603. /**
  83604. * Updates in place the current Size from the given floats.
  83605. * @param width width of the new size
  83606. * @param height height of the new size
  83607. * @returns the updated Size.
  83608. */
  83609. copyFromFloats(width: number, height: number): Size;
  83610. /**
  83611. * Updates in place the current Size from the given floats.
  83612. * @param width width to set
  83613. * @param height height to set
  83614. * @returns the updated Size.
  83615. */
  83616. set(width: number, height: number): Size;
  83617. /**
  83618. * Multiplies the width and height by numbers
  83619. * @param w factor to multiple the width by
  83620. * @param h factor to multiple the height by
  83621. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83622. */
  83623. multiplyByFloats(w: number, h: number): Size;
  83624. /**
  83625. * Clones the size
  83626. * @returns a new Size copied from the given one.
  83627. */
  83628. clone(): Size;
  83629. /**
  83630. * True if the current Size and the given one width and height are strictly equal.
  83631. * @param other the other size to compare against
  83632. * @returns True if the current Size and the given one width and height are strictly equal.
  83633. */
  83634. equals(other: Size): boolean;
  83635. /**
  83636. * The surface of the Size : width * height (float).
  83637. */
  83638. get surface(): number;
  83639. /**
  83640. * Create a new size of zero
  83641. * @returns a new Size set to (0.0, 0.0)
  83642. */
  83643. static Zero(): Size;
  83644. /**
  83645. * Sums the width and height of two sizes
  83646. * @param otherSize size to add to this size
  83647. * @returns a new Size set as the addition result of the current Size and the given one.
  83648. */
  83649. add(otherSize: Size): Size;
  83650. /**
  83651. * Subtracts the width and height of two
  83652. * @param otherSize size to subtract to this size
  83653. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83654. */
  83655. subtract(otherSize: Size): Size;
  83656. /**
  83657. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83658. * @param start starting size to lerp between
  83659. * @param end end size to lerp between
  83660. * @param amount amount to lerp between the start and end values
  83661. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83662. */
  83663. static Lerp(start: Size, end: Size, amount: number): Size;
  83664. }
  83665. }
  83666. declare module BABYLON {
  83667. interface ThinEngine {
  83668. /**
  83669. * Creates a dynamic texture
  83670. * @param width defines the width of the texture
  83671. * @param height defines the height of the texture
  83672. * @param generateMipMaps defines if the engine should generate the mip levels
  83673. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83674. * @returns the dynamic texture inside an InternalTexture
  83675. */
  83676. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83677. /**
  83678. * Update the content of a dynamic texture
  83679. * @param texture defines the texture to update
  83680. * @param canvas defines the canvas containing the source
  83681. * @param invertY defines if data must be stored with Y axis inverted
  83682. * @param premulAlpha defines if alpha is stored as premultiplied
  83683. * @param format defines the format of the data
  83684. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83685. */
  83686. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83687. }
  83688. }
  83689. declare module BABYLON {
  83690. /**
  83691. * Helper class used to generate a canvas to manipulate images
  83692. */
  83693. export class CanvasGenerator {
  83694. /**
  83695. * Create a new canvas (or offscreen canvas depending on the context)
  83696. * @param width defines the expected width
  83697. * @param height defines the expected height
  83698. * @return a new canvas or offscreen canvas
  83699. */
  83700. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83701. }
  83702. }
  83703. declare module BABYLON {
  83704. /**
  83705. * A class extending Texture allowing drawing on a texture
  83706. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83707. */
  83708. export class DynamicTexture extends Texture {
  83709. private _generateMipMaps;
  83710. private _canvas;
  83711. private _context;
  83712. private _engine;
  83713. /**
  83714. * Creates a DynamicTexture
  83715. * @param name defines the name of the texture
  83716. * @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
  83717. * @param scene defines the scene where you want the texture
  83718. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83719. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83720. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83721. */
  83722. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83723. /**
  83724. * Get the current class name of the texture useful for serialization or dynamic coding.
  83725. * @returns "DynamicTexture"
  83726. */
  83727. getClassName(): string;
  83728. /**
  83729. * Gets the current state of canRescale
  83730. */
  83731. get canRescale(): boolean;
  83732. private _recreate;
  83733. /**
  83734. * Scales the texture
  83735. * @param ratio the scale factor to apply to both width and height
  83736. */
  83737. scale(ratio: number): void;
  83738. /**
  83739. * Resizes the texture
  83740. * @param width the new width
  83741. * @param height the new height
  83742. */
  83743. scaleTo(width: number, height: number): void;
  83744. /**
  83745. * Gets the context of the canvas used by the texture
  83746. * @returns the canvas context of the dynamic texture
  83747. */
  83748. getContext(): CanvasRenderingContext2D;
  83749. /**
  83750. * Clears the texture
  83751. */
  83752. clear(): void;
  83753. /**
  83754. * Updates the texture
  83755. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83756. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83757. */
  83758. update(invertY?: boolean, premulAlpha?: boolean): void;
  83759. /**
  83760. * Draws text onto the texture
  83761. * @param text defines the text to be drawn
  83762. * @param x defines the placement of the text from the left
  83763. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83764. * @param font defines the font to be used with font-style, font-size, font-name
  83765. * @param color defines the color used for the text
  83766. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83767. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83768. * @param update defines whether texture is immediately update (default is true)
  83769. */
  83770. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83771. /**
  83772. * Clones the texture
  83773. * @returns the clone of the texture.
  83774. */
  83775. clone(): DynamicTexture;
  83776. /**
  83777. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83778. * @returns a serialized dynamic texture object
  83779. */
  83780. serialize(): any;
  83781. /** @hidden */
  83782. _rebuild(): void;
  83783. }
  83784. }
  83785. declare module BABYLON {
  83786. interface Engine {
  83787. /**
  83788. * Creates a raw texture
  83789. * @param data defines the data to store in the texture
  83790. * @param width defines the width of the texture
  83791. * @param height defines the height of the texture
  83792. * @param format defines the format of the data
  83793. * @param generateMipMaps defines if the engine should generate the mip levels
  83794. * @param invertY defines if data must be stored with Y axis inverted
  83795. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83796. * @param compression defines the compression used (null by default)
  83797. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83798. * @returns the raw texture inside an InternalTexture
  83799. */
  83800. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83801. /**
  83802. * Update a raw texture
  83803. * @param texture defines the texture to update
  83804. * @param data defines the data to store in the texture
  83805. * @param format defines the format of the data
  83806. * @param invertY defines if data must be stored with Y axis inverted
  83807. */
  83808. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83809. /**
  83810. * Update a raw texture
  83811. * @param texture defines the texture to update
  83812. * @param data defines the data to store in the texture
  83813. * @param format defines the format of the data
  83814. * @param invertY defines if data must be stored with Y axis inverted
  83815. * @param compression defines the compression used (null by default)
  83816. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83817. */
  83818. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83819. /**
  83820. * Creates a new raw cube texture
  83821. * @param data defines the array of data to use to create each face
  83822. * @param size defines the size of the textures
  83823. * @param format defines the format of the data
  83824. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83825. * @param generateMipMaps defines if the engine should generate the mip levels
  83826. * @param invertY defines if data must be stored with Y axis inverted
  83827. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83828. * @param compression defines the compression used (null by default)
  83829. * @returns the cube texture as an InternalTexture
  83830. */
  83831. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83832. /**
  83833. * Update a raw cube texture
  83834. * @param texture defines the texture to udpdate
  83835. * @param data defines the data to store
  83836. * @param format defines the data format
  83837. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83838. * @param invertY defines if data must be stored with Y axis inverted
  83839. */
  83840. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83841. /**
  83842. * Update a raw cube texture
  83843. * @param texture defines the texture to udpdate
  83844. * @param data defines the data to store
  83845. * @param format defines the data format
  83846. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83847. * @param invertY defines if data must be stored with Y axis inverted
  83848. * @param compression defines the compression used (null by default)
  83849. */
  83850. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83851. /**
  83852. * Update a raw cube texture
  83853. * @param texture defines the texture to udpdate
  83854. * @param data defines the data to store
  83855. * @param format defines the data format
  83856. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83857. * @param invertY defines if data must be stored with Y axis inverted
  83858. * @param compression defines the compression used (null by default)
  83859. * @param level defines which level of the texture to update
  83860. */
  83861. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83862. /**
  83863. * Creates a new raw cube texture from a specified url
  83864. * @param url defines the url where the data is located
  83865. * @param scene defines the current scene
  83866. * @param size defines the size of the textures
  83867. * @param format defines the format of the data
  83868. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83869. * @param noMipmap defines if the engine should avoid generating the mip levels
  83870. * @param callback defines a callback used to extract texture data from loaded data
  83871. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83872. * @param onLoad defines a callback called when texture is loaded
  83873. * @param onError defines a callback called if there is an error
  83874. * @returns the cube texture as an InternalTexture
  83875. */
  83876. 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;
  83877. /**
  83878. * Creates a new raw cube texture from a specified url
  83879. * @param url defines the url where the data is located
  83880. * @param scene defines the current scene
  83881. * @param size defines the size of the textures
  83882. * @param format defines the format of the data
  83883. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83884. * @param noMipmap defines if the engine should avoid generating the mip levels
  83885. * @param callback defines a callback used to extract texture data from loaded data
  83886. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83887. * @param onLoad defines a callback called when texture is loaded
  83888. * @param onError defines a callback called if there is an error
  83889. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83890. * @param invertY defines if data must be stored with Y axis inverted
  83891. * @returns the cube texture as an InternalTexture
  83892. */
  83893. 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;
  83894. /**
  83895. * Creates a new raw 3D texture
  83896. * @param data defines the data used to create the texture
  83897. * @param width defines the width of the texture
  83898. * @param height defines the height of the texture
  83899. * @param depth defines the depth of the texture
  83900. * @param format defines the format of the texture
  83901. * @param generateMipMaps defines if the engine must generate mip levels
  83902. * @param invertY defines if data must be stored with Y axis inverted
  83903. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83904. * @param compression defines the compressed used (can be null)
  83905. * @param textureType defines the compressed used (can be null)
  83906. * @returns a new raw 3D texture (stored in an InternalTexture)
  83907. */
  83908. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83909. /**
  83910. * Update a raw 3D texture
  83911. * @param texture defines the texture to update
  83912. * @param data defines the data to store
  83913. * @param format defines the data format
  83914. * @param invertY defines if data must be stored with Y axis inverted
  83915. */
  83916. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83917. /**
  83918. * Update a raw 3D texture
  83919. * @param texture defines the texture to update
  83920. * @param data defines the data to store
  83921. * @param format defines the data format
  83922. * @param invertY defines if data must be stored with Y axis inverted
  83923. * @param compression defines the used compression (can be null)
  83924. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83925. */
  83926. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83927. /**
  83928. * Creates a new raw 2D array texture
  83929. * @param data defines the data used to create the texture
  83930. * @param width defines the width of the texture
  83931. * @param height defines the height of the texture
  83932. * @param depth defines the number of layers of the texture
  83933. * @param format defines the format of the texture
  83934. * @param generateMipMaps defines if the engine must generate mip levels
  83935. * @param invertY defines if data must be stored with Y axis inverted
  83936. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83937. * @param compression defines the compressed used (can be null)
  83938. * @param textureType defines the compressed used (can be null)
  83939. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83940. */
  83941. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83942. /**
  83943. * Update a raw 2D array texture
  83944. * @param texture defines the texture to update
  83945. * @param data defines the data to store
  83946. * @param format defines the data format
  83947. * @param invertY defines if data must be stored with Y axis inverted
  83948. */
  83949. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83950. /**
  83951. * Update a raw 2D array texture
  83952. * @param texture defines the texture to update
  83953. * @param data defines the data to store
  83954. * @param format defines the data format
  83955. * @param invertY defines if data must be stored with Y axis inverted
  83956. * @param compression defines the used compression (can be null)
  83957. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83958. */
  83959. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83960. }
  83961. }
  83962. declare module BABYLON {
  83963. /**
  83964. * Raw texture can help creating a texture directly from an array of data.
  83965. * This can be super useful if you either get the data from an uncompressed source or
  83966. * if you wish to create your texture pixel by pixel.
  83967. */
  83968. export class RawTexture extends Texture {
  83969. /**
  83970. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83971. */
  83972. format: number;
  83973. private _engine;
  83974. /**
  83975. * Instantiates a new RawTexture.
  83976. * Raw texture can help creating a texture directly from an array of data.
  83977. * This can be super useful if you either get the data from an uncompressed source or
  83978. * if you wish to create your texture pixel by pixel.
  83979. * @param data define the array of data to use to create the texture
  83980. * @param width define the width of the texture
  83981. * @param height define the height of the texture
  83982. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83983. * @param scene define the scene the texture belongs to
  83984. * @param generateMipMaps define whether mip maps should be generated or not
  83985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83988. */
  83989. constructor(data: ArrayBufferView, width: number, height: number,
  83990. /**
  83991. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83992. */
  83993. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83994. /**
  83995. * Updates the texture underlying data.
  83996. * @param data Define the new data of the texture
  83997. */
  83998. update(data: ArrayBufferView): void;
  83999. /**
  84000. * Creates a luminance texture from some data.
  84001. * @param data Define the texture data
  84002. * @param width Define the width of the texture
  84003. * @param height Define the height of the texture
  84004. * @param scene Define the scene the texture belongs to
  84005. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84006. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84007. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84008. * @returns the luminance texture
  84009. */
  84010. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84011. /**
  84012. * Creates a luminance alpha texture from some data.
  84013. * @param data Define the texture data
  84014. * @param width Define the width of the texture
  84015. * @param height Define the height of the texture
  84016. * @param scene Define the scene the texture belongs to
  84017. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84018. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84019. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84020. * @returns the luminance alpha texture
  84021. */
  84022. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84023. /**
  84024. * Creates an alpha texture from some data.
  84025. * @param data Define the texture data
  84026. * @param width Define the width of the texture
  84027. * @param height Define the height of the texture
  84028. * @param scene Define the scene the texture belongs to
  84029. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84030. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84031. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84032. * @returns the alpha texture
  84033. */
  84034. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84035. /**
  84036. * Creates a RGB texture from some data.
  84037. * @param data Define the texture data
  84038. * @param width Define the width of the texture
  84039. * @param height Define the height of the texture
  84040. * @param scene Define the scene the texture belongs to
  84041. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84042. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84043. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84044. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84045. * @returns the RGB alpha texture
  84046. */
  84047. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84048. /**
  84049. * Creates a RGBA texture from some data.
  84050. * @param data Define the texture data
  84051. * @param width Define the width of the texture
  84052. * @param height Define the height of the texture
  84053. * @param scene Define the scene the texture belongs to
  84054. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84055. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84056. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84057. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84058. * @returns the RGBA texture
  84059. */
  84060. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84061. /**
  84062. * Creates a R texture from some data.
  84063. * @param data Define the texture data
  84064. * @param width Define the width of the texture
  84065. * @param height Define the height of the texture
  84066. * @param scene Define the scene the texture belongs to
  84067. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84068. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84069. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84070. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84071. * @returns the R texture
  84072. */
  84073. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84074. }
  84075. }
  84076. declare module BABYLON {
  84077. interface AbstractScene {
  84078. /**
  84079. * The list of procedural textures added to the scene
  84080. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84081. */
  84082. proceduralTextures: Array<ProceduralTexture>;
  84083. }
  84084. /**
  84085. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84086. * in a given scene.
  84087. */
  84088. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84089. /**
  84090. * The component name helpfull to identify the component in the list of scene components.
  84091. */
  84092. readonly name: string;
  84093. /**
  84094. * The scene the component belongs to.
  84095. */
  84096. scene: Scene;
  84097. /**
  84098. * Creates a new instance of the component for the given scene
  84099. * @param scene Defines the scene to register the component in
  84100. */
  84101. constructor(scene: Scene);
  84102. /**
  84103. * Registers the component in a given scene
  84104. */
  84105. register(): void;
  84106. /**
  84107. * Rebuilds the elements related to this component in case of
  84108. * context lost for instance.
  84109. */
  84110. rebuild(): void;
  84111. /**
  84112. * Disposes the component and the associated ressources.
  84113. */
  84114. dispose(): void;
  84115. private _beforeClear;
  84116. }
  84117. }
  84118. declare module BABYLON {
  84119. interface ThinEngine {
  84120. /**
  84121. * Creates a new render target cube texture
  84122. * @param size defines the size of the texture
  84123. * @param options defines the options used to create the texture
  84124. * @returns a new render target cube texture stored in an InternalTexture
  84125. */
  84126. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84127. }
  84128. }
  84129. declare module BABYLON {
  84130. /** @hidden */
  84131. export var proceduralVertexShader: {
  84132. name: string;
  84133. shader: string;
  84134. };
  84135. }
  84136. declare module BABYLON {
  84137. /**
  84138. * 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.
  84139. * This is the base class of any Procedural texture and contains most of the shareable code.
  84140. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84141. */
  84142. export class ProceduralTexture extends Texture {
  84143. isCube: boolean;
  84144. /**
  84145. * Define if the texture is enabled or not (disabled texture will not render)
  84146. */
  84147. isEnabled: boolean;
  84148. /**
  84149. * Define if the texture must be cleared before rendering (default is true)
  84150. */
  84151. autoClear: boolean;
  84152. /**
  84153. * Callback called when the texture is generated
  84154. */
  84155. onGenerated: () => void;
  84156. /**
  84157. * Event raised when the texture is generated
  84158. */
  84159. onGeneratedObservable: Observable<ProceduralTexture>;
  84160. /** @hidden */
  84161. _generateMipMaps: boolean;
  84162. /** @hidden **/
  84163. _effect: Effect;
  84164. /** @hidden */
  84165. _textures: {
  84166. [key: string]: Texture;
  84167. };
  84168. private _size;
  84169. private _currentRefreshId;
  84170. private _frameId;
  84171. private _refreshRate;
  84172. private _vertexBuffers;
  84173. private _indexBuffer;
  84174. private _uniforms;
  84175. private _samplers;
  84176. private _fragment;
  84177. private _floats;
  84178. private _ints;
  84179. private _floatsArrays;
  84180. private _colors3;
  84181. private _colors4;
  84182. private _vectors2;
  84183. private _vectors3;
  84184. private _matrices;
  84185. private _fallbackTexture;
  84186. private _fallbackTextureUsed;
  84187. private _engine;
  84188. private _cachedDefines;
  84189. private _contentUpdateId;
  84190. private _contentData;
  84191. /**
  84192. * Instantiates a new procedural texture.
  84193. * 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.
  84194. * This is the base class of any Procedural texture and contains most of the shareable code.
  84195. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84196. * @param name Define the name of the texture
  84197. * @param size Define the size of the texture to create
  84198. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84199. * @param scene Define the scene the texture belongs to
  84200. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84201. * @param generateMipMaps Define if the texture should creates mip maps or not
  84202. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84203. */
  84204. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84205. /**
  84206. * The effect that is created when initializing the post process.
  84207. * @returns The created effect corresponding the the postprocess.
  84208. */
  84209. getEffect(): Effect;
  84210. /**
  84211. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84212. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84213. */
  84214. getContent(): Nullable<ArrayBufferView>;
  84215. private _createIndexBuffer;
  84216. /** @hidden */
  84217. _rebuild(): void;
  84218. /**
  84219. * Resets the texture in order to recreate its associated resources.
  84220. * This can be called in case of context loss
  84221. */
  84222. reset(): void;
  84223. protected _getDefines(): string;
  84224. /**
  84225. * Is the texture ready to be used ? (rendered at least once)
  84226. * @returns true if ready, otherwise, false.
  84227. */
  84228. isReady(): boolean;
  84229. /**
  84230. * Resets the refresh counter of the texture and start bak from scratch.
  84231. * Could be useful to regenerate the texture if it is setup to render only once.
  84232. */
  84233. resetRefreshCounter(): void;
  84234. /**
  84235. * Set the fragment shader to use in order to render the texture.
  84236. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84237. */
  84238. setFragment(fragment: any): void;
  84239. /**
  84240. * Define the refresh rate of the texture or the rendering frequency.
  84241. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84242. */
  84243. get refreshRate(): number;
  84244. set refreshRate(value: number);
  84245. /** @hidden */
  84246. _shouldRender(): boolean;
  84247. /**
  84248. * Get the size the texture is rendering at.
  84249. * @returns the size (texture is always squared)
  84250. */
  84251. getRenderSize(): number;
  84252. /**
  84253. * Resize the texture to new value.
  84254. * @param size Define the new size the texture should have
  84255. * @param generateMipMaps Define whether the new texture should create mip maps
  84256. */
  84257. resize(size: number, generateMipMaps: boolean): void;
  84258. private _checkUniform;
  84259. /**
  84260. * Set a texture in the shader program used to render.
  84261. * @param name Define the name of the uniform samplers as defined in the shader
  84262. * @param texture Define the texture to bind to this sampler
  84263. * @return the texture itself allowing "fluent" like uniform updates
  84264. */
  84265. setTexture(name: string, texture: Texture): ProceduralTexture;
  84266. /**
  84267. * Set a float in the shader.
  84268. * @param name Define the name of the uniform as defined in the shader
  84269. * @param value Define the value to give to the uniform
  84270. * @return the texture itself allowing "fluent" like uniform updates
  84271. */
  84272. setFloat(name: string, value: number): ProceduralTexture;
  84273. /**
  84274. * Set a int in the shader.
  84275. * @param name Define the name of the uniform as defined in the shader
  84276. * @param value Define the value to give to the uniform
  84277. * @return the texture itself allowing "fluent" like uniform updates
  84278. */
  84279. setInt(name: string, value: number): ProceduralTexture;
  84280. /**
  84281. * Set an array of floats in the shader.
  84282. * @param name Define the name of the uniform as defined in the shader
  84283. * @param value Define the value to give to the uniform
  84284. * @return the texture itself allowing "fluent" like uniform updates
  84285. */
  84286. setFloats(name: string, value: number[]): ProceduralTexture;
  84287. /**
  84288. * Set a vec3 in the shader from a Color3.
  84289. * @param name Define the name of the uniform as defined in the shader
  84290. * @param value Define the value to give to the uniform
  84291. * @return the texture itself allowing "fluent" like uniform updates
  84292. */
  84293. setColor3(name: string, value: Color3): ProceduralTexture;
  84294. /**
  84295. * Set a vec4 in the shader from a Color4.
  84296. * @param name Define the name of the uniform as defined in the shader
  84297. * @param value Define the value to give to the uniform
  84298. * @return the texture itself allowing "fluent" like uniform updates
  84299. */
  84300. setColor4(name: string, value: Color4): ProceduralTexture;
  84301. /**
  84302. * Set a vec2 in the shader from a Vector2.
  84303. * @param name Define the name of the uniform as defined in the shader
  84304. * @param value Define the value to give to the uniform
  84305. * @return the texture itself allowing "fluent" like uniform updates
  84306. */
  84307. setVector2(name: string, value: Vector2): ProceduralTexture;
  84308. /**
  84309. * Set a vec3 in the shader from a Vector3.
  84310. * @param name Define the name of the uniform as defined in the shader
  84311. * @param value Define the value to give to the uniform
  84312. * @return the texture itself allowing "fluent" like uniform updates
  84313. */
  84314. setVector3(name: string, value: Vector3): ProceduralTexture;
  84315. /**
  84316. * Set a mat4 in the shader from a MAtrix.
  84317. * @param name Define the name of the uniform as defined in the shader
  84318. * @param value Define the value to give to the uniform
  84319. * @return the texture itself allowing "fluent" like uniform updates
  84320. */
  84321. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84322. /**
  84323. * Render the texture to its associated render target.
  84324. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84325. */
  84326. render(useCameraPostProcess?: boolean): void;
  84327. /**
  84328. * Clone the texture.
  84329. * @returns the cloned texture
  84330. */
  84331. clone(): ProceduralTexture;
  84332. /**
  84333. * Dispose the texture and release its asoociated resources.
  84334. */
  84335. dispose(): void;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /**
  84340. * This represents the base class for particle system in Babylon.
  84341. * 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.
  84342. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84343. * @example https://doc.babylonjs.com/babylon101/particles
  84344. */
  84345. export class BaseParticleSystem {
  84346. /**
  84347. * Source color is added to the destination color without alpha affecting the result
  84348. */
  84349. static BLENDMODE_ONEONE: number;
  84350. /**
  84351. * Blend current color and particle color using particle’s alpha
  84352. */
  84353. static BLENDMODE_STANDARD: number;
  84354. /**
  84355. * Add current color and particle color multiplied by particle’s alpha
  84356. */
  84357. static BLENDMODE_ADD: number;
  84358. /**
  84359. * Multiply current color with particle color
  84360. */
  84361. static BLENDMODE_MULTIPLY: number;
  84362. /**
  84363. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84364. */
  84365. static BLENDMODE_MULTIPLYADD: number;
  84366. /**
  84367. * List of animations used by the particle system.
  84368. */
  84369. animations: Animation[];
  84370. /**
  84371. * The id of the Particle system.
  84372. */
  84373. id: string;
  84374. /**
  84375. * The friendly name of the Particle system.
  84376. */
  84377. name: string;
  84378. /**
  84379. * The rendering group used by the Particle system to chose when to render.
  84380. */
  84381. renderingGroupId: number;
  84382. /**
  84383. * The emitter represents the Mesh or position we are attaching the particle system to.
  84384. */
  84385. emitter: Nullable<AbstractMesh | Vector3>;
  84386. /**
  84387. * The maximum number of particles to emit per frame
  84388. */
  84389. emitRate: number;
  84390. /**
  84391. * If you want to launch only a few particles at once, that can be done, as well.
  84392. */
  84393. manualEmitCount: number;
  84394. /**
  84395. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84396. */
  84397. updateSpeed: number;
  84398. /**
  84399. * The amount of time the particle system is running (depends of the overall update speed).
  84400. */
  84401. targetStopDuration: number;
  84402. /**
  84403. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84404. */
  84405. disposeOnStop: boolean;
  84406. /**
  84407. * Minimum power of emitting particles.
  84408. */
  84409. minEmitPower: number;
  84410. /**
  84411. * Maximum power of emitting particles.
  84412. */
  84413. maxEmitPower: number;
  84414. /**
  84415. * Minimum life time of emitting particles.
  84416. */
  84417. minLifeTime: number;
  84418. /**
  84419. * Maximum life time of emitting particles.
  84420. */
  84421. maxLifeTime: number;
  84422. /**
  84423. * Minimum Size of emitting particles.
  84424. */
  84425. minSize: number;
  84426. /**
  84427. * Maximum Size of emitting particles.
  84428. */
  84429. maxSize: number;
  84430. /**
  84431. * Minimum scale of emitting particles on X axis.
  84432. */
  84433. minScaleX: number;
  84434. /**
  84435. * Maximum scale of emitting particles on X axis.
  84436. */
  84437. maxScaleX: number;
  84438. /**
  84439. * Minimum scale of emitting particles on Y axis.
  84440. */
  84441. minScaleY: number;
  84442. /**
  84443. * Maximum scale of emitting particles on Y axis.
  84444. */
  84445. maxScaleY: number;
  84446. /**
  84447. * Gets or sets the minimal initial rotation in radians.
  84448. */
  84449. minInitialRotation: number;
  84450. /**
  84451. * Gets or sets the maximal initial rotation in radians.
  84452. */
  84453. maxInitialRotation: number;
  84454. /**
  84455. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84456. */
  84457. minAngularSpeed: number;
  84458. /**
  84459. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84460. */
  84461. maxAngularSpeed: number;
  84462. /**
  84463. * The texture used to render each particle. (this can be a spritesheet)
  84464. */
  84465. particleTexture: Nullable<Texture>;
  84466. /**
  84467. * The layer mask we are rendering the particles through.
  84468. */
  84469. layerMask: number;
  84470. /**
  84471. * This can help using your own shader to render the particle system.
  84472. * The according effect will be created
  84473. */
  84474. customShader: any;
  84475. /**
  84476. * By default particle system starts as soon as they are created. This prevents the
  84477. * automatic start to happen and let you decide when to start emitting particles.
  84478. */
  84479. preventAutoStart: boolean;
  84480. private _noiseTexture;
  84481. /**
  84482. * Gets or sets a texture used to add random noise to particle positions
  84483. */
  84484. get noiseTexture(): Nullable<ProceduralTexture>;
  84485. set noiseTexture(value: Nullable<ProceduralTexture>);
  84486. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84487. noiseStrength: Vector3;
  84488. /**
  84489. * Callback triggered when the particle animation is ending.
  84490. */
  84491. onAnimationEnd: Nullable<() => void>;
  84492. /**
  84493. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84494. */
  84495. blendMode: number;
  84496. /**
  84497. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84498. * to override the particles.
  84499. */
  84500. forceDepthWrite: boolean;
  84501. /** 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 */
  84502. preWarmCycles: number;
  84503. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84504. preWarmStepOffset: number;
  84505. /**
  84506. * 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)
  84507. */
  84508. spriteCellChangeSpeed: number;
  84509. /**
  84510. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84511. */
  84512. startSpriteCellID: number;
  84513. /**
  84514. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84515. */
  84516. endSpriteCellID: number;
  84517. /**
  84518. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84519. */
  84520. spriteCellWidth: number;
  84521. /**
  84522. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84523. */
  84524. spriteCellHeight: number;
  84525. /**
  84526. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84527. */
  84528. spriteRandomStartCell: boolean;
  84529. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84530. translationPivot: Vector2;
  84531. /** @hidden */
  84532. protected _isAnimationSheetEnabled: boolean;
  84533. /**
  84534. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84535. */
  84536. beginAnimationOnStart: boolean;
  84537. /**
  84538. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84539. */
  84540. beginAnimationFrom: number;
  84541. /**
  84542. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84543. */
  84544. beginAnimationTo: number;
  84545. /**
  84546. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84547. */
  84548. beginAnimationLoop: boolean;
  84549. /**
  84550. * Gets or sets a world offset applied to all particles
  84551. */
  84552. worldOffset: Vector3;
  84553. /**
  84554. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84555. */
  84556. get isAnimationSheetEnabled(): boolean;
  84557. set isAnimationSheetEnabled(value: boolean);
  84558. /**
  84559. * Get hosting scene
  84560. * @returns the scene
  84561. */
  84562. getScene(): Scene;
  84563. /**
  84564. * You can use gravity if you want to give an orientation to your particles.
  84565. */
  84566. gravity: Vector3;
  84567. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84568. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84569. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84570. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84571. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84572. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84573. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84574. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84575. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84576. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84577. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84578. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84579. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84580. /**
  84581. * Defines the delay in milliseconds before starting the system (0 by default)
  84582. */
  84583. startDelay: number;
  84584. /**
  84585. * Gets the current list of drag gradients.
  84586. * You must use addDragGradient and removeDragGradient to udpate this list
  84587. * @returns the list of drag gradients
  84588. */
  84589. getDragGradients(): Nullable<Array<FactorGradient>>;
  84590. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84591. limitVelocityDamping: number;
  84592. /**
  84593. * Gets the current list of limit velocity gradients.
  84594. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84595. * @returns the list of limit velocity gradients
  84596. */
  84597. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84598. /**
  84599. * Gets the current list of color gradients.
  84600. * You must use addColorGradient and removeColorGradient to udpate this list
  84601. * @returns the list of color gradients
  84602. */
  84603. getColorGradients(): Nullable<Array<ColorGradient>>;
  84604. /**
  84605. * Gets the current list of size gradients.
  84606. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84607. * @returns the list of size gradients
  84608. */
  84609. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84610. /**
  84611. * Gets the current list of color remap gradients.
  84612. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84613. * @returns the list of color remap gradients
  84614. */
  84615. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84616. /**
  84617. * Gets the current list of alpha remap gradients.
  84618. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84619. * @returns the list of alpha remap gradients
  84620. */
  84621. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84622. /**
  84623. * Gets the current list of life time gradients.
  84624. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84625. * @returns the list of life time gradients
  84626. */
  84627. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84628. /**
  84629. * Gets the current list of angular speed gradients.
  84630. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84631. * @returns the list of angular speed gradients
  84632. */
  84633. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84634. /**
  84635. * Gets the current list of velocity gradients.
  84636. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84637. * @returns the list of velocity gradients
  84638. */
  84639. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84640. /**
  84641. * Gets the current list of start size gradients.
  84642. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84643. * @returns the list of start size gradients
  84644. */
  84645. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84646. /**
  84647. * Gets the current list of emit rate gradients.
  84648. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84649. * @returns the list of emit rate gradients
  84650. */
  84651. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84652. /**
  84653. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84654. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84655. */
  84656. get direction1(): Vector3;
  84657. set direction1(value: Vector3);
  84658. /**
  84659. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84660. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84661. */
  84662. get direction2(): Vector3;
  84663. set direction2(value: Vector3);
  84664. /**
  84665. * 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.
  84666. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84667. */
  84668. get minEmitBox(): Vector3;
  84669. set minEmitBox(value: Vector3);
  84670. /**
  84671. * 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.
  84672. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84673. */
  84674. get maxEmitBox(): Vector3;
  84675. set maxEmitBox(value: Vector3);
  84676. /**
  84677. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84678. */
  84679. color1: Color4;
  84680. /**
  84681. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84682. */
  84683. color2: Color4;
  84684. /**
  84685. * Color the particle will have at the end of its lifetime
  84686. */
  84687. colorDead: Color4;
  84688. /**
  84689. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84690. */
  84691. textureMask: Color4;
  84692. /**
  84693. * The particle emitter type defines the emitter used by the particle system.
  84694. * It can be for example box, sphere, or cone...
  84695. */
  84696. particleEmitterType: IParticleEmitterType;
  84697. /** @hidden */
  84698. _isSubEmitter: boolean;
  84699. /**
  84700. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84701. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84702. */
  84703. billboardMode: number;
  84704. protected _isBillboardBased: boolean;
  84705. /**
  84706. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84707. */
  84708. get isBillboardBased(): boolean;
  84709. set isBillboardBased(value: boolean);
  84710. /**
  84711. * The scene the particle system belongs to.
  84712. */
  84713. protected _scene: Scene;
  84714. /**
  84715. * Local cache of defines for image processing.
  84716. */
  84717. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84718. /**
  84719. * Default configuration related to image processing available in the standard Material.
  84720. */
  84721. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84722. /**
  84723. * Gets the image processing configuration used either in this material.
  84724. */
  84725. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84726. /**
  84727. * Sets the Default image processing configuration used either in the this material.
  84728. *
  84729. * If sets to null, the scene one is in use.
  84730. */
  84731. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84732. /**
  84733. * Attaches a new image processing configuration to the Standard Material.
  84734. * @param configuration
  84735. */
  84736. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84737. /** @hidden */
  84738. protected _reset(): void;
  84739. /** @hidden */
  84740. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84741. /**
  84742. * Instantiates a particle system.
  84743. * 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.
  84744. * @param name The name of the particle system
  84745. */
  84746. constructor(name: string);
  84747. /**
  84748. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84749. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84750. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84751. * @returns the emitter
  84752. */
  84753. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84754. /**
  84755. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84756. * @param radius The radius of the hemisphere to emit from
  84757. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84758. * @returns the emitter
  84759. */
  84760. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84761. /**
  84762. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84763. * @param radius The radius of the sphere to emit from
  84764. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84765. * @returns the emitter
  84766. */
  84767. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84768. /**
  84769. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84770. * @param radius The radius of the sphere to emit from
  84771. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84772. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84773. * @returns the emitter
  84774. */
  84775. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84776. /**
  84777. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84778. * @param radius The radius of the emission cylinder
  84779. * @param height The height of the emission cylinder
  84780. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84781. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84782. * @returns the emitter
  84783. */
  84784. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84785. /**
  84786. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84787. * @param radius The radius of the cylinder to emit from
  84788. * @param height The height of the emission cylinder
  84789. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84790. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84791. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84792. * @returns the emitter
  84793. */
  84794. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84795. /**
  84796. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84797. * @param radius The radius of the cone to emit from
  84798. * @param angle The base angle of the cone
  84799. * @returns the emitter
  84800. */
  84801. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84802. /**
  84803. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84804. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84805. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84806. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84807. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84808. * @returns the emitter
  84809. */
  84810. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84811. }
  84812. }
  84813. declare module BABYLON {
  84814. /**
  84815. * Type of sub emitter
  84816. */
  84817. export enum SubEmitterType {
  84818. /**
  84819. * Attached to the particle over it's lifetime
  84820. */
  84821. ATTACHED = 0,
  84822. /**
  84823. * Created when the particle dies
  84824. */
  84825. END = 1
  84826. }
  84827. /**
  84828. * Sub emitter class used to emit particles from an existing particle
  84829. */
  84830. export class SubEmitter {
  84831. /**
  84832. * the particle system to be used by the sub emitter
  84833. */
  84834. particleSystem: ParticleSystem;
  84835. /**
  84836. * Type of the submitter (Default: END)
  84837. */
  84838. type: SubEmitterType;
  84839. /**
  84840. * 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)
  84841. * Note: This only is supported when using an emitter of type Mesh
  84842. */
  84843. inheritDirection: boolean;
  84844. /**
  84845. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84846. */
  84847. inheritedVelocityAmount: number;
  84848. /**
  84849. * Creates a sub emitter
  84850. * @param particleSystem the particle system to be used by the sub emitter
  84851. */
  84852. constructor(
  84853. /**
  84854. * the particle system to be used by the sub emitter
  84855. */
  84856. particleSystem: ParticleSystem);
  84857. /**
  84858. * Clones the sub emitter
  84859. * @returns the cloned sub emitter
  84860. */
  84861. clone(): SubEmitter;
  84862. /**
  84863. * Serialize current object to a JSON object
  84864. * @returns the serialized object
  84865. */
  84866. serialize(): any;
  84867. /** @hidden */
  84868. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84869. /**
  84870. * Creates a new SubEmitter from a serialized JSON version
  84871. * @param serializationObject defines the JSON object to read from
  84872. * @param scene defines the hosting scene
  84873. * @param rootUrl defines the rootUrl for data loading
  84874. * @returns a new SubEmitter
  84875. */
  84876. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84877. /** Release associated resources */
  84878. dispose(): void;
  84879. }
  84880. }
  84881. declare module BABYLON {
  84882. /** @hidden */
  84883. export var imageProcessingDeclaration: {
  84884. name: string;
  84885. shader: string;
  84886. };
  84887. }
  84888. declare module BABYLON {
  84889. /** @hidden */
  84890. export var imageProcessingFunctions: {
  84891. name: string;
  84892. shader: string;
  84893. };
  84894. }
  84895. declare module BABYLON {
  84896. /** @hidden */
  84897. export var particlesPixelShader: {
  84898. name: string;
  84899. shader: string;
  84900. };
  84901. }
  84902. declare module BABYLON {
  84903. /** @hidden */
  84904. export var particlesVertexShader: {
  84905. name: string;
  84906. shader: string;
  84907. };
  84908. }
  84909. declare module BABYLON {
  84910. /**
  84911. * This represents a particle system in Babylon.
  84912. * 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.
  84913. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84914. * @example https://doc.babylonjs.com/babylon101/particles
  84915. */
  84916. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84917. /**
  84918. * Billboard mode will only apply to Y axis
  84919. */
  84920. static readonly BILLBOARDMODE_Y: number;
  84921. /**
  84922. * Billboard mode will apply to all axes
  84923. */
  84924. static readonly BILLBOARDMODE_ALL: number;
  84925. /**
  84926. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84927. */
  84928. static readonly BILLBOARDMODE_STRETCHED: number;
  84929. /**
  84930. * This function can be defined to provide custom update for active particles.
  84931. * This function will be called instead of regular update (age, position, color, etc.).
  84932. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84933. */
  84934. updateFunction: (particles: Particle[]) => void;
  84935. private _emitterWorldMatrix;
  84936. /**
  84937. * This function can be defined to specify initial direction for every new particle.
  84938. * It by default use the emitterType defined function
  84939. */
  84940. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84941. /**
  84942. * This function can be defined to specify initial position for every new particle.
  84943. * It by default use the emitterType defined function
  84944. */
  84945. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  84946. /**
  84947. * @hidden
  84948. */
  84949. _inheritedVelocityOffset: Vector3;
  84950. /**
  84951. * An event triggered when the system is disposed
  84952. */
  84953. onDisposeObservable: Observable<ParticleSystem>;
  84954. private _onDisposeObserver;
  84955. /**
  84956. * Sets a callback that will be triggered when the system is disposed
  84957. */
  84958. set onDispose(callback: () => void);
  84959. private _particles;
  84960. private _epsilon;
  84961. private _capacity;
  84962. private _stockParticles;
  84963. private _newPartsExcess;
  84964. private _vertexData;
  84965. private _vertexBuffer;
  84966. private _vertexBuffers;
  84967. private _spriteBuffer;
  84968. private _indexBuffer;
  84969. private _effect;
  84970. private _customEffect;
  84971. private _cachedDefines;
  84972. private _scaledColorStep;
  84973. private _colorDiff;
  84974. private _scaledDirection;
  84975. private _scaledGravity;
  84976. private _currentRenderId;
  84977. private _alive;
  84978. private _useInstancing;
  84979. private _started;
  84980. private _stopped;
  84981. private _actualFrame;
  84982. private _scaledUpdateSpeed;
  84983. private _vertexBufferSize;
  84984. /** @hidden */
  84985. _currentEmitRateGradient: Nullable<FactorGradient>;
  84986. /** @hidden */
  84987. _currentEmitRate1: number;
  84988. /** @hidden */
  84989. _currentEmitRate2: number;
  84990. /** @hidden */
  84991. _currentStartSizeGradient: Nullable<FactorGradient>;
  84992. /** @hidden */
  84993. _currentStartSize1: number;
  84994. /** @hidden */
  84995. _currentStartSize2: number;
  84996. private readonly _rawTextureWidth;
  84997. private _rampGradientsTexture;
  84998. private _useRampGradients;
  84999. /** Gets or sets a boolean indicating that ramp gradients must be used
  85000. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85001. */
  85002. get useRampGradients(): boolean;
  85003. set useRampGradients(value: boolean);
  85004. /**
  85005. * 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.
  85006. * 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: [])
  85007. */
  85008. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85009. private _subEmitters;
  85010. /**
  85011. * @hidden
  85012. * If the particle systems emitter should be disposed when the particle system is disposed
  85013. */
  85014. _disposeEmitterOnDispose: boolean;
  85015. /**
  85016. * The current active Sub-systems, this property is used by the root particle system only.
  85017. */
  85018. activeSubSystems: Array<ParticleSystem>;
  85019. /**
  85020. * Specifies if the particles are updated in emitter local space or world space
  85021. */
  85022. isLocal: boolean;
  85023. private _rootParticleSystem;
  85024. /**
  85025. * Gets the current list of active particles
  85026. */
  85027. get particles(): Particle[];
  85028. /**
  85029. * Returns the string "ParticleSystem"
  85030. * @returns a string containing the class name
  85031. */
  85032. getClassName(): string;
  85033. /**
  85034. * Instantiates a particle system.
  85035. * 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.
  85036. * @param name The name of the particle system
  85037. * @param capacity The max number of particles alive at the same time
  85038. * @param scene The scene the particle system belongs to
  85039. * @param customEffect a custom effect used to change the way particles are rendered by default
  85040. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85041. * @param epsilon Offset used to render the particles
  85042. */
  85043. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85044. private _addFactorGradient;
  85045. private _removeFactorGradient;
  85046. /**
  85047. * Adds a new life time gradient
  85048. * @param gradient defines the gradient to use (between 0 and 1)
  85049. * @param factor defines the life time factor to affect to the specified gradient
  85050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85051. * @returns the current particle system
  85052. */
  85053. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85054. /**
  85055. * Remove a specific life time gradient
  85056. * @param gradient defines the gradient to remove
  85057. * @returns the current particle system
  85058. */
  85059. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85060. /**
  85061. * Adds a new size gradient
  85062. * @param gradient defines the gradient to use (between 0 and 1)
  85063. * @param factor defines the size factor to affect to the specified gradient
  85064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85065. * @returns the current particle system
  85066. */
  85067. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85068. /**
  85069. * Remove a specific size gradient
  85070. * @param gradient defines the gradient to remove
  85071. * @returns the current particle system
  85072. */
  85073. removeSizeGradient(gradient: number): IParticleSystem;
  85074. /**
  85075. * Adds a new color remap gradient
  85076. * @param gradient defines the gradient to use (between 0 and 1)
  85077. * @param min defines the color remap minimal range
  85078. * @param max defines the color remap maximal range
  85079. * @returns the current particle system
  85080. */
  85081. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85082. /**
  85083. * Remove a specific color remap gradient
  85084. * @param gradient defines the gradient to remove
  85085. * @returns the current particle system
  85086. */
  85087. removeColorRemapGradient(gradient: number): IParticleSystem;
  85088. /**
  85089. * Adds a new alpha remap gradient
  85090. * @param gradient defines the gradient to use (between 0 and 1)
  85091. * @param min defines the alpha remap minimal range
  85092. * @param max defines the alpha remap maximal range
  85093. * @returns the current particle system
  85094. */
  85095. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85096. /**
  85097. * Remove a specific alpha remap gradient
  85098. * @param gradient defines the gradient to remove
  85099. * @returns the current particle system
  85100. */
  85101. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85102. /**
  85103. * Adds a new angular speed gradient
  85104. * @param gradient defines the gradient to use (between 0 and 1)
  85105. * @param factor defines the angular speed to affect to the specified gradient
  85106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85107. * @returns the current particle system
  85108. */
  85109. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85110. /**
  85111. * Remove a specific angular speed gradient
  85112. * @param gradient defines the gradient to remove
  85113. * @returns the current particle system
  85114. */
  85115. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85116. /**
  85117. * Adds a new velocity gradient
  85118. * @param gradient defines the gradient to use (between 0 and 1)
  85119. * @param factor defines the velocity to affect to the specified gradient
  85120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85121. * @returns the current particle system
  85122. */
  85123. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85124. /**
  85125. * Remove a specific velocity gradient
  85126. * @param gradient defines the gradient to remove
  85127. * @returns the current particle system
  85128. */
  85129. removeVelocityGradient(gradient: number): IParticleSystem;
  85130. /**
  85131. * Adds a new limit velocity gradient
  85132. * @param gradient defines the gradient to use (between 0 and 1)
  85133. * @param factor defines the limit velocity value to affect to the specified gradient
  85134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85135. * @returns the current particle system
  85136. */
  85137. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85138. /**
  85139. * Remove a specific limit velocity gradient
  85140. * @param gradient defines the gradient to remove
  85141. * @returns the current particle system
  85142. */
  85143. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85144. /**
  85145. * Adds a new drag gradient
  85146. * @param gradient defines the gradient to use (between 0 and 1)
  85147. * @param factor defines the drag value to affect to the specified gradient
  85148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85149. * @returns the current particle system
  85150. */
  85151. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85152. /**
  85153. * Remove a specific drag gradient
  85154. * @param gradient defines the gradient to remove
  85155. * @returns the current particle system
  85156. */
  85157. removeDragGradient(gradient: number): IParticleSystem;
  85158. /**
  85159. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85160. * @param gradient defines the gradient to use (between 0 and 1)
  85161. * @param factor defines the emit rate value to affect to the specified gradient
  85162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85163. * @returns the current particle system
  85164. */
  85165. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85166. /**
  85167. * Remove a specific emit rate gradient
  85168. * @param gradient defines the gradient to remove
  85169. * @returns the current particle system
  85170. */
  85171. removeEmitRateGradient(gradient: number): IParticleSystem;
  85172. /**
  85173. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85174. * @param gradient defines the gradient to use (between 0 and 1)
  85175. * @param factor defines the start size value to affect to the specified gradient
  85176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85177. * @returns the current particle system
  85178. */
  85179. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85180. /**
  85181. * Remove a specific start size gradient
  85182. * @param gradient defines the gradient to remove
  85183. * @returns the current particle system
  85184. */
  85185. removeStartSizeGradient(gradient: number): IParticleSystem;
  85186. private _createRampGradientTexture;
  85187. /**
  85188. * Gets the current list of ramp gradients.
  85189. * You must use addRampGradient and removeRampGradient to udpate this list
  85190. * @returns the list of ramp gradients
  85191. */
  85192. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85193. /**
  85194. * Adds a new ramp gradient used to remap particle colors
  85195. * @param gradient defines the gradient to use (between 0 and 1)
  85196. * @param color defines the color to affect to the specified gradient
  85197. * @returns the current particle system
  85198. */
  85199. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85200. /**
  85201. * Remove a specific ramp gradient
  85202. * @param gradient defines the gradient to remove
  85203. * @returns the current particle system
  85204. */
  85205. removeRampGradient(gradient: number): ParticleSystem;
  85206. /**
  85207. * Adds a new color gradient
  85208. * @param gradient defines the gradient to use (between 0 and 1)
  85209. * @param color1 defines the color to affect to the specified gradient
  85210. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85211. * @returns this particle system
  85212. */
  85213. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85214. /**
  85215. * Remove a specific color gradient
  85216. * @param gradient defines the gradient to remove
  85217. * @returns this particle system
  85218. */
  85219. removeColorGradient(gradient: number): IParticleSystem;
  85220. private _fetchR;
  85221. protected _reset(): void;
  85222. private _resetEffect;
  85223. private _createVertexBuffers;
  85224. private _createIndexBuffer;
  85225. /**
  85226. * Gets the maximum number of particles active at the same time.
  85227. * @returns The max number of active particles.
  85228. */
  85229. getCapacity(): number;
  85230. /**
  85231. * Gets whether there are still active particles in the system.
  85232. * @returns True if it is alive, otherwise false.
  85233. */
  85234. isAlive(): boolean;
  85235. /**
  85236. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85237. * @returns True if it has been started, otherwise false.
  85238. */
  85239. isStarted(): boolean;
  85240. private _prepareSubEmitterInternalArray;
  85241. /**
  85242. * Starts the particle system and begins to emit
  85243. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85244. */
  85245. start(delay?: number): void;
  85246. /**
  85247. * Stops the particle system.
  85248. * @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.
  85249. */
  85250. stop(stopSubEmitters?: boolean): void;
  85251. /**
  85252. * Remove all active particles
  85253. */
  85254. reset(): void;
  85255. /**
  85256. * @hidden (for internal use only)
  85257. */
  85258. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85259. /**
  85260. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85261. * Its lifetime will start back at 0.
  85262. */
  85263. recycleParticle: (particle: Particle) => void;
  85264. private _stopSubEmitters;
  85265. private _createParticle;
  85266. private _removeFromRoot;
  85267. private _emitFromParticle;
  85268. private _update;
  85269. /** @hidden */
  85270. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85271. /** @hidden */
  85272. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85273. /** @hidden */
  85274. private _getEffect;
  85275. /**
  85276. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85277. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85278. */
  85279. animate(preWarmOnly?: boolean): void;
  85280. private _appendParticleVertices;
  85281. /**
  85282. * Rebuilds the particle system.
  85283. */
  85284. rebuild(): void;
  85285. /**
  85286. * Is this system ready to be used/rendered
  85287. * @return true if the system is ready
  85288. */
  85289. isReady(): boolean;
  85290. private _render;
  85291. /**
  85292. * Renders the particle system in its current state.
  85293. * @returns the current number of particles
  85294. */
  85295. render(): number;
  85296. /**
  85297. * Disposes the particle system and free the associated resources
  85298. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85299. */
  85300. dispose(disposeTexture?: boolean): void;
  85301. /**
  85302. * Clones the particle system.
  85303. * @param name The name of the cloned object
  85304. * @param newEmitter The new emitter to use
  85305. * @returns the cloned particle system
  85306. */
  85307. clone(name: string, newEmitter: any): ParticleSystem;
  85308. /**
  85309. * Serializes the particle system to a JSON object.
  85310. * @returns the JSON object
  85311. */
  85312. serialize(): any;
  85313. /** @hidden */
  85314. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85315. /** @hidden */
  85316. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85317. /**
  85318. * Parses a JSON object to create a particle system.
  85319. * @param parsedParticleSystem The JSON object to parse
  85320. * @param scene The scene to create the particle system in
  85321. * @param rootUrl The root url to use to load external dependencies like texture
  85322. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85323. * @returns the Parsed particle system
  85324. */
  85325. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85326. }
  85327. }
  85328. declare module BABYLON {
  85329. /**
  85330. * A particle represents one of the element emitted by a particle system.
  85331. * This is mainly define by its coordinates, direction, velocity and age.
  85332. */
  85333. export class Particle {
  85334. /**
  85335. * The particle system the particle belongs to.
  85336. */
  85337. particleSystem: ParticleSystem;
  85338. private static _Count;
  85339. /**
  85340. * Unique ID of the particle
  85341. */
  85342. id: number;
  85343. /**
  85344. * The world position of the particle in the scene.
  85345. */
  85346. position: Vector3;
  85347. /**
  85348. * The world direction of the particle in the scene.
  85349. */
  85350. direction: Vector3;
  85351. /**
  85352. * The color of the particle.
  85353. */
  85354. color: Color4;
  85355. /**
  85356. * The color change of the particle per step.
  85357. */
  85358. colorStep: Color4;
  85359. /**
  85360. * Defines how long will the life of the particle be.
  85361. */
  85362. lifeTime: number;
  85363. /**
  85364. * The current age of the particle.
  85365. */
  85366. age: number;
  85367. /**
  85368. * The current size of the particle.
  85369. */
  85370. size: number;
  85371. /**
  85372. * The current scale of the particle.
  85373. */
  85374. scale: Vector2;
  85375. /**
  85376. * The current angle of the particle.
  85377. */
  85378. angle: number;
  85379. /**
  85380. * Defines how fast is the angle changing.
  85381. */
  85382. angularSpeed: number;
  85383. /**
  85384. * Defines the cell index used by the particle to be rendered from a sprite.
  85385. */
  85386. cellIndex: number;
  85387. /**
  85388. * The information required to support color remapping
  85389. */
  85390. remapData: Vector4;
  85391. /** @hidden */
  85392. _randomCellOffset?: number;
  85393. /** @hidden */
  85394. _initialDirection: Nullable<Vector3>;
  85395. /** @hidden */
  85396. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85397. /** @hidden */
  85398. _initialStartSpriteCellID: number;
  85399. /** @hidden */
  85400. _initialEndSpriteCellID: number;
  85401. /** @hidden */
  85402. _currentColorGradient: Nullable<ColorGradient>;
  85403. /** @hidden */
  85404. _currentColor1: Color4;
  85405. /** @hidden */
  85406. _currentColor2: Color4;
  85407. /** @hidden */
  85408. _currentSizeGradient: Nullable<FactorGradient>;
  85409. /** @hidden */
  85410. _currentSize1: number;
  85411. /** @hidden */
  85412. _currentSize2: number;
  85413. /** @hidden */
  85414. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85415. /** @hidden */
  85416. _currentAngularSpeed1: number;
  85417. /** @hidden */
  85418. _currentAngularSpeed2: number;
  85419. /** @hidden */
  85420. _currentVelocityGradient: Nullable<FactorGradient>;
  85421. /** @hidden */
  85422. _currentVelocity1: number;
  85423. /** @hidden */
  85424. _currentVelocity2: number;
  85425. /** @hidden */
  85426. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85427. /** @hidden */
  85428. _currentLimitVelocity1: number;
  85429. /** @hidden */
  85430. _currentLimitVelocity2: number;
  85431. /** @hidden */
  85432. _currentDragGradient: Nullable<FactorGradient>;
  85433. /** @hidden */
  85434. _currentDrag1: number;
  85435. /** @hidden */
  85436. _currentDrag2: number;
  85437. /** @hidden */
  85438. _randomNoiseCoordinates1: Vector3;
  85439. /** @hidden */
  85440. _randomNoiseCoordinates2: Vector3;
  85441. /** @hidden */
  85442. _localPosition?: Vector3;
  85443. /**
  85444. * Creates a new instance Particle
  85445. * @param particleSystem the particle system the particle belongs to
  85446. */
  85447. constructor(
  85448. /**
  85449. * The particle system the particle belongs to.
  85450. */
  85451. particleSystem: ParticleSystem);
  85452. private updateCellInfoFromSystem;
  85453. /**
  85454. * Defines how the sprite cell index is updated for the particle
  85455. */
  85456. updateCellIndex(): void;
  85457. /** @hidden */
  85458. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85459. /** @hidden */
  85460. _inheritParticleInfoToSubEmitters(): void;
  85461. /** @hidden */
  85462. _reset(): void;
  85463. /**
  85464. * Copy the properties of particle to another one.
  85465. * @param other the particle to copy the information to.
  85466. */
  85467. copyTo(other: Particle): void;
  85468. }
  85469. }
  85470. declare module BABYLON {
  85471. /**
  85472. * Particle emitter represents a volume emitting particles.
  85473. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85474. */
  85475. export interface IParticleEmitterType {
  85476. /**
  85477. * Called by the particle System when the direction is computed for the created particle.
  85478. * @param worldMatrix is the world matrix of the particle system
  85479. * @param directionToUpdate is the direction vector to update with the result
  85480. * @param particle is the particle we are computed the direction for
  85481. * @param isLocal defines if the direction should be set in local space
  85482. */
  85483. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85484. /**
  85485. * Called by the particle System when the position is computed for the created particle.
  85486. * @param worldMatrix is the world matrix of the particle system
  85487. * @param positionToUpdate is the position vector to update with the result
  85488. * @param particle is the particle we are computed the position for
  85489. * @param isLocal defines if the position should be set in local space
  85490. */
  85491. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85492. /**
  85493. * Clones the current emitter and returns a copy of it
  85494. * @returns the new emitter
  85495. */
  85496. clone(): IParticleEmitterType;
  85497. /**
  85498. * Called by the GPUParticleSystem to setup the update shader
  85499. * @param effect defines the update shader
  85500. */
  85501. applyToShader(effect: Effect): void;
  85502. /**
  85503. * Returns a string to use to update the GPU particles update shader
  85504. * @returns the effect defines string
  85505. */
  85506. getEffectDefines(): string;
  85507. /**
  85508. * Returns a string representing the class name
  85509. * @returns a string containing the class name
  85510. */
  85511. getClassName(): string;
  85512. /**
  85513. * Serializes the particle system to a JSON object.
  85514. * @returns the JSON object
  85515. */
  85516. serialize(): any;
  85517. /**
  85518. * Parse properties from a JSON object
  85519. * @param serializationObject defines the JSON object
  85520. * @param scene defines the hosting scene
  85521. */
  85522. parse(serializationObject: any, scene: Scene): void;
  85523. }
  85524. }
  85525. declare module BABYLON {
  85526. /**
  85527. * Particle emitter emitting particles from the inside of a box.
  85528. * It emits the particles randomly between 2 given directions.
  85529. */
  85530. export class BoxParticleEmitter implements IParticleEmitterType {
  85531. /**
  85532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85533. */
  85534. direction1: Vector3;
  85535. /**
  85536. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85537. */
  85538. direction2: Vector3;
  85539. /**
  85540. * 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.
  85541. */
  85542. minEmitBox: Vector3;
  85543. /**
  85544. * 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.
  85545. */
  85546. maxEmitBox: Vector3;
  85547. /**
  85548. * Creates a new instance BoxParticleEmitter
  85549. */
  85550. constructor();
  85551. /**
  85552. * Called by the particle System when the direction is computed for the created particle.
  85553. * @param worldMatrix is the world matrix of the particle system
  85554. * @param directionToUpdate is the direction vector to update with the result
  85555. * @param particle is the particle we are computed the direction for
  85556. * @param isLocal defines if the direction should be set in local space
  85557. */
  85558. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85559. /**
  85560. * Called by the particle System when the position is computed for the created particle.
  85561. * @param worldMatrix is the world matrix of the particle system
  85562. * @param positionToUpdate is the position vector to update with the result
  85563. * @param particle is the particle we are computed the position for
  85564. * @param isLocal defines if the position should be set in local space
  85565. */
  85566. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85567. /**
  85568. * Clones the current emitter and returns a copy of it
  85569. * @returns the new emitter
  85570. */
  85571. clone(): BoxParticleEmitter;
  85572. /**
  85573. * Called by the GPUParticleSystem to setup the update shader
  85574. * @param effect defines the update shader
  85575. */
  85576. applyToShader(effect: Effect): void;
  85577. /**
  85578. * Returns a string to use to update the GPU particles update shader
  85579. * @returns a string containng the defines string
  85580. */
  85581. getEffectDefines(): string;
  85582. /**
  85583. * Returns the string "BoxParticleEmitter"
  85584. * @returns a string containing the class name
  85585. */
  85586. getClassName(): string;
  85587. /**
  85588. * Serializes the particle system to a JSON object.
  85589. * @returns the JSON object
  85590. */
  85591. serialize(): any;
  85592. /**
  85593. * Parse properties from a JSON object
  85594. * @param serializationObject defines the JSON object
  85595. */
  85596. parse(serializationObject: any): void;
  85597. }
  85598. }
  85599. declare module BABYLON {
  85600. /**
  85601. * Particle emitter emitting particles from the inside of a cone.
  85602. * It emits the particles alongside the cone volume from the base to the particle.
  85603. * The emission direction might be randomized.
  85604. */
  85605. export class ConeParticleEmitter implements IParticleEmitterType {
  85606. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85607. directionRandomizer: number;
  85608. private _radius;
  85609. private _angle;
  85610. private _height;
  85611. /**
  85612. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85613. */
  85614. radiusRange: number;
  85615. /**
  85616. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85617. */
  85618. heightRange: number;
  85619. /**
  85620. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85621. */
  85622. emitFromSpawnPointOnly: boolean;
  85623. /**
  85624. * Gets or sets the radius of the emission cone
  85625. */
  85626. get radius(): number;
  85627. set radius(value: number);
  85628. /**
  85629. * Gets or sets the angle of the emission cone
  85630. */
  85631. get angle(): number;
  85632. set angle(value: number);
  85633. private _buildHeight;
  85634. /**
  85635. * Creates a new instance ConeParticleEmitter
  85636. * @param radius the radius of the emission cone (1 by default)
  85637. * @param angle the cone base angle (PI by default)
  85638. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85639. */
  85640. constructor(radius?: number, angle?: number,
  85641. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85642. directionRandomizer?: number);
  85643. /**
  85644. * Called by the particle System when the direction is computed for the created particle.
  85645. * @param worldMatrix is the world matrix of the particle system
  85646. * @param directionToUpdate is the direction vector to update with the result
  85647. * @param particle is the particle we are computed the direction for
  85648. * @param isLocal defines if the direction should be set in local space
  85649. */
  85650. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85651. /**
  85652. * Called by the particle System when the position is computed for the created particle.
  85653. * @param worldMatrix is the world matrix of the particle system
  85654. * @param positionToUpdate is the position vector to update with the result
  85655. * @param particle is the particle we are computed the position for
  85656. * @param isLocal defines if the position should be set in local space
  85657. */
  85658. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85659. /**
  85660. * Clones the current emitter and returns a copy of it
  85661. * @returns the new emitter
  85662. */
  85663. clone(): ConeParticleEmitter;
  85664. /**
  85665. * Called by the GPUParticleSystem to setup the update shader
  85666. * @param effect defines the update shader
  85667. */
  85668. applyToShader(effect: Effect): void;
  85669. /**
  85670. * Returns a string to use to update the GPU particles update shader
  85671. * @returns a string containng the defines string
  85672. */
  85673. getEffectDefines(): string;
  85674. /**
  85675. * Returns the string "ConeParticleEmitter"
  85676. * @returns a string containing the class name
  85677. */
  85678. getClassName(): string;
  85679. /**
  85680. * Serializes the particle system to a JSON object.
  85681. * @returns the JSON object
  85682. */
  85683. serialize(): any;
  85684. /**
  85685. * Parse properties from a JSON object
  85686. * @param serializationObject defines the JSON object
  85687. */
  85688. parse(serializationObject: any): void;
  85689. }
  85690. }
  85691. declare module BABYLON {
  85692. /**
  85693. * Particle emitter emitting particles from the inside of a cylinder.
  85694. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85695. */
  85696. export class CylinderParticleEmitter implements IParticleEmitterType {
  85697. /**
  85698. * The radius of the emission cylinder.
  85699. */
  85700. radius: number;
  85701. /**
  85702. * The height of the emission cylinder.
  85703. */
  85704. height: number;
  85705. /**
  85706. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85707. */
  85708. radiusRange: number;
  85709. /**
  85710. * How much to randomize the particle direction [0-1].
  85711. */
  85712. directionRandomizer: number;
  85713. /**
  85714. * Creates a new instance CylinderParticleEmitter
  85715. * @param radius the radius of the emission cylinder (1 by default)
  85716. * @param height the height of the emission cylinder (1 by default)
  85717. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85718. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85719. */
  85720. constructor(
  85721. /**
  85722. * The radius of the emission cylinder.
  85723. */
  85724. radius?: number,
  85725. /**
  85726. * The height of the emission cylinder.
  85727. */
  85728. height?: number,
  85729. /**
  85730. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85731. */
  85732. radiusRange?: number,
  85733. /**
  85734. * How much to randomize the particle direction [0-1].
  85735. */
  85736. directionRandomizer?: number);
  85737. /**
  85738. * Called by the particle System when the direction is computed for the created particle.
  85739. * @param worldMatrix is the world matrix of the particle system
  85740. * @param directionToUpdate is the direction vector to update with the result
  85741. * @param particle is the particle we are computed the direction for
  85742. * @param isLocal defines if the direction should be set in local space
  85743. */
  85744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85745. /**
  85746. * Called by the particle System when the position is computed for the created particle.
  85747. * @param worldMatrix is the world matrix of the particle system
  85748. * @param positionToUpdate is the position vector to update with the result
  85749. * @param particle is the particle we are computed the position for
  85750. * @param isLocal defines if the position should be set in local space
  85751. */
  85752. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85753. /**
  85754. * Clones the current emitter and returns a copy of it
  85755. * @returns the new emitter
  85756. */
  85757. clone(): CylinderParticleEmitter;
  85758. /**
  85759. * Called by the GPUParticleSystem to setup the update shader
  85760. * @param effect defines the update shader
  85761. */
  85762. applyToShader(effect: Effect): void;
  85763. /**
  85764. * Returns a string to use to update the GPU particles update shader
  85765. * @returns a string containng the defines string
  85766. */
  85767. getEffectDefines(): string;
  85768. /**
  85769. * Returns the string "CylinderParticleEmitter"
  85770. * @returns a string containing the class name
  85771. */
  85772. getClassName(): string;
  85773. /**
  85774. * Serializes the particle system to a JSON object.
  85775. * @returns the JSON object
  85776. */
  85777. serialize(): any;
  85778. /**
  85779. * Parse properties from a JSON object
  85780. * @param serializationObject defines the JSON object
  85781. */
  85782. parse(serializationObject: any): void;
  85783. }
  85784. /**
  85785. * Particle emitter emitting particles from the inside of a cylinder.
  85786. * It emits the particles randomly between two vectors.
  85787. */
  85788. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85789. /**
  85790. * The min limit of the emission direction.
  85791. */
  85792. direction1: Vector3;
  85793. /**
  85794. * The max limit of the emission direction.
  85795. */
  85796. direction2: Vector3;
  85797. /**
  85798. * Creates a new instance CylinderDirectedParticleEmitter
  85799. * @param radius the radius of the emission cylinder (1 by default)
  85800. * @param height the height of the emission cylinder (1 by default)
  85801. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85802. * @param direction1 the min limit of the emission direction (up vector by default)
  85803. * @param direction2 the max limit of the emission direction (up vector by default)
  85804. */
  85805. constructor(radius?: number, height?: number, radiusRange?: number,
  85806. /**
  85807. * The min limit of the emission direction.
  85808. */
  85809. direction1?: Vector3,
  85810. /**
  85811. * The max limit of the emission direction.
  85812. */
  85813. direction2?: Vector3);
  85814. /**
  85815. * Called by the particle System when the direction is computed for the created particle.
  85816. * @param worldMatrix is the world matrix of the particle system
  85817. * @param directionToUpdate is the direction vector to update with the result
  85818. * @param particle is the particle we are computed the direction for
  85819. */
  85820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85821. /**
  85822. * Clones the current emitter and returns a copy of it
  85823. * @returns the new emitter
  85824. */
  85825. clone(): CylinderDirectedParticleEmitter;
  85826. /**
  85827. * Called by the GPUParticleSystem to setup the update shader
  85828. * @param effect defines the update shader
  85829. */
  85830. applyToShader(effect: Effect): void;
  85831. /**
  85832. * Returns a string to use to update the GPU particles update shader
  85833. * @returns a string containng the defines string
  85834. */
  85835. getEffectDefines(): string;
  85836. /**
  85837. * Returns the string "CylinderDirectedParticleEmitter"
  85838. * @returns a string containing the class name
  85839. */
  85840. getClassName(): string;
  85841. /**
  85842. * Serializes the particle system to a JSON object.
  85843. * @returns the JSON object
  85844. */
  85845. serialize(): any;
  85846. /**
  85847. * Parse properties from a JSON object
  85848. * @param serializationObject defines the JSON object
  85849. */
  85850. parse(serializationObject: any): void;
  85851. }
  85852. }
  85853. declare module BABYLON {
  85854. /**
  85855. * Particle emitter emitting particles from the inside of a hemisphere.
  85856. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85857. */
  85858. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85859. /**
  85860. * The radius of the emission hemisphere.
  85861. */
  85862. radius: number;
  85863. /**
  85864. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85865. */
  85866. radiusRange: number;
  85867. /**
  85868. * How much to randomize the particle direction [0-1].
  85869. */
  85870. directionRandomizer: number;
  85871. /**
  85872. * Creates a new instance HemisphericParticleEmitter
  85873. * @param radius the radius of the emission hemisphere (1 by default)
  85874. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85875. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85876. */
  85877. constructor(
  85878. /**
  85879. * The radius of the emission hemisphere.
  85880. */
  85881. radius?: number,
  85882. /**
  85883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85884. */
  85885. radiusRange?: number,
  85886. /**
  85887. * How much to randomize the particle direction [0-1].
  85888. */
  85889. directionRandomizer?: number);
  85890. /**
  85891. * Called by the particle System when the direction is computed for the created particle.
  85892. * @param worldMatrix is the world matrix of the particle system
  85893. * @param directionToUpdate is the direction vector to update with the result
  85894. * @param particle is the particle we are computed the direction for
  85895. * @param isLocal defines if the direction should be set in local space
  85896. */
  85897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85898. /**
  85899. * Called by the particle System when the position is computed for the created particle.
  85900. * @param worldMatrix is the world matrix of the particle system
  85901. * @param positionToUpdate is the position vector to update with the result
  85902. * @param particle is the particle we are computed the position for
  85903. * @param isLocal defines if the position should be set in local space
  85904. */
  85905. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85906. /**
  85907. * Clones the current emitter and returns a copy of it
  85908. * @returns the new emitter
  85909. */
  85910. clone(): HemisphericParticleEmitter;
  85911. /**
  85912. * Called by the GPUParticleSystem to setup the update shader
  85913. * @param effect defines the update shader
  85914. */
  85915. applyToShader(effect: Effect): void;
  85916. /**
  85917. * Returns a string to use to update the GPU particles update shader
  85918. * @returns a string containng the defines string
  85919. */
  85920. getEffectDefines(): string;
  85921. /**
  85922. * Returns the string "HemisphericParticleEmitter"
  85923. * @returns a string containing the class name
  85924. */
  85925. getClassName(): string;
  85926. /**
  85927. * Serializes the particle system to a JSON object.
  85928. * @returns the JSON object
  85929. */
  85930. serialize(): any;
  85931. /**
  85932. * Parse properties from a JSON object
  85933. * @param serializationObject defines the JSON object
  85934. */
  85935. parse(serializationObject: any): void;
  85936. }
  85937. }
  85938. declare module BABYLON {
  85939. /**
  85940. * Particle emitter emitting particles from a point.
  85941. * It emits the particles randomly between 2 given directions.
  85942. */
  85943. export class PointParticleEmitter implements IParticleEmitterType {
  85944. /**
  85945. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85946. */
  85947. direction1: Vector3;
  85948. /**
  85949. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85950. */
  85951. direction2: Vector3;
  85952. /**
  85953. * Creates a new instance PointParticleEmitter
  85954. */
  85955. constructor();
  85956. /**
  85957. * Called by the particle System when the direction is computed for the created particle.
  85958. * @param worldMatrix is the world matrix of the particle system
  85959. * @param directionToUpdate is the direction vector to update with the result
  85960. * @param particle is the particle we are computed the direction for
  85961. * @param isLocal defines if the direction should be set in local space
  85962. */
  85963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85964. /**
  85965. * Called by the particle System when the position is computed for the created particle.
  85966. * @param worldMatrix is the world matrix of the particle system
  85967. * @param positionToUpdate is the position vector to update with the result
  85968. * @param particle is the particle we are computed the position for
  85969. * @param isLocal defines if the position should be set in local space
  85970. */
  85971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85972. /**
  85973. * Clones the current emitter and returns a copy of it
  85974. * @returns the new emitter
  85975. */
  85976. clone(): PointParticleEmitter;
  85977. /**
  85978. * Called by the GPUParticleSystem to setup the update shader
  85979. * @param effect defines the update shader
  85980. */
  85981. applyToShader(effect: Effect): void;
  85982. /**
  85983. * Returns a string to use to update the GPU particles update shader
  85984. * @returns a string containng the defines string
  85985. */
  85986. getEffectDefines(): string;
  85987. /**
  85988. * Returns the string "PointParticleEmitter"
  85989. * @returns a string containing the class name
  85990. */
  85991. getClassName(): string;
  85992. /**
  85993. * Serializes the particle system to a JSON object.
  85994. * @returns the JSON object
  85995. */
  85996. serialize(): any;
  85997. /**
  85998. * Parse properties from a JSON object
  85999. * @param serializationObject defines the JSON object
  86000. */
  86001. parse(serializationObject: any): void;
  86002. }
  86003. }
  86004. declare module BABYLON {
  86005. /**
  86006. * Particle emitter emitting particles from the inside of a sphere.
  86007. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86008. */
  86009. export class SphereParticleEmitter implements IParticleEmitterType {
  86010. /**
  86011. * The radius of the emission sphere.
  86012. */
  86013. radius: number;
  86014. /**
  86015. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86016. */
  86017. radiusRange: number;
  86018. /**
  86019. * How much to randomize the particle direction [0-1].
  86020. */
  86021. directionRandomizer: number;
  86022. /**
  86023. * Creates a new instance SphereParticleEmitter
  86024. * @param radius the radius of the emission sphere (1 by default)
  86025. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86026. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86027. */
  86028. constructor(
  86029. /**
  86030. * The radius of the emission sphere.
  86031. */
  86032. radius?: number,
  86033. /**
  86034. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86035. */
  86036. radiusRange?: number,
  86037. /**
  86038. * How much to randomize the particle direction [0-1].
  86039. */
  86040. directionRandomizer?: number);
  86041. /**
  86042. * Called by the particle System when the direction is computed for the created particle.
  86043. * @param worldMatrix is the world matrix of the particle system
  86044. * @param directionToUpdate is the direction vector to update with the result
  86045. * @param particle is the particle we are computed the direction for
  86046. * @param isLocal defines if the direction should be set in local space
  86047. */
  86048. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86049. /**
  86050. * Called by the particle System when the position is computed for the created particle.
  86051. * @param worldMatrix is the world matrix of the particle system
  86052. * @param positionToUpdate is the position vector to update with the result
  86053. * @param particle is the particle we are computed the position for
  86054. * @param isLocal defines if the position should be set in local space
  86055. */
  86056. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86057. /**
  86058. * Clones the current emitter and returns a copy of it
  86059. * @returns the new emitter
  86060. */
  86061. clone(): SphereParticleEmitter;
  86062. /**
  86063. * Called by the GPUParticleSystem to setup the update shader
  86064. * @param effect defines the update shader
  86065. */
  86066. applyToShader(effect: Effect): void;
  86067. /**
  86068. * Returns a string to use to update the GPU particles update shader
  86069. * @returns a string containng the defines string
  86070. */
  86071. getEffectDefines(): string;
  86072. /**
  86073. * Returns the string "SphereParticleEmitter"
  86074. * @returns a string containing the class name
  86075. */
  86076. getClassName(): string;
  86077. /**
  86078. * Serializes the particle system to a JSON object.
  86079. * @returns the JSON object
  86080. */
  86081. serialize(): any;
  86082. /**
  86083. * Parse properties from a JSON object
  86084. * @param serializationObject defines the JSON object
  86085. */
  86086. parse(serializationObject: any): void;
  86087. }
  86088. /**
  86089. * Particle emitter emitting particles from the inside of a sphere.
  86090. * It emits the particles randomly between two vectors.
  86091. */
  86092. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86093. /**
  86094. * The min limit of the emission direction.
  86095. */
  86096. direction1: Vector3;
  86097. /**
  86098. * The max limit of the emission direction.
  86099. */
  86100. direction2: Vector3;
  86101. /**
  86102. * Creates a new instance SphereDirectedParticleEmitter
  86103. * @param radius the radius of the emission sphere (1 by default)
  86104. * @param direction1 the min limit of the emission direction (up vector by default)
  86105. * @param direction2 the max limit of the emission direction (up vector by default)
  86106. */
  86107. constructor(radius?: number,
  86108. /**
  86109. * The min limit of the emission direction.
  86110. */
  86111. direction1?: Vector3,
  86112. /**
  86113. * The max limit of the emission direction.
  86114. */
  86115. direction2?: Vector3);
  86116. /**
  86117. * Called by the particle System when the direction is computed for the created particle.
  86118. * @param worldMatrix is the world matrix of the particle system
  86119. * @param directionToUpdate is the direction vector to update with the result
  86120. * @param particle is the particle we are computed the direction for
  86121. */
  86122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86123. /**
  86124. * Clones the current emitter and returns a copy of it
  86125. * @returns the new emitter
  86126. */
  86127. clone(): SphereDirectedParticleEmitter;
  86128. /**
  86129. * Called by the GPUParticleSystem to setup the update shader
  86130. * @param effect defines the update shader
  86131. */
  86132. applyToShader(effect: Effect): void;
  86133. /**
  86134. * Returns a string to use to update the GPU particles update shader
  86135. * @returns a string containng the defines string
  86136. */
  86137. getEffectDefines(): string;
  86138. /**
  86139. * Returns the string "SphereDirectedParticleEmitter"
  86140. * @returns a string containing the class name
  86141. */
  86142. getClassName(): string;
  86143. /**
  86144. * Serializes the particle system to a JSON object.
  86145. * @returns the JSON object
  86146. */
  86147. serialize(): any;
  86148. /**
  86149. * Parse properties from a JSON object
  86150. * @param serializationObject defines the JSON object
  86151. */
  86152. parse(serializationObject: any): void;
  86153. }
  86154. }
  86155. declare module BABYLON {
  86156. /**
  86157. * Particle emitter emitting particles from a custom list of positions.
  86158. */
  86159. export class CustomParticleEmitter implements IParticleEmitterType {
  86160. /**
  86161. * Gets or sets the position generator that will create the inital position of each particle.
  86162. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86163. */
  86164. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86165. /**
  86166. * Gets or sets the destination generator that will create the final destination of each particle.
  86167. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86168. */
  86169. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86170. /**
  86171. * Creates a new instance CustomParticleEmitter
  86172. */
  86173. constructor();
  86174. /**
  86175. * Called by the particle System when the direction is computed for the created particle.
  86176. * @param worldMatrix is the world matrix of the particle system
  86177. * @param directionToUpdate is the direction vector to update with the result
  86178. * @param particle is the particle we are computed the direction for
  86179. * @param isLocal defines if the direction should be set in local space
  86180. */
  86181. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86182. /**
  86183. * Called by the particle System when the position is computed for the created particle.
  86184. * @param worldMatrix is the world matrix of the particle system
  86185. * @param positionToUpdate is the position vector to update with the result
  86186. * @param particle is the particle we are computed the position for
  86187. * @param isLocal defines if the position should be set in local space
  86188. */
  86189. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86190. /**
  86191. * Clones the current emitter and returns a copy of it
  86192. * @returns the new emitter
  86193. */
  86194. clone(): CustomParticleEmitter;
  86195. /**
  86196. * Called by the GPUParticleSystem to setup the update shader
  86197. * @param effect defines the update shader
  86198. */
  86199. applyToShader(effect: Effect): void;
  86200. /**
  86201. * Returns a string to use to update the GPU particles update shader
  86202. * @returns a string containng the defines string
  86203. */
  86204. getEffectDefines(): string;
  86205. /**
  86206. * Returns the string "PointParticleEmitter"
  86207. * @returns a string containing the class name
  86208. */
  86209. getClassName(): string;
  86210. /**
  86211. * Serializes the particle system to a JSON object.
  86212. * @returns the JSON object
  86213. */
  86214. serialize(): any;
  86215. /**
  86216. * Parse properties from a JSON object
  86217. * @param serializationObject defines the JSON object
  86218. */
  86219. parse(serializationObject: any): void;
  86220. }
  86221. }
  86222. declare module BABYLON {
  86223. /**
  86224. * Particle emitter emitting particles from the inside of a box.
  86225. * It emits the particles randomly between 2 given directions.
  86226. */
  86227. export class MeshParticleEmitter implements IParticleEmitterType {
  86228. /** Defines the mesh to use as source */
  86229. mesh?: AbstractMesh | undefined;
  86230. private _indices;
  86231. private _positions;
  86232. private _normals;
  86233. private _storedNormal;
  86234. /**
  86235. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86236. */
  86237. direction1: Vector3;
  86238. /**
  86239. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86240. */
  86241. direction2: Vector3;
  86242. /**
  86243. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86244. */
  86245. useMeshNormalsForDirection: boolean;
  86246. /**
  86247. * Creates a new instance MeshParticleEmitter
  86248. * @param mesh defines the mesh to use as source
  86249. */
  86250. constructor(
  86251. /** Defines the mesh to use as source */
  86252. mesh?: AbstractMesh | undefined);
  86253. /**
  86254. * Called by the particle System when the direction is computed for the created particle.
  86255. * @param worldMatrix is the world matrix of the particle system
  86256. * @param directionToUpdate is the direction vector to update with the result
  86257. * @param particle is the particle we are computed the direction for
  86258. * @param isLocal defines if the direction should be set in local space
  86259. */
  86260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86261. /**
  86262. * Called by the particle System when the position is computed for the created particle.
  86263. * @param worldMatrix is the world matrix of the particle system
  86264. * @param positionToUpdate is the position vector to update with the result
  86265. * @param particle is the particle we are computed the position for
  86266. * @param isLocal defines if the position should be set in local space
  86267. */
  86268. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86269. /**
  86270. * Clones the current emitter and returns a copy of it
  86271. * @returns the new emitter
  86272. */
  86273. clone(): MeshParticleEmitter;
  86274. /**
  86275. * Called by the GPUParticleSystem to setup the update shader
  86276. * @param effect defines the update shader
  86277. */
  86278. applyToShader(effect: Effect): void;
  86279. /**
  86280. * Returns a string to use to update the GPU particles update shader
  86281. * @returns a string containng the defines string
  86282. */
  86283. getEffectDefines(): string;
  86284. /**
  86285. * Returns the string "BoxParticleEmitter"
  86286. * @returns a string containing the class name
  86287. */
  86288. getClassName(): string;
  86289. /**
  86290. * Serializes the particle system to a JSON object.
  86291. * @returns the JSON object
  86292. */
  86293. serialize(): any;
  86294. /**
  86295. * Parse properties from a JSON object
  86296. * @param serializationObject defines the JSON object
  86297. * @param scene defines the hosting scene
  86298. */
  86299. parse(serializationObject: any, scene: Scene): void;
  86300. }
  86301. }
  86302. declare module BABYLON {
  86303. /**
  86304. * Interface representing a particle system in Babylon.js.
  86305. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86306. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86307. */
  86308. export interface IParticleSystem {
  86309. /**
  86310. * List of animations used by the particle system.
  86311. */
  86312. animations: Animation[];
  86313. /**
  86314. * The id of the Particle system.
  86315. */
  86316. id: string;
  86317. /**
  86318. * The name of the Particle system.
  86319. */
  86320. name: string;
  86321. /**
  86322. * The emitter represents the Mesh or position we are attaching the particle system to.
  86323. */
  86324. emitter: Nullable<AbstractMesh | Vector3>;
  86325. /**
  86326. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86327. */
  86328. isBillboardBased: boolean;
  86329. /**
  86330. * The rendering group used by the Particle system to chose when to render.
  86331. */
  86332. renderingGroupId: number;
  86333. /**
  86334. * The layer mask we are rendering the particles through.
  86335. */
  86336. layerMask: number;
  86337. /**
  86338. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86339. */
  86340. updateSpeed: number;
  86341. /**
  86342. * The amount of time the particle system is running (depends of the overall update speed).
  86343. */
  86344. targetStopDuration: number;
  86345. /**
  86346. * The texture used to render each particle. (this can be a spritesheet)
  86347. */
  86348. particleTexture: Nullable<Texture>;
  86349. /**
  86350. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86351. */
  86352. blendMode: number;
  86353. /**
  86354. * Minimum life time of emitting particles.
  86355. */
  86356. minLifeTime: number;
  86357. /**
  86358. * Maximum life time of emitting particles.
  86359. */
  86360. maxLifeTime: number;
  86361. /**
  86362. * Minimum Size of emitting particles.
  86363. */
  86364. minSize: number;
  86365. /**
  86366. * Maximum Size of emitting particles.
  86367. */
  86368. maxSize: number;
  86369. /**
  86370. * Minimum scale of emitting particles on X axis.
  86371. */
  86372. minScaleX: number;
  86373. /**
  86374. * Maximum scale of emitting particles on X axis.
  86375. */
  86376. maxScaleX: number;
  86377. /**
  86378. * Minimum scale of emitting particles on Y axis.
  86379. */
  86380. minScaleY: number;
  86381. /**
  86382. * Maximum scale of emitting particles on Y axis.
  86383. */
  86384. maxScaleY: number;
  86385. /**
  86386. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86387. */
  86388. color1: Color4;
  86389. /**
  86390. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86391. */
  86392. color2: Color4;
  86393. /**
  86394. * Color the particle will have at the end of its lifetime.
  86395. */
  86396. colorDead: Color4;
  86397. /**
  86398. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86399. */
  86400. emitRate: number;
  86401. /**
  86402. * You can use gravity if you want to give an orientation to your particles.
  86403. */
  86404. gravity: Vector3;
  86405. /**
  86406. * Minimum power of emitting particles.
  86407. */
  86408. minEmitPower: number;
  86409. /**
  86410. * Maximum power of emitting particles.
  86411. */
  86412. maxEmitPower: number;
  86413. /**
  86414. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86415. */
  86416. minAngularSpeed: number;
  86417. /**
  86418. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86419. */
  86420. maxAngularSpeed: number;
  86421. /**
  86422. * Gets or sets the minimal initial rotation in radians.
  86423. */
  86424. minInitialRotation: number;
  86425. /**
  86426. * Gets or sets the maximal initial rotation in radians.
  86427. */
  86428. maxInitialRotation: number;
  86429. /**
  86430. * The particle emitter type defines the emitter used by the particle system.
  86431. * It can be for example box, sphere, or cone...
  86432. */
  86433. particleEmitterType: Nullable<IParticleEmitterType>;
  86434. /**
  86435. * Defines the delay in milliseconds before starting the system (0 by default)
  86436. */
  86437. startDelay: number;
  86438. /**
  86439. * 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
  86440. */
  86441. preWarmCycles: number;
  86442. /**
  86443. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86444. */
  86445. preWarmStepOffset: number;
  86446. /**
  86447. * 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)
  86448. */
  86449. spriteCellChangeSpeed: number;
  86450. /**
  86451. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86452. */
  86453. startSpriteCellID: number;
  86454. /**
  86455. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86456. */
  86457. endSpriteCellID: number;
  86458. /**
  86459. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86460. */
  86461. spriteCellWidth: number;
  86462. /**
  86463. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86464. */
  86465. spriteCellHeight: number;
  86466. /**
  86467. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86468. */
  86469. spriteRandomStartCell: boolean;
  86470. /**
  86471. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86472. */
  86473. isAnimationSheetEnabled: boolean;
  86474. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86475. translationPivot: Vector2;
  86476. /**
  86477. * Gets or sets a texture used to add random noise to particle positions
  86478. */
  86479. noiseTexture: Nullable<BaseTexture>;
  86480. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86481. noiseStrength: Vector3;
  86482. /**
  86483. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86484. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86485. */
  86486. billboardMode: number;
  86487. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86488. limitVelocityDamping: number;
  86489. /**
  86490. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86491. */
  86492. beginAnimationOnStart: boolean;
  86493. /**
  86494. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86495. */
  86496. beginAnimationFrom: number;
  86497. /**
  86498. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86499. */
  86500. beginAnimationTo: number;
  86501. /**
  86502. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86503. */
  86504. beginAnimationLoop: boolean;
  86505. /**
  86506. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86507. */
  86508. disposeOnStop: boolean;
  86509. /**
  86510. * Specifies if the particles are updated in emitter local space or world space
  86511. */
  86512. isLocal: boolean;
  86513. /**
  86514. * Gets the maximum number of particles active at the same time.
  86515. * @returns The max number of active particles.
  86516. */
  86517. getCapacity(): number;
  86518. /**
  86519. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86520. * @returns True if it has been started, otherwise false.
  86521. */
  86522. isStarted(): boolean;
  86523. /**
  86524. * Animates the particle system for this frame.
  86525. */
  86526. animate(): void;
  86527. /**
  86528. * Renders the particle system in its current state.
  86529. * @returns the current number of particles
  86530. */
  86531. render(): number;
  86532. /**
  86533. * Dispose the particle system and frees its associated resources.
  86534. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86535. */
  86536. dispose(disposeTexture?: boolean): void;
  86537. /**
  86538. * Clones the particle system.
  86539. * @param name The name of the cloned object
  86540. * @param newEmitter The new emitter to use
  86541. * @returns the cloned particle system
  86542. */
  86543. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86544. /**
  86545. * Serializes the particle system to a JSON object.
  86546. * @returns the JSON object
  86547. */
  86548. serialize(): any;
  86549. /**
  86550. * Rebuild the particle system
  86551. */
  86552. rebuild(): void;
  86553. /**
  86554. * Starts the particle system and begins to emit
  86555. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86556. */
  86557. start(delay?: number): void;
  86558. /**
  86559. * Stops the particle system.
  86560. */
  86561. stop(): void;
  86562. /**
  86563. * Remove all active particles
  86564. */
  86565. reset(): void;
  86566. /**
  86567. * Is this system ready to be used/rendered
  86568. * @return true if the system is ready
  86569. */
  86570. isReady(): boolean;
  86571. /**
  86572. * Returns the string "ParticleSystem"
  86573. * @returns a string containing the class name
  86574. */
  86575. getClassName(): string;
  86576. /**
  86577. * Adds a new color gradient
  86578. * @param gradient defines the gradient to use (between 0 and 1)
  86579. * @param color1 defines the color to affect to the specified gradient
  86580. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86581. * @returns the current particle system
  86582. */
  86583. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86584. /**
  86585. * Remove a specific color gradient
  86586. * @param gradient defines the gradient to remove
  86587. * @returns the current particle system
  86588. */
  86589. removeColorGradient(gradient: number): IParticleSystem;
  86590. /**
  86591. * Adds a new size gradient
  86592. * @param gradient defines the gradient to use (between 0 and 1)
  86593. * @param factor defines the size factor to affect to the specified gradient
  86594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86595. * @returns the current particle system
  86596. */
  86597. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86598. /**
  86599. * Remove a specific size gradient
  86600. * @param gradient defines the gradient to remove
  86601. * @returns the current particle system
  86602. */
  86603. removeSizeGradient(gradient: number): IParticleSystem;
  86604. /**
  86605. * Gets the current list of color gradients.
  86606. * You must use addColorGradient and removeColorGradient to udpate this list
  86607. * @returns the list of color gradients
  86608. */
  86609. getColorGradients(): Nullable<Array<ColorGradient>>;
  86610. /**
  86611. * Gets the current list of size gradients.
  86612. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86613. * @returns the list of size gradients
  86614. */
  86615. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86616. /**
  86617. * Gets the current list of angular speed gradients.
  86618. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86619. * @returns the list of angular speed gradients
  86620. */
  86621. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86622. /**
  86623. * Adds a new angular speed gradient
  86624. * @param gradient defines the gradient to use (between 0 and 1)
  86625. * @param factor defines the angular speed to affect to the specified gradient
  86626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86627. * @returns the current particle system
  86628. */
  86629. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86630. /**
  86631. * Remove a specific angular speed gradient
  86632. * @param gradient defines the gradient to remove
  86633. * @returns the current particle system
  86634. */
  86635. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86636. /**
  86637. * Gets the current list of velocity gradients.
  86638. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86639. * @returns the list of velocity gradients
  86640. */
  86641. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86642. /**
  86643. * Adds a new velocity gradient
  86644. * @param gradient defines the gradient to use (between 0 and 1)
  86645. * @param factor defines the velocity to affect to the specified gradient
  86646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86647. * @returns the current particle system
  86648. */
  86649. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86650. /**
  86651. * Remove a specific velocity gradient
  86652. * @param gradient defines the gradient to remove
  86653. * @returns the current particle system
  86654. */
  86655. removeVelocityGradient(gradient: number): IParticleSystem;
  86656. /**
  86657. * Gets the current list of limit velocity gradients.
  86658. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86659. * @returns the list of limit velocity gradients
  86660. */
  86661. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86662. /**
  86663. * Adds a new limit velocity gradient
  86664. * @param gradient defines the gradient to use (between 0 and 1)
  86665. * @param factor defines the limit velocity to affect to the specified gradient
  86666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86667. * @returns the current particle system
  86668. */
  86669. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86670. /**
  86671. * Remove a specific limit velocity gradient
  86672. * @param gradient defines the gradient to remove
  86673. * @returns the current particle system
  86674. */
  86675. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86676. /**
  86677. * Adds a new drag gradient
  86678. * @param gradient defines the gradient to use (between 0 and 1)
  86679. * @param factor defines the drag to affect to the specified gradient
  86680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86681. * @returns the current particle system
  86682. */
  86683. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86684. /**
  86685. * Remove a specific drag gradient
  86686. * @param gradient defines the gradient to remove
  86687. * @returns the current particle system
  86688. */
  86689. removeDragGradient(gradient: number): IParticleSystem;
  86690. /**
  86691. * Gets the current list of drag gradients.
  86692. * You must use addDragGradient and removeDragGradient to udpate this list
  86693. * @returns the list of drag gradients
  86694. */
  86695. getDragGradients(): Nullable<Array<FactorGradient>>;
  86696. /**
  86697. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86698. * @param gradient defines the gradient to use (between 0 and 1)
  86699. * @param factor defines the emit rate to affect to the specified gradient
  86700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86701. * @returns the current particle system
  86702. */
  86703. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86704. /**
  86705. * Remove a specific emit rate gradient
  86706. * @param gradient defines the gradient to remove
  86707. * @returns the current particle system
  86708. */
  86709. removeEmitRateGradient(gradient: number): IParticleSystem;
  86710. /**
  86711. * Gets the current list of emit rate gradients.
  86712. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86713. * @returns the list of emit rate gradients
  86714. */
  86715. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86716. /**
  86717. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86718. * @param gradient defines the gradient to use (between 0 and 1)
  86719. * @param factor defines the start size to affect to the specified gradient
  86720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86721. * @returns the current particle system
  86722. */
  86723. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86724. /**
  86725. * Remove a specific start size gradient
  86726. * @param gradient defines the gradient to remove
  86727. * @returns the current particle system
  86728. */
  86729. removeStartSizeGradient(gradient: number): IParticleSystem;
  86730. /**
  86731. * Gets the current list of start size gradients.
  86732. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86733. * @returns the list of start size gradients
  86734. */
  86735. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86736. /**
  86737. * Adds a new life time gradient
  86738. * @param gradient defines the gradient to use (between 0 and 1)
  86739. * @param factor defines the life time factor to affect to the specified gradient
  86740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86741. * @returns the current particle system
  86742. */
  86743. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86744. /**
  86745. * Remove a specific life time gradient
  86746. * @param gradient defines the gradient to remove
  86747. * @returns the current particle system
  86748. */
  86749. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86750. /**
  86751. * Gets the current list of life time gradients.
  86752. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86753. * @returns the list of life time gradients
  86754. */
  86755. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86756. /**
  86757. * Gets the current list of color gradients.
  86758. * You must use addColorGradient and removeColorGradient to udpate this list
  86759. * @returns the list of color gradients
  86760. */
  86761. getColorGradients(): Nullable<Array<ColorGradient>>;
  86762. /**
  86763. * Adds a new ramp gradient used to remap particle colors
  86764. * @param gradient defines the gradient to use (between 0 and 1)
  86765. * @param color defines the color to affect to the specified gradient
  86766. * @returns the current particle system
  86767. */
  86768. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86769. /**
  86770. * Gets the current list of ramp gradients.
  86771. * You must use addRampGradient and removeRampGradient to udpate this list
  86772. * @returns the list of ramp gradients
  86773. */
  86774. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86775. /** Gets or sets a boolean indicating that ramp gradients must be used
  86776. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86777. */
  86778. useRampGradients: boolean;
  86779. /**
  86780. * Adds a new color remap gradient
  86781. * @param gradient defines the gradient to use (between 0 and 1)
  86782. * @param min defines the color remap minimal range
  86783. * @param max defines the color remap maximal range
  86784. * @returns the current particle system
  86785. */
  86786. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86787. /**
  86788. * Gets the current list of color remap gradients.
  86789. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86790. * @returns the list of color remap gradients
  86791. */
  86792. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86793. /**
  86794. * Adds a new alpha remap gradient
  86795. * @param gradient defines the gradient to use (between 0 and 1)
  86796. * @param min defines the alpha remap minimal range
  86797. * @param max defines the alpha remap maximal range
  86798. * @returns the current particle system
  86799. */
  86800. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86801. /**
  86802. * Gets the current list of alpha remap gradients.
  86803. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86804. * @returns the list of alpha remap gradients
  86805. */
  86806. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86807. /**
  86808. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86809. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86810. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86811. * @returns the emitter
  86812. */
  86813. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86814. /**
  86815. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86816. * @param radius The radius of the hemisphere to emit from
  86817. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86818. * @returns the emitter
  86819. */
  86820. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86821. /**
  86822. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86823. * @param radius The radius of the sphere to emit from
  86824. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86825. * @returns the emitter
  86826. */
  86827. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86828. /**
  86829. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86830. * @param radius The radius of the sphere to emit from
  86831. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86832. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86833. * @returns the emitter
  86834. */
  86835. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86836. /**
  86837. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86838. * @param radius The radius of the emission cylinder
  86839. * @param height The height of the emission cylinder
  86840. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86841. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86842. * @returns the emitter
  86843. */
  86844. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86845. /**
  86846. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86847. * @param radius The radius of the cylinder to emit from
  86848. * @param height The height of the emission cylinder
  86849. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86850. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86851. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86852. * @returns the emitter
  86853. */
  86854. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86855. /**
  86856. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86857. * @param radius The radius of the cone to emit from
  86858. * @param angle The base angle of the cone
  86859. * @returns the emitter
  86860. */
  86861. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86862. /**
  86863. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86864. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86865. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86866. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86867. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86868. * @returns the emitter
  86869. */
  86870. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86871. /**
  86872. * Get hosting scene
  86873. * @returns the scene
  86874. */
  86875. getScene(): Scene;
  86876. }
  86877. }
  86878. declare module BABYLON {
  86879. /**
  86880. * 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.
  86881. * @see https://doc.babylonjs.com/how_to/transformnode
  86882. */
  86883. export class TransformNode extends Node {
  86884. /**
  86885. * Object will not rotate to face the camera
  86886. */
  86887. static BILLBOARDMODE_NONE: number;
  86888. /**
  86889. * Object will rotate to face the camera but only on the x axis
  86890. */
  86891. static BILLBOARDMODE_X: number;
  86892. /**
  86893. * Object will rotate to face the camera but only on the y axis
  86894. */
  86895. static BILLBOARDMODE_Y: number;
  86896. /**
  86897. * Object will rotate to face the camera but only on the z axis
  86898. */
  86899. static BILLBOARDMODE_Z: number;
  86900. /**
  86901. * Object will rotate to face the camera
  86902. */
  86903. static BILLBOARDMODE_ALL: number;
  86904. /**
  86905. * Object will rotate to face the camera's position instead of orientation
  86906. */
  86907. static BILLBOARDMODE_USE_POSITION: number;
  86908. private _forward;
  86909. private _forwardInverted;
  86910. private _up;
  86911. private _right;
  86912. private _rightInverted;
  86913. private _position;
  86914. private _rotation;
  86915. private _rotationQuaternion;
  86916. protected _scaling: Vector3;
  86917. protected _isDirty: boolean;
  86918. private _transformToBoneReferal;
  86919. private _isAbsoluteSynced;
  86920. private _billboardMode;
  86921. /**
  86922. * Gets or sets the billboard mode. Default is 0.
  86923. *
  86924. * | Value | Type | Description |
  86925. * | --- | --- | --- |
  86926. * | 0 | BILLBOARDMODE_NONE | |
  86927. * | 1 | BILLBOARDMODE_X | |
  86928. * | 2 | BILLBOARDMODE_Y | |
  86929. * | 4 | BILLBOARDMODE_Z | |
  86930. * | 7 | BILLBOARDMODE_ALL | |
  86931. *
  86932. */
  86933. get billboardMode(): number;
  86934. set billboardMode(value: number);
  86935. private _preserveParentRotationForBillboard;
  86936. /**
  86937. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86938. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86939. */
  86940. get preserveParentRotationForBillboard(): boolean;
  86941. set preserveParentRotationForBillboard(value: boolean);
  86942. /**
  86943. * 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
  86944. */
  86945. scalingDeterminant: number;
  86946. private _infiniteDistance;
  86947. /**
  86948. * Gets or sets the distance of the object to max, often used by skybox
  86949. */
  86950. get infiniteDistance(): boolean;
  86951. set infiniteDistance(value: boolean);
  86952. /**
  86953. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86954. * By default the system will update normals to compensate
  86955. */
  86956. ignoreNonUniformScaling: boolean;
  86957. /**
  86958. * 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
  86959. */
  86960. reIntegrateRotationIntoRotationQuaternion: boolean;
  86961. /** @hidden */
  86962. _poseMatrix: Nullable<Matrix>;
  86963. /** @hidden */
  86964. _localMatrix: Matrix;
  86965. private _usePivotMatrix;
  86966. private _absolutePosition;
  86967. private _absoluteScaling;
  86968. private _absoluteRotationQuaternion;
  86969. private _pivotMatrix;
  86970. private _pivotMatrixInverse;
  86971. protected _postMultiplyPivotMatrix: boolean;
  86972. protected _isWorldMatrixFrozen: boolean;
  86973. /** @hidden */
  86974. _indexInSceneTransformNodesArray: number;
  86975. /**
  86976. * An event triggered after the world matrix is updated
  86977. */
  86978. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86979. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86980. /**
  86981. * Gets a string identifying the name of the class
  86982. * @returns "TransformNode" string
  86983. */
  86984. getClassName(): string;
  86985. /**
  86986. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86987. */
  86988. get position(): Vector3;
  86989. set position(newPosition: Vector3);
  86990. /**
  86991. * 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)).
  86992. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86993. */
  86994. get rotation(): Vector3;
  86995. set rotation(newRotation: Vector3);
  86996. /**
  86997. * 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)).
  86998. */
  86999. get scaling(): Vector3;
  87000. set scaling(newScaling: Vector3);
  87001. /**
  87002. * 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).
  87003. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87004. */
  87005. get rotationQuaternion(): Nullable<Quaternion>;
  87006. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87007. /**
  87008. * The forward direction of that transform in world space.
  87009. */
  87010. get forward(): Vector3;
  87011. /**
  87012. * The up direction of that transform in world space.
  87013. */
  87014. get up(): Vector3;
  87015. /**
  87016. * The right direction of that transform in world space.
  87017. */
  87018. get right(): Vector3;
  87019. /**
  87020. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87021. * @param matrix the matrix to copy the pose from
  87022. * @returns this TransformNode.
  87023. */
  87024. updatePoseMatrix(matrix: Matrix): TransformNode;
  87025. /**
  87026. * Returns the mesh Pose matrix.
  87027. * @returns the pose matrix
  87028. */
  87029. getPoseMatrix(): Matrix;
  87030. /** @hidden */
  87031. _isSynchronized(): boolean;
  87032. /** @hidden */
  87033. _initCache(): void;
  87034. /**
  87035. * Flag the transform node as dirty (Forcing it to update everything)
  87036. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87037. * @returns this transform node
  87038. */
  87039. markAsDirty(property: string): TransformNode;
  87040. /**
  87041. * Returns the current mesh absolute position.
  87042. * Returns a Vector3.
  87043. */
  87044. get absolutePosition(): Vector3;
  87045. /**
  87046. * Returns the current mesh absolute scaling.
  87047. * Returns a Vector3.
  87048. */
  87049. get absoluteScaling(): Vector3;
  87050. /**
  87051. * Returns the current mesh absolute rotation.
  87052. * Returns a Quaternion.
  87053. */
  87054. get absoluteRotationQuaternion(): Quaternion;
  87055. /**
  87056. * Sets a new matrix to apply before all other transformation
  87057. * @param matrix defines the transform matrix
  87058. * @returns the current TransformNode
  87059. */
  87060. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87061. /**
  87062. * Sets a new pivot matrix to the current node
  87063. * @param matrix defines the new pivot matrix to use
  87064. * @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
  87065. * @returns the current TransformNode
  87066. */
  87067. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87068. /**
  87069. * Returns the mesh pivot matrix.
  87070. * Default : Identity.
  87071. * @returns the matrix
  87072. */
  87073. getPivotMatrix(): Matrix;
  87074. /**
  87075. * Instantiate (when possible) or clone that node with its hierarchy
  87076. * @param newParent defines the new parent to use for the instance (or clone)
  87077. * @param options defines options to configure how copy is done
  87078. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87079. * @returns an instance (or a clone) of the current node with its hiearchy
  87080. */
  87081. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87082. doNotInstantiate: boolean;
  87083. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87084. /**
  87085. * Prevents the World matrix to be computed any longer
  87086. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87087. * @returns the TransformNode.
  87088. */
  87089. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87090. /**
  87091. * Allows back the World matrix computation.
  87092. * @returns the TransformNode.
  87093. */
  87094. unfreezeWorldMatrix(): this;
  87095. /**
  87096. * True if the World matrix has been frozen.
  87097. */
  87098. get isWorldMatrixFrozen(): boolean;
  87099. /**
  87100. * Retuns the mesh absolute position in the World.
  87101. * @returns a Vector3.
  87102. */
  87103. getAbsolutePosition(): Vector3;
  87104. /**
  87105. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87106. * @param absolutePosition the absolute position to set
  87107. * @returns the TransformNode.
  87108. */
  87109. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87110. /**
  87111. * Sets the mesh position in its local space.
  87112. * @param vector3 the position to set in localspace
  87113. * @returns the TransformNode.
  87114. */
  87115. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87116. /**
  87117. * Returns the mesh position in the local space from the current World matrix values.
  87118. * @returns a new Vector3.
  87119. */
  87120. getPositionExpressedInLocalSpace(): Vector3;
  87121. /**
  87122. * Translates the mesh along the passed Vector3 in its local space.
  87123. * @param vector3 the distance to translate in localspace
  87124. * @returns the TransformNode.
  87125. */
  87126. locallyTranslate(vector3: Vector3): TransformNode;
  87127. private static _lookAtVectorCache;
  87128. /**
  87129. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87130. * @param targetPoint the position (must be in same space as current mesh) to look at
  87131. * @param yawCor optional yaw (y-axis) correction in radians
  87132. * @param pitchCor optional pitch (x-axis) correction in radians
  87133. * @param rollCor optional roll (z-axis) correction in radians
  87134. * @param space the choosen space of the target
  87135. * @returns the TransformNode.
  87136. */
  87137. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87138. /**
  87139. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87140. * This Vector3 is expressed in the World space.
  87141. * @param localAxis axis to rotate
  87142. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87143. */
  87144. getDirection(localAxis: Vector3): Vector3;
  87145. /**
  87146. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87147. * localAxis is expressed in the mesh local space.
  87148. * result is computed in the Wordl space from the mesh World matrix.
  87149. * @param localAxis axis to rotate
  87150. * @param result the resulting transformnode
  87151. * @returns this TransformNode.
  87152. */
  87153. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87154. /**
  87155. * Sets this transform node rotation to the given local axis.
  87156. * @param localAxis the axis in local space
  87157. * @param yawCor optional yaw (y-axis) correction in radians
  87158. * @param pitchCor optional pitch (x-axis) correction in radians
  87159. * @param rollCor optional roll (z-axis) correction in radians
  87160. * @returns this TransformNode
  87161. */
  87162. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87163. /**
  87164. * Sets a new pivot point to the current node
  87165. * @param point defines the new pivot point to use
  87166. * @param space defines if the point is in world or local space (local by default)
  87167. * @returns the current TransformNode
  87168. */
  87169. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87170. /**
  87171. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87172. * @returns the pivot point
  87173. */
  87174. getPivotPoint(): Vector3;
  87175. /**
  87176. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87177. * @param result the vector3 to store the result
  87178. * @returns this TransformNode.
  87179. */
  87180. getPivotPointToRef(result: Vector3): TransformNode;
  87181. /**
  87182. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87183. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87184. */
  87185. getAbsolutePivotPoint(): Vector3;
  87186. /**
  87187. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87188. * @param result vector3 to store the result
  87189. * @returns this TransformNode.
  87190. */
  87191. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87192. /**
  87193. * Defines the passed node as the parent of the current node.
  87194. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87195. * @see https://doc.babylonjs.com/how_to/parenting
  87196. * @param node the node ot set as the parent
  87197. * @returns this TransformNode.
  87198. */
  87199. setParent(node: Nullable<Node>): TransformNode;
  87200. private _nonUniformScaling;
  87201. /**
  87202. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87203. */
  87204. get nonUniformScaling(): boolean;
  87205. /** @hidden */
  87206. _updateNonUniformScalingState(value: boolean): boolean;
  87207. /**
  87208. * Attach the current TransformNode to another TransformNode associated with a bone
  87209. * @param bone Bone affecting the TransformNode
  87210. * @param affectedTransformNode TransformNode associated with the bone
  87211. * @returns this object
  87212. */
  87213. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87214. /**
  87215. * Detach the transform node if its associated with a bone
  87216. * @returns this object
  87217. */
  87218. detachFromBone(): TransformNode;
  87219. private static _rotationAxisCache;
  87220. /**
  87221. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87222. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87223. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87224. * The passed axis is also normalized.
  87225. * @param axis the axis to rotate around
  87226. * @param amount the amount to rotate in radians
  87227. * @param space Space to rotate in (Default: local)
  87228. * @returns the TransformNode.
  87229. */
  87230. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87231. /**
  87232. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87233. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87234. * The passed axis is also normalized. .
  87235. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87236. * @param point the point to rotate around
  87237. * @param axis the axis to rotate around
  87238. * @param amount the amount to rotate in radians
  87239. * @returns the TransformNode
  87240. */
  87241. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87242. /**
  87243. * Translates the mesh along the axis vector for the passed distance in the given space.
  87244. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87245. * @param axis the axis to translate in
  87246. * @param distance the distance to translate
  87247. * @param space Space to rotate in (Default: local)
  87248. * @returns the TransformNode.
  87249. */
  87250. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87251. /**
  87252. * Adds a rotation step to the mesh current rotation.
  87253. * x, y, z are Euler angles expressed in radians.
  87254. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87255. * This means this rotation is made in the mesh local space only.
  87256. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87257. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87258. * ```javascript
  87259. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87260. * ```
  87261. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87262. * 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.
  87263. * @param x Rotation to add
  87264. * @param y Rotation to add
  87265. * @param z Rotation to add
  87266. * @returns the TransformNode.
  87267. */
  87268. addRotation(x: number, y: number, z: number): TransformNode;
  87269. /**
  87270. * @hidden
  87271. */
  87272. protected _getEffectiveParent(): Nullable<Node>;
  87273. /**
  87274. * Computes the world matrix of the node
  87275. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87276. * @returns the world matrix
  87277. */
  87278. computeWorldMatrix(force?: boolean): Matrix;
  87279. /**
  87280. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87281. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87282. */
  87283. resetLocalMatrix(independentOfChildren?: boolean): void;
  87284. protected _afterComputeWorldMatrix(): void;
  87285. /**
  87286. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87287. * @param func callback function to add
  87288. *
  87289. * @returns the TransformNode.
  87290. */
  87291. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87292. /**
  87293. * Removes a registered callback function.
  87294. * @param func callback function to remove
  87295. * @returns the TransformNode.
  87296. */
  87297. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87298. /**
  87299. * Gets the position of the current mesh in camera space
  87300. * @param camera defines the camera to use
  87301. * @returns a position
  87302. */
  87303. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87304. /**
  87305. * Returns the distance from the mesh to the active camera
  87306. * @param camera defines the camera to use
  87307. * @returns the distance
  87308. */
  87309. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87310. /**
  87311. * Clone the current transform node
  87312. * @param name Name of the new clone
  87313. * @param newParent New parent for the clone
  87314. * @param doNotCloneChildren Do not clone children hierarchy
  87315. * @returns the new transform node
  87316. */
  87317. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87318. /**
  87319. * Serializes the objects information.
  87320. * @param currentSerializationObject defines the object to serialize in
  87321. * @returns the serialized object
  87322. */
  87323. serialize(currentSerializationObject?: any): any;
  87324. /**
  87325. * Returns a new TransformNode object parsed from the source provided.
  87326. * @param parsedTransformNode is the source.
  87327. * @param scene the scne the object belongs to
  87328. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87329. * @returns a new TransformNode object parsed from the source provided.
  87330. */
  87331. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87332. /**
  87333. * Get all child-transformNodes of this node
  87334. * @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
  87335. * @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
  87336. * @returns an array of TransformNode
  87337. */
  87338. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87339. /**
  87340. * Releases resources associated with this transform node.
  87341. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87342. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87343. */
  87344. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87345. /**
  87346. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87347. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87348. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87349. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87350. * @returns the current mesh
  87351. */
  87352. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87353. private _syncAbsoluteScalingAndRotation;
  87354. }
  87355. }
  87356. declare module BABYLON {
  87357. /**
  87358. * Class used to override all child animations of a given target
  87359. */
  87360. export class AnimationPropertiesOverride {
  87361. /**
  87362. * Gets or sets a value indicating if animation blending must be used
  87363. */
  87364. enableBlending: boolean;
  87365. /**
  87366. * Gets or sets the blending speed to use when enableBlending is true
  87367. */
  87368. blendingSpeed: number;
  87369. /**
  87370. * Gets or sets the default loop mode to use
  87371. */
  87372. loopMode: number;
  87373. }
  87374. }
  87375. declare module BABYLON {
  87376. /**
  87377. * Class used to store bone information
  87378. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87379. */
  87380. export class Bone extends Node {
  87381. /**
  87382. * defines the bone name
  87383. */
  87384. name: string;
  87385. private static _tmpVecs;
  87386. private static _tmpQuat;
  87387. private static _tmpMats;
  87388. /**
  87389. * Gets the list of child bones
  87390. */
  87391. children: Bone[];
  87392. /** Gets the animations associated with this bone */
  87393. animations: Animation[];
  87394. /**
  87395. * Gets or sets bone length
  87396. */
  87397. length: number;
  87398. /**
  87399. * @hidden Internal only
  87400. * Set this value to map this bone to a different index in the transform matrices
  87401. * Set this value to -1 to exclude the bone from the transform matrices
  87402. */
  87403. _index: Nullable<number>;
  87404. private _skeleton;
  87405. private _localMatrix;
  87406. private _restPose;
  87407. private _baseMatrix;
  87408. private _absoluteTransform;
  87409. private _invertedAbsoluteTransform;
  87410. private _parent;
  87411. private _scalingDeterminant;
  87412. private _worldTransform;
  87413. private _localScaling;
  87414. private _localRotation;
  87415. private _localPosition;
  87416. private _needToDecompose;
  87417. private _needToCompose;
  87418. /** @hidden */
  87419. _linkedTransformNode: Nullable<TransformNode>;
  87420. /** @hidden */
  87421. _waitingTransformNodeId: Nullable<string>;
  87422. /** @hidden */
  87423. get _matrix(): Matrix;
  87424. /** @hidden */
  87425. set _matrix(value: Matrix);
  87426. /**
  87427. * Create a new bone
  87428. * @param name defines the bone name
  87429. * @param skeleton defines the parent skeleton
  87430. * @param parentBone defines the parent (can be null if the bone is the root)
  87431. * @param localMatrix defines the local matrix
  87432. * @param restPose defines the rest pose matrix
  87433. * @param baseMatrix defines the base matrix
  87434. * @param index defines index of the bone in the hiearchy
  87435. */
  87436. constructor(
  87437. /**
  87438. * defines the bone name
  87439. */
  87440. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87441. /**
  87442. * Gets the current object class name.
  87443. * @return the class name
  87444. */
  87445. getClassName(): string;
  87446. /**
  87447. * Gets the parent skeleton
  87448. * @returns a skeleton
  87449. */
  87450. getSkeleton(): Skeleton;
  87451. /**
  87452. * Gets parent bone
  87453. * @returns a bone or null if the bone is the root of the bone hierarchy
  87454. */
  87455. getParent(): Nullable<Bone>;
  87456. /**
  87457. * Returns an array containing the root bones
  87458. * @returns an array containing the root bones
  87459. */
  87460. getChildren(): Array<Bone>;
  87461. /**
  87462. * Gets the node index in matrix array generated for rendering
  87463. * @returns the node index
  87464. */
  87465. getIndex(): number;
  87466. /**
  87467. * Sets the parent bone
  87468. * @param parent defines the parent (can be null if the bone is the root)
  87469. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87470. */
  87471. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87472. /**
  87473. * Gets the local matrix
  87474. * @returns a matrix
  87475. */
  87476. getLocalMatrix(): Matrix;
  87477. /**
  87478. * Gets the base matrix (initial matrix which remains unchanged)
  87479. * @returns a matrix
  87480. */
  87481. getBaseMatrix(): Matrix;
  87482. /**
  87483. * Gets the rest pose matrix
  87484. * @returns a matrix
  87485. */
  87486. getRestPose(): Matrix;
  87487. /**
  87488. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87489. */
  87490. getWorldMatrix(): Matrix;
  87491. /**
  87492. * Sets the local matrix to rest pose matrix
  87493. */
  87494. returnToRest(): void;
  87495. /**
  87496. * Gets the inverse of the absolute transform matrix.
  87497. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87498. * @returns a matrix
  87499. */
  87500. getInvertedAbsoluteTransform(): Matrix;
  87501. /**
  87502. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87503. * @returns a matrix
  87504. */
  87505. getAbsoluteTransform(): Matrix;
  87506. /**
  87507. * Links with the given transform node.
  87508. * The local matrix of this bone is copied from the transform node every frame.
  87509. * @param transformNode defines the transform node to link to
  87510. */
  87511. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87512. /**
  87513. * Gets the node used to drive the bone's transformation
  87514. * @returns a transform node or null
  87515. */
  87516. getTransformNode(): Nullable<TransformNode>;
  87517. /** Gets or sets current position (in local space) */
  87518. get position(): Vector3;
  87519. set position(newPosition: Vector3);
  87520. /** Gets or sets current rotation (in local space) */
  87521. get rotation(): Vector3;
  87522. set rotation(newRotation: Vector3);
  87523. /** Gets or sets current rotation quaternion (in local space) */
  87524. get rotationQuaternion(): Quaternion;
  87525. set rotationQuaternion(newRotation: Quaternion);
  87526. /** Gets or sets current scaling (in local space) */
  87527. get scaling(): Vector3;
  87528. set scaling(newScaling: Vector3);
  87529. /**
  87530. * Gets the animation properties override
  87531. */
  87532. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87533. private _decompose;
  87534. private _compose;
  87535. /**
  87536. * Update the base and local matrices
  87537. * @param matrix defines the new base or local matrix
  87538. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87539. * @param updateLocalMatrix defines if the local matrix should be updated
  87540. */
  87541. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87542. /** @hidden */
  87543. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87544. /**
  87545. * Flag the bone as dirty (Forcing it to update everything)
  87546. */
  87547. markAsDirty(): void;
  87548. /** @hidden */
  87549. _markAsDirtyAndCompose(): void;
  87550. private _markAsDirtyAndDecompose;
  87551. /**
  87552. * Translate the bone in local or world space
  87553. * @param vec The amount to translate the bone
  87554. * @param space The space that the translation is in
  87555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87556. */
  87557. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87558. /**
  87559. * Set the postion of the bone in local or world space
  87560. * @param position The position to set the bone
  87561. * @param space The space that the position is in
  87562. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87563. */
  87564. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87565. /**
  87566. * Set the absolute position of the bone (world space)
  87567. * @param position The position to set the bone
  87568. * @param mesh The mesh that this bone is attached to
  87569. */
  87570. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87571. /**
  87572. * Scale the bone on the x, y and z axes (in local space)
  87573. * @param x The amount to scale the bone on the x axis
  87574. * @param y The amount to scale the bone on the y axis
  87575. * @param z The amount to scale the bone on the z axis
  87576. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87577. */
  87578. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87579. /**
  87580. * Set the bone scaling in local space
  87581. * @param scale defines the scaling vector
  87582. */
  87583. setScale(scale: Vector3): void;
  87584. /**
  87585. * Gets the current scaling in local space
  87586. * @returns the current scaling vector
  87587. */
  87588. getScale(): Vector3;
  87589. /**
  87590. * Gets the current scaling in local space and stores it in a target vector
  87591. * @param result defines the target vector
  87592. */
  87593. getScaleToRef(result: Vector3): void;
  87594. /**
  87595. * Set the yaw, pitch, and roll of the bone in local or world space
  87596. * @param yaw The rotation of the bone on the y axis
  87597. * @param pitch The rotation of the bone on the x axis
  87598. * @param roll The rotation of the bone on the z axis
  87599. * @param space The space that the axes of rotation are in
  87600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87601. */
  87602. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87603. /**
  87604. * Add a rotation to the bone on an axis in local or world space
  87605. * @param axis The axis to rotate the bone on
  87606. * @param amount The amount to rotate the bone
  87607. * @param space The space that the axis is in
  87608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87609. */
  87610. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87611. /**
  87612. * Set the rotation of the bone to a particular axis angle in local or world space
  87613. * @param axis The axis to rotate the bone on
  87614. * @param angle The angle that the bone should be rotated to
  87615. * @param space The space that the axis is in
  87616. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87617. */
  87618. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87619. /**
  87620. * Set the euler rotation of the bone in local of world space
  87621. * @param rotation The euler rotation that the bone should be set to
  87622. * @param space The space that the rotation is in
  87623. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87624. */
  87625. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87626. /**
  87627. * Set the quaternion rotation of the bone in local of world space
  87628. * @param quat The quaternion rotation that the bone should be set to
  87629. * @param space The space that the rotation is in
  87630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87631. */
  87632. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87633. /**
  87634. * Set the rotation matrix of the bone in local of world space
  87635. * @param rotMat The rotation matrix that the bone should be set to
  87636. * @param space The space that the rotation is in
  87637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87638. */
  87639. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87640. private _rotateWithMatrix;
  87641. private _getNegativeRotationToRef;
  87642. /**
  87643. * Get the position of the bone in local or world space
  87644. * @param space The space that the returned position is in
  87645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87646. * @returns The position of the bone
  87647. */
  87648. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87649. /**
  87650. * Copy the position of the bone to a vector3 in local or world space
  87651. * @param space The space that the returned position is in
  87652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87653. * @param result The vector3 to copy the position to
  87654. */
  87655. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87656. /**
  87657. * Get the absolute position of the bone (world space)
  87658. * @param mesh The mesh that this bone is attached to
  87659. * @returns The absolute position of the bone
  87660. */
  87661. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87662. /**
  87663. * Copy the absolute position of the bone (world space) to the result param
  87664. * @param mesh The mesh that this bone is attached to
  87665. * @param result The vector3 to copy the absolute position to
  87666. */
  87667. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87668. /**
  87669. * Compute the absolute transforms of this bone and its children
  87670. */
  87671. computeAbsoluteTransforms(): void;
  87672. /**
  87673. * Get the world direction from an axis that is in the local space of the bone
  87674. * @param localAxis The local direction that is used to compute the world direction
  87675. * @param mesh The mesh that this bone is attached to
  87676. * @returns The world direction
  87677. */
  87678. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87679. /**
  87680. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87681. * @param localAxis The local direction that is used to compute the world direction
  87682. * @param mesh The mesh that this bone is attached to
  87683. * @param result The vector3 that the world direction will be copied to
  87684. */
  87685. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87686. /**
  87687. * Get the euler rotation of the bone in local or world space
  87688. * @param space The space that the rotation should be in
  87689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87690. * @returns The euler rotation
  87691. */
  87692. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87693. /**
  87694. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87695. * @param space The space that the rotation should be in
  87696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87697. * @param result The vector3 that the rotation should be copied to
  87698. */
  87699. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87700. /**
  87701. * Get the quaternion rotation of the bone in either local or world space
  87702. * @param space The space that the rotation should be in
  87703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87704. * @returns The quaternion rotation
  87705. */
  87706. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87707. /**
  87708. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87709. * @param space The space that the rotation should be in
  87710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87711. * @param result The quaternion that the rotation should be copied to
  87712. */
  87713. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87714. /**
  87715. * Get the rotation matrix of the bone in local or world space
  87716. * @param space The space that the rotation should be in
  87717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87718. * @returns The rotation matrix
  87719. */
  87720. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87721. /**
  87722. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87723. * @param space The space that the rotation should be in
  87724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87725. * @param result The quaternion that the rotation should be copied to
  87726. */
  87727. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87728. /**
  87729. * Get the world position of a point that is in the local space of the bone
  87730. * @param position The local position
  87731. * @param mesh The mesh that this bone is attached to
  87732. * @returns The world position
  87733. */
  87734. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87735. /**
  87736. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87737. * @param position The local position
  87738. * @param mesh The mesh that this bone is attached to
  87739. * @param result The vector3 that the world position should be copied to
  87740. */
  87741. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87742. /**
  87743. * Get the local position of a point that is in world space
  87744. * @param position The world position
  87745. * @param mesh The mesh that this bone is attached to
  87746. * @returns The local position
  87747. */
  87748. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87749. /**
  87750. * Get the local position of a point that is in world space and copy it to the result param
  87751. * @param position The world position
  87752. * @param mesh The mesh that this bone is attached to
  87753. * @param result The vector3 that the local position should be copied to
  87754. */
  87755. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87756. }
  87757. }
  87758. declare module BABYLON {
  87759. /**
  87760. * Defines a runtime animation
  87761. */
  87762. export class RuntimeAnimation {
  87763. private _events;
  87764. /**
  87765. * The current frame of the runtime animation
  87766. */
  87767. private _currentFrame;
  87768. /**
  87769. * The animation used by the runtime animation
  87770. */
  87771. private _animation;
  87772. /**
  87773. * The target of the runtime animation
  87774. */
  87775. private _target;
  87776. /**
  87777. * The initiating animatable
  87778. */
  87779. private _host;
  87780. /**
  87781. * The original value of the runtime animation
  87782. */
  87783. private _originalValue;
  87784. /**
  87785. * The original blend value of the runtime animation
  87786. */
  87787. private _originalBlendValue;
  87788. /**
  87789. * The offsets cache of the runtime animation
  87790. */
  87791. private _offsetsCache;
  87792. /**
  87793. * The high limits cache of the runtime animation
  87794. */
  87795. private _highLimitsCache;
  87796. /**
  87797. * Specifies if the runtime animation has been stopped
  87798. */
  87799. private _stopped;
  87800. /**
  87801. * The blending factor of the runtime animation
  87802. */
  87803. private _blendingFactor;
  87804. /**
  87805. * The BabylonJS scene
  87806. */
  87807. private _scene;
  87808. /**
  87809. * The current value of the runtime animation
  87810. */
  87811. private _currentValue;
  87812. /** @hidden */
  87813. _animationState: _IAnimationState;
  87814. /**
  87815. * The active target of the runtime animation
  87816. */
  87817. private _activeTargets;
  87818. private _currentActiveTarget;
  87819. private _directTarget;
  87820. /**
  87821. * The target path of the runtime animation
  87822. */
  87823. private _targetPath;
  87824. /**
  87825. * The weight of the runtime animation
  87826. */
  87827. private _weight;
  87828. /**
  87829. * The ratio offset of the runtime animation
  87830. */
  87831. private _ratioOffset;
  87832. /**
  87833. * The previous delay of the runtime animation
  87834. */
  87835. private _previousDelay;
  87836. /**
  87837. * The previous ratio of the runtime animation
  87838. */
  87839. private _previousRatio;
  87840. private _enableBlending;
  87841. private _keys;
  87842. private _minFrame;
  87843. private _maxFrame;
  87844. private _minValue;
  87845. private _maxValue;
  87846. private _targetIsArray;
  87847. /**
  87848. * Gets the current frame of the runtime animation
  87849. */
  87850. get currentFrame(): number;
  87851. /**
  87852. * Gets the weight of the runtime animation
  87853. */
  87854. get weight(): number;
  87855. /**
  87856. * Gets the current value of the runtime animation
  87857. */
  87858. get currentValue(): any;
  87859. /**
  87860. * Gets the target path of the runtime animation
  87861. */
  87862. get targetPath(): string;
  87863. /**
  87864. * Gets the actual target of the runtime animation
  87865. */
  87866. get target(): any;
  87867. /** @hidden */
  87868. _onLoop: () => void;
  87869. /**
  87870. * Create a new RuntimeAnimation object
  87871. * @param target defines the target of the animation
  87872. * @param animation defines the source animation object
  87873. * @param scene defines the hosting scene
  87874. * @param host defines the initiating Animatable
  87875. */
  87876. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87877. private _preparePath;
  87878. /**
  87879. * Gets the animation from the runtime animation
  87880. */
  87881. get animation(): Animation;
  87882. /**
  87883. * Resets the runtime animation to the beginning
  87884. * @param restoreOriginal defines whether to restore the target property to the original value
  87885. */
  87886. reset(restoreOriginal?: boolean): void;
  87887. /**
  87888. * Specifies if the runtime animation is stopped
  87889. * @returns Boolean specifying if the runtime animation is stopped
  87890. */
  87891. isStopped(): boolean;
  87892. /**
  87893. * Disposes of the runtime animation
  87894. */
  87895. dispose(): void;
  87896. /**
  87897. * Apply the interpolated value to the target
  87898. * @param currentValue defines the value computed by the animation
  87899. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87900. */
  87901. setValue(currentValue: any, weight: number): void;
  87902. private _getOriginalValues;
  87903. private _setValue;
  87904. /**
  87905. * Gets the loop pmode of the runtime animation
  87906. * @returns Loop Mode
  87907. */
  87908. private _getCorrectLoopMode;
  87909. /**
  87910. * Move the current animation to a given frame
  87911. * @param frame defines the frame to move to
  87912. */
  87913. goToFrame(frame: number): void;
  87914. /**
  87915. * @hidden Internal use only
  87916. */
  87917. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87918. /**
  87919. * Execute the current animation
  87920. * @param delay defines the delay to add to the current frame
  87921. * @param from defines the lower bound of the animation range
  87922. * @param to defines the upper bound of the animation range
  87923. * @param loop defines if the current animation must loop
  87924. * @param speedRatio defines the current speed ratio
  87925. * @param weight defines the weight of the animation (default is -1 so no weight)
  87926. * @param onLoop optional callback called when animation loops
  87927. * @returns a boolean indicating if the animation is running
  87928. */
  87929. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87930. }
  87931. }
  87932. declare module BABYLON {
  87933. /**
  87934. * Class used to store an actual running animation
  87935. */
  87936. export class Animatable {
  87937. /** defines the target object */
  87938. target: any;
  87939. /** defines the starting frame number (default is 0) */
  87940. fromFrame: number;
  87941. /** defines the ending frame number (default is 100) */
  87942. toFrame: number;
  87943. /** defines if the animation must loop (default is false) */
  87944. loopAnimation: boolean;
  87945. /** defines a callback to call when animation ends if it is not looping */
  87946. onAnimationEnd?: (() => void) | null | undefined;
  87947. /** defines a callback to call when animation loops */
  87948. onAnimationLoop?: (() => void) | null | undefined;
  87949. private _localDelayOffset;
  87950. private _pausedDelay;
  87951. private _runtimeAnimations;
  87952. private _paused;
  87953. private _scene;
  87954. private _speedRatio;
  87955. private _weight;
  87956. private _syncRoot;
  87957. /**
  87958. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87959. * This will only apply for non looping animation (default is true)
  87960. */
  87961. disposeOnEnd: boolean;
  87962. /**
  87963. * Gets a boolean indicating if the animation has started
  87964. */
  87965. animationStarted: boolean;
  87966. /**
  87967. * Observer raised when the animation ends
  87968. */
  87969. onAnimationEndObservable: Observable<Animatable>;
  87970. /**
  87971. * Observer raised when the animation loops
  87972. */
  87973. onAnimationLoopObservable: Observable<Animatable>;
  87974. /**
  87975. * Gets the root Animatable used to synchronize and normalize animations
  87976. */
  87977. get syncRoot(): Nullable<Animatable>;
  87978. /**
  87979. * Gets the current frame of the first RuntimeAnimation
  87980. * Used to synchronize Animatables
  87981. */
  87982. get masterFrame(): number;
  87983. /**
  87984. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87985. */
  87986. get weight(): number;
  87987. set weight(value: number);
  87988. /**
  87989. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87990. */
  87991. get speedRatio(): number;
  87992. set speedRatio(value: number);
  87993. /**
  87994. * Creates a new Animatable
  87995. * @param scene defines the hosting scene
  87996. * @param target defines the target object
  87997. * @param fromFrame defines the starting frame number (default is 0)
  87998. * @param toFrame defines the ending frame number (default is 100)
  87999. * @param loopAnimation defines if the animation must loop (default is false)
  88000. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88001. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88002. * @param animations defines a group of animation to add to the new Animatable
  88003. * @param onAnimationLoop defines a callback to call when animation loops
  88004. */
  88005. constructor(scene: Scene,
  88006. /** defines the target object */
  88007. target: any,
  88008. /** defines the starting frame number (default is 0) */
  88009. fromFrame?: number,
  88010. /** defines the ending frame number (default is 100) */
  88011. toFrame?: number,
  88012. /** defines if the animation must loop (default is false) */
  88013. loopAnimation?: boolean, speedRatio?: number,
  88014. /** defines a callback to call when animation ends if it is not looping */
  88015. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  88016. /** defines a callback to call when animation loops */
  88017. onAnimationLoop?: (() => void) | null | undefined);
  88018. /**
  88019. * Synchronize and normalize current Animatable with a source Animatable
  88020. * This is useful when using animation weights and when animations are not of the same length
  88021. * @param root defines the root Animatable to synchronize with
  88022. * @returns the current Animatable
  88023. */
  88024. syncWith(root: Animatable): Animatable;
  88025. /**
  88026. * Gets the list of runtime animations
  88027. * @returns an array of RuntimeAnimation
  88028. */
  88029. getAnimations(): RuntimeAnimation[];
  88030. /**
  88031. * Adds more animations to the current animatable
  88032. * @param target defines the target of the animations
  88033. * @param animations defines the new animations to add
  88034. */
  88035. appendAnimations(target: any, animations: Animation[]): void;
  88036. /**
  88037. * Gets the source animation for a specific property
  88038. * @param property defines the propertyu to look for
  88039. * @returns null or the source animation for the given property
  88040. */
  88041. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  88042. /**
  88043. * Gets the runtime animation for a specific property
  88044. * @param property defines the propertyu to look for
  88045. * @returns null or the runtime animation for the given property
  88046. */
  88047. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  88048. /**
  88049. * Resets the animatable to its original state
  88050. */
  88051. reset(): void;
  88052. /**
  88053. * Allows the animatable to blend with current running animations
  88054. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88055. * @param blendingSpeed defines the blending speed to use
  88056. */
  88057. enableBlending(blendingSpeed: number): void;
  88058. /**
  88059. * Disable animation blending
  88060. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88061. */
  88062. disableBlending(): void;
  88063. /**
  88064. * Jump directly to a given frame
  88065. * @param frame defines the frame to jump to
  88066. */
  88067. goToFrame(frame: number): void;
  88068. /**
  88069. * Pause the animation
  88070. */
  88071. pause(): void;
  88072. /**
  88073. * Restart the animation
  88074. */
  88075. restart(): void;
  88076. private _raiseOnAnimationEnd;
  88077. /**
  88078. * Stop and delete the current animation
  88079. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  88080. * @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)
  88081. */
  88082. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  88083. /**
  88084. * Wait asynchronously for the animation to end
  88085. * @returns a promise which will be fullfilled when the animation ends
  88086. */
  88087. waitAsync(): Promise<Animatable>;
  88088. /** @hidden */
  88089. _animate(delay: number): boolean;
  88090. }
  88091. interface Scene {
  88092. /** @hidden */
  88093. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88094. /** @hidden */
  88095. _processLateAnimationBindingsForMatrices(holder: {
  88096. totalWeight: number;
  88097. animations: RuntimeAnimation[];
  88098. originalValue: Matrix;
  88099. }): any;
  88100. /** @hidden */
  88101. _processLateAnimationBindingsForQuaternions(holder: {
  88102. totalWeight: number;
  88103. animations: RuntimeAnimation[];
  88104. originalValue: Quaternion;
  88105. }, refQuaternion: Quaternion): Quaternion;
  88106. /** @hidden */
  88107. _processLateAnimationBindings(): void;
  88108. /**
  88109. * Will start the animation sequence of a given target
  88110. * @param target defines the target
  88111. * @param from defines from which frame should animation start
  88112. * @param to defines until which frame should animation run.
  88113. * @param weight defines the weight to apply to the animation (1.0 by default)
  88114. * @param loop defines if the animation loops
  88115. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88116. * @param onAnimationEnd defines the function to be executed when the animation ends
  88117. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88118. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88119. * @param onAnimationLoop defines the callback to call when an animation loops
  88120. * @returns the animatable object created for this animation
  88121. */
  88122. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88123. /**
  88124. * Will start the animation sequence of a given target
  88125. * @param target defines the target
  88126. * @param from defines from which frame should animation start
  88127. * @param to defines until which frame should animation run.
  88128. * @param loop defines if the animation loops
  88129. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88130. * @param onAnimationEnd defines the function to be executed when the animation ends
  88131. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88132. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88133. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88134. * @param onAnimationLoop defines the callback to call when an animation loops
  88135. * @returns the animatable object created for this animation
  88136. */
  88137. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88138. /**
  88139. * Will start the animation sequence of a given target and its hierarchy
  88140. * @param target defines the target
  88141. * @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.
  88142. * @param from defines from which frame should animation start
  88143. * @param to defines until which frame should animation run.
  88144. * @param loop defines if the animation loops
  88145. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88146. * @param onAnimationEnd defines the function to be executed when the animation ends
  88147. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88148. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88149. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88150. * @param onAnimationLoop defines the callback to call when an animation loops
  88151. * @returns the list of created animatables
  88152. */
  88153. 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[];
  88154. /**
  88155. * Begin a new animation on a given node
  88156. * @param target defines the target where the animation will take place
  88157. * @param animations defines the list of animations to start
  88158. * @param from defines the initial value
  88159. * @param to defines the final value
  88160. * @param loop defines if you want animation to loop (off by default)
  88161. * @param speedRatio defines the speed ratio to apply to all animations
  88162. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88163. * @param onAnimationLoop defines the callback to call when an animation loops
  88164. * @returns the list of created animatables
  88165. */
  88166. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88167. /**
  88168. * Begin a new animation on a given node and its hierarchy
  88169. * @param target defines the root node where the animation will take place
  88170. * @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.
  88171. * @param animations defines the list of animations to start
  88172. * @param from defines the initial value
  88173. * @param to defines the final value
  88174. * @param loop defines if you want animation to loop (off by default)
  88175. * @param speedRatio defines the speed ratio to apply to all animations
  88176. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88177. * @param onAnimationLoop defines the callback to call when an animation loops
  88178. * @returns the list of animatables created for all nodes
  88179. */
  88180. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88181. /**
  88182. * Gets the animatable associated with a specific target
  88183. * @param target defines the target of the animatable
  88184. * @returns the required animatable if found
  88185. */
  88186. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88187. /**
  88188. * Gets all animatables associated with a given target
  88189. * @param target defines the target to look animatables for
  88190. * @returns an array of Animatables
  88191. */
  88192. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88193. /**
  88194. * Stops and removes all animations that have been applied to the scene
  88195. */
  88196. stopAllAnimations(): void;
  88197. /**
  88198. * Gets the current delta time used by animation engine
  88199. */
  88200. deltaTime: number;
  88201. }
  88202. interface Bone {
  88203. /**
  88204. * Copy an animation range from another bone
  88205. * @param source defines the source bone
  88206. * @param rangeName defines the range name to copy
  88207. * @param frameOffset defines the frame offset
  88208. * @param rescaleAsRequired defines if rescaling must be applied if required
  88209. * @param skelDimensionsRatio defines the scaling ratio
  88210. * @returns true if operation was successful
  88211. */
  88212. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88213. }
  88214. }
  88215. declare module BABYLON {
  88216. /**
  88217. * Class used to handle skinning animations
  88218. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88219. */
  88220. export class Skeleton implements IAnimatable {
  88221. /** defines the skeleton name */
  88222. name: string;
  88223. /** defines the skeleton Id */
  88224. id: string;
  88225. /**
  88226. * Defines the list of child bones
  88227. */
  88228. bones: Bone[];
  88229. /**
  88230. * Defines an estimate of the dimension of the skeleton at rest
  88231. */
  88232. dimensionsAtRest: Vector3;
  88233. /**
  88234. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88235. */
  88236. needInitialSkinMatrix: boolean;
  88237. /**
  88238. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88239. */
  88240. overrideMesh: Nullable<AbstractMesh>;
  88241. /**
  88242. * Gets the list of animations attached to this skeleton
  88243. */
  88244. animations: Array<Animation>;
  88245. private _scene;
  88246. private _isDirty;
  88247. private _transformMatrices;
  88248. private _transformMatrixTexture;
  88249. private _meshesWithPoseMatrix;
  88250. private _animatables;
  88251. private _identity;
  88252. private _synchronizedWithMesh;
  88253. private _ranges;
  88254. private _lastAbsoluteTransformsUpdateId;
  88255. private _canUseTextureForBones;
  88256. private _uniqueId;
  88257. /** @hidden */
  88258. _numBonesWithLinkedTransformNode: number;
  88259. /** @hidden */
  88260. _hasWaitingData: Nullable<boolean>;
  88261. /**
  88262. * Specifies if the skeleton should be serialized
  88263. */
  88264. doNotSerialize: boolean;
  88265. private _useTextureToStoreBoneMatrices;
  88266. /**
  88267. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88268. * Please note that this option is not available if the hardware does not support it
  88269. */
  88270. get useTextureToStoreBoneMatrices(): boolean;
  88271. set useTextureToStoreBoneMatrices(value: boolean);
  88272. private _animationPropertiesOverride;
  88273. /**
  88274. * Gets or sets the animation properties override
  88275. */
  88276. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88277. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88278. /**
  88279. * List of inspectable custom properties (used by the Inspector)
  88280. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88281. */
  88282. inspectableCustomProperties: IInspectable[];
  88283. /**
  88284. * An observable triggered before computing the skeleton's matrices
  88285. */
  88286. onBeforeComputeObservable: Observable<Skeleton>;
  88287. /**
  88288. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88289. */
  88290. get isUsingTextureForMatrices(): boolean;
  88291. /**
  88292. * Gets the unique ID of this skeleton
  88293. */
  88294. get uniqueId(): number;
  88295. /**
  88296. * Creates a new skeleton
  88297. * @param name defines the skeleton name
  88298. * @param id defines the skeleton Id
  88299. * @param scene defines the hosting scene
  88300. */
  88301. constructor(
  88302. /** defines the skeleton name */
  88303. name: string,
  88304. /** defines the skeleton Id */
  88305. id: string, scene: Scene);
  88306. /**
  88307. * Gets the current object class name.
  88308. * @return the class name
  88309. */
  88310. getClassName(): string;
  88311. /**
  88312. * Returns an array containing the root bones
  88313. * @returns an array containing the root bones
  88314. */
  88315. getChildren(): Array<Bone>;
  88316. /**
  88317. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88318. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88319. * @returns a Float32Array containing matrices data
  88320. */
  88321. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88322. /**
  88323. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88324. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88325. * @returns a raw texture containing the data
  88326. */
  88327. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88328. /**
  88329. * Gets the current hosting scene
  88330. * @returns a scene object
  88331. */
  88332. getScene(): Scene;
  88333. /**
  88334. * Gets a string representing the current skeleton data
  88335. * @param fullDetails defines a boolean indicating if we want a verbose version
  88336. * @returns a string representing the current skeleton data
  88337. */
  88338. toString(fullDetails?: boolean): string;
  88339. /**
  88340. * Get bone's index searching by name
  88341. * @param name defines bone's name to search for
  88342. * @return the indice of the bone. Returns -1 if not found
  88343. */
  88344. getBoneIndexByName(name: string): number;
  88345. /**
  88346. * Creater a new animation range
  88347. * @param name defines the name of the range
  88348. * @param from defines the start key
  88349. * @param to defines the end key
  88350. */
  88351. createAnimationRange(name: string, from: number, to: number): void;
  88352. /**
  88353. * Delete a specific animation range
  88354. * @param name defines the name of the range
  88355. * @param deleteFrames defines if frames must be removed as well
  88356. */
  88357. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88358. /**
  88359. * Gets a specific animation range
  88360. * @param name defines the name of the range to look for
  88361. * @returns the requested animation range or null if not found
  88362. */
  88363. getAnimationRange(name: string): Nullable<AnimationRange>;
  88364. /**
  88365. * Gets the list of all animation ranges defined on this skeleton
  88366. * @returns an array
  88367. */
  88368. getAnimationRanges(): Nullable<AnimationRange>[];
  88369. /**
  88370. * Copy animation range from a source skeleton.
  88371. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88372. * @param source defines the source skeleton
  88373. * @param name defines the name of the range to copy
  88374. * @param rescaleAsRequired defines if rescaling must be applied if required
  88375. * @returns true if operation was successful
  88376. */
  88377. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88378. /**
  88379. * Forces the skeleton to go to rest pose
  88380. */
  88381. returnToRest(): void;
  88382. private _getHighestAnimationFrame;
  88383. /**
  88384. * Begin a specific animation range
  88385. * @param name defines the name of the range to start
  88386. * @param loop defines if looping must be turned on (false by default)
  88387. * @param speedRatio defines the speed ratio to apply (1 by default)
  88388. * @param onAnimationEnd defines a callback which will be called when animation will end
  88389. * @returns a new animatable
  88390. */
  88391. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88392. /** @hidden */
  88393. _markAsDirty(): void;
  88394. /** @hidden */
  88395. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88396. /** @hidden */
  88397. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88398. private _computeTransformMatrices;
  88399. /**
  88400. * Build all resources required to render a skeleton
  88401. */
  88402. prepare(): void;
  88403. /**
  88404. * Gets the list of animatables currently running for this skeleton
  88405. * @returns an array of animatables
  88406. */
  88407. getAnimatables(): IAnimatable[];
  88408. /**
  88409. * Clone the current skeleton
  88410. * @param name defines the name of the new skeleton
  88411. * @param id defines the id of the new skeleton
  88412. * @returns the new skeleton
  88413. */
  88414. clone(name: string, id?: string): Skeleton;
  88415. /**
  88416. * Enable animation blending for this skeleton
  88417. * @param blendingSpeed defines the blending speed to apply
  88418. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88419. */
  88420. enableBlending(blendingSpeed?: number): void;
  88421. /**
  88422. * Releases all resources associated with the current skeleton
  88423. */
  88424. dispose(): void;
  88425. /**
  88426. * Serialize the skeleton in a JSON object
  88427. * @returns a JSON object
  88428. */
  88429. serialize(): any;
  88430. /**
  88431. * Creates a new skeleton from serialized data
  88432. * @param parsedSkeleton defines the serialized data
  88433. * @param scene defines the hosting scene
  88434. * @returns a new skeleton
  88435. */
  88436. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88437. /**
  88438. * Compute all node absolute transforms
  88439. * @param forceUpdate defines if computation must be done even if cache is up to date
  88440. */
  88441. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88442. /**
  88443. * Gets the root pose matrix
  88444. * @returns a matrix
  88445. */
  88446. getPoseMatrix(): Nullable<Matrix>;
  88447. /**
  88448. * Sorts bones per internal index
  88449. */
  88450. sortBones(): void;
  88451. private _sortBones;
  88452. }
  88453. }
  88454. declare module BABYLON {
  88455. /**
  88456. * Creates an instance based on a source mesh.
  88457. */
  88458. export class InstancedMesh extends AbstractMesh {
  88459. private _sourceMesh;
  88460. private _currentLOD;
  88461. /** @hidden */
  88462. _indexInSourceMeshInstanceArray: number;
  88463. constructor(name: string, source: Mesh);
  88464. /**
  88465. * Returns the string "InstancedMesh".
  88466. */
  88467. getClassName(): string;
  88468. /** Gets the list of lights affecting that mesh */
  88469. get lightSources(): Light[];
  88470. _resyncLightSources(): void;
  88471. _resyncLightSource(light: Light): void;
  88472. _removeLightSource(light: Light, dispose: boolean): void;
  88473. /**
  88474. * If the source mesh receives shadows
  88475. */
  88476. get receiveShadows(): boolean;
  88477. /**
  88478. * The material of the source mesh
  88479. */
  88480. get material(): Nullable<Material>;
  88481. /**
  88482. * Visibility of the source mesh
  88483. */
  88484. get visibility(): number;
  88485. /**
  88486. * Skeleton of the source mesh
  88487. */
  88488. get skeleton(): Nullable<Skeleton>;
  88489. /**
  88490. * Rendering ground id of the source mesh
  88491. */
  88492. get renderingGroupId(): number;
  88493. set renderingGroupId(value: number);
  88494. /**
  88495. * Returns the total number of vertices (integer).
  88496. */
  88497. getTotalVertices(): number;
  88498. /**
  88499. * Returns a positive integer : the total number of indices in this mesh geometry.
  88500. * @returns the numner of indices or zero if the mesh has no geometry.
  88501. */
  88502. getTotalIndices(): number;
  88503. /**
  88504. * The source mesh of the instance
  88505. */
  88506. get sourceMesh(): Mesh;
  88507. /**
  88508. * Is this node ready to be used/rendered
  88509. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88510. * @return {boolean} is it ready
  88511. */
  88512. isReady(completeCheck?: boolean): boolean;
  88513. /**
  88514. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88515. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88516. * @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.
  88517. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88518. */
  88519. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88520. /**
  88521. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88522. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88523. * The `data` are either a numeric array either a Float32Array.
  88524. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88525. * 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).
  88526. * Note that a new underlying VertexBuffer object is created each call.
  88527. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88528. *
  88529. * Possible `kind` values :
  88530. * - VertexBuffer.PositionKind
  88531. * - VertexBuffer.UVKind
  88532. * - VertexBuffer.UV2Kind
  88533. * - VertexBuffer.UV3Kind
  88534. * - VertexBuffer.UV4Kind
  88535. * - VertexBuffer.UV5Kind
  88536. * - VertexBuffer.UV6Kind
  88537. * - VertexBuffer.ColorKind
  88538. * - VertexBuffer.MatricesIndicesKind
  88539. * - VertexBuffer.MatricesIndicesExtraKind
  88540. * - VertexBuffer.MatricesWeightsKind
  88541. * - VertexBuffer.MatricesWeightsExtraKind
  88542. *
  88543. * Returns the Mesh.
  88544. */
  88545. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88546. /**
  88547. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88548. * If the mesh has no geometry, it is simply returned as it is.
  88549. * The `data` are either a numeric array either a Float32Array.
  88550. * No new underlying VertexBuffer object is created.
  88551. * 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.
  88552. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88553. *
  88554. * Possible `kind` values :
  88555. * - VertexBuffer.PositionKind
  88556. * - VertexBuffer.UVKind
  88557. * - VertexBuffer.UV2Kind
  88558. * - VertexBuffer.UV3Kind
  88559. * - VertexBuffer.UV4Kind
  88560. * - VertexBuffer.UV5Kind
  88561. * - VertexBuffer.UV6Kind
  88562. * - VertexBuffer.ColorKind
  88563. * - VertexBuffer.MatricesIndicesKind
  88564. * - VertexBuffer.MatricesIndicesExtraKind
  88565. * - VertexBuffer.MatricesWeightsKind
  88566. * - VertexBuffer.MatricesWeightsExtraKind
  88567. *
  88568. * Returns the Mesh.
  88569. */
  88570. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88571. /**
  88572. * Sets the mesh indices.
  88573. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88574. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88575. * This method creates a new index buffer each call.
  88576. * Returns the Mesh.
  88577. */
  88578. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88579. /**
  88580. * Boolean : True if the mesh owns the requested kind of data.
  88581. */
  88582. isVerticesDataPresent(kind: string): boolean;
  88583. /**
  88584. * Returns an array of indices (IndicesArray).
  88585. */
  88586. getIndices(): Nullable<IndicesArray>;
  88587. get _positions(): Nullable<Vector3[]>;
  88588. /**
  88589. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88590. * This means the mesh underlying bounding box and sphere are recomputed.
  88591. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88592. * @returns the current mesh
  88593. */
  88594. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88595. /** @hidden */
  88596. _preActivate(): InstancedMesh;
  88597. /** @hidden */
  88598. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88599. /** @hidden */
  88600. _postActivate(): void;
  88601. getWorldMatrix(): Matrix;
  88602. get isAnInstance(): boolean;
  88603. /**
  88604. * Returns the current associated LOD AbstractMesh.
  88605. */
  88606. getLOD(camera: Camera): AbstractMesh;
  88607. /** @hidden */
  88608. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88609. /** @hidden */
  88610. _syncSubMeshes(): InstancedMesh;
  88611. /** @hidden */
  88612. _generatePointsArray(): boolean;
  88613. /**
  88614. * Creates a new InstancedMesh from the current mesh.
  88615. * - name (string) : the cloned mesh name
  88616. * - newParent (optional Node) : the optional Node to parent the clone to.
  88617. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88618. *
  88619. * Returns the clone.
  88620. */
  88621. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88622. /**
  88623. * Disposes the InstancedMesh.
  88624. * Returns nothing.
  88625. */
  88626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88627. }
  88628. interface Mesh {
  88629. /**
  88630. * Register a custom buffer that will be instanced
  88631. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88632. * @param kind defines the buffer kind
  88633. * @param stride defines the stride in floats
  88634. */
  88635. registerInstancedBuffer(kind: string, stride: number): void;
  88636. /** @hidden */
  88637. _userInstancedBuffersStorage: {
  88638. data: {
  88639. [key: string]: Float32Array;
  88640. };
  88641. sizes: {
  88642. [key: string]: number;
  88643. };
  88644. vertexBuffers: {
  88645. [key: string]: Nullable<VertexBuffer>;
  88646. };
  88647. strides: {
  88648. [key: string]: number;
  88649. };
  88650. };
  88651. }
  88652. interface AbstractMesh {
  88653. /**
  88654. * Object used to store instanced buffers defined by user
  88655. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88656. */
  88657. instancedBuffers: {
  88658. [key: string]: any;
  88659. };
  88660. }
  88661. }
  88662. declare module BABYLON {
  88663. /**
  88664. * Defines the options associated with the creation of a shader material.
  88665. */
  88666. export interface IShaderMaterialOptions {
  88667. /**
  88668. * Does the material work in alpha blend mode
  88669. */
  88670. needAlphaBlending: boolean;
  88671. /**
  88672. * Does the material work in alpha test mode
  88673. */
  88674. needAlphaTesting: boolean;
  88675. /**
  88676. * The list of attribute names used in the shader
  88677. */
  88678. attributes: string[];
  88679. /**
  88680. * The list of unifrom names used in the shader
  88681. */
  88682. uniforms: string[];
  88683. /**
  88684. * The list of UBO names used in the shader
  88685. */
  88686. uniformBuffers: string[];
  88687. /**
  88688. * The list of sampler names used in the shader
  88689. */
  88690. samplers: string[];
  88691. /**
  88692. * The list of defines used in the shader
  88693. */
  88694. defines: string[];
  88695. }
  88696. /**
  88697. * 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.
  88698. *
  88699. * This returned material effects how the mesh will look based on the code in the shaders.
  88700. *
  88701. * @see http://doc.babylonjs.com/how_to/shader_material
  88702. */
  88703. export class ShaderMaterial extends Material {
  88704. private _shaderPath;
  88705. private _options;
  88706. private _textures;
  88707. private _textureArrays;
  88708. private _floats;
  88709. private _ints;
  88710. private _floatsArrays;
  88711. private _colors3;
  88712. private _colors3Arrays;
  88713. private _colors4;
  88714. private _colors4Arrays;
  88715. private _vectors2;
  88716. private _vectors3;
  88717. private _vectors4;
  88718. private _matrices;
  88719. private _matrixArrays;
  88720. private _matrices3x3;
  88721. private _matrices2x2;
  88722. private _vectors2Arrays;
  88723. private _vectors3Arrays;
  88724. private _vectors4Arrays;
  88725. private _cachedWorldViewMatrix;
  88726. private _cachedWorldViewProjectionMatrix;
  88727. private _renderId;
  88728. private _multiview;
  88729. /**
  88730. * Instantiate a new shader material.
  88731. * 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.
  88732. * This returned material effects how the mesh will look based on the code in the shaders.
  88733. * @see http://doc.babylonjs.com/how_to/shader_material
  88734. * @param name Define the name of the material in the scene
  88735. * @param scene Define the scene the material belongs to
  88736. * @param shaderPath Defines the route to the shader code in one of three ways:
  88737. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88738. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88739. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88740. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88741. * @param options Define the options used to create the shader
  88742. */
  88743. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88744. /**
  88745. * Gets the shader path used to define the shader code
  88746. * It can be modified to trigger a new compilation
  88747. */
  88748. get shaderPath(): any;
  88749. /**
  88750. * Sets the shader path used to define the shader code
  88751. * It can be modified to trigger a new compilation
  88752. */
  88753. set shaderPath(shaderPath: any);
  88754. /**
  88755. * Gets the options used to compile the shader.
  88756. * They can be modified to trigger a new compilation
  88757. */
  88758. get options(): IShaderMaterialOptions;
  88759. /**
  88760. * Gets the current class name of the material e.g. "ShaderMaterial"
  88761. * Mainly use in serialization.
  88762. * @returns the class name
  88763. */
  88764. getClassName(): string;
  88765. /**
  88766. * Specifies if the material will require alpha blending
  88767. * @returns a boolean specifying if alpha blending is needed
  88768. */
  88769. needAlphaBlending(): boolean;
  88770. /**
  88771. * Specifies if this material should be rendered in alpha test mode
  88772. * @returns a boolean specifying if an alpha test is needed.
  88773. */
  88774. needAlphaTesting(): boolean;
  88775. private _checkUniform;
  88776. /**
  88777. * Set a texture in the shader.
  88778. * @param name Define the name of the uniform samplers as defined in the shader
  88779. * @param texture Define the texture to bind to this sampler
  88780. * @return the material itself allowing "fluent" like uniform updates
  88781. */
  88782. setTexture(name: string, texture: Texture): ShaderMaterial;
  88783. /**
  88784. * Set a texture array in the shader.
  88785. * @param name Define the name of the uniform sampler array as defined in the shader
  88786. * @param textures Define the list of textures to bind to this sampler
  88787. * @return the material itself allowing "fluent" like uniform updates
  88788. */
  88789. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88790. /**
  88791. * Set a float in the shader.
  88792. * @param name Define the name of the uniform as defined in the shader
  88793. * @param value Define the value to give to the uniform
  88794. * @return the material itself allowing "fluent" like uniform updates
  88795. */
  88796. setFloat(name: string, value: number): ShaderMaterial;
  88797. /**
  88798. * Set a int in the shader.
  88799. * @param name Define the name of the uniform as defined in the shader
  88800. * @param value Define the value to give to the uniform
  88801. * @return the material itself allowing "fluent" like uniform updates
  88802. */
  88803. setInt(name: string, value: number): ShaderMaterial;
  88804. /**
  88805. * Set an array of floats in the shader.
  88806. * @param name Define the name of the uniform as defined in the shader
  88807. * @param value Define the value to give to the uniform
  88808. * @return the material itself allowing "fluent" like uniform updates
  88809. */
  88810. setFloats(name: string, value: number[]): ShaderMaterial;
  88811. /**
  88812. * Set a vec3 in the shader from a Color3.
  88813. * @param name Define the name of the uniform as defined in the shader
  88814. * @param value Define the value to give to the uniform
  88815. * @return the material itself allowing "fluent" like uniform updates
  88816. */
  88817. setColor3(name: string, value: Color3): ShaderMaterial;
  88818. /**
  88819. * Set a vec3 array in the shader from a Color3 array.
  88820. * @param name Define the name of the uniform as defined in the shader
  88821. * @param value Define the value to give to the uniform
  88822. * @return the material itself allowing "fluent" like uniform updates
  88823. */
  88824. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88825. /**
  88826. * Set a vec4 in the shader from a Color4.
  88827. * @param name Define the name of the uniform as defined in the shader
  88828. * @param value Define the value to give to the uniform
  88829. * @return the material itself allowing "fluent" like uniform updates
  88830. */
  88831. setColor4(name: string, value: Color4): ShaderMaterial;
  88832. /**
  88833. * Set a vec4 array in the shader from a Color4 array.
  88834. * @param name Define the name of the uniform as defined in the shader
  88835. * @param value Define the value to give to the uniform
  88836. * @return the material itself allowing "fluent" like uniform updates
  88837. */
  88838. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88839. /**
  88840. * Set a vec2 in the shader from a Vector2.
  88841. * @param name Define the name of the uniform as defined in the shader
  88842. * @param value Define the value to give to the uniform
  88843. * @return the material itself allowing "fluent" like uniform updates
  88844. */
  88845. setVector2(name: string, value: Vector2): ShaderMaterial;
  88846. /**
  88847. * Set a vec3 in the shader from a Vector3.
  88848. * @param name Define the name of the uniform as defined in the shader
  88849. * @param value Define the value to give to the uniform
  88850. * @return the material itself allowing "fluent" like uniform updates
  88851. */
  88852. setVector3(name: string, value: Vector3): ShaderMaterial;
  88853. /**
  88854. * Set a vec4 in the shader from a Vector4.
  88855. * @param name Define the name of the uniform as defined in the shader
  88856. * @param value Define the value to give to the uniform
  88857. * @return the material itself allowing "fluent" like uniform updates
  88858. */
  88859. setVector4(name: string, value: Vector4): ShaderMaterial;
  88860. /**
  88861. * Set a mat4 in the shader from a Matrix.
  88862. * @param name Define the name of the uniform as defined in the shader
  88863. * @param value Define the value to give to the uniform
  88864. * @return the material itself allowing "fluent" like uniform updates
  88865. */
  88866. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88867. /**
  88868. * Set a float32Array in the shader from a matrix array.
  88869. * @param name Define the name of the uniform as defined in the shader
  88870. * @param value Define the value to give to the uniform
  88871. * @return the material itself allowing "fluent" like uniform updates
  88872. */
  88873. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88874. /**
  88875. * Set a mat3 in the shader from a Float32Array.
  88876. * @param name Define the name of the uniform as defined in the shader
  88877. * @param value Define the value to give to the uniform
  88878. * @return the material itself allowing "fluent" like uniform updates
  88879. */
  88880. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88881. /**
  88882. * Set a mat2 in the shader from a Float32Array.
  88883. * @param name Define the name of the uniform as defined in the shader
  88884. * @param value Define the value to give to the uniform
  88885. * @return the material itself allowing "fluent" like uniform updates
  88886. */
  88887. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88888. /**
  88889. * Set a vec2 array in the shader from a number array.
  88890. * @param name Define the name of the uniform as defined in the shader
  88891. * @param value Define the value to give to the uniform
  88892. * @return the material itself allowing "fluent" like uniform updates
  88893. */
  88894. setArray2(name: string, value: number[]): ShaderMaterial;
  88895. /**
  88896. * Set a vec3 array in the shader from a number array.
  88897. * @param name Define the name of the uniform as defined in the shader
  88898. * @param value Define the value to give to the uniform
  88899. * @return the material itself allowing "fluent" like uniform updates
  88900. */
  88901. setArray3(name: string, value: number[]): ShaderMaterial;
  88902. /**
  88903. * Set a vec4 array in the shader from a number array.
  88904. * @param name Define the name of the uniform as defined in the shader
  88905. * @param value Define the value to give to the uniform
  88906. * @return the material itself allowing "fluent" like uniform updates
  88907. */
  88908. setArray4(name: string, value: number[]): ShaderMaterial;
  88909. private _checkCache;
  88910. /**
  88911. * Specifies that the submesh is ready to be used
  88912. * @param mesh defines the mesh to check
  88913. * @param subMesh defines which submesh to check
  88914. * @param useInstances specifies that instances should be used
  88915. * @returns a boolean indicating that the submesh is ready or not
  88916. */
  88917. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88918. /**
  88919. * Checks if the material is ready to render the requested mesh
  88920. * @param mesh Define the mesh to render
  88921. * @param useInstances Define whether or not the material is used with instances
  88922. * @returns true if ready, otherwise false
  88923. */
  88924. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88925. /**
  88926. * Binds the world matrix to the material
  88927. * @param world defines the world transformation matrix
  88928. */
  88929. bindOnlyWorldMatrix(world: Matrix): void;
  88930. /**
  88931. * Binds the material to the mesh
  88932. * @param world defines the world transformation matrix
  88933. * @param mesh defines the mesh to bind the material to
  88934. */
  88935. bind(world: Matrix, mesh?: Mesh): void;
  88936. /**
  88937. * Gets the active textures from the material
  88938. * @returns an array of textures
  88939. */
  88940. getActiveTextures(): BaseTexture[];
  88941. /**
  88942. * Specifies if the material uses a texture
  88943. * @param texture defines the texture to check against the material
  88944. * @returns a boolean specifying if the material uses the texture
  88945. */
  88946. hasTexture(texture: BaseTexture): boolean;
  88947. /**
  88948. * Makes a duplicate of the material, and gives it a new name
  88949. * @param name defines the new name for the duplicated material
  88950. * @returns the cloned material
  88951. */
  88952. clone(name: string): ShaderMaterial;
  88953. /**
  88954. * Disposes the material
  88955. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88956. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88957. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88958. */
  88959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88960. /**
  88961. * Serializes this material in a JSON representation
  88962. * @returns the serialized material object
  88963. */
  88964. serialize(): any;
  88965. /**
  88966. * Creates a shader material from parsed shader material data
  88967. * @param source defines the JSON represnetation of the material
  88968. * @param scene defines the hosting scene
  88969. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88970. * @returns a new material
  88971. */
  88972. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88973. }
  88974. }
  88975. declare module BABYLON {
  88976. /** @hidden */
  88977. export var colorPixelShader: {
  88978. name: string;
  88979. shader: string;
  88980. };
  88981. }
  88982. declare module BABYLON {
  88983. /** @hidden */
  88984. export var colorVertexShader: {
  88985. name: string;
  88986. shader: string;
  88987. };
  88988. }
  88989. declare module BABYLON {
  88990. /**
  88991. * Line mesh
  88992. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88993. */
  88994. export class LinesMesh extends Mesh {
  88995. /**
  88996. * If vertex color should be applied to the mesh
  88997. */
  88998. readonly useVertexColor?: boolean | undefined;
  88999. /**
  89000. * If vertex alpha should be applied to the mesh
  89001. */
  89002. readonly useVertexAlpha?: boolean | undefined;
  89003. /**
  89004. * Color of the line (Default: White)
  89005. */
  89006. color: Color3;
  89007. /**
  89008. * Alpha of the line (Default: 1)
  89009. */
  89010. alpha: number;
  89011. /**
  89012. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89013. * This margin is expressed in world space coordinates, so its value may vary.
  89014. * Default value is 0.1
  89015. */
  89016. intersectionThreshold: number;
  89017. private _colorShader;
  89018. private color4;
  89019. /**
  89020. * Creates a new LinesMesh
  89021. * @param name defines the name
  89022. * @param scene defines the hosting scene
  89023. * @param parent defines the parent mesh if any
  89024. * @param source defines the optional source LinesMesh used to clone data from
  89025. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89026. * When false, achieved by calling a clone(), also passing False.
  89027. * This will make creation of children, recursive.
  89028. * @param useVertexColor defines if this LinesMesh supports vertex color
  89029. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89030. */
  89031. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89032. /**
  89033. * If vertex color should be applied to the mesh
  89034. */
  89035. useVertexColor?: boolean | undefined,
  89036. /**
  89037. * If vertex alpha should be applied to the mesh
  89038. */
  89039. useVertexAlpha?: boolean | undefined);
  89040. private _addClipPlaneDefine;
  89041. private _removeClipPlaneDefine;
  89042. isReady(): boolean;
  89043. /**
  89044. * Returns the string "LineMesh"
  89045. */
  89046. getClassName(): string;
  89047. /**
  89048. * @hidden
  89049. */
  89050. get material(): Material;
  89051. /**
  89052. * @hidden
  89053. */
  89054. set material(value: Material);
  89055. /**
  89056. * @hidden
  89057. */
  89058. get checkCollisions(): boolean;
  89059. /** @hidden */
  89060. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89061. /** @hidden */
  89062. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89063. /**
  89064. * Disposes of the line mesh
  89065. * @param doNotRecurse If children should be disposed
  89066. */
  89067. dispose(doNotRecurse?: boolean): void;
  89068. /**
  89069. * Returns a new LineMesh object cloned from the current one.
  89070. */
  89071. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  89072. /**
  89073. * Creates a new InstancedLinesMesh object from the mesh model.
  89074. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89075. * @param name defines the name of the new instance
  89076. * @returns a new InstancedLinesMesh
  89077. */
  89078. createInstance(name: string): InstancedLinesMesh;
  89079. }
  89080. /**
  89081. * Creates an instance based on a source LinesMesh
  89082. */
  89083. export class InstancedLinesMesh extends InstancedMesh {
  89084. /**
  89085. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89086. * This margin is expressed in world space coordinates, so its value may vary.
  89087. * Initilized with the intersectionThreshold value of the source LinesMesh
  89088. */
  89089. intersectionThreshold: number;
  89090. constructor(name: string, source: LinesMesh);
  89091. /**
  89092. * Returns the string "InstancedLinesMesh".
  89093. */
  89094. getClassName(): string;
  89095. }
  89096. }
  89097. declare module BABYLON {
  89098. /** @hidden */
  89099. export var linePixelShader: {
  89100. name: string;
  89101. shader: string;
  89102. };
  89103. }
  89104. declare module BABYLON {
  89105. /** @hidden */
  89106. export var lineVertexShader: {
  89107. name: string;
  89108. shader: string;
  89109. };
  89110. }
  89111. declare module BABYLON {
  89112. interface AbstractMesh {
  89113. /**
  89114. * Gets the edgesRenderer associated with the mesh
  89115. */
  89116. edgesRenderer: Nullable<EdgesRenderer>;
  89117. }
  89118. interface LinesMesh {
  89119. /**
  89120. * Enables the edge rendering mode on the mesh.
  89121. * This mode makes the mesh edges visible
  89122. * @param epsilon defines the maximal distance between two angles to detect a face
  89123. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89124. * @returns the currentAbstractMesh
  89125. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89126. */
  89127. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89128. }
  89129. interface InstancedLinesMesh {
  89130. /**
  89131. * Enables the edge rendering mode on the mesh.
  89132. * This mode makes the mesh edges visible
  89133. * @param epsilon defines the maximal distance between two angles to detect a face
  89134. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89135. * @returns the current InstancedLinesMesh
  89136. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89137. */
  89138. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89139. }
  89140. /**
  89141. * Defines the minimum contract an Edges renderer should follow.
  89142. */
  89143. export interface IEdgesRenderer extends IDisposable {
  89144. /**
  89145. * Gets or sets a boolean indicating if the edgesRenderer is active
  89146. */
  89147. isEnabled: boolean;
  89148. /**
  89149. * Renders the edges of the attached mesh,
  89150. */
  89151. render(): void;
  89152. /**
  89153. * Checks wether or not the edges renderer is ready to render.
  89154. * @return true if ready, otherwise false.
  89155. */
  89156. isReady(): boolean;
  89157. }
  89158. /**
  89159. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89160. */
  89161. export class EdgesRenderer implements IEdgesRenderer {
  89162. /**
  89163. * Define the size of the edges with an orthographic camera
  89164. */
  89165. edgesWidthScalerForOrthographic: number;
  89166. /**
  89167. * Define the size of the edges with a perspective camera
  89168. */
  89169. edgesWidthScalerForPerspective: number;
  89170. protected _source: AbstractMesh;
  89171. protected _linesPositions: number[];
  89172. protected _linesNormals: number[];
  89173. protected _linesIndices: number[];
  89174. protected _epsilon: number;
  89175. protected _indicesCount: number;
  89176. protected _lineShader: ShaderMaterial;
  89177. protected _ib: DataBuffer;
  89178. protected _buffers: {
  89179. [key: string]: Nullable<VertexBuffer>;
  89180. };
  89181. protected _checkVerticesInsteadOfIndices: boolean;
  89182. private _meshRebuildObserver;
  89183. private _meshDisposeObserver;
  89184. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89185. isEnabled: boolean;
  89186. /**
  89187. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89188. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89189. * @param source Mesh used to create edges
  89190. * @param epsilon sum of angles in adjacency to check for edge
  89191. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89192. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89193. */
  89194. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89195. protected _prepareRessources(): void;
  89196. /** @hidden */
  89197. _rebuild(): void;
  89198. /**
  89199. * Releases the required resources for the edges renderer
  89200. */
  89201. dispose(): void;
  89202. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89203. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89204. /**
  89205. * Checks if the pair of p0 and p1 is en edge
  89206. * @param faceIndex
  89207. * @param edge
  89208. * @param faceNormals
  89209. * @param p0
  89210. * @param p1
  89211. * @private
  89212. */
  89213. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89214. /**
  89215. * push line into the position, normal and index buffer
  89216. * @protected
  89217. */
  89218. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89219. /**
  89220. * Generates lines edges from adjacencjes
  89221. * @private
  89222. */
  89223. _generateEdgesLines(): void;
  89224. /**
  89225. * Checks wether or not the edges renderer is ready to render.
  89226. * @return true if ready, otherwise false.
  89227. */
  89228. isReady(): boolean;
  89229. /**
  89230. * Renders the edges of the attached mesh,
  89231. */
  89232. render(): void;
  89233. }
  89234. /**
  89235. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89236. */
  89237. export class LineEdgesRenderer extends EdgesRenderer {
  89238. /**
  89239. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89240. * @param source LineMesh used to generate edges
  89241. * @param epsilon not important (specified angle for edge detection)
  89242. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89243. */
  89244. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89245. /**
  89246. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89247. */
  89248. _generateEdgesLines(): void;
  89249. }
  89250. }
  89251. declare module BABYLON {
  89252. /**
  89253. * This represents the object necessary to create a rendering group.
  89254. * This is exclusively used and created by the rendering manager.
  89255. * To modify the behavior, you use the available helpers in your scene or meshes.
  89256. * @hidden
  89257. */
  89258. export class RenderingGroup {
  89259. index: number;
  89260. private static _zeroVector;
  89261. private _scene;
  89262. private _opaqueSubMeshes;
  89263. private _transparentSubMeshes;
  89264. private _alphaTestSubMeshes;
  89265. private _depthOnlySubMeshes;
  89266. private _particleSystems;
  89267. private _spriteManagers;
  89268. private _opaqueSortCompareFn;
  89269. private _alphaTestSortCompareFn;
  89270. private _transparentSortCompareFn;
  89271. private _renderOpaque;
  89272. private _renderAlphaTest;
  89273. private _renderTransparent;
  89274. /** @hidden */
  89275. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89276. onBeforeTransparentRendering: () => void;
  89277. /**
  89278. * Set the opaque sort comparison function.
  89279. * If null the sub meshes will be render in the order they were created
  89280. */
  89281. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89282. /**
  89283. * Set the alpha test sort comparison function.
  89284. * If null the sub meshes will be render in the order they were created
  89285. */
  89286. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89287. /**
  89288. * Set the transparent sort comparison function.
  89289. * If null the sub meshes will be render in the order they were created
  89290. */
  89291. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89292. /**
  89293. * Creates a new rendering group.
  89294. * @param index The rendering group index
  89295. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89296. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89297. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89298. */
  89299. 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>);
  89300. /**
  89301. * Render all the sub meshes contained in the group.
  89302. * @param customRenderFunction Used to override the default render behaviour of the group.
  89303. * @returns true if rendered some submeshes.
  89304. */
  89305. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89306. /**
  89307. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89308. * @param subMeshes The submeshes to render
  89309. */
  89310. private renderOpaqueSorted;
  89311. /**
  89312. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89313. * @param subMeshes The submeshes to render
  89314. */
  89315. private renderAlphaTestSorted;
  89316. /**
  89317. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89318. * @param subMeshes The submeshes to render
  89319. */
  89320. private renderTransparentSorted;
  89321. /**
  89322. * Renders the submeshes in a specified order.
  89323. * @param subMeshes The submeshes to sort before render
  89324. * @param sortCompareFn The comparison function use to sort
  89325. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89326. * @param transparent Specifies to activate blending if true
  89327. */
  89328. private static renderSorted;
  89329. /**
  89330. * Renders the submeshes in the order they were dispatched (no sort applied).
  89331. * @param subMeshes The submeshes to render
  89332. */
  89333. private static renderUnsorted;
  89334. /**
  89335. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89336. * are rendered back to front if in the same alpha index.
  89337. *
  89338. * @param a The first submesh
  89339. * @param b The second submesh
  89340. * @returns The result of the comparison
  89341. */
  89342. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89343. /**
  89344. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89345. * are rendered back to front.
  89346. *
  89347. * @param a The first submesh
  89348. * @param b The second submesh
  89349. * @returns The result of the comparison
  89350. */
  89351. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89352. /**
  89353. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89354. * are rendered front to back (prevent overdraw).
  89355. *
  89356. * @param a The first submesh
  89357. * @param b The second submesh
  89358. * @returns The result of the comparison
  89359. */
  89360. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89361. /**
  89362. * Resets the different lists of submeshes to prepare a new frame.
  89363. */
  89364. prepare(): void;
  89365. dispose(): void;
  89366. /**
  89367. * Inserts the submesh in its correct queue depending on its material.
  89368. * @param subMesh The submesh to dispatch
  89369. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89370. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89371. */
  89372. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89373. dispatchSprites(spriteManager: ISpriteManager): void;
  89374. dispatchParticles(particleSystem: IParticleSystem): void;
  89375. private _renderParticles;
  89376. private _renderSprites;
  89377. }
  89378. }
  89379. declare module BABYLON {
  89380. /**
  89381. * Interface describing the different options available in the rendering manager
  89382. * regarding Auto Clear between groups.
  89383. */
  89384. export interface IRenderingManagerAutoClearSetup {
  89385. /**
  89386. * Defines whether or not autoclear is enable.
  89387. */
  89388. autoClear: boolean;
  89389. /**
  89390. * Defines whether or not to autoclear the depth buffer.
  89391. */
  89392. depth: boolean;
  89393. /**
  89394. * Defines whether or not to autoclear the stencil buffer.
  89395. */
  89396. stencil: boolean;
  89397. }
  89398. /**
  89399. * This class is used by the onRenderingGroupObservable
  89400. */
  89401. export class RenderingGroupInfo {
  89402. /**
  89403. * The Scene that being rendered
  89404. */
  89405. scene: Scene;
  89406. /**
  89407. * The camera currently used for the rendering pass
  89408. */
  89409. camera: Nullable<Camera>;
  89410. /**
  89411. * The ID of the renderingGroup being processed
  89412. */
  89413. renderingGroupId: number;
  89414. }
  89415. /**
  89416. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89417. * It is enable to manage the different groups as well as the different necessary sort functions.
  89418. * This should not be used directly aside of the few static configurations
  89419. */
  89420. export class RenderingManager {
  89421. /**
  89422. * The max id used for rendering groups (not included)
  89423. */
  89424. static MAX_RENDERINGGROUPS: number;
  89425. /**
  89426. * The min id used for rendering groups (included)
  89427. */
  89428. static MIN_RENDERINGGROUPS: number;
  89429. /**
  89430. * Used to globally prevent autoclearing scenes.
  89431. */
  89432. static AUTOCLEAR: boolean;
  89433. /**
  89434. * @hidden
  89435. */
  89436. _useSceneAutoClearSetup: boolean;
  89437. private _scene;
  89438. private _renderingGroups;
  89439. private _depthStencilBufferAlreadyCleaned;
  89440. private _autoClearDepthStencil;
  89441. private _customOpaqueSortCompareFn;
  89442. private _customAlphaTestSortCompareFn;
  89443. private _customTransparentSortCompareFn;
  89444. private _renderingGroupInfo;
  89445. /**
  89446. * Instantiates a new rendering group for a particular scene
  89447. * @param scene Defines the scene the groups belongs to
  89448. */
  89449. constructor(scene: Scene);
  89450. private _clearDepthStencilBuffer;
  89451. /**
  89452. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89453. * @hidden
  89454. */
  89455. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89456. /**
  89457. * Resets the different information of the group to prepare a new frame
  89458. * @hidden
  89459. */
  89460. reset(): void;
  89461. /**
  89462. * Dispose and release the group and its associated resources.
  89463. * @hidden
  89464. */
  89465. dispose(): void;
  89466. /**
  89467. * Clear the info related to rendering groups preventing retention points during dispose.
  89468. */
  89469. freeRenderingGroups(): void;
  89470. private _prepareRenderingGroup;
  89471. /**
  89472. * Add a sprite manager to the rendering manager in order to render it this frame.
  89473. * @param spriteManager Define the sprite manager to render
  89474. */
  89475. dispatchSprites(spriteManager: ISpriteManager): void;
  89476. /**
  89477. * Add a particle system to the rendering manager in order to render it this frame.
  89478. * @param particleSystem Define the particle system to render
  89479. */
  89480. dispatchParticles(particleSystem: IParticleSystem): void;
  89481. /**
  89482. * Add a submesh to the manager in order to render it this frame
  89483. * @param subMesh The submesh to dispatch
  89484. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89485. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89486. */
  89487. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89488. /**
  89489. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89490. * This allowed control for front to back rendering or reversly depending of the special needs.
  89491. *
  89492. * @param renderingGroupId The rendering group id corresponding to its index
  89493. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89494. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89495. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89496. */
  89497. 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;
  89498. /**
  89499. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89500. *
  89501. * @param renderingGroupId The rendering group id corresponding to its index
  89502. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89503. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89504. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89505. */
  89506. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89507. /**
  89508. * Gets the current auto clear configuration for one rendering group of the rendering
  89509. * manager.
  89510. * @param index the rendering group index to get the information for
  89511. * @returns The auto clear setup for the requested rendering group
  89512. */
  89513. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89514. }
  89515. }
  89516. declare module BABYLON {
  89517. /**
  89518. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89519. */
  89520. export interface ICustomShaderOptions {
  89521. /**
  89522. * Gets or sets the custom shader name to use
  89523. */
  89524. shaderName: string;
  89525. /**
  89526. * The list of attribute names used in the shader
  89527. */
  89528. attributes?: string[];
  89529. /**
  89530. * The list of unifrom names used in the shader
  89531. */
  89532. uniforms?: string[];
  89533. /**
  89534. * The list of sampler names used in the shader
  89535. */
  89536. samplers?: string[];
  89537. /**
  89538. * The list of defines used in the shader
  89539. */
  89540. defines?: string[];
  89541. }
  89542. /**
  89543. * Interface to implement to create a shadow generator compatible with BJS.
  89544. */
  89545. export interface IShadowGenerator {
  89546. /**
  89547. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89548. * @returns The render target texture if present otherwise, null
  89549. */
  89550. getShadowMap(): Nullable<RenderTargetTexture>;
  89551. /**
  89552. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89553. * @param subMesh The submesh we want to render in the shadow map
  89554. * @param useInstances Defines wether will draw in the map using instances
  89555. * @returns true if ready otherwise, false
  89556. */
  89557. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89558. /**
  89559. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89560. * @param defines Defines of the material we want to update
  89561. * @param lightIndex Index of the light in the enabled light list of the material
  89562. */
  89563. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89564. /**
  89565. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89566. * defined in the generator but impacting the effect).
  89567. * It implies the unifroms available on the materials are the standard BJS ones.
  89568. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89569. * @param effect The effect we are binfing the information for
  89570. */
  89571. bindShadowLight(lightIndex: string, effect: Effect): void;
  89572. /**
  89573. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89574. * (eq to shadow prjection matrix * light transform matrix)
  89575. * @returns The transform matrix used to create the shadow map
  89576. */
  89577. getTransformMatrix(): Matrix;
  89578. /**
  89579. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89580. * Cube and 2D textures for instance.
  89581. */
  89582. recreateShadowMap(): void;
  89583. /**
  89584. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89585. * @param onCompiled Callback triggered at the and of the effects compilation
  89586. * @param options Sets of optional options forcing the compilation with different modes
  89587. */
  89588. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89589. useInstances: boolean;
  89590. }>): void;
  89591. /**
  89592. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89593. * @param options Sets of optional options forcing the compilation with different modes
  89594. * @returns A promise that resolves when the compilation completes
  89595. */
  89596. forceCompilationAsync(options?: Partial<{
  89597. useInstances: boolean;
  89598. }>): Promise<void>;
  89599. /**
  89600. * Serializes the shadow generator setup to a json object.
  89601. * @returns The serialized JSON object
  89602. */
  89603. serialize(): any;
  89604. /**
  89605. * Disposes the Shadow map and related Textures and effects.
  89606. */
  89607. dispose(): void;
  89608. }
  89609. /**
  89610. * Default implementation IShadowGenerator.
  89611. * This is the main object responsible of generating shadows in the framework.
  89612. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89613. */
  89614. export class ShadowGenerator implements IShadowGenerator {
  89615. /**
  89616. * Name of the shadow generator class
  89617. */
  89618. static CLASSNAME: string;
  89619. /**
  89620. * Shadow generator mode None: no filtering applied.
  89621. */
  89622. static readonly FILTER_NONE: number;
  89623. /**
  89624. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89626. */
  89627. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89628. /**
  89629. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89630. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89631. */
  89632. static readonly FILTER_POISSONSAMPLING: number;
  89633. /**
  89634. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89635. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89636. */
  89637. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89638. /**
  89639. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89640. * edge artifacts on steep falloff.
  89641. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89642. */
  89643. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89644. /**
  89645. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89646. * edge artifacts on steep falloff.
  89647. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89648. */
  89649. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89650. /**
  89651. * Shadow generator mode PCF: Percentage Closer Filtering
  89652. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89653. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89654. */
  89655. static readonly FILTER_PCF: number;
  89656. /**
  89657. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89658. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89659. * Contact Hardening
  89660. */
  89661. static readonly FILTER_PCSS: number;
  89662. /**
  89663. * Reserved for PCF and PCSS
  89664. * Highest Quality.
  89665. *
  89666. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89667. *
  89668. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89669. */
  89670. static readonly QUALITY_HIGH: number;
  89671. /**
  89672. * Reserved for PCF and PCSS
  89673. * Good tradeoff for quality/perf cross devices
  89674. *
  89675. * Execute PCF on a 3*3 kernel.
  89676. *
  89677. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89678. */
  89679. static readonly QUALITY_MEDIUM: number;
  89680. /**
  89681. * Reserved for PCF and PCSS
  89682. * The lowest quality but the fastest.
  89683. *
  89684. * Execute PCF on a 1*1 kernel.
  89685. *
  89686. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89687. */
  89688. static readonly QUALITY_LOW: number;
  89689. /** Gets or sets the custom shader name to use */
  89690. customShaderOptions: ICustomShaderOptions;
  89691. /**
  89692. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89693. */
  89694. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89695. /**
  89696. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89697. */
  89698. onAfterShadowMapRenderObservable: Observable<Effect>;
  89699. /**
  89700. * Observable triggered before a mesh is rendered in the shadow map.
  89701. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89702. */
  89703. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89704. /**
  89705. * Observable triggered after a mesh is rendered in the shadow map.
  89706. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89707. */
  89708. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89709. protected _bias: number;
  89710. /**
  89711. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89712. */
  89713. get bias(): number;
  89714. /**
  89715. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89716. */
  89717. set bias(bias: number);
  89718. protected _normalBias: number;
  89719. /**
  89720. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89721. */
  89722. get normalBias(): number;
  89723. /**
  89724. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89725. */
  89726. set normalBias(normalBias: number);
  89727. protected _blurBoxOffset: number;
  89728. /**
  89729. * Gets the blur box offset: offset applied during the blur pass.
  89730. * Only useful if useKernelBlur = false
  89731. */
  89732. get blurBoxOffset(): number;
  89733. /**
  89734. * Sets the blur box offset: offset applied during the blur pass.
  89735. * Only useful if useKernelBlur = false
  89736. */
  89737. set blurBoxOffset(value: number);
  89738. protected _blurScale: number;
  89739. /**
  89740. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89741. * 2 means half of the size.
  89742. */
  89743. get blurScale(): number;
  89744. /**
  89745. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89746. * 2 means half of the size.
  89747. */
  89748. set blurScale(value: number);
  89749. protected _blurKernel: number;
  89750. /**
  89751. * Gets the blur kernel: kernel size of the blur pass.
  89752. * Only useful if useKernelBlur = true
  89753. */
  89754. get blurKernel(): number;
  89755. /**
  89756. * Sets the blur kernel: kernel size of the blur pass.
  89757. * Only useful if useKernelBlur = true
  89758. */
  89759. set blurKernel(value: number);
  89760. protected _useKernelBlur: boolean;
  89761. /**
  89762. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89763. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89764. */
  89765. get useKernelBlur(): boolean;
  89766. /**
  89767. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89768. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89769. */
  89770. set useKernelBlur(value: boolean);
  89771. protected _depthScale: number;
  89772. /**
  89773. * Gets the depth scale used in ESM mode.
  89774. */
  89775. get depthScale(): number;
  89776. /**
  89777. * Sets the depth scale used in ESM mode.
  89778. * This can override the scale stored on the light.
  89779. */
  89780. set depthScale(value: number);
  89781. protected _validateFilter(filter: number): number;
  89782. protected _filter: number;
  89783. /**
  89784. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89785. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89786. */
  89787. get filter(): number;
  89788. /**
  89789. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89790. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89791. */
  89792. set filter(value: number);
  89793. /**
  89794. * Gets if the current filter is set to Poisson Sampling.
  89795. */
  89796. get usePoissonSampling(): boolean;
  89797. /**
  89798. * Sets the current filter to Poisson Sampling.
  89799. */
  89800. set usePoissonSampling(value: boolean);
  89801. /**
  89802. * Gets if the current filter is set to ESM.
  89803. */
  89804. get useExponentialShadowMap(): boolean;
  89805. /**
  89806. * Sets the current filter is to ESM.
  89807. */
  89808. set useExponentialShadowMap(value: boolean);
  89809. /**
  89810. * Gets if the current filter is set to filtered ESM.
  89811. */
  89812. get useBlurExponentialShadowMap(): boolean;
  89813. /**
  89814. * Gets if the current filter is set to filtered ESM.
  89815. */
  89816. set useBlurExponentialShadowMap(value: boolean);
  89817. /**
  89818. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89819. * exponential to prevent steep falloff artifacts).
  89820. */
  89821. get useCloseExponentialShadowMap(): boolean;
  89822. /**
  89823. * Sets the current filter to "close ESM" (using the inverse of the
  89824. * exponential to prevent steep falloff artifacts).
  89825. */
  89826. set useCloseExponentialShadowMap(value: boolean);
  89827. /**
  89828. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89829. * exponential to prevent steep falloff artifacts).
  89830. */
  89831. get useBlurCloseExponentialShadowMap(): boolean;
  89832. /**
  89833. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89834. * exponential to prevent steep falloff artifacts).
  89835. */
  89836. set useBlurCloseExponentialShadowMap(value: boolean);
  89837. /**
  89838. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89839. */
  89840. get usePercentageCloserFiltering(): boolean;
  89841. /**
  89842. * Sets the current filter to "PCF" (percentage closer filtering).
  89843. */
  89844. set usePercentageCloserFiltering(value: boolean);
  89845. protected _filteringQuality: number;
  89846. /**
  89847. * Gets the PCF or PCSS Quality.
  89848. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89849. */
  89850. get filteringQuality(): number;
  89851. /**
  89852. * Sets the PCF or PCSS Quality.
  89853. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89854. */
  89855. set filteringQuality(filteringQuality: number);
  89856. /**
  89857. * Gets if the current filter is set to "PCSS" (contact hardening).
  89858. */
  89859. get useContactHardeningShadow(): boolean;
  89860. /**
  89861. * Sets the current filter to "PCSS" (contact hardening).
  89862. */
  89863. set useContactHardeningShadow(value: boolean);
  89864. protected _contactHardeningLightSizeUVRatio: number;
  89865. /**
  89866. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89867. * Using a ratio helps keeping shape stability independently of the map size.
  89868. *
  89869. * It does not account for the light projection as it was having too much
  89870. * instability during the light setup or during light position changes.
  89871. *
  89872. * Only valid if useContactHardeningShadow is true.
  89873. */
  89874. get contactHardeningLightSizeUVRatio(): number;
  89875. /**
  89876. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89877. * Using a ratio helps keeping shape stability independently of the map size.
  89878. *
  89879. * It does not account for the light projection as it was having too much
  89880. * instability during the light setup or during light position changes.
  89881. *
  89882. * Only valid if useContactHardeningShadow is true.
  89883. */
  89884. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89885. protected _darkness: number;
  89886. /** Gets or sets the actual darkness of a shadow */
  89887. get darkness(): number;
  89888. set darkness(value: number);
  89889. /**
  89890. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89891. * 0 means strongest and 1 would means no shadow.
  89892. * @returns the darkness.
  89893. */
  89894. getDarkness(): number;
  89895. /**
  89896. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89897. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89898. * @returns the shadow generator allowing fluent coding.
  89899. */
  89900. setDarkness(darkness: number): ShadowGenerator;
  89901. protected _transparencyShadow: boolean;
  89902. /** Gets or sets the ability to have transparent shadow */
  89903. get transparencyShadow(): boolean;
  89904. set transparencyShadow(value: boolean);
  89905. /**
  89906. * Sets the ability to have transparent shadow (boolean).
  89907. * @param transparent True if transparent else False
  89908. * @returns the shadow generator allowing fluent coding
  89909. */
  89910. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89911. protected _shadowMap: Nullable<RenderTargetTexture>;
  89912. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89913. /**
  89914. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89915. * @returns The render target texture if present otherwise, null
  89916. */
  89917. getShadowMap(): Nullable<RenderTargetTexture>;
  89918. /**
  89919. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89920. * @returns The render target texture if the shadow map is present otherwise, null
  89921. */
  89922. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89923. /**
  89924. * Gets the class name of that object
  89925. * @returns "ShadowGenerator"
  89926. */
  89927. getClassName(): string;
  89928. /**
  89929. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89930. * @param mesh Mesh to add
  89931. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89932. * @returns the Shadow Generator itself
  89933. */
  89934. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89935. /**
  89936. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89937. * @param mesh Mesh to remove
  89938. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89939. * @returns the Shadow Generator itself
  89940. */
  89941. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89942. /**
  89943. * Controls the extent to which the shadows fade out at the edge of the frustum
  89944. */
  89945. frustumEdgeFalloff: number;
  89946. protected _light: IShadowLight;
  89947. /**
  89948. * Returns the associated light object.
  89949. * @returns the light generating the shadow
  89950. */
  89951. getLight(): IShadowLight;
  89952. /**
  89953. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89954. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89955. * It might on the other hand introduce peter panning.
  89956. */
  89957. forceBackFacesOnly: boolean;
  89958. protected _scene: Scene;
  89959. protected _lightDirection: Vector3;
  89960. protected _effect: Effect;
  89961. protected _viewMatrix: Matrix;
  89962. protected _projectionMatrix: Matrix;
  89963. protected _transformMatrix: Matrix;
  89964. protected _cachedPosition: Vector3;
  89965. protected _cachedDirection: Vector3;
  89966. protected _cachedDefines: string;
  89967. protected _currentRenderID: number;
  89968. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89969. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89970. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89971. protected _blurPostProcesses: PostProcess[];
  89972. protected _mapSize: number;
  89973. protected _currentFaceIndex: number;
  89974. protected _currentFaceIndexCache: number;
  89975. protected _textureType: number;
  89976. protected _defaultTextureMatrix: Matrix;
  89977. protected _storedUniqueId: Nullable<number>;
  89978. /** @hidden */
  89979. static _SceneComponentInitialization: (scene: Scene) => void;
  89980. /**
  89981. * Creates a ShadowGenerator object.
  89982. * A ShadowGenerator is the required tool to use the shadows.
  89983. * Each light casting shadows needs to use its own ShadowGenerator.
  89984. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89985. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89986. * @param light The light object generating the shadows.
  89987. * @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.
  89988. */
  89989. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89990. protected _initializeGenerator(): void;
  89991. protected _createTargetRenderTexture(): void;
  89992. protected _initializeShadowMap(): void;
  89993. protected _initializeBlurRTTAndPostProcesses(): void;
  89994. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89995. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89996. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89997. protected _applyFilterValues(): void;
  89998. /**
  89999. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90000. * @param onCompiled Callback triggered at the and of the effects compilation
  90001. * @param options Sets of optional options forcing the compilation with different modes
  90002. */
  90003. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90004. useInstances: boolean;
  90005. }>): void;
  90006. /**
  90007. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90008. * @param options Sets of optional options forcing the compilation with different modes
  90009. * @returns A promise that resolves when the compilation completes
  90010. */
  90011. forceCompilationAsync(options?: Partial<{
  90012. useInstances: boolean;
  90013. }>): Promise<void>;
  90014. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  90015. /**
  90016. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90017. * @param subMesh The submesh we want to render in the shadow map
  90018. * @param useInstances Defines wether will draw in the map using instances
  90019. * @returns true if ready otherwise, false
  90020. */
  90021. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90022. /**
  90023. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90024. * @param defines Defines of the material we want to update
  90025. * @param lightIndex Index of the light in the enabled light list of the material
  90026. */
  90027. prepareDefines(defines: any, lightIndex: number): void;
  90028. /**
  90029. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90030. * defined in the generator but impacting the effect).
  90031. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90032. * @param effect The effect we are binfing the information for
  90033. */
  90034. bindShadowLight(lightIndex: string, effect: Effect): void;
  90035. /**
  90036. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90037. * (eq to shadow prjection matrix * light transform matrix)
  90038. * @returns The transform matrix used to create the shadow map
  90039. */
  90040. getTransformMatrix(): Matrix;
  90041. /**
  90042. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90043. * Cube and 2D textures for instance.
  90044. */
  90045. recreateShadowMap(): void;
  90046. protected _disposeBlurPostProcesses(): void;
  90047. protected _disposeRTTandPostProcesses(): void;
  90048. /**
  90049. * Disposes the ShadowGenerator.
  90050. * Returns nothing.
  90051. */
  90052. dispose(): void;
  90053. /**
  90054. * Serializes the shadow generator setup to a json object.
  90055. * @returns The serialized JSON object
  90056. */
  90057. serialize(): any;
  90058. /**
  90059. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  90060. * @param parsedShadowGenerator The JSON object to parse
  90061. * @param scene The scene to create the shadow map for
  90062. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  90063. * @returns The parsed shadow generator
  90064. */
  90065. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  90066. }
  90067. }
  90068. declare module BABYLON {
  90069. /**
  90070. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  90071. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  90072. * 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.
  90073. */
  90074. export abstract class Light extends Node {
  90075. /**
  90076. * Falloff Default: light is falling off following the material specification:
  90077. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  90078. */
  90079. static readonly FALLOFF_DEFAULT: number;
  90080. /**
  90081. * Falloff Physical: light is falling off following the inverse squared distance law.
  90082. */
  90083. static readonly FALLOFF_PHYSICAL: number;
  90084. /**
  90085. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  90086. * to enhance interoperability with other engines.
  90087. */
  90088. static readonly FALLOFF_GLTF: number;
  90089. /**
  90090. * Falloff Standard: light is falling off like in the standard material
  90091. * to enhance interoperability with other materials.
  90092. */
  90093. static readonly FALLOFF_STANDARD: number;
  90094. /**
  90095. * If every light affecting the material is in this lightmapMode,
  90096. * material.lightmapTexture adds or multiplies
  90097. * (depends on material.useLightmapAsShadowmap)
  90098. * after every other light calculations.
  90099. */
  90100. static readonly LIGHTMAP_DEFAULT: number;
  90101. /**
  90102. * material.lightmapTexture as only diffuse lighting from this light
  90103. * adds only specular lighting from this light
  90104. * adds dynamic shadows
  90105. */
  90106. static readonly LIGHTMAP_SPECULAR: number;
  90107. /**
  90108. * material.lightmapTexture as only lighting
  90109. * no light calculation from this light
  90110. * only adds dynamic shadows from this light
  90111. */
  90112. static readonly LIGHTMAP_SHADOWSONLY: number;
  90113. /**
  90114. * Each light type uses the default quantity according to its type:
  90115. * point/spot lights use luminous intensity
  90116. * directional lights use illuminance
  90117. */
  90118. static readonly INTENSITYMODE_AUTOMATIC: number;
  90119. /**
  90120. * lumen (lm)
  90121. */
  90122. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90123. /**
  90124. * candela (lm/sr)
  90125. */
  90126. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90127. /**
  90128. * lux (lm/m^2)
  90129. */
  90130. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90131. /**
  90132. * nit (cd/m^2)
  90133. */
  90134. static readonly INTENSITYMODE_LUMINANCE: number;
  90135. /**
  90136. * Light type const id of the point light.
  90137. */
  90138. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90139. /**
  90140. * Light type const id of the directional light.
  90141. */
  90142. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90143. /**
  90144. * Light type const id of the spot light.
  90145. */
  90146. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90147. /**
  90148. * Light type const id of the hemispheric light.
  90149. */
  90150. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90151. /**
  90152. * Diffuse gives the basic color to an object.
  90153. */
  90154. diffuse: Color3;
  90155. /**
  90156. * Specular produces a highlight color on an object.
  90157. * Note: This is note affecting PBR materials.
  90158. */
  90159. specular: Color3;
  90160. /**
  90161. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90162. * falling off base on range or angle.
  90163. * This can be set to any values in Light.FALLOFF_x.
  90164. *
  90165. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90166. * other types of materials.
  90167. */
  90168. falloffType: number;
  90169. /**
  90170. * Strength of the light.
  90171. * Note: By default it is define in the framework own unit.
  90172. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90173. */
  90174. intensity: number;
  90175. private _range;
  90176. protected _inverseSquaredRange: number;
  90177. /**
  90178. * Defines how far from the source the light is impacting in scene units.
  90179. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90180. */
  90181. get range(): number;
  90182. /**
  90183. * Defines how far from the source the light is impacting in scene units.
  90184. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90185. */
  90186. set range(value: number);
  90187. /**
  90188. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90189. * of light.
  90190. */
  90191. private _photometricScale;
  90192. private _intensityMode;
  90193. /**
  90194. * Gets the photometric scale used to interpret the intensity.
  90195. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90196. */
  90197. get intensityMode(): number;
  90198. /**
  90199. * Sets the photometric scale used to interpret the intensity.
  90200. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90201. */
  90202. set intensityMode(value: number);
  90203. private _radius;
  90204. /**
  90205. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90206. */
  90207. get radius(): number;
  90208. /**
  90209. * sets the light radius used by PBR Materials to simulate soft area lights.
  90210. */
  90211. set radius(value: number);
  90212. private _renderPriority;
  90213. /**
  90214. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90215. * exceeding the number allowed of the materials.
  90216. */
  90217. renderPriority: number;
  90218. private _shadowEnabled;
  90219. /**
  90220. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90221. * the current shadow generator.
  90222. */
  90223. get shadowEnabled(): boolean;
  90224. /**
  90225. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90226. * the current shadow generator.
  90227. */
  90228. set shadowEnabled(value: boolean);
  90229. private _includedOnlyMeshes;
  90230. /**
  90231. * Gets the only meshes impacted by this light.
  90232. */
  90233. get includedOnlyMeshes(): AbstractMesh[];
  90234. /**
  90235. * Sets the only meshes impacted by this light.
  90236. */
  90237. set includedOnlyMeshes(value: AbstractMesh[]);
  90238. private _excludedMeshes;
  90239. /**
  90240. * Gets the meshes not impacted by this light.
  90241. */
  90242. get excludedMeshes(): AbstractMesh[];
  90243. /**
  90244. * Sets the meshes not impacted by this light.
  90245. */
  90246. set excludedMeshes(value: AbstractMesh[]);
  90247. private _excludeWithLayerMask;
  90248. /**
  90249. * Gets the layer id use to find what meshes are not impacted by the light.
  90250. * Inactive if 0
  90251. */
  90252. get excludeWithLayerMask(): number;
  90253. /**
  90254. * Sets the layer id use to find what meshes are not impacted by the light.
  90255. * Inactive if 0
  90256. */
  90257. set excludeWithLayerMask(value: number);
  90258. private _includeOnlyWithLayerMask;
  90259. /**
  90260. * Gets the layer id use to find what meshes are impacted by the light.
  90261. * Inactive if 0
  90262. */
  90263. get includeOnlyWithLayerMask(): number;
  90264. /**
  90265. * Sets the layer id use to find what meshes are impacted by the light.
  90266. * Inactive if 0
  90267. */
  90268. set includeOnlyWithLayerMask(value: number);
  90269. private _lightmapMode;
  90270. /**
  90271. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90272. */
  90273. get lightmapMode(): number;
  90274. /**
  90275. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90276. */
  90277. set lightmapMode(value: number);
  90278. /**
  90279. * Shadow generator associted to the light.
  90280. * @hidden Internal use only.
  90281. */
  90282. _shadowGenerator: Nullable<IShadowGenerator>;
  90283. /**
  90284. * @hidden Internal use only.
  90285. */
  90286. _excludedMeshesIds: string[];
  90287. /**
  90288. * @hidden Internal use only.
  90289. */
  90290. _includedOnlyMeshesIds: string[];
  90291. /**
  90292. * The current light unifom buffer.
  90293. * @hidden Internal use only.
  90294. */
  90295. _uniformBuffer: UniformBuffer;
  90296. /** @hidden */
  90297. _renderId: number;
  90298. /**
  90299. * Creates a Light object in the scene.
  90300. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90301. * @param name The firendly name of the light
  90302. * @param scene The scene the light belongs too
  90303. */
  90304. constructor(name: string, scene: Scene);
  90305. protected abstract _buildUniformLayout(): void;
  90306. /**
  90307. * Sets the passed Effect "effect" with the Light information.
  90308. * @param effect The effect to update
  90309. * @param lightIndex The index of the light in the effect to update
  90310. * @returns The light
  90311. */
  90312. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90313. /**
  90314. * Sets the passed Effect "effect" with the Light textures.
  90315. * @param effect The effect to update
  90316. * @param lightIndex The index of the light in the effect to update
  90317. * @returns The light
  90318. */
  90319. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90320. /**
  90321. * Binds the lights information from the scene to the effect for the given mesh.
  90322. * @param lightIndex Light index
  90323. * @param scene The scene where the light belongs to
  90324. * @param effect The effect we are binding the data to
  90325. * @param useSpecular Defines if specular is supported
  90326. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90327. */
  90328. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90329. /**
  90330. * Sets the passed Effect "effect" with the Light information.
  90331. * @param effect The effect to update
  90332. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90333. * @returns The light
  90334. */
  90335. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90336. /**
  90337. * Returns the string "Light".
  90338. * @returns the class name
  90339. */
  90340. getClassName(): string;
  90341. /** @hidden */
  90342. readonly _isLight: boolean;
  90343. /**
  90344. * Converts the light information to a readable string for debug purpose.
  90345. * @param fullDetails Supports for multiple levels of logging within scene loading
  90346. * @returns the human readable light info
  90347. */
  90348. toString(fullDetails?: boolean): string;
  90349. /** @hidden */
  90350. protected _syncParentEnabledState(): void;
  90351. /**
  90352. * Set the enabled state of this node.
  90353. * @param value - the new enabled state
  90354. */
  90355. setEnabled(value: boolean): void;
  90356. /**
  90357. * Returns the Light associated shadow generator if any.
  90358. * @return the associated shadow generator.
  90359. */
  90360. getShadowGenerator(): Nullable<IShadowGenerator>;
  90361. /**
  90362. * Returns a Vector3, the absolute light position in the World.
  90363. * @returns the world space position of the light
  90364. */
  90365. getAbsolutePosition(): Vector3;
  90366. /**
  90367. * Specifies if the light will affect the passed mesh.
  90368. * @param mesh The mesh to test against the light
  90369. * @return true the mesh is affected otherwise, false.
  90370. */
  90371. canAffectMesh(mesh: AbstractMesh): boolean;
  90372. /**
  90373. * Sort function to order lights for rendering.
  90374. * @param a First Light object to compare to second.
  90375. * @param b Second Light object to compare first.
  90376. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90377. */
  90378. static CompareLightsPriority(a: Light, b: Light): number;
  90379. /**
  90380. * Releases resources associated with this node.
  90381. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90382. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90383. */
  90384. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90385. /**
  90386. * Returns the light type ID (integer).
  90387. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90388. */
  90389. getTypeID(): number;
  90390. /**
  90391. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90392. * @returns the scaled intensity in intensity mode unit
  90393. */
  90394. getScaledIntensity(): number;
  90395. /**
  90396. * Returns a new Light object, named "name", from the current one.
  90397. * @param name The name of the cloned light
  90398. * @returns the new created light
  90399. */
  90400. clone(name: string): Nullable<Light>;
  90401. /**
  90402. * Serializes the current light into a Serialization object.
  90403. * @returns the serialized object.
  90404. */
  90405. serialize(): any;
  90406. /**
  90407. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90408. * This new light is named "name" and added to the passed scene.
  90409. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90410. * @param name The friendly name of the light
  90411. * @param scene The scene the new light will belong to
  90412. * @returns the constructor function
  90413. */
  90414. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90415. /**
  90416. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90417. * @param parsedLight The JSON representation of the light
  90418. * @param scene The scene to create the parsed light in
  90419. * @returns the created light after parsing
  90420. */
  90421. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90422. private _hookArrayForExcluded;
  90423. private _hookArrayForIncludedOnly;
  90424. private _resyncMeshes;
  90425. /**
  90426. * Forces the meshes to update their light related information in their rendering used effects
  90427. * @hidden Internal Use Only
  90428. */
  90429. _markMeshesAsLightDirty(): void;
  90430. /**
  90431. * Recomputes the cached photometric scale if needed.
  90432. */
  90433. private _computePhotometricScale;
  90434. /**
  90435. * Returns the Photometric Scale according to the light type and intensity mode.
  90436. */
  90437. private _getPhotometricScale;
  90438. /**
  90439. * Reorder the light in the scene according to their defined priority.
  90440. * @hidden Internal Use Only
  90441. */
  90442. _reorderLightsInScene(): void;
  90443. /**
  90444. * Prepares the list of defines specific to the light type.
  90445. * @param defines the list of defines
  90446. * @param lightIndex defines the index of the light for the effect
  90447. */
  90448. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90449. }
  90450. }
  90451. declare module BABYLON {
  90452. /**
  90453. * Interface used to define Action
  90454. */
  90455. export interface IAction {
  90456. /**
  90457. * Trigger for the action
  90458. */
  90459. trigger: number;
  90460. /** Options of the trigger */
  90461. triggerOptions: any;
  90462. /**
  90463. * Gets the trigger parameters
  90464. * @returns the trigger parameters
  90465. */
  90466. getTriggerParameter(): any;
  90467. /**
  90468. * Internal only - executes current action event
  90469. * @hidden
  90470. */
  90471. _executeCurrent(evt?: ActionEvent): void;
  90472. /**
  90473. * Serialize placeholder for child classes
  90474. * @param parent of child
  90475. * @returns the serialized object
  90476. */
  90477. serialize(parent: any): any;
  90478. /**
  90479. * Internal only
  90480. * @hidden
  90481. */
  90482. _prepare(): void;
  90483. /**
  90484. * Internal only - manager for action
  90485. * @hidden
  90486. */
  90487. _actionManager: AbstractActionManager;
  90488. /**
  90489. * Adds action to chain of actions, may be a DoNothingAction
  90490. * @param action defines the next action to execute
  90491. * @returns The action passed in
  90492. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90493. */
  90494. then(action: IAction): IAction;
  90495. }
  90496. /**
  90497. * The action to be carried out following a trigger
  90498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90499. */
  90500. export class Action implements IAction {
  90501. /** the trigger, with or without parameters, for the action */
  90502. triggerOptions: any;
  90503. /**
  90504. * Trigger for the action
  90505. */
  90506. trigger: number;
  90507. /**
  90508. * Internal only - manager for action
  90509. * @hidden
  90510. */
  90511. _actionManager: ActionManager;
  90512. private _nextActiveAction;
  90513. private _child;
  90514. private _condition?;
  90515. private _triggerParameter;
  90516. /**
  90517. * An event triggered prior to action being executed.
  90518. */
  90519. onBeforeExecuteObservable: Observable<Action>;
  90520. /**
  90521. * Creates a new Action
  90522. * @param triggerOptions the trigger, with or without parameters, for the action
  90523. * @param condition an optional determinant of action
  90524. */
  90525. constructor(
  90526. /** the trigger, with or without parameters, for the action */
  90527. triggerOptions: any, condition?: Condition);
  90528. /**
  90529. * Internal only
  90530. * @hidden
  90531. */
  90532. _prepare(): void;
  90533. /**
  90534. * Gets the trigger parameters
  90535. * @returns the trigger parameters
  90536. */
  90537. getTriggerParameter(): any;
  90538. /**
  90539. * Internal only - executes current action event
  90540. * @hidden
  90541. */
  90542. _executeCurrent(evt?: ActionEvent): void;
  90543. /**
  90544. * Execute placeholder for child classes
  90545. * @param evt optional action event
  90546. */
  90547. execute(evt?: ActionEvent): void;
  90548. /**
  90549. * Skips to next active action
  90550. */
  90551. skipToNextActiveAction(): void;
  90552. /**
  90553. * Adds action to chain of actions, may be a DoNothingAction
  90554. * @param action defines the next action to execute
  90555. * @returns The action passed in
  90556. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90557. */
  90558. then(action: Action): Action;
  90559. /**
  90560. * Internal only
  90561. * @hidden
  90562. */
  90563. _getProperty(propertyPath: string): string;
  90564. /**
  90565. * Internal only
  90566. * @hidden
  90567. */
  90568. _getEffectiveTarget(target: any, propertyPath: string): any;
  90569. /**
  90570. * Serialize placeholder for child classes
  90571. * @param parent of child
  90572. * @returns the serialized object
  90573. */
  90574. serialize(parent: any): any;
  90575. /**
  90576. * Internal only called by serialize
  90577. * @hidden
  90578. */
  90579. protected _serialize(serializedAction: any, parent?: any): any;
  90580. /**
  90581. * Internal only
  90582. * @hidden
  90583. */
  90584. static _SerializeValueAsString: (value: any) => string;
  90585. /**
  90586. * Internal only
  90587. * @hidden
  90588. */
  90589. static _GetTargetProperty: (target: Node | Scene) => {
  90590. name: string;
  90591. targetType: string;
  90592. value: string;
  90593. };
  90594. }
  90595. }
  90596. declare module BABYLON {
  90597. /**
  90598. * A Condition applied to an Action
  90599. */
  90600. export class Condition {
  90601. /**
  90602. * Internal only - manager for action
  90603. * @hidden
  90604. */
  90605. _actionManager: ActionManager;
  90606. /**
  90607. * Internal only
  90608. * @hidden
  90609. */
  90610. _evaluationId: number;
  90611. /**
  90612. * Internal only
  90613. * @hidden
  90614. */
  90615. _currentResult: boolean;
  90616. /**
  90617. * Creates a new Condition
  90618. * @param actionManager the manager of the action the condition is applied to
  90619. */
  90620. constructor(actionManager: ActionManager);
  90621. /**
  90622. * Check if the current condition is valid
  90623. * @returns a boolean
  90624. */
  90625. isValid(): boolean;
  90626. /**
  90627. * Internal only
  90628. * @hidden
  90629. */
  90630. _getProperty(propertyPath: string): string;
  90631. /**
  90632. * Internal only
  90633. * @hidden
  90634. */
  90635. _getEffectiveTarget(target: any, propertyPath: string): any;
  90636. /**
  90637. * Serialize placeholder for child classes
  90638. * @returns the serialized object
  90639. */
  90640. serialize(): any;
  90641. /**
  90642. * Internal only
  90643. * @hidden
  90644. */
  90645. protected _serialize(serializedCondition: any): any;
  90646. }
  90647. /**
  90648. * Defines specific conditional operators as extensions of Condition
  90649. */
  90650. export class ValueCondition extends Condition {
  90651. /** path to specify the property of the target the conditional operator uses */
  90652. propertyPath: string;
  90653. /** the value compared by the conditional operator against the current value of the property */
  90654. value: any;
  90655. /** the conditional operator, default ValueCondition.IsEqual */
  90656. operator: number;
  90657. /**
  90658. * Internal only
  90659. * @hidden
  90660. */
  90661. private static _IsEqual;
  90662. /**
  90663. * Internal only
  90664. * @hidden
  90665. */
  90666. private static _IsDifferent;
  90667. /**
  90668. * Internal only
  90669. * @hidden
  90670. */
  90671. private static _IsGreater;
  90672. /**
  90673. * Internal only
  90674. * @hidden
  90675. */
  90676. private static _IsLesser;
  90677. /**
  90678. * returns the number for IsEqual
  90679. */
  90680. static get IsEqual(): number;
  90681. /**
  90682. * Returns the number for IsDifferent
  90683. */
  90684. static get IsDifferent(): number;
  90685. /**
  90686. * Returns the number for IsGreater
  90687. */
  90688. static get IsGreater(): number;
  90689. /**
  90690. * Returns the number for IsLesser
  90691. */
  90692. static get IsLesser(): number;
  90693. /**
  90694. * Internal only The action manager for the condition
  90695. * @hidden
  90696. */
  90697. _actionManager: ActionManager;
  90698. /**
  90699. * Internal only
  90700. * @hidden
  90701. */
  90702. private _target;
  90703. /**
  90704. * Internal only
  90705. * @hidden
  90706. */
  90707. private _effectiveTarget;
  90708. /**
  90709. * Internal only
  90710. * @hidden
  90711. */
  90712. private _property;
  90713. /**
  90714. * Creates a new ValueCondition
  90715. * @param actionManager manager for the action the condition applies to
  90716. * @param target for the action
  90717. * @param propertyPath path to specify the property of the target the conditional operator uses
  90718. * @param value the value compared by the conditional operator against the current value of the property
  90719. * @param operator the conditional operator, default ValueCondition.IsEqual
  90720. */
  90721. constructor(actionManager: ActionManager, target: any,
  90722. /** path to specify the property of the target the conditional operator uses */
  90723. propertyPath: string,
  90724. /** the value compared by the conditional operator against the current value of the property */
  90725. value: any,
  90726. /** the conditional operator, default ValueCondition.IsEqual */
  90727. operator?: number);
  90728. /**
  90729. * Compares the given value with the property value for the specified conditional operator
  90730. * @returns the result of the comparison
  90731. */
  90732. isValid(): boolean;
  90733. /**
  90734. * Serialize the ValueCondition into a JSON compatible object
  90735. * @returns serialization object
  90736. */
  90737. serialize(): any;
  90738. /**
  90739. * Gets the name of the conditional operator for the ValueCondition
  90740. * @param operator the conditional operator
  90741. * @returns the name
  90742. */
  90743. static GetOperatorName(operator: number): string;
  90744. }
  90745. /**
  90746. * Defines a predicate condition as an extension of Condition
  90747. */
  90748. export class PredicateCondition extends Condition {
  90749. /** defines the predicate function used to validate the condition */
  90750. predicate: () => boolean;
  90751. /**
  90752. * Internal only - manager for action
  90753. * @hidden
  90754. */
  90755. _actionManager: ActionManager;
  90756. /**
  90757. * Creates a new PredicateCondition
  90758. * @param actionManager manager for the action the condition applies to
  90759. * @param predicate defines the predicate function used to validate the condition
  90760. */
  90761. constructor(actionManager: ActionManager,
  90762. /** defines the predicate function used to validate the condition */
  90763. predicate: () => boolean);
  90764. /**
  90765. * @returns the validity of the predicate condition
  90766. */
  90767. isValid(): boolean;
  90768. }
  90769. /**
  90770. * Defines a state condition as an extension of Condition
  90771. */
  90772. export class StateCondition extends Condition {
  90773. /** Value to compare with target state */
  90774. value: string;
  90775. /**
  90776. * Internal only - manager for action
  90777. * @hidden
  90778. */
  90779. _actionManager: ActionManager;
  90780. /**
  90781. * Internal only
  90782. * @hidden
  90783. */
  90784. private _target;
  90785. /**
  90786. * Creates a new StateCondition
  90787. * @param actionManager manager for the action the condition applies to
  90788. * @param target of the condition
  90789. * @param value to compare with target state
  90790. */
  90791. constructor(actionManager: ActionManager, target: any,
  90792. /** Value to compare with target state */
  90793. value: string);
  90794. /**
  90795. * Gets a boolean indicating if the current condition is met
  90796. * @returns the validity of the state
  90797. */
  90798. isValid(): boolean;
  90799. /**
  90800. * Serialize the StateCondition into a JSON compatible object
  90801. * @returns serialization object
  90802. */
  90803. serialize(): any;
  90804. }
  90805. }
  90806. declare module BABYLON {
  90807. /**
  90808. * This defines an action responsible to toggle a boolean once triggered.
  90809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90810. */
  90811. export class SwitchBooleanAction extends Action {
  90812. /**
  90813. * The path to the boolean property in the target object
  90814. */
  90815. propertyPath: string;
  90816. private _target;
  90817. private _effectiveTarget;
  90818. private _property;
  90819. /**
  90820. * Instantiate the action
  90821. * @param triggerOptions defines the trigger options
  90822. * @param target defines the object containing the boolean
  90823. * @param propertyPath defines the path to the boolean property in the target object
  90824. * @param condition defines the trigger related conditions
  90825. */
  90826. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90827. /** @hidden */
  90828. _prepare(): void;
  90829. /**
  90830. * Execute the action toggle the boolean value.
  90831. */
  90832. execute(): void;
  90833. /**
  90834. * Serializes the actions and its related information.
  90835. * @param parent defines the object to serialize in
  90836. * @returns the serialized object
  90837. */
  90838. serialize(parent: any): any;
  90839. }
  90840. /**
  90841. * This defines an action responsible to set a the state field of the target
  90842. * to a desired value once triggered.
  90843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90844. */
  90845. export class SetStateAction extends Action {
  90846. /**
  90847. * The value to store in the state field.
  90848. */
  90849. value: string;
  90850. private _target;
  90851. /**
  90852. * Instantiate the action
  90853. * @param triggerOptions defines the trigger options
  90854. * @param target defines the object containing the state property
  90855. * @param value defines the value to store in the state field
  90856. * @param condition defines the trigger related conditions
  90857. */
  90858. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90859. /**
  90860. * Execute the action and store the value on the target state property.
  90861. */
  90862. execute(): void;
  90863. /**
  90864. * Serializes the actions and its related information.
  90865. * @param parent defines the object to serialize in
  90866. * @returns the serialized object
  90867. */
  90868. serialize(parent: any): any;
  90869. }
  90870. /**
  90871. * This defines an action responsible to set a property of the target
  90872. * to a desired value once triggered.
  90873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90874. */
  90875. export class SetValueAction extends Action {
  90876. /**
  90877. * The path of the property to set in the target.
  90878. */
  90879. propertyPath: string;
  90880. /**
  90881. * The value to set in the property
  90882. */
  90883. value: any;
  90884. private _target;
  90885. private _effectiveTarget;
  90886. private _property;
  90887. /**
  90888. * Instantiate the action
  90889. * @param triggerOptions defines the trigger options
  90890. * @param target defines the object containing the property
  90891. * @param propertyPath defines the path of the property to set in the target
  90892. * @param value defines the value to set in the property
  90893. * @param condition defines the trigger related conditions
  90894. */
  90895. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90896. /** @hidden */
  90897. _prepare(): void;
  90898. /**
  90899. * Execute the action and set the targetted property to the desired value.
  90900. */
  90901. execute(): void;
  90902. /**
  90903. * Serializes the actions and its related information.
  90904. * @param parent defines the object to serialize in
  90905. * @returns the serialized object
  90906. */
  90907. serialize(parent: any): any;
  90908. }
  90909. /**
  90910. * This defines an action responsible to increment the target value
  90911. * to a desired value once triggered.
  90912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90913. */
  90914. export class IncrementValueAction extends Action {
  90915. /**
  90916. * The path of the property to increment in the target.
  90917. */
  90918. propertyPath: string;
  90919. /**
  90920. * The value we should increment the property by.
  90921. */
  90922. value: any;
  90923. private _target;
  90924. private _effectiveTarget;
  90925. private _property;
  90926. /**
  90927. * Instantiate the action
  90928. * @param triggerOptions defines the trigger options
  90929. * @param target defines the object containing the property
  90930. * @param propertyPath defines the path of the property to increment in the target
  90931. * @param value defines the value value we should increment the property by
  90932. * @param condition defines the trigger related conditions
  90933. */
  90934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90935. /** @hidden */
  90936. _prepare(): void;
  90937. /**
  90938. * Execute the action and increment the target of the value amount.
  90939. */
  90940. execute(): void;
  90941. /**
  90942. * Serializes the actions and its related information.
  90943. * @param parent defines the object to serialize in
  90944. * @returns the serialized object
  90945. */
  90946. serialize(parent: any): any;
  90947. }
  90948. /**
  90949. * This defines an action responsible to start an animation once triggered.
  90950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90951. */
  90952. export class PlayAnimationAction extends Action {
  90953. /**
  90954. * Where the animation should start (animation frame)
  90955. */
  90956. from: number;
  90957. /**
  90958. * Where the animation should stop (animation frame)
  90959. */
  90960. to: number;
  90961. /**
  90962. * Define if the animation should loop or stop after the first play.
  90963. */
  90964. loop?: boolean;
  90965. private _target;
  90966. /**
  90967. * Instantiate the action
  90968. * @param triggerOptions defines the trigger options
  90969. * @param target defines the target animation or animation name
  90970. * @param from defines from where the animation should start (animation frame)
  90971. * @param end defines where the animation should stop (animation frame)
  90972. * @param loop defines if the animation should loop or stop after the first play
  90973. * @param condition defines the trigger related conditions
  90974. */
  90975. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90976. /** @hidden */
  90977. _prepare(): void;
  90978. /**
  90979. * Execute the action and play the animation.
  90980. */
  90981. execute(): void;
  90982. /**
  90983. * Serializes the actions and its related information.
  90984. * @param parent defines the object to serialize in
  90985. * @returns the serialized object
  90986. */
  90987. serialize(parent: any): any;
  90988. }
  90989. /**
  90990. * This defines an action responsible to stop an animation once triggered.
  90991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90992. */
  90993. export class StopAnimationAction extends Action {
  90994. private _target;
  90995. /**
  90996. * Instantiate the action
  90997. * @param triggerOptions defines the trigger options
  90998. * @param target defines the target animation or animation name
  90999. * @param condition defines the trigger related conditions
  91000. */
  91001. constructor(triggerOptions: any, target: any, condition?: Condition);
  91002. /** @hidden */
  91003. _prepare(): void;
  91004. /**
  91005. * Execute the action and stop the animation.
  91006. */
  91007. execute(): void;
  91008. /**
  91009. * Serializes the actions and its related information.
  91010. * @param parent defines the object to serialize in
  91011. * @returns the serialized object
  91012. */
  91013. serialize(parent: any): any;
  91014. }
  91015. /**
  91016. * This defines an action responsible that does nothing once triggered.
  91017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91018. */
  91019. export class DoNothingAction extends Action {
  91020. /**
  91021. * Instantiate the action
  91022. * @param triggerOptions defines the trigger options
  91023. * @param condition defines the trigger related conditions
  91024. */
  91025. constructor(triggerOptions?: any, condition?: Condition);
  91026. /**
  91027. * Execute the action and do nothing.
  91028. */
  91029. execute(): void;
  91030. /**
  91031. * Serializes the actions and its related information.
  91032. * @param parent defines the object to serialize in
  91033. * @returns the serialized object
  91034. */
  91035. serialize(parent: any): any;
  91036. }
  91037. /**
  91038. * This defines an action responsible to trigger several actions once triggered.
  91039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91040. */
  91041. export class CombineAction extends Action {
  91042. /**
  91043. * The list of aggregated animations to run.
  91044. */
  91045. children: Action[];
  91046. /**
  91047. * Instantiate the action
  91048. * @param triggerOptions defines the trigger options
  91049. * @param children defines the list of aggregated animations to run
  91050. * @param condition defines the trigger related conditions
  91051. */
  91052. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91053. /** @hidden */
  91054. _prepare(): void;
  91055. /**
  91056. * Execute the action and executes all the aggregated actions.
  91057. */
  91058. execute(evt: ActionEvent): void;
  91059. /**
  91060. * Serializes the actions and its related information.
  91061. * @param parent defines the object to serialize in
  91062. * @returns the serialized object
  91063. */
  91064. serialize(parent: any): any;
  91065. }
  91066. /**
  91067. * This defines an action responsible to run code (external event) once triggered.
  91068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91069. */
  91070. export class ExecuteCodeAction extends Action {
  91071. /**
  91072. * The callback function to run.
  91073. */
  91074. func: (evt: ActionEvent) => void;
  91075. /**
  91076. * Instantiate the action
  91077. * @param triggerOptions defines the trigger options
  91078. * @param func defines the callback function to run
  91079. * @param condition defines the trigger related conditions
  91080. */
  91081. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91082. /**
  91083. * Execute the action and run the attached code.
  91084. */
  91085. execute(evt: ActionEvent): void;
  91086. }
  91087. /**
  91088. * This defines an action responsible to set the parent property of the target once triggered.
  91089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91090. */
  91091. export class SetParentAction extends Action {
  91092. private _parent;
  91093. private _target;
  91094. /**
  91095. * Instantiate the action
  91096. * @param triggerOptions defines the trigger options
  91097. * @param target defines the target containing the parent property
  91098. * @param parent defines from where the animation should start (animation frame)
  91099. * @param condition defines the trigger related conditions
  91100. */
  91101. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91102. /** @hidden */
  91103. _prepare(): void;
  91104. /**
  91105. * Execute the action and set the parent property.
  91106. */
  91107. execute(): void;
  91108. /**
  91109. * Serializes the actions and its related information.
  91110. * @param parent defines the object to serialize in
  91111. * @returns the serialized object
  91112. */
  91113. serialize(parent: any): any;
  91114. }
  91115. }
  91116. declare module BABYLON {
  91117. /**
  91118. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91119. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91121. */
  91122. export class ActionManager extends AbstractActionManager {
  91123. /**
  91124. * Nothing
  91125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91126. */
  91127. static readonly NothingTrigger: number;
  91128. /**
  91129. * On pick
  91130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91131. */
  91132. static readonly OnPickTrigger: number;
  91133. /**
  91134. * On left pick
  91135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91136. */
  91137. static readonly OnLeftPickTrigger: number;
  91138. /**
  91139. * On right pick
  91140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91141. */
  91142. static readonly OnRightPickTrigger: number;
  91143. /**
  91144. * On center pick
  91145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91146. */
  91147. static readonly OnCenterPickTrigger: number;
  91148. /**
  91149. * On pick down
  91150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91151. */
  91152. static readonly OnPickDownTrigger: number;
  91153. /**
  91154. * On double pick
  91155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91156. */
  91157. static readonly OnDoublePickTrigger: number;
  91158. /**
  91159. * On pick up
  91160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91161. */
  91162. static readonly OnPickUpTrigger: number;
  91163. /**
  91164. * On pick out.
  91165. * This trigger will only be raised if you also declared a OnPickDown
  91166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91167. */
  91168. static readonly OnPickOutTrigger: number;
  91169. /**
  91170. * On long press
  91171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91172. */
  91173. static readonly OnLongPressTrigger: number;
  91174. /**
  91175. * On pointer over
  91176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91177. */
  91178. static readonly OnPointerOverTrigger: number;
  91179. /**
  91180. * On pointer out
  91181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91182. */
  91183. static readonly OnPointerOutTrigger: number;
  91184. /**
  91185. * On every frame
  91186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91187. */
  91188. static readonly OnEveryFrameTrigger: number;
  91189. /**
  91190. * On intersection enter
  91191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91192. */
  91193. static readonly OnIntersectionEnterTrigger: number;
  91194. /**
  91195. * On intersection exit
  91196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91197. */
  91198. static readonly OnIntersectionExitTrigger: number;
  91199. /**
  91200. * On key down
  91201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91202. */
  91203. static readonly OnKeyDownTrigger: number;
  91204. /**
  91205. * On key up
  91206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91207. */
  91208. static readonly OnKeyUpTrigger: number;
  91209. private _scene;
  91210. /**
  91211. * Creates a new action manager
  91212. * @param scene defines the hosting scene
  91213. */
  91214. constructor(scene: Scene);
  91215. /**
  91216. * Releases all associated resources
  91217. */
  91218. dispose(): void;
  91219. /**
  91220. * Gets hosting scene
  91221. * @returns the hosting scene
  91222. */
  91223. getScene(): Scene;
  91224. /**
  91225. * Does this action manager handles actions of any of the given triggers
  91226. * @param triggers defines the triggers to be tested
  91227. * @return a boolean indicating whether one (or more) of the triggers is handled
  91228. */
  91229. hasSpecificTriggers(triggers: number[]): boolean;
  91230. /**
  91231. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91232. * speed.
  91233. * @param triggerA defines the trigger to be tested
  91234. * @param triggerB defines the trigger to be tested
  91235. * @return a boolean indicating whether one (or more) of the triggers is handled
  91236. */
  91237. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91238. /**
  91239. * Does this action manager handles actions of a given trigger
  91240. * @param trigger defines the trigger to be tested
  91241. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91242. * @return whether the trigger is handled
  91243. */
  91244. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91245. /**
  91246. * Does this action manager has pointer triggers
  91247. */
  91248. get hasPointerTriggers(): boolean;
  91249. /**
  91250. * Does this action manager has pick triggers
  91251. */
  91252. get hasPickTriggers(): boolean;
  91253. /**
  91254. * Registers an action to this action manager
  91255. * @param action defines the action to be registered
  91256. * @return the action amended (prepared) after registration
  91257. */
  91258. registerAction(action: IAction): Nullable<IAction>;
  91259. /**
  91260. * Unregisters an action to this action manager
  91261. * @param action defines the action to be unregistered
  91262. * @return a boolean indicating whether the action has been unregistered
  91263. */
  91264. unregisterAction(action: IAction): Boolean;
  91265. /**
  91266. * Process a specific trigger
  91267. * @param trigger defines the trigger to process
  91268. * @param evt defines the event details to be processed
  91269. */
  91270. processTrigger(trigger: number, evt?: IActionEvent): void;
  91271. /** @hidden */
  91272. _getEffectiveTarget(target: any, propertyPath: string): any;
  91273. /** @hidden */
  91274. _getProperty(propertyPath: string): string;
  91275. /**
  91276. * Serialize this manager to a JSON object
  91277. * @param name defines the property name to store this manager
  91278. * @returns a JSON representation of this manager
  91279. */
  91280. serialize(name: string): any;
  91281. /**
  91282. * Creates a new ActionManager from a JSON data
  91283. * @param parsedActions defines the JSON data to read from
  91284. * @param object defines the hosting mesh
  91285. * @param scene defines the hosting scene
  91286. */
  91287. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91288. /**
  91289. * Get a trigger name by index
  91290. * @param trigger defines the trigger index
  91291. * @returns a trigger name
  91292. */
  91293. static GetTriggerName(trigger: number): string;
  91294. }
  91295. }
  91296. declare module BABYLON {
  91297. /**
  91298. * Class used to represent a sprite
  91299. * @see http://doc.babylonjs.com/babylon101/sprites
  91300. */
  91301. export class Sprite {
  91302. /** defines the name */
  91303. name: string;
  91304. /** Gets or sets the current world position */
  91305. position: Vector3;
  91306. /** Gets or sets the main color */
  91307. color: Color4;
  91308. /** Gets or sets the width */
  91309. width: number;
  91310. /** Gets or sets the height */
  91311. height: number;
  91312. /** Gets or sets rotation angle */
  91313. angle: number;
  91314. /** Gets or sets the cell index in the sprite sheet */
  91315. cellIndex: number;
  91316. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91317. cellRef: string;
  91318. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91319. invertU: number;
  91320. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91321. invertV: number;
  91322. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91323. disposeWhenFinishedAnimating: boolean;
  91324. /** Gets the list of attached animations */
  91325. animations: Animation[];
  91326. /** Gets or sets a boolean indicating if the sprite can be picked */
  91327. isPickable: boolean;
  91328. /**
  91329. * Gets or sets the associated action manager
  91330. */
  91331. actionManager: Nullable<ActionManager>;
  91332. private _animationStarted;
  91333. private _loopAnimation;
  91334. private _fromIndex;
  91335. private _toIndex;
  91336. private _delay;
  91337. private _direction;
  91338. private _manager;
  91339. private _time;
  91340. private _onAnimationEnd;
  91341. /**
  91342. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91343. */
  91344. isVisible: boolean;
  91345. /**
  91346. * Gets or sets the sprite size
  91347. */
  91348. get size(): number;
  91349. set size(value: number);
  91350. /**
  91351. * Creates a new Sprite
  91352. * @param name defines the name
  91353. * @param manager defines the manager
  91354. */
  91355. constructor(
  91356. /** defines the name */
  91357. name: string, manager: ISpriteManager);
  91358. /**
  91359. * Starts an animation
  91360. * @param from defines the initial key
  91361. * @param to defines the end key
  91362. * @param loop defines if the animation must loop
  91363. * @param delay defines the start delay (in ms)
  91364. * @param onAnimationEnd defines a callback to call when animation ends
  91365. */
  91366. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91367. /** Stops current animation (if any) */
  91368. stopAnimation(): void;
  91369. /** @hidden */
  91370. _animate(deltaTime: number): void;
  91371. /** Release associated resources */
  91372. dispose(): void;
  91373. }
  91374. }
  91375. declare module BABYLON {
  91376. /**
  91377. * Information about the result of picking within a scene
  91378. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91379. */
  91380. export class PickingInfo {
  91381. /** @hidden */
  91382. _pickingUnavailable: boolean;
  91383. /**
  91384. * If the pick collided with an object
  91385. */
  91386. hit: boolean;
  91387. /**
  91388. * Distance away where the pick collided
  91389. */
  91390. distance: number;
  91391. /**
  91392. * The location of pick collision
  91393. */
  91394. pickedPoint: Nullable<Vector3>;
  91395. /**
  91396. * The mesh corresponding the the pick collision
  91397. */
  91398. pickedMesh: Nullable<AbstractMesh>;
  91399. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91400. bu: number;
  91401. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91402. bv: number;
  91403. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91404. faceId: number;
  91405. /** Id of the the submesh that was picked */
  91406. subMeshId: number;
  91407. /** If a sprite was picked, this will be the sprite the pick collided with */
  91408. pickedSprite: Nullable<Sprite>;
  91409. /**
  91410. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91411. */
  91412. originMesh: Nullable<AbstractMesh>;
  91413. /**
  91414. * The ray that was used to perform the picking.
  91415. */
  91416. ray: Nullable<Ray>;
  91417. /**
  91418. * Gets the normal correspodning to the face the pick collided with
  91419. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91420. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91421. * @returns The normal correspodning to the face the pick collided with
  91422. */
  91423. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91424. /**
  91425. * Gets the texture coordinates of where the pick occured
  91426. * @returns the vector containing the coordnates of the texture
  91427. */
  91428. getTextureCoordinates(): Nullable<Vector2>;
  91429. }
  91430. }
  91431. declare module BABYLON {
  91432. /**
  91433. * Gather the list of pointer event types as constants.
  91434. */
  91435. export class PointerEventTypes {
  91436. /**
  91437. * 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.
  91438. */
  91439. static readonly POINTERDOWN: number;
  91440. /**
  91441. * The pointerup event is fired when a pointer is no longer active.
  91442. */
  91443. static readonly POINTERUP: number;
  91444. /**
  91445. * The pointermove event is fired when a pointer changes coordinates.
  91446. */
  91447. static readonly POINTERMOVE: number;
  91448. /**
  91449. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91450. */
  91451. static readonly POINTERWHEEL: number;
  91452. /**
  91453. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91454. */
  91455. static readonly POINTERPICK: number;
  91456. /**
  91457. * The pointertap event is fired when a the object has been touched and released without drag.
  91458. */
  91459. static readonly POINTERTAP: number;
  91460. /**
  91461. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91462. */
  91463. static readonly POINTERDOUBLETAP: number;
  91464. }
  91465. /**
  91466. * Base class of pointer info types.
  91467. */
  91468. export class PointerInfoBase {
  91469. /**
  91470. * Defines the type of event (PointerEventTypes)
  91471. */
  91472. type: number;
  91473. /**
  91474. * Defines the related dom event
  91475. */
  91476. event: PointerEvent | MouseWheelEvent;
  91477. /**
  91478. * Instantiates the base class of pointers info.
  91479. * @param type Defines the type of event (PointerEventTypes)
  91480. * @param event Defines the related dom event
  91481. */
  91482. constructor(
  91483. /**
  91484. * Defines the type of event (PointerEventTypes)
  91485. */
  91486. type: number,
  91487. /**
  91488. * Defines the related dom event
  91489. */
  91490. event: PointerEvent | MouseWheelEvent);
  91491. }
  91492. /**
  91493. * This class is used to store pointer related info for the onPrePointerObservable event.
  91494. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91495. */
  91496. export class PointerInfoPre extends PointerInfoBase {
  91497. /**
  91498. * Ray from a pointer if availible (eg. 6dof controller)
  91499. */
  91500. ray: Nullable<Ray>;
  91501. /**
  91502. * Defines the local position of the pointer on the canvas.
  91503. */
  91504. localPosition: Vector2;
  91505. /**
  91506. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91507. */
  91508. skipOnPointerObservable: boolean;
  91509. /**
  91510. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91511. * @param type Defines the type of event (PointerEventTypes)
  91512. * @param event Defines the related dom event
  91513. * @param localX Defines the local x coordinates of the pointer when the event occured
  91514. * @param localY Defines the local y coordinates of the pointer when the event occured
  91515. */
  91516. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91517. }
  91518. /**
  91519. * This type contains all the data related to a pointer event in Babylon.js.
  91520. * 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.
  91521. */
  91522. export class PointerInfo extends PointerInfoBase {
  91523. /**
  91524. * Defines the picking info associated to the info (if any)\
  91525. */
  91526. pickInfo: Nullable<PickingInfo>;
  91527. /**
  91528. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91529. * @param type Defines the type of event (PointerEventTypes)
  91530. * @param event Defines the related dom event
  91531. * @param pickInfo Defines the picking info associated to the info (if any)\
  91532. */
  91533. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91534. /**
  91535. * Defines the picking info associated to the info (if any)\
  91536. */
  91537. pickInfo: Nullable<PickingInfo>);
  91538. }
  91539. /**
  91540. * Data relating to a touch event on the screen.
  91541. */
  91542. export interface PointerTouch {
  91543. /**
  91544. * X coordinate of touch.
  91545. */
  91546. x: number;
  91547. /**
  91548. * Y coordinate of touch.
  91549. */
  91550. y: number;
  91551. /**
  91552. * Id of touch. Unique for each finger.
  91553. */
  91554. pointerId: number;
  91555. /**
  91556. * Event type passed from DOM.
  91557. */
  91558. type: any;
  91559. }
  91560. }
  91561. declare module BABYLON {
  91562. /**
  91563. * Manage the mouse inputs to control the movement of a free camera.
  91564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91565. */
  91566. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91567. /**
  91568. * Define if touch is enabled in the mouse input
  91569. */
  91570. touchEnabled: boolean;
  91571. /**
  91572. * Defines the camera the input is attached to.
  91573. */
  91574. camera: FreeCamera;
  91575. /**
  91576. * Defines the buttons associated with the input to handle camera move.
  91577. */
  91578. buttons: number[];
  91579. /**
  91580. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91581. */
  91582. angularSensibility: number;
  91583. private _pointerInput;
  91584. private _onMouseMove;
  91585. private _observer;
  91586. private previousPosition;
  91587. /**
  91588. * Observable for when a pointer move event occurs containing the move offset
  91589. */
  91590. onPointerMovedObservable: Observable<{
  91591. offsetX: number;
  91592. offsetY: number;
  91593. }>;
  91594. /**
  91595. * @hidden
  91596. * If the camera should be rotated automatically based on pointer movement
  91597. */
  91598. _allowCameraRotation: boolean;
  91599. /**
  91600. * Manage the mouse inputs to control the movement of a free camera.
  91601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91602. * @param touchEnabled Defines if touch is enabled or not
  91603. */
  91604. constructor(
  91605. /**
  91606. * Define if touch is enabled in the mouse input
  91607. */
  91608. touchEnabled?: boolean);
  91609. /**
  91610. * Attach the input controls to a specific dom element to get the input from.
  91611. * @param element Defines the element the controls should be listened from
  91612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91613. */
  91614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91615. /**
  91616. * Called on JS contextmenu event.
  91617. * Override this method to provide functionality.
  91618. */
  91619. protected onContextMenu(evt: PointerEvent): void;
  91620. /**
  91621. * Detach the current controls from the specified dom element.
  91622. * @param element Defines the element to stop listening the inputs from
  91623. */
  91624. detachControl(element: Nullable<HTMLElement>): void;
  91625. /**
  91626. * Gets the class name of the current intput.
  91627. * @returns the class name
  91628. */
  91629. getClassName(): string;
  91630. /**
  91631. * Get the friendly name associated with the input class.
  91632. * @returns the input friendly name
  91633. */
  91634. getSimpleName(): string;
  91635. }
  91636. }
  91637. declare module BABYLON {
  91638. /**
  91639. * Manage the touch inputs to control the movement of a free camera.
  91640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91641. */
  91642. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91643. /**
  91644. * Defines the camera the input is attached to.
  91645. */
  91646. camera: FreeCamera;
  91647. /**
  91648. * Defines the touch sensibility for rotation.
  91649. * The higher the faster.
  91650. */
  91651. touchAngularSensibility: number;
  91652. /**
  91653. * Defines the touch sensibility for move.
  91654. * The higher the faster.
  91655. */
  91656. touchMoveSensibility: number;
  91657. private _offsetX;
  91658. private _offsetY;
  91659. private _pointerPressed;
  91660. private _pointerInput;
  91661. private _observer;
  91662. private _onLostFocus;
  91663. /**
  91664. * Attach the input controls to a specific dom element to get the input from.
  91665. * @param element Defines the element the controls should be listened from
  91666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91667. */
  91668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91669. /**
  91670. * Detach the current controls from the specified dom element.
  91671. * @param element Defines the element to stop listening the inputs from
  91672. */
  91673. detachControl(element: Nullable<HTMLElement>): void;
  91674. /**
  91675. * Update the current camera state depending on the inputs that have been used this frame.
  91676. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91677. */
  91678. checkInputs(): void;
  91679. /**
  91680. * Gets the class name of the current intput.
  91681. * @returns the class name
  91682. */
  91683. getClassName(): string;
  91684. /**
  91685. * Get the friendly name associated with the input class.
  91686. * @returns the input friendly name
  91687. */
  91688. getSimpleName(): string;
  91689. }
  91690. }
  91691. declare module BABYLON {
  91692. /**
  91693. * Default Inputs manager for the FreeCamera.
  91694. * It groups all the default supported inputs for ease of use.
  91695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91696. */
  91697. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91698. /**
  91699. * @hidden
  91700. */
  91701. _mouseInput: Nullable<FreeCameraMouseInput>;
  91702. /**
  91703. * Instantiates a new FreeCameraInputsManager.
  91704. * @param camera Defines the camera the inputs belong to
  91705. */
  91706. constructor(camera: FreeCamera);
  91707. /**
  91708. * Add keyboard input support to the input manager.
  91709. * @returns the current input manager
  91710. */
  91711. addKeyboard(): FreeCameraInputsManager;
  91712. /**
  91713. * Add mouse input support to the input manager.
  91714. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91715. * @returns the current input manager
  91716. */
  91717. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91718. /**
  91719. * Removes the mouse input support from the manager
  91720. * @returns the current input manager
  91721. */
  91722. removeMouse(): FreeCameraInputsManager;
  91723. /**
  91724. * Add touch input support to the input manager.
  91725. * @returns the current input manager
  91726. */
  91727. addTouch(): FreeCameraInputsManager;
  91728. /**
  91729. * Remove all attached input methods from a camera
  91730. */
  91731. clear(): void;
  91732. }
  91733. }
  91734. declare module BABYLON {
  91735. /**
  91736. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91737. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91738. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91739. */
  91740. export class FreeCamera extends TargetCamera {
  91741. /**
  91742. * Define the collision ellipsoid of the camera.
  91743. * This is helpful to simulate a camera body like the player body around the camera
  91744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91745. */
  91746. ellipsoid: Vector3;
  91747. /**
  91748. * Define an offset for the position of the ellipsoid around the camera.
  91749. * This can be helpful to determine the center of the body near the gravity center of the body
  91750. * instead of its head.
  91751. */
  91752. ellipsoidOffset: Vector3;
  91753. /**
  91754. * Enable or disable collisions of the camera with the rest of the scene objects.
  91755. */
  91756. checkCollisions: boolean;
  91757. /**
  91758. * Enable or disable gravity on the camera.
  91759. */
  91760. applyGravity: boolean;
  91761. /**
  91762. * Define the input manager associated to the camera.
  91763. */
  91764. inputs: FreeCameraInputsManager;
  91765. /**
  91766. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91767. * Higher values reduce sensitivity.
  91768. */
  91769. get angularSensibility(): number;
  91770. /**
  91771. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91772. * Higher values reduce sensitivity.
  91773. */
  91774. set angularSensibility(value: number);
  91775. /**
  91776. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91777. */
  91778. get keysUp(): number[];
  91779. set keysUp(value: number[]);
  91780. /**
  91781. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91782. */
  91783. get keysDown(): number[];
  91784. set keysDown(value: number[]);
  91785. /**
  91786. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91787. */
  91788. get keysLeft(): number[];
  91789. set keysLeft(value: number[]);
  91790. /**
  91791. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91792. */
  91793. get keysRight(): number[];
  91794. set keysRight(value: number[]);
  91795. /**
  91796. * Event raised when the camera collide with a mesh in the scene.
  91797. */
  91798. onCollide: (collidedMesh: AbstractMesh) => void;
  91799. private _collider;
  91800. private _needMoveForGravity;
  91801. private _oldPosition;
  91802. private _diffPosition;
  91803. private _newPosition;
  91804. /** @hidden */
  91805. _localDirection: Vector3;
  91806. /** @hidden */
  91807. _transformedDirection: Vector3;
  91808. /**
  91809. * Instantiates a Free Camera.
  91810. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91811. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91812. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91813. * @param name Define the name of the camera in the scene
  91814. * @param position Define the start position of the camera in the scene
  91815. * @param scene Define the scene the camera belongs to
  91816. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91817. */
  91818. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91819. /**
  91820. * Attached controls to the current camera.
  91821. * @param element Defines the element the controls should be listened from
  91822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91823. */
  91824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91825. /**
  91826. * Detach the current controls from the camera.
  91827. * The camera will stop reacting to inputs.
  91828. * @param element Defines the element to stop listening the inputs from
  91829. */
  91830. detachControl(element: HTMLElement): void;
  91831. private _collisionMask;
  91832. /**
  91833. * Define a collision mask to limit the list of object the camera can collide with
  91834. */
  91835. get collisionMask(): number;
  91836. set collisionMask(mask: number);
  91837. /** @hidden */
  91838. _collideWithWorld(displacement: Vector3): void;
  91839. private _onCollisionPositionChange;
  91840. /** @hidden */
  91841. _checkInputs(): void;
  91842. /** @hidden */
  91843. _decideIfNeedsToMove(): boolean;
  91844. /** @hidden */
  91845. _updatePosition(): void;
  91846. /**
  91847. * Destroy the camera and release the current resources hold by it.
  91848. */
  91849. dispose(): void;
  91850. /**
  91851. * Gets the current object class name.
  91852. * @return the class name
  91853. */
  91854. getClassName(): string;
  91855. }
  91856. }
  91857. declare module BABYLON {
  91858. /**
  91859. * Represents a gamepad control stick position
  91860. */
  91861. export class StickValues {
  91862. /**
  91863. * The x component of the control stick
  91864. */
  91865. x: number;
  91866. /**
  91867. * The y component of the control stick
  91868. */
  91869. y: number;
  91870. /**
  91871. * Initializes the gamepad x and y control stick values
  91872. * @param x The x component of the gamepad control stick value
  91873. * @param y The y component of the gamepad control stick value
  91874. */
  91875. constructor(
  91876. /**
  91877. * The x component of the control stick
  91878. */
  91879. x: number,
  91880. /**
  91881. * The y component of the control stick
  91882. */
  91883. y: number);
  91884. }
  91885. /**
  91886. * An interface which manages callbacks for gamepad button changes
  91887. */
  91888. export interface GamepadButtonChanges {
  91889. /**
  91890. * Called when a gamepad has been changed
  91891. */
  91892. changed: boolean;
  91893. /**
  91894. * Called when a gamepad press event has been triggered
  91895. */
  91896. pressChanged: boolean;
  91897. /**
  91898. * Called when a touch event has been triggered
  91899. */
  91900. touchChanged: boolean;
  91901. /**
  91902. * Called when a value has changed
  91903. */
  91904. valueChanged: boolean;
  91905. }
  91906. /**
  91907. * Represents a gamepad
  91908. */
  91909. export class Gamepad {
  91910. /**
  91911. * The id of the gamepad
  91912. */
  91913. id: string;
  91914. /**
  91915. * The index of the gamepad
  91916. */
  91917. index: number;
  91918. /**
  91919. * The browser gamepad
  91920. */
  91921. browserGamepad: any;
  91922. /**
  91923. * Specifies what type of gamepad this represents
  91924. */
  91925. type: number;
  91926. private _leftStick;
  91927. private _rightStick;
  91928. /** @hidden */
  91929. _isConnected: boolean;
  91930. private _leftStickAxisX;
  91931. private _leftStickAxisY;
  91932. private _rightStickAxisX;
  91933. private _rightStickAxisY;
  91934. /**
  91935. * Triggered when the left control stick has been changed
  91936. */
  91937. private _onleftstickchanged;
  91938. /**
  91939. * Triggered when the right control stick has been changed
  91940. */
  91941. private _onrightstickchanged;
  91942. /**
  91943. * Represents a gamepad controller
  91944. */
  91945. static GAMEPAD: number;
  91946. /**
  91947. * Represents a generic controller
  91948. */
  91949. static GENERIC: number;
  91950. /**
  91951. * Represents an XBox controller
  91952. */
  91953. static XBOX: number;
  91954. /**
  91955. * Represents a pose-enabled controller
  91956. */
  91957. static POSE_ENABLED: number;
  91958. /**
  91959. * Represents an Dual Shock controller
  91960. */
  91961. static DUALSHOCK: number;
  91962. /**
  91963. * Specifies whether the left control stick should be Y-inverted
  91964. */
  91965. protected _invertLeftStickY: boolean;
  91966. /**
  91967. * Specifies if the gamepad has been connected
  91968. */
  91969. get isConnected(): boolean;
  91970. /**
  91971. * Initializes the gamepad
  91972. * @param id The id of the gamepad
  91973. * @param index The index of the gamepad
  91974. * @param browserGamepad The browser gamepad
  91975. * @param leftStickX The x component of the left joystick
  91976. * @param leftStickY The y component of the left joystick
  91977. * @param rightStickX The x component of the right joystick
  91978. * @param rightStickY The y component of the right joystick
  91979. */
  91980. constructor(
  91981. /**
  91982. * The id of the gamepad
  91983. */
  91984. id: string,
  91985. /**
  91986. * The index of the gamepad
  91987. */
  91988. index: number,
  91989. /**
  91990. * The browser gamepad
  91991. */
  91992. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91993. /**
  91994. * Callback triggered when the left joystick has changed
  91995. * @param callback
  91996. */
  91997. onleftstickchanged(callback: (values: StickValues) => void): void;
  91998. /**
  91999. * Callback triggered when the right joystick has changed
  92000. * @param callback
  92001. */
  92002. onrightstickchanged(callback: (values: StickValues) => void): void;
  92003. /**
  92004. * Gets the left joystick
  92005. */
  92006. get leftStick(): StickValues;
  92007. /**
  92008. * Sets the left joystick values
  92009. */
  92010. set leftStick(newValues: StickValues);
  92011. /**
  92012. * Gets the right joystick
  92013. */
  92014. get rightStick(): StickValues;
  92015. /**
  92016. * Sets the right joystick value
  92017. */
  92018. set rightStick(newValues: StickValues);
  92019. /**
  92020. * Updates the gamepad joystick positions
  92021. */
  92022. update(): void;
  92023. /**
  92024. * Disposes the gamepad
  92025. */
  92026. dispose(): void;
  92027. }
  92028. /**
  92029. * Represents a generic gamepad
  92030. */
  92031. export class GenericPad extends Gamepad {
  92032. private _buttons;
  92033. private _onbuttondown;
  92034. private _onbuttonup;
  92035. /**
  92036. * Observable triggered when a button has been pressed
  92037. */
  92038. onButtonDownObservable: Observable<number>;
  92039. /**
  92040. * Observable triggered when a button has been released
  92041. */
  92042. onButtonUpObservable: Observable<number>;
  92043. /**
  92044. * Callback triggered when a button has been pressed
  92045. * @param callback Called when a button has been pressed
  92046. */
  92047. onbuttondown(callback: (buttonPressed: number) => void): void;
  92048. /**
  92049. * Callback triggered when a button has been released
  92050. * @param callback Called when a button has been released
  92051. */
  92052. onbuttonup(callback: (buttonReleased: number) => void): void;
  92053. /**
  92054. * Initializes the generic gamepad
  92055. * @param id The id of the generic gamepad
  92056. * @param index The index of the generic gamepad
  92057. * @param browserGamepad The browser gamepad
  92058. */
  92059. constructor(id: string, index: number, browserGamepad: any);
  92060. private _setButtonValue;
  92061. /**
  92062. * Updates the generic gamepad
  92063. */
  92064. update(): void;
  92065. /**
  92066. * Disposes the generic gamepad
  92067. */
  92068. dispose(): void;
  92069. }
  92070. }
  92071. declare module BABYLON {
  92072. /**
  92073. * Defines the types of pose enabled controllers that are supported
  92074. */
  92075. export enum PoseEnabledControllerType {
  92076. /**
  92077. * HTC Vive
  92078. */
  92079. VIVE = 0,
  92080. /**
  92081. * Oculus Rift
  92082. */
  92083. OCULUS = 1,
  92084. /**
  92085. * Windows mixed reality
  92086. */
  92087. WINDOWS = 2,
  92088. /**
  92089. * Samsung gear VR
  92090. */
  92091. GEAR_VR = 3,
  92092. /**
  92093. * Google Daydream
  92094. */
  92095. DAYDREAM = 4,
  92096. /**
  92097. * Generic
  92098. */
  92099. GENERIC = 5
  92100. }
  92101. /**
  92102. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92103. */
  92104. export interface MutableGamepadButton {
  92105. /**
  92106. * Value of the button/trigger
  92107. */
  92108. value: number;
  92109. /**
  92110. * If the button/trigger is currently touched
  92111. */
  92112. touched: boolean;
  92113. /**
  92114. * If the button/trigger is currently pressed
  92115. */
  92116. pressed: boolean;
  92117. }
  92118. /**
  92119. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92120. * @hidden
  92121. */
  92122. export interface ExtendedGamepadButton extends GamepadButton {
  92123. /**
  92124. * If the button/trigger is currently pressed
  92125. */
  92126. readonly pressed: boolean;
  92127. /**
  92128. * If the button/trigger is currently touched
  92129. */
  92130. readonly touched: boolean;
  92131. /**
  92132. * Value of the button/trigger
  92133. */
  92134. readonly value: number;
  92135. }
  92136. /** @hidden */
  92137. export interface _GamePadFactory {
  92138. /**
  92139. * Returns whether or not the current gamepad can be created for this type of controller.
  92140. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92141. * @returns true if it can be created, otherwise false
  92142. */
  92143. canCreate(gamepadInfo: any): boolean;
  92144. /**
  92145. * Creates a new instance of the Gamepad.
  92146. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92147. * @returns the new gamepad instance
  92148. */
  92149. create(gamepadInfo: any): Gamepad;
  92150. }
  92151. /**
  92152. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92153. */
  92154. export class PoseEnabledControllerHelper {
  92155. /** @hidden */
  92156. static _ControllerFactories: _GamePadFactory[];
  92157. /** @hidden */
  92158. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92159. /**
  92160. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92161. * @param vrGamepad the gamepad to initialized
  92162. * @returns a vr controller of the type the gamepad identified as
  92163. */
  92164. static InitiateController(vrGamepad: any): Gamepad;
  92165. }
  92166. /**
  92167. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92168. */
  92169. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92170. /**
  92171. * If the controller is used in a webXR session
  92172. */
  92173. isXR: boolean;
  92174. private _deviceRoomPosition;
  92175. private _deviceRoomRotationQuaternion;
  92176. /**
  92177. * The device position in babylon space
  92178. */
  92179. devicePosition: Vector3;
  92180. /**
  92181. * The device rotation in babylon space
  92182. */
  92183. deviceRotationQuaternion: Quaternion;
  92184. /**
  92185. * The scale factor of the device in babylon space
  92186. */
  92187. deviceScaleFactor: number;
  92188. /**
  92189. * (Likely devicePosition should be used instead) The device position in its room space
  92190. */
  92191. position: Vector3;
  92192. /**
  92193. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92194. */
  92195. rotationQuaternion: Quaternion;
  92196. /**
  92197. * The type of controller (Eg. Windows mixed reality)
  92198. */
  92199. controllerType: PoseEnabledControllerType;
  92200. protected _calculatedPosition: Vector3;
  92201. private _calculatedRotation;
  92202. /**
  92203. * The raw pose from the device
  92204. */
  92205. rawPose: DevicePose;
  92206. private _trackPosition;
  92207. private _maxRotationDistFromHeadset;
  92208. private _draggedRoomRotation;
  92209. /**
  92210. * @hidden
  92211. */
  92212. _disableTrackPosition(fixedPosition: Vector3): void;
  92213. /**
  92214. * Internal, the mesh attached to the controller
  92215. * @hidden
  92216. */
  92217. _mesh: Nullable<AbstractMesh>;
  92218. private _poseControlledCamera;
  92219. private _leftHandSystemQuaternion;
  92220. /**
  92221. * Internal, matrix used to convert room space to babylon space
  92222. * @hidden
  92223. */
  92224. _deviceToWorld: Matrix;
  92225. /**
  92226. * Node to be used when casting a ray from the controller
  92227. * @hidden
  92228. */
  92229. _pointingPoseNode: Nullable<TransformNode>;
  92230. /**
  92231. * Name of the child mesh that can be used to cast a ray from the controller
  92232. */
  92233. static readonly POINTING_POSE: string;
  92234. /**
  92235. * Creates a new PoseEnabledController from a gamepad
  92236. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92237. */
  92238. constructor(browserGamepad: any);
  92239. private _workingMatrix;
  92240. /**
  92241. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92242. */
  92243. update(): void;
  92244. /**
  92245. * Updates only the pose device and mesh without doing any button event checking
  92246. */
  92247. protected _updatePoseAndMesh(): void;
  92248. /**
  92249. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92250. * @param poseData raw pose fromthe device
  92251. */
  92252. updateFromDevice(poseData: DevicePose): void;
  92253. /**
  92254. * @hidden
  92255. */
  92256. _meshAttachedObservable: Observable<AbstractMesh>;
  92257. /**
  92258. * Attaches a mesh to the controller
  92259. * @param mesh the mesh to be attached
  92260. */
  92261. attachToMesh(mesh: AbstractMesh): void;
  92262. /**
  92263. * Attaches the controllers mesh to a camera
  92264. * @param camera the camera the mesh should be attached to
  92265. */
  92266. attachToPoseControlledCamera(camera: TargetCamera): void;
  92267. /**
  92268. * Disposes of the controller
  92269. */
  92270. dispose(): void;
  92271. /**
  92272. * The mesh that is attached to the controller
  92273. */
  92274. get mesh(): Nullable<AbstractMesh>;
  92275. /**
  92276. * Gets the ray of the controller in the direction the controller is pointing
  92277. * @param length the length the resulting ray should be
  92278. * @returns a ray in the direction the controller is pointing
  92279. */
  92280. getForwardRay(length?: number): Ray;
  92281. }
  92282. }
  92283. declare module BABYLON {
  92284. /**
  92285. * Defines the WebVRController object that represents controllers tracked in 3D space
  92286. */
  92287. export abstract class WebVRController extends PoseEnabledController {
  92288. /**
  92289. * Internal, the default controller model for the controller
  92290. */
  92291. protected _defaultModel: Nullable<AbstractMesh>;
  92292. /**
  92293. * Fired when the trigger state has changed
  92294. */
  92295. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92296. /**
  92297. * Fired when the main button state has changed
  92298. */
  92299. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92300. /**
  92301. * Fired when the secondary button state has changed
  92302. */
  92303. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92304. /**
  92305. * Fired when the pad state has changed
  92306. */
  92307. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92308. /**
  92309. * Fired when controllers stick values have changed
  92310. */
  92311. onPadValuesChangedObservable: Observable<StickValues>;
  92312. /**
  92313. * Array of button availible on the controller
  92314. */
  92315. protected _buttons: Array<MutableGamepadButton>;
  92316. private _onButtonStateChange;
  92317. /**
  92318. * Fired when a controller button's state has changed
  92319. * @param callback the callback containing the button that was modified
  92320. */
  92321. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92322. /**
  92323. * X and Y axis corresponding to the controllers joystick
  92324. */
  92325. pad: StickValues;
  92326. /**
  92327. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92328. */
  92329. hand: string;
  92330. /**
  92331. * The default controller model for the controller
  92332. */
  92333. get defaultModel(): Nullable<AbstractMesh>;
  92334. /**
  92335. * Creates a new WebVRController from a gamepad
  92336. * @param vrGamepad the gamepad that the WebVRController should be created from
  92337. */
  92338. constructor(vrGamepad: any);
  92339. /**
  92340. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92341. */
  92342. update(): void;
  92343. /**
  92344. * Function to be called when a button is modified
  92345. */
  92346. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92347. /**
  92348. * Loads a mesh and attaches it to the controller
  92349. * @param scene the scene the mesh should be added to
  92350. * @param meshLoaded callback for when the mesh has been loaded
  92351. */
  92352. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92353. private _setButtonValue;
  92354. private _changes;
  92355. private _checkChanges;
  92356. /**
  92357. * Disposes of th webVRCOntroller
  92358. */
  92359. dispose(): void;
  92360. }
  92361. }
  92362. declare module BABYLON {
  92363. /**
  92364. * The HemisphericLight simulates the ambient environment light,
  92365. * so the passed direction is the light reflection direction, not the incoming direction.
  92366. */
  92367. export class HemisphericLight extends Light {
  92368. /**
  92369. * The groundColor is the light in the opposite direction to the one specified during creation.
  92370. * 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.
  92371. */
  92372. groundColor: Color3;
  92373. /**
  92374. * The light reflection direction, not the incoming direction.
  92375. */
  92376. direction: Vector3;
  92377. /**
  92378. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92379. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92380. * The HemisphericLight can't cast shadows.
  92381. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92382. * @param name The friendly name of the light
  92383. * @param direction The direction of the light reflection
  92384. * @param scene The scene the light belongs to
  92385. */
  92386. constructor(name: string, direction: Vector3, scene: Scene);
  92387. protected _buildUniformLayout(): void;
  92388. /**
  92389. * Returns the string "HemisphericLight".
  92390. * @return The class name
  92391. */
  92392. getClassName(): string;
  92393. /**
  92394. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92395. * Returns the updated direction.
  92396. * @param target The target the direction should point to
  92397. * @return The computed direction
  92398. */
  92399. setDirectionToTarget(target: Vector3): Vector3;
  92400. /**
  92401. * Returns the shadow generator associated to the light.
  92402. * @returns Always null for hemispheric lights because it does not support shadows.
  92403. */
  92404. getShadowGenerator(): Nullable<IShadowGenerator>;
  92405. /**
  92406. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92407. * @param effect The effect to update
  92408. * @param lightIndex The index of the light in the effect to update
  92409. * @returns The hemispheric light
  92410. */
  92411. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92412. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92413. /**
  92414. * Computes the world matrix of the node
  92415. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92416. * @param useWasUpdatedFlag defines a reserved property
  92417. * @returns the world matrix
  92418. */
  92419. computeWorldMatrix(): Matrix;
  92420. /**
  92421. * Returns the integer 3.
  92422. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92423. */
  92424. getTypeID(): number;
  92425. /**
  92426. * Prepares the list of defines specific to the light type.
  92427. * @param defines the list of defines
  92428. * @param lightIndex defines the index of the light for the effect
  92429. */
  92430. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92431. }
  92432. }
  92433. declare module BABYLON {
  92434. /** @hidden */
  92435. export var vrMultiviewToSingleviewPixelShader: {
  92436. name: string;
  92437. shader: string;
  92438. };
  92439. }
  92440. declare module BABYLON {
  92441. /**
  92442. * Renders to multiple views with a single draw call
  92443. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92444. */
  92445. export class MultiviewRenderTarget extends RenderTargetTexture {
  92446. /**
  92447. * Creates a multiview render target
  92448. * @param scene scene used with the render target
  92449. * @param size the size of the render target (used for each view)
  92450. */
  92451. constructor(scene: Scene, size?: number | {
  92452. width: number;
  92453. height: number;
  92454. } | {
  92455. ratio: number;
  92456. });
  92457. /**
  92458. * @hidden
  92459. * @param faceIndex the face index, if its a cube texture
  92460. */
  92461. _bindFrameBuffer(faceIndex?: number): void;
  92462. /**
  92463. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92464. * @returns the view count
  92465. */
  92466. getViewCount(): number;
  92467. }
  92468. }
  92469. declare module BABYLON {
  92470. /**
  92471. * Represents a camera frustum
  92472. */
  92473. export class Frustum {
  92474. /**
  92475. * Gets the planes representing the frustum
  92476. * @param transform matrix to be applied to the returned planes
  92477. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92478. */
  92479. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92480. /**
  92481. * Gets the near frustum plane transformed by the transform matrix
  92482. * @param transform transformation matrix to be applied to the resulting frustum plane
  92483. * @param frustumPlane the resuling frustum plane
  92484. */
  92485. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92486. /**
  92487. * Gets the far frustum plane transformed by the transform matrix
  92488. * @param transform transformation matrix to be applied to the resulting frustum plane
  92489. * @param frustumPlane the resuling frustum plane
  92490. */
  92491. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92492. /**
  92493. * Gets the left frustum plane transformed by the transform matrix
  92494. * @param transform transformation matrix to be applied to the resulting frustum plane
  92495. * @param frustumPlane the resuling frustum plane
  92496. */
  92497. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92498. /**
  92499. * Gets the right frustum plane transformed by the transform matrix
  92500. * @param transform transformation matrix to be applied to the resulting frustum plane
  92501. * @param frustumPlane the resuling frustum plane
  92502. */
  92503. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92504. /**
  92505. * Gets the top frustum plane transformed by the transform matrix
  92506. * @param transform transformation matrix to be applied to the resulting frustum plane
  92507. * @param frustumPlane the resuling frustum plane
  92508. */
  92509. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92510. /**
  92511. * Gets the bottom frustum plane transformed by the transform matrix
  92512. * @param transform transformation matrix to be applied to the resulting frustum plane
  92513. * @param frustumPlane the resuling frustum plane
  92514. */
  92515. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92516. /**
  92517. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92518. * @param transform transformation matrix to be applied to the resulting frustum planes
  92519. * @param frustumPlanes the resuling frustum planes
  92520. */
  92521. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92522. }
  92523. }
  92524. declare module BABYLON {
  92525. interface Engine {
  92526. /**
  92527. * Creates a new multiview render target
  92528. * @param width defines the width of the texture
  92529. * @param height defines the height of the texture
  92530. * @returns the created multiview texture
  92531. */
  92532. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92533. /**
  92534. * Binds a multiview framebuffer to be drawn to
  92535. * @param multiviewTexture texture to bind
  92536. */
  92537. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92538. }
  92539. interface Camera {
  92540. /**
  92541. * @hidden
  92542. * 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)
  92543. */
  92544. _useMultiviewToSingleView: boolean;
  92545. /**
  92546. * @hidden
  92547. * 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)
  92548. */
  92549. _multiviewTexture: Nullable<RenderTargetTexture>;
  92550. /**
  92551. * @hidden
  92552. * ensures the multiview texture of the camera exists and has the specified width/height
  92553. * @param width height to set on the multiview texture
  92554. * @param height width to set on the multiview texture
  92555. */
  92556. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92557. }
  92558. interface Scene {
  92559. /** @hidden */
  92560. _transformMatrixR: Matrix;
  92561. /** @hidden */
  92562. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92563. /** @hidden */
  92564. _createMultiviewUbo(): void;
  92565. /** @hidden */
  92566. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92567. /** @hidden */
  92568. _renderMultiviewToSingleView(camera: Camera): void;
  92569. }
  92570. }
  92571. declare module BABYLON {
  92572. /**
  92573. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92574. * This will not be used for webXR as it supports displaying texture arrays directly
  92575. */
  92576. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92577. /**
  92578. * Initializes a VRMultiviewToSingleview
  92579. * @param name name of the post process
  92580. * @param camera camera to be applied to
  92581. * @param scaleFactor scaling factor to the size of the output texture
  92582. */
  92583. constructor(name: string, camera: Camera, scaleFactor: number);
  92584. }
  92585. }
  92586. declare module BABYLON {
  92587. /**
  92588. * Interface used to define additional presentation attributes
  92589. */
  92590. export interface IVRPresentationAttributes {
  92591. /**
  92592. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92593. */
  92594. highRefreshRate: boolean;
  92595. /**
  92596. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92597. */
  92598. foveationLevel: number;
  92599. }
  92600. interface Engine {
  92601. /** @hidden */
  92602. _vrDisplay: any;
  92603. /** @hidden */
  92604. _vrSupported: boolean;
  92605. /** @hidden */
  92606. _oldSize: Size;
  92607. /** @hidden */
  92608. _oldHardwareScaleFactor: number;
  92609. /** @hidden */
  92610. _vrExclusivePointerMode: boolean;
  92611. /** @hidden */
  92612. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92613. /** @hidden */
  92614. _onVRDisplayPointerRestricted: () => void;
  92615. /** @hidden */
  92616. _onVRDisplayPointerUnrestricted: () => void;
  92617. /** @hidden */
  92618. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92619. /** @hidden */
  92620. _onVrDisplayDisconnect: Nullable<() => void>;
  92621. /** @hidden */
  92622. _onVrDisplayPresentChange: Nullable<() => void>;
  92623. /**
  92624. * Observable signaled when VR display mode changes
  92625. */
  92626. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92627. /**
  92628. * Observable signaled when VR request present is complete
  92629. */
  92630. onVRRequestPresentComplete: Observable<boolean>;
  92631. /**
  92632. * Observable signaled when VR request present starts
  92633. */
  92634. onVRRequestPresentStart: Observable<Engine>;
  92635. /**
  92636. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92637. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92638. */
  92639. isInVRExclusivePointerMode: boolean;
  92640. /**
  92641. * Gets a boolean indicating if a webVR device was detected
  92642. * @returns true if a webVR device was detected
  92643. */
  92644. isVRDevicePresent(): boolean;
  92645. /**
  92646. * Gets the current webVR device
  92647. * @returns the current webVR device (or null)
  92648. */
  92649. getVRDevice(): any;
  92650. /**
  92651. * Initializes a webVR display and starts listening to display change events
  92652. * The onVRDisplayChangedObservable will be notified upon these changes
  92653. * @returns A promise containing a VRDisplay and if vr is supported
  92654. */
  92655. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92656. /** @hidden */
  92657. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92658. /**
  92659. * Gets or sets the presentation attributes used to configure VR rendering
  92660. */
  92661. vrPresentationAttributes?: IVRPresentationAttributes;
  92662. /**
  92663. * Call this function to switch to webVR mode
  92664. * Will do nothing if webVR is not supported or if there is no webVR device
  92665. * @param options the webvr options provided to the camera. mainly used for multiview
  92666. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92667. */
  92668. enableVR(options: WebVROptions): void;
  92669. /** @hidden */
  92670. _onVRFullScreenTriggered(): void;
  92671. }
  92672. }
  92673. declare module BABYLON {
  92674. /**
  92675. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92676. * IMPORTANT!! The data is right-hand data.
  92677. * @export
  92678. * @interface DevicePose
  92679. */
  92680. export interface DevicePose {
  92681. /**
  92682. * The position of the device, values in array are [x,y,z].
  92683. */
  92684. readonly position: Nullable<Float32Array>;
  92685. /**
  92686. * The linearVelocity of the device, values in array are [x,y,z].
  92687. */
  92688. readonly linearVelocity: Nullable<Float32Array>;
  92689. /**
  92690. * The linearAcceleration of the device, values in array are [x,y,z].
  92691. */
  92692. readonly linearAcceleration: Nullable<Float32Array>;
  92693. /**
  92694. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92695. */
  92696. readonly orientation: Nullable<Float32Array>;
  92697. /**
  92698. * The angularVelocity of the device, values in array are [x,y,z].
  92699. */
  92700. readonly angularVelocity: Nullable<Float32Array>;
  92701. /**
  92702. * The angularAcceleration of the device, values in array are [x,y,z].
  92703. */
  92704. readonly angularAcceleration: Nullable<Float32Array>;
  92705. }
  92706. /**
  92707. * Interface representing a pose controlled object in Babylon.
  92708. * A pose controlled object has both regular pose values as well as pose values
  92709. * from an external device such as a VR head mounted display
  92710. */
  92711. export interface PoseControlled {
  92712. /**
  92713. * The position of the object in babylon space.
  92714. */
  92715. position: Vector3;
  92716. /**
  92717. * The rotation quaternion of the object in babylon space.
  92718. */
  92719. rotationQuaternion: Quaternion;
  92720. /**
  92721. * The position of the device in babylon space.
  92722. */
  92723. devicePosition?: Vector3;
  92724. /**
  92725. * The rotation quaternion of the device in babylon space.
  92726. */
  92727. deviceRotationQuaternion: Quaternion;
  92728. /**
  92729. * The raw pose coming from the device.
  92730. */
  92731. rawPose: Nullable<DevicePose>;
  92732. /**
  92733. * The scale of the device to be used when translating from device space to babylon space.
  92734. */
  92735. deviceScaleFactor: number;
  92736. /**
  92737. * Updates the poseControlled values based on the input device pose.
  92738. * @param poseData the pose data to update the object with
  92739. */
  92740. updateFromDevice(poseData: DevicePose): void;
  92741. }
  92742. /**
  92743. * Set of options to customize the webVRCamera
  92744. */
  92745. export interface WebVROptions {
  92746. /**
  92747. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92748. */
  92749. trackPosition?: boolean;
  92750. /**
  92751. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92752. */
  92753. positionScale?: number;
  92754. /**
  92755. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92756. */
  92757. displayName?: string;
  92758. /**
  92759. * Should the native controller meshes be initialized. (default: true)
  92760. */
  92761. controllerMeshes?: boolean;
  92762. /**
  92763. * Creating a default HemiLight only on controllers. (default: true)
  92764. */
  92765. defaultLightingOnControllers?: boolean;
  92766. /**
  92767. * If you don't want to use the default VR button of the helper. (default: false)
  92768. */
  92769. useCustomVRButton?: boolean;
  92770. /**
  92771. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92772. */
  92773. customVRButton?: HTMLButtonElement;
  92774. /**
  92775. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92776. */
  92777. rayLength?: number;
  92778. /**
  92779. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92780. */
  92781. defaultHeight?: number;
  92782. /**
  92783. * If multiview should be used if availible (default: false)
  92784. */
  92785. useMultiview?: boolean;
  92786. }
  92787. /**
  92788. * This represents a WebVR camera.
  92789. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92790. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92791. */
  92792. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92793. private webVROptions;
  92794. /**
  92795. * @hidden
  92796. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92797. */
  92798. _vrDevice: any;
  92799. /**
  92800. * The rawPose of the vrDevice.
  92801. */
  92802. rawPose: Nullable<DevicePose>;
  92803. private _onVREnabled;
  92804. private _specsVersion;
  92805. private _attached;
  92806. private _frameData;
  92807. protected _descendants: Array<Node>;
  92808. private _deviceRoomPosition;
  92809. /** @hidden */
  92810. _deviceRoomRotationQuaternion: Quaternion;
  92811. private _standingMatrix;
  92812. /**
  92813. * Represents device position in babylon space.
  92814. */
  92815. devicePosition: Vector3;
  92816. /**
  92817. * Represents device rotation in babylon space.
  92818. */
  92819. deviceRotationQuaternion: Quaternion;
  92820. /**
  92821. * The scale of the device to be used when translating from device space to babylon space.
  92822. */
  92823. deviceScaleFactor: number;
  92824. private _deviceToWorld;
  92825. private _worldToDevice;
  92826. /**
  92827. * References to the webVR controllers for the vrDevice.
  92828. */
  92829. controllers: Array<WebVRController>;
  92830. /**
  92831. * Emits an event when a controller is attached.
  92832. */
  92833. onControllersAttachedObservable: Observable<WebVRController[]>;
  92834. /**
  92835. * Emits an event when a controller's mesh has been loaded;
  92836. */
  92837. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92838. /**
  92839. * Emits an event when the HMD's pose has been updated.
  92840. */
  92841. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92842. private _poseSet;
  92843. /**
  92844. * If the rig cameras be used as parent instead of this camera.
  92845. */
  92846. rigParenting: boolean;
  92847. private _lightOnControllers;
  92848. private _defaultHeight?;
  92849. /**
  92850. * Instantiates a WebVRFreeCamera.
  92851. * @param name The name of the WebVRFreeCamera
  92852. * @param position The starting anchor position for the camera
  92853. * @param scene The scene the camera belongs to
  92854. * @param webVROptions a set of customizable options for the webVRCamera
  92855. */
  92856. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92857. /**
  92858. * Gets the device distance from the ground in meters.
  92859. * @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.
  92860. */
  92861. deviceDistanceToRoomGround(): number;
  92862. /**
  92863. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92864. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92865. */
  92866. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92867. /**
  92868. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92869. * @returns A promise with a boolean set to if the standing matrix is supported.
  92870. */
  92871. useStandingMatrixAsync(): Promise<boolean>;
  92872. /**
  92873. * Disposes the camera
  92874. */
  92875. dispose(): void;
  92876. /**
  92877. * Gets a vrController by name.
  92878. * @param name The name of the controller to retreive
  92879. * @returns the controller matching the name specified or null if not found
  92880. */
  92881. getControllerByName(name: string): Nullable<WebVRController>;
  92882. private _leftController;
  92883. /**
  92884. * The controller corresponding to the users left hand.
  92885. */
  92886. get leftController(): Nullable<WebVRController>;
  92887. private _rightController;
  92888. /**
  92889. * The controller corresponding to the users right hand.
  92890. */
  92891. get rightController(): Nullable<WebVRController>;
  92892. /**
  92893. * Casts a ray forward from the vrCamera's gaze.
  92894. * @param length Length of the ray (default: 100)
  92895. * @returns the ray corresponding to the gaze
  92896. */
  92897. getForwardRay(length?: number): Ray;
  92898. /**
  92899. * @hidden
  92900. * Updates the camera based on device's frame data
  92901. */
  92902. _checkInputs(): void;
  92903. /**
  92904. * Updates the poseControlled values based on the input device pose.
  92905. * @param poseData Pose coming from the device
  92906. */
  92907. updateFromDevice(poseData: DevicePose): void;
  92908. private _htmlElementAttached;
  92909. private _detachIfAttached;
  92910. /**
  92911. * WebVR's attach control will start broadcasting frames to the device.
  92912. * Note that in certain browsers (chrome for example) this function must be called
  92913. * within a user-interaction callback. Example:
  92914. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92915. *
  92916. * @param element html element to attach the vrDevice to
  92917. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92918. */
  92919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92920. /**
  92921. * Detaches the camera from the html element and disables VR
  92922. *
  92923. * @param element html element to detach from
  92924. */
  92925. detachControl(element: HTMLElement): void;
  92926. /**
  92927. * @returns the name of this class
  92928. */
  92929. getClassName(): string;
  92930. /**
  92931. * Calls resetPose on the vrDisplay
  92932. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92933. */
  92934. resetToCurrentRotation(): void;
  92935. /**
  92936. * @hidden
  92937. * Updates the rig cameras (left and right eye)
  92938. */
  92939. _updateRigCameras(): void;
  92940. private _workingVector;
  92941. private _oneVector;
  92942. private _workingMatrix;
  92943. private updateCacheCalled;
  92944. private _correctPositionIfNotTrackPosition;
  92945. /**
  92946. * @hidden
  92947. * Updates the cached values of the camera
  92948. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92949. */
  92950. _updateCache(ignoreParentClass?: boolean): void;
  92951. /**
  92952. * @hidden
  92953. * Get current device position in babylon world
  92954. */
  92955. _computeDevicePosition(): void;
  92956. /**
  92957. * Updates the current device position and rotation in the babylon world
  92958. */
  92959. update(): void;
  92960. /**
  92961. * @hidden
  92962. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92963. * @returns an identity matrix
  92964. */
  92965. _getViewMatrix(): Matrix;
  92966. private _tmpMatrix;
  92967. /**
  92968. * This function is called by the two RIG cameras.
  92969. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92970. * @hidden
  92971. */
  92972. _getWebVRViewMatrix(): Matrix;
  92973. /** @hidden */
  92974. _getWebVRProjectionMatrix(): Matrix;
  92975. private _onGamepadConnectedObserver;
  92976. private _onGamepadDisconnectedObserver;
  92977. private _updateCacheWhenTrackingDisabledObserver;
  92978. /**
  92979. * Initializes the controllers and their meshes
  92980. */
  92981. initControllers(): void;
  92982. }
  92983. }
  92984. declare module BABYLON {
  92985. /**
  92986. * Size options for a post process
  92987. */
  92988. export type PostProcessOptions = {
  92989. width: number;
  92990. height: number;
  92991. };
  92992. /**
  92993. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92994. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92995. */
  92996. export class PostProcess {
  92997. /** Name of the PostProcess. */
  92998. name: string;
  92999. /**
  93000. * Gets or sets the unique id of the post process
  93001. */
  93002. uniqueId: number;
  93003. /**
  93004. * Width of the texture to apply the post process on
  93005. */
  93006. width: number;
  93007. /**
  93008. * Height of the texture to apply the post process on
  93009. */
  93010. height: number;
  93011. /**
  93012. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  93013. * @hidden
  93014. */
  93015. _outputTexture: Nullable<InternalTexture>;
  93016. /**
  93017. * Sampling mode used by the shader
  93018. * See https://doc.babylonjs.com/classes/3.1/texture
  93019. */
  93020. renderTargetSamplingMode: number;
  93021. /**
  93022. * Clear color to use when screen clearing
  93023. */
  93024. clearColor: Color4;
  93025. /**
  93026. * If the buffer needs to be cleared before applying the post process. (default: true)
  93027. * Should be set to false if shader will overwrite all previous pixels.
  93028. */
  93029. autoClear: boolean;
  93030. /**
  93031. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  93032. */
  93033. alphaMode: number;
  93034. /**
  93035. * Sets the setAlphaBlendConstants of the babylon engine
  93036. */
  93037. alphaConstants: Color4;
  93038. /**
  93039. * Animations to be used for the post processing
  93040. */
  93041. animations: Animation[];
  93042. /**
  93043. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  93044. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  93045. */
  93046. enablePixelPerfectMode: boolean;
  93047. /**
  93048. * Force the postprocess to be applied without taking in account viewport
  93049. */
  93050. forceFullscreenViewport: boolean;
  93051. /**
  93052. * List of inspectable custom properties (used by the Inspector)
  93053. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93054. */
  93055. inspectableCustomProperties: IInspectable[];
  93056. /**
  93057. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  93058. *
  93059. * | Value | Type | Description |
  93060. * | ----- | ----------------------------------- | ----------- |
  93061. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  93062. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  93063. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  93064. *
  93065. */
  93066. scaleMode: number;
  93067. /**
  93068. * Force textures to be a power of two (default: false)
  93069. */
  93070. alwaysForcePOT: boolean;
  93071. private _samples;
  93072. /**
  93073. * Number of sample textures (default: 1)
  93074. */
  93075. get samples(): number;
  93076. set samples(n: number);
  93077. /**
  93078. * Modify the scale of the post process to be the same as the viewport (default: false)
  93079. */
  93080. adaptScaleToCurrentViewport: boolean;
  93081. private _camera;
  93082. private _scene;
  93083. private _engine;
  93084. private _options;
  93085. private _reusable;
  93086. private _textureType;
  93087. private _textureFormat;
  93088. /**
  93089. * Smart array of input and output textures for the post process.
  93090. * @hidden
  93091. */
  93092. _textures: SmartArray<InternalTexture>;
  93093. /**
  93094. * The index in _textures that corresponds to the output texture.
  93095. * @hidden
  93096. */
  93097. _currentRenderTextureInd: number;
  93098. private _effect;
  93099. private _samplers;
  93100. private _fragmentUrl;
  93101. private _vertexUrl;
  93102. private _parameters;
  93103. private _scaleRatio;
  93104. protected _indexParameters: any;
  93105. private _shareOutputWithPostProcess;
  93106. private _texelSize;
  93107. private _forcedOutputTexture;
  93108. /**
  93109. * Returns the fragment url or shader name used in the post process.
  93110. * @returns the fragment url or name in the shader store.
  93111. */
  93112. getEffectName(): string;
  93113. /**
  93114. * An event triggered when the postprocess is activated.
  93115. */
  93116. onActivateObservable: Observable<Camera>;
  93117. private _onActivateObserver;
  93118. /**
  93119. * A function that is added to the onActivateObservable
  93120. */
  93121. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93122. /**
  93123. * An event triggered when the postprocess changes its size.
  93124. */
  93125. onSizeChangedObservable: Observable<PostProcess>;
  93126. private _onSizeChangedObserver;
  93127. /**
  93128. * A function that is added to the onSizeChangedObservable
  93129. */
  93130. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93131. /**
  93132. * An event triggered when the postprocess applies its effect.
  93133. */
  93134. onApplyObservable: Observable<Effect>;
  93135. private _onApplyObserver;
  93136. /**
  93137. * A function that is added to the onApplyObservable
  93138. */
  93139. set onApply(callback: (effect: Effect) => void);
  93140. /**
  93141. * An event triggered before rendering the postprocess
  93142. */
  93143. onBeforeRenderObservable: Observable<Effect>;
  93144. private _onBeforeRenderObserver;
  93145. /**
  93146. * A function that is added to the onBeforeRenderObservable
  93147. */
  93148. set onBeforeRender(callback: (effect: Effect) => void);
  93149. /**
  93150. * An event triggered after rendering the postprocess
  93151. */
  93152. onAfterRenderObservable: Observable<Effect>;
  93153. private _onAfterRenderObserver;
  93154. /**
  93155. * A function that is added to the onAfterRenderObservable
  93156. */
  93157. set onAfterRender(callback: (efect: Effect) => void);
  93158. /**
  93159. * 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
  93160. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93161. */
  93162. get inputTexture(): InternalTexture;
  93163. set inputTexture(value: InternalTexture);
  93164. /**
  93165. * Gets the camera which post process is applied to.
  93166. * @returns The camera the post process is applied to.
  93167. */
  93168. getCamera(): Camera;
  93169. /**
  93170. * Gets the texel size of the postprocess.
  93171. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93172. */
  93173. get texelSize(): Vector2;
  93174. /**
  93175. * Creates a new instance PostProcess
  93176. * @param name The name of the PostProcess.
  93177. * @param fragmentUrl The url of the fragment shader to be used.
  93178. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93179. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93180. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93181. * @param camera The camera to apply the render pass to.
  93182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93183. * @param engine The engine which the post process will be applied. (default: current engine)
  93184. * @param reusable If the post process can be reused on the same frame. (default: false)
  93185. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93186. * @param textureType Type of textures used when performing the post process. (default: 0)
  93187. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93188. * @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
  93189. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93190. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93191. */
  93192. constructor(
  93193. /** Name of the PostProcess. */
  93194. 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, textureFormat?: number);
  93195. /**
  93196. * Gets a string idenfifying the name of the class
  93197. * @returns "PostProcess" string
  93198. */
  93199. getClassName(): string;
  93200. /**
  93201. * Gets the engine which this post process belongs to.
  93202. * @returns The engine the post process was enabled with.
  93203. */
  93204. getEngine(): Engine;
  93205. /**
  93206. * The effect that is created when initializing the post process.
  93207. * @returns The created effect corresponding the the postprocess.
  93208. */
  93209. getEffect(): Effect;
  93210. /**
  93211. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93212. * @param postProcess The post process to share the output with.
  93213. * @returns This post process.
  93214. */
  93215. shareOutputWith(postProcess: PostProcess): PostProcess;
  93216. /**
  93217. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93218. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93219. */
  93220. useOwnOutput(): void;
  93221. /**
  93222. * Updates the effect with the current post process compile time values and recompiles the shader.
  93223. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93224. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93225. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93226. * @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
  93227. * @param onCompiled Called when the shader has been compiled.
  93228. * @param onError Called if there is an error when compiling a shader.
  93229. */
  93230. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93231. /**
  93232. * The post process is reusable if it can be used multiple times within one frame.
  93233. * @returns If the post process is reusable
  93234. */
  93235. isReusable(): boolean;
  93236. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93237. markTextureDirty(): void;
  93238. /**
  93239. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93240. * 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.
  93241. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93242. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93243. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93244. * @returns The target texture that was bound to be written to.
  93245. */
  93246. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93247. /**
  93248. * If the post process is supported.
  93249. */
  93250. get isSupported(): boolean;
  93251. /**
  93252. * The aspect ratio of the output texture.
  93253. */
  93254. get aspectRatio(): number;
  93255. /**
  93256. * Get a value indicating if the post-process is ready to be used
  93257. * @returns true if the post-process is ready (shader is compiled)
  93258. */
  93259. isReady(): boolean;
  93260. /**
  93261. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93262. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93263. */
  93264. apply(): Nullable<Effect>;
  93265. private _disposeTextures;
  93266. /**
  93267. * Disposes the post process.
  93268. * @param camera The camera to dispose the post process on.
  93269. */
  93270. dispose(camera?: Camera): void;
  93271. }
  93272. }
  93273. declare module BABYLON {
  93274. /** @hidden */
  93275. export var kernelBlurVaryingDeclaration: {
  93276. name: string;
  93277. shader: string;
  93278. };
  93279. }
  93280. declare module BABYLON {
  93281. /** @hidden */
  93282. export var kernelBlurFragment: {
  93283. name: string;
  93284. shader: string;
  93285. };
  93286. }
  93287. declare module BABYLON {
  93288. /** @hidden */
  93289. export var kernelBlurFragment2: {
  93290. name: string;
  93291. shader: string;
  93292. };
  93293. }
  93294. declare module BABYLON {
  93295. /** @hidden */
  93296. export var kernelBlurPixelShader: {
  93297. name: string;
  93298. shader: string;
  93299. };
  93300. }
  93301. declare module BABYLON {
  93302. /** @hidden */
  93303. export var kernelBlurVertex: {
  93304. name: string;
  93305. shader: string;
  93306. };
  93307. }
  93308. declare module BABYLON {
  93309. /** @hidden */
  93310. export var kernelBlurVertexShader: {
  93311. name: string;
  93312. shader: string;
  93313. };
  93314. }
  93315. declare module BABYLON {
  93316. /**
  93317. * The Blur Post Process which blurs an image based on a kernel and direction.
  93318. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93319. */
  93320. export class BlurPostProcess extends PostProcess {
  93321. /** The direction in which to blur the image. */
  93322. direction: Vector2;
  93323. private blockCompilation;
  93324. protected _kernel: number;
  93325. protected _idealKernel: number;
  93326. protected _packedFloat: boolean;
  93327. private _staticDefines;
  93328. /**
  93329. * Sets the length in pixels of the blur sample region
  93330. */
  93331. set kernel(v: number);
  93332. /**
  93333. * Gets the length in pixels of the blur sample region
  93334. */
  93335. get kernel(): number;
  93336. /**
  93337. * Sets wether or not the blur needs to unpack/repack floats
  93338. */
  93339. set packedFloat(v: boolean);
  93340. /**
  93341. * Gets wether or not the blur is unpacking/repacking floats
  93342. */
  93343. get packedFloat(): boolean;
  93344. /**
  93345. * Creates a new instance BlurPostProcess
  93346. * @param name The name of the effect.
  93347. * @param direction The direction in which to blur the image.
  93348. * @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.
  93349. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93350. * @param camera The camera to apply the render pass to.
  93351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93352. * @param engine The engine which the post process will be applied. (default: current engine)
  93353. * @param reusable If the post process can be reused on the same frame. (default: false)
  93354. * @param textureType Type of textures used when performing the post process. (default: 0)
  93355. * @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)
  93356. */
  93357. constructor(name: string,
  93358. /** The direction in which to blur the image. */
  93359. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93360. /**
  93361. * Updates the effect with the current post process compile time values and recompiles the shader.
  93362. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93363. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93364. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93365. * @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
  93366. * @param onCompiled Called when the shader has been compiled.
  93367. * @param onError Called if there is an error when compiling a shader.
  93368. */
  93369. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93370. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93371. /**
  93372. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93373. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93374. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93375. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93376. * The gaps between physical kernels are compensated for in the weighting of the samples
  93377. * @param idealKernel Ideal blur kernel.
  93378. * @return Nearest best kernel.
  93379. */
  93380. protected _nearestBestKernel(idealKernel: number): number;
  93381. /**
  93382. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93383. * @param x The point on the Gaussian distribution to sample.
  93384. * @return the value of the Gaussian function at x.
  93385. */
  93386. protected _gaussianWeight(x: number): number;
  93387. /**
  93388. * Generates a string that can be used as a floating point number in GLSL.
  93389. * @param x Value to print.
  93390. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93391. * @return GLSL float string.
  93392. */
  93393. protected _glslFloat(x: number, decimalFigures?: number): string;
  93394. }
  93395. }
  93396. declare module BABYLON {
  93397. /**
  93398. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93399. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93400. * You can then easily use it as a reflectionTexture on a flat surface.
  93401. * In case the surface is not a plane, please consider relying on reflection probes.
  93402. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93403. */
  93404. export class MirrorTexture extends RenderTargetTexture {
  93405. private scene;
  93406. /**
  93407. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93408. * 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.
  93409. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93410. */
  93411. mirrorPlane: Plane;
  93412. /**
  93413. * Define the blur ratio used to blur the reflection if needed.
  93414. */
  93415. set blurRatio(value: number);
  93416. get blurRatio(): number;
  93417. /**
  93418. * Define the adaptive blur kernel used to blur the reflection if needed.
  93419. * This will autocompute the closest best match for the `blurKernel`
  93420. */
  93421. set adaptiveBlurKernel(value: number);
  93422. /**
  93423. * Define the blur kernel used to blur the reflection if needed.
  93424. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93425. */
  93426. set blurKernel(value: number);
  93427. /**
  93428. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93429. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93430. */
  93431. set blurKernelX(value: number);
  93432. get blurKernelX(): number;
  93433. /**
  93434. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93435. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93436. */
  93437. set blurKernelY(value: number);
  93438. get blurKernelY(): number;
  93439. private _autoComputeBlurKernel;
  93440. protected _onRatioRescale(): void;
  93441. private _updateGammaSpace;
  93442. private _imageProcessingConfigChangeObserver;
  93443. private _transformMatrix;
  93444. private _mirrorMatrix;
  93445. private _savedViewMatrix;
  93446. private _blurX;
  93447. private _blurY;
  93448. private _adaptiveBlurKernel;
  93449. private _blurKernelX;
  93450. private _blurKernelY;
  93451. private _blurRatio;
  93452. /**
  93453. * Instantiates a Mirror Texture.
  93454. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93455. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93456. * You can then easily use it as a reflectionTexture on a flat surface.
  93457. * In case the surface is not a plane, please consider relying on reflection probes.
  93458. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93459. * @param name
  93460. * @param size
  93461. * @param scene
  93462. * @param generateMipMaps
  93463. * @param type
  93464. * @param samplingMode
  93465. * @param generateDepthBuffer
  93466. */
  93467. constructor(name: string, size: number | {
  93468. width: number;
  93469. height: number;
  93470. } | {
  93471. ratio: number;
  93472. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93473. private _preparePostProcesses;
  93474. /**
  93475. * Clone the mirror texture.
  93476. * @returns the cloned texture
  93477. */
  93478. clone(): MirrorTexture;
  93479. /**
  93480. * Serialize the texture to a JSON representation you could use in Parse later on
  93481. * @returns the serialized JSON representation
  93482. */
  93483. serialize(): any;
  93484. /**
  93485. * Dispose the texture and release its associated resources.
  93486. */
  93487. dispose(): void;
  93488. }
  93489. }
  93490. declare module BABYLON {
  93491. /**
  93492. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93493. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93494. */
  93495. export class Texture extends BaseTexture {
  93496. /**
  93497. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93498. */
  93499. static SerializeBuffers: boolean;
  93500. /** @hidden */
  93501. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93502. /** @hidden */
  93503. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93504. /** @hidden */
  93505. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93506. /** nearest is mag = nearest and min = nearest and mip = linear */
  93507. static readonly NEAREST_SAMPLINGMODE: number;
  93508. /** nearest is mag = nearest and min = nearest and mip = linear */
  93509. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93511. static readonly BILINEAR_SAMPLINGMODE: number;
  93512. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93513. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93514. /** Trilinear is mag = linear and min = linear and mip = linear */
  93515. static readonly TRILINEAR_SAMPLINGMODE: number;
  93516. /** Trilinear is mag = linear and min = linear and mip = linear */
  93517. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93518. /** mag = nearest and min = nearest and mip = nearest */
  93519. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93520. /** mag = nearest and min = linear and mip = nearest */
  93521. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93522. /** mag = nearest and min = linear and mip = linear */
  93523. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93524. /** mag = nearest and min = linear and mip = none */
  93525. static readonly NEAREST_LINEAR: number;
  93526. /** mag = nearest and min = nearest and mip = none */
  93527. static readonly NEAREST_NEAREST: number;
  93528. /** mag = linear and min = nearest and mip = nearest */
  93529. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93530. /** mag = linear and min = nearest and mip = linear */
  93531. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93532. /** mag = linear and min = linear and mip = none */
  93533. static readonly LINEAR_LINEAR: number;
  93534. /** mag = linear and min = nearest and mip = none */
  93535. static readonly LINEAR_NEAREST: number;
  93536. /** Explicit coordinates mode */
  93537. static readonly EXPLICIT_MODE: number;
  93538. /** Spherical coordinates mode */
  93539. static readonly SPHERICAL_MODE: number;
  93540. /** Planar coordinates mode */
  93541. static readonly PLANAR_MODE: number;
  93542. /** Cubic coordinates mode */
  93543. static readonly CUBIC_MODE: number;
  93544. /** Projection coordinates mode */
  93545. static readonly PROJECTION_MODE: number;
  93546. /** Inverse Cubic coordinates mode */
  93547. static readonly SKYBOX_MODE: number;
  93548. /** Inverse Cubic coordinates mode */
  93549. static readonly INVCUBIC_MODE: number;
  93550. /** Equirectangular coordinates mode */
  93551. static readonly EQUIRECTANGULAR_MODE: number;
  93552. /** Equirectangular Fixed coordinates mode */
  93553. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93554. /** Equirectangular Fixed Mirrored coordinates mode */
  93555. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93556. /** Texture is not repeating outside of 0..1 UVs */
  93557. static readonly CLAMP_ADDRESSMODE: number;
  93558. /** Texture is repeating outside of 0..1 UVs */
  93559. static readonly WRAP_ADDRESSMODE: number;
  93560. /** Texture is repeating and mirrored */
  93561. static readonly MIRROR_ADDRESSMODE: number;
  93562. /**
  93563. * 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
  93564. */
  93565. static UseSerializedUrlIfAny: boolean;
  93566. /**
  93567. * Define the url of the texture.
  93568. */
  93569. url: Nullable<string>;
  93570. /**
  93571. * Define an offset on the texture to offset the u coordinates of the UVs
  93572. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93573. */
  93574. uOffset: number;
  93575. /**
  93576. * Define an offset on the texture to offset the v coordinates of the UVs
  93577. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93578. */
  93579. vOffset: number;
  93580. /**
  93581. * Define an offset on the texture to scale the u coordinates of the UVs
  93582. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93583. */
  93584. uScale: number;
  93585. /**
  93586. * Define an offset on the texture to scale the v coordinates of the UVs
  93587. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93588. */
  93589. vScale: number;
  93590. /**
  93591. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93592. * @see http://doc.babylonjs.com/how_to/more_materials
  93593. */
  93594. uAng: number;
  93595. /**
  93596. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93597. * @see http://doc.babylonjs.com/how_to/more_materials
  93598. */
  93599. vAng: number;
  93600. /**
  93601. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93602. * @see http://doc.babylonjs.com/how_to/more_materials
  93603. */
  93604. wAng: number;
  93605. /**
  93606. * Defines the center of rotation (U)
  93607. */
  93608. uRotationCenter: number;
  93609. /**
  93610. * Defines the center of rotation (V)
  93611. */
  93612. vRotationCenter: number;
  93613. /**
  93614. * Defines the center of rotation (W)
  93615. */
  93616. wRotationCenter: number;
  93617. /**
  93618. * Are mip maps generated for this texture or not.
  93619. */
  93620. get noMipmap(): boolean;
  93621. /**
  93622. * List of inspectable custom properties (used by the Inspector)
  93623. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93624. */
  93625. inspectableCustomProperties: Nullable<IInspectable[]>;
  93626. private _noMipmap;
  93627. /** @hidden */
  93628. _invertY: boolean;
  93629. private _rowGenerationMatrix;
  93630. private _cachedTextureMatrix;
  93631. private _projectionModeMatrix;
  93632. private _t0;
  93633. private _t1;
  93634. private _t2;
  93635. private _cachedUOffset;
  93636. private _cachedVOffset;
  93637. private _cachedUScale;
  93638. private _cachedVScale;
  93639. private _cachedUAng;
  93640. private _cachedVAng;
  93641. private _cachedWAng;
  93642. private _cachedProjectionMatrixId;
  93643. private _cachedCoordinatesMode;
  93644. /** @hidden */
  93645. protected _initialSamplingMode: number;
  93646. /** @hidden */
  93647. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93648. private _deleteBuffer;
  93649. protected _format: Nullable<number>;
  93650. private _delayedOnLoad;
  93651. private _delayedOnError;
  93652. private _mimeType?;
  93653. /**
  93654. * Observable triggered once the texture has been loaded.
  93655. */
  93656. onLoadObservable: Observable<Texture>;
  93657. protected _isBlocking: boolean;
  93658. /**
  93659. * Is the texture preventing material to render while loading.
  93660. * If false, a default texture will be used instead of the loading one during the preparation step.
  93661. */
  93662. set isBlocking(value: boolean);
  93663. get isBlocking(): boolean;
  93664. /**
  93665. * Get the current sampling mode associated with the texture.
  93666. */
  93667. get samplingMode(): number;
  93668. /**
  93669. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93670. */
  93671. get invertY(): boolean;
  93672. /**
  93673. * Instantiates a new texture.
  93674. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93675. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93676. * @param url defines the url of the picture to load as a texture
  93677. * @param scene defines the scene or engine the texture will belong to
  93678. * @param noMipmap defines if the texture will require mip maps or not
  93679. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93680. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93681. * @param onLoad defines a callback triggered when the texture has been loaded
  93682. * @param onError defines a callback triggered when an error occurred during the loading session
  93683. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93684. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93685. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93686. * @param mimeType defines an optional mime type information
  93687. */
  93688. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  93689. /**
  93690. * Update the url (and optional buffer) of this texture if url was null during construction.
  93691. * @param url the url of the texture
  93692. * @param buffer the buffer of the texture (defaults to null)
  93693. * @param onLoad callback called when the texture is loaded (defaults to null)
  93694. */
  93695. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93696. /**
  93697. * Finish the loading sequence of a texture flagged as delayed load.
  93698. * @hidden
  93699. */
  93700. delayLoad(): void;
  93701. private _prepareRowForTextureGeneration;
  93702. /**
  93703. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93704. * @returns the transform matrix of the texture.
  93705. */
  93706. getTextureMatrix(uBase?: number): Matrix;
  93707. /**
  93708. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93709. * @returns The reflection texture transform
  93710. */
  93711. getReflectionTextureMatrix(): Matrix;
  93712. /**
  93713. * Clones the texture.
  93714. * @returns the cloned texture
  93715. */
  93716. clone(): Texture;
  93717. /**
  93718. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93719. * @returns The JSON representation of the texture
  93720. */
  93721. serialize(): any;
  93722. /**
  93723. * Get the current class name of the texture useful for serialization or dynamic coding.
  93724. * @returns "Texture"
  93725. */
  93726. getClassName(): string;
  93727. /**
  93728. * Dispose the texture and release its associated resources.
  93729. */
  93730. dispose(): void;
  93731. /**
  93732. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93733. * @param parsedTexture Define the JSON representation of the texture
  93734. * @param scene Define the scene the parsed texture should be instantiated in
  93735. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93736. * @returns The parsed texture if successful
  93737. */
  93738. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93739. /**
  93740. * Creates a texture from its base 64 representation.
  93741. * @param data Define the base64 payload without the data: prefix
  93742. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93743. * @param scene Define the scene the texture should belong to
  93744. * @param noMipmap Forces the texture to not create mip map information if true
  93745. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93746. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93747. * @param onLoad define a callback triggered when the texture has been loaded
  93748. * @param onError define a callback triggered when an error occurred during the loading session
  93749. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93750. * @returns the created texture
  93751. */
  93752. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93753. /**
  93754. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93755. * @param data Define the base64 payload without the data: prefix
  93756. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93757. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93758. * @param scene Define the scene the texture should belong to
  93759. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93760. * @param noMipmap Forces the texture to not create mip map information if true
  93761. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93762. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93763. * @param onLoad define a callback triggered when the texture has been loaded
  93764. * @param onError define a callback triggered when an error occurred during the loading session
  93765. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93766. * @returns the created texture
  93767. */
  93768. 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;
  93769. }
  93770. }
  93771. declare module BABYLON {
  93772. /**
  93773. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93774. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93775. */
  93776. export class PostProcessManager {
  93777. private _scene;
  93778. private _indexBuffer;
  93779. private _vertexBuffers;
  93780. /**
  93781. * Creates a new instance PostProcess
  93782. * @param scene The scene that the post process is associated with.
  93783. */
  93784. constructor(scene: Scene);
  93785. private _prepareBuffers;
  93786. private _buildIndexBuffer;
  93787. /**
  93788. * Rebuilds the vertex buffers of the manager.
  93789. * @hidden
  93790. */
  93791. _rebuild(): void;
  93792. /**
  93793. * Prepares a frame to be run through a post process.
  93794. * @param sourceTexture The input texture to the post procesess. (default: null)
  93795. * @param postProcesses An array of post processes to be run. (default: null)
  93796. * @returns True if the post processes were able to be run.
  93797. * @hidden
  93798. */
  93799. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93800. /**
  93801. * Manually render a set of post processes to a texture.
  93802. * @param postProcesses An array of post processes to be run.
  93803. * @param targetTexture The target texture to render to.
  93804. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93805. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93806. * @param lodLevel defines which lod of the texture to render to
  93807. */
  93808. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93809. /**
  93810. * Finalize the result of the output of the postprocesses.
  93811. * @param doNotPresent If true the result will not be displayed to the screen.
  93812. * @param targetTexture The target texture to render to.
  93813. * @param faceIndex The index of the face to bind the target texture to.
  93814. * @param postProcesses The array of post processes to render.
  93815. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93816. * @hidden
  93817. */
  93818. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93819. /**
  93820. * Disposes of the post process manager.
  93821. */
  93822. dispose(): void;
  93823. }
  93824. }
  93825. declare module BABYLON {
  93826. /**
  93827. * This Helps creating a texture that will be created from a camera in your scene.
  93828. * It is basically a dynamic texture that could be used to create special effects for instance.
  93829. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93830. */
  93831. export class RenderTargetTexture extends Texture {
  93832. isCube: boolean;
  93833. /**
  93834. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93835. */
  93836. static readonly REFRESHRATE_RENDER_ONCE: number;
  93837. /**
  93838. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93839. */
  93840. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93841. /**
  93842. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93843. * the central point of your effect and can save a lot of performances.
  93844. */
  93845. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93846. /**
  93847. * Use this predicate to dynamically define the list of mesh you want to render.
  93848. * If set, the renderList property will be overwritten.
  93849. */
  93850. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93851. private _renderList;
  93852. /**
  93853. * Use this list to define the list of mesh you want to render.
  93854. */
  93855. get renderList(): Nullable<Array<AbstractMesh>>;
  93856. set renderList(value: Nullable<Array<AbstractMesh>>);
  93857. /**
  93858. * Use this function to overload the renderList array at rendering time.
  93859. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93860. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93861. * the cube (if the RTT is a cube, else layerOrFace=0).
  93862. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93863. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93864. * hold dummy elements!
  93865. */
  93866. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93867. private _hookArray;
  93868. /**
  93869. * Define if particles should be rendered in your texture.
  93870. */
  93871. renderParticles: boolean;
  93872. /**
  93873. * Define if sprites should be rendered in your texture.
  93874. */
  93875. renderSprites: boolean;
  93876. /**
  93877. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93878. */
  93879. coordinatesMode: number;
  93880. /**
  93881. * Define the camera used to render the texture.
  93882. */
  93883. activeCamera: Nullable<Camera>;
  93884. /**
  93885. * Override the render function of the texture with your own one.
  93886. */
  93887. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93888. /**
  93889. * Define if camera post processes should be use while rendering the texture.
  93890. */
  93891. useCameraPostProcesses: boolean;
  93892. /**
  93893. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93894. */
  93895. ignoreCameraViewport: boolean;
  93896. private _postProcessManager;
  93897. private _postProcesses;
  93898. private _resizeObserver;
  93899. /**
  93900. * An event triggered when the texture is unbind.
  93901. */
  93902. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93903. /**
  93904. * An event triggered when the texture is unbind.
  93905. */
  93906. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93907. private _onAfterUnbindObserver;
  93908. /**
  93909. * Set a after unbind callback in the texture.
  93910. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93911. */
  93912. set onAfterUnbind(callback: () => void);
  93913. /**
  93914. * An event triggered before rendering the texture
  93915. */
  93916. onBeforeRenderObservable: Observable<number>;
  93917. private _onBeforeRenderObserver;
  93918. /**
  93919. * Set a before render callback in the texture.
  93920. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93921. */
  93922. set onBeforeRender(callback: (faceIndex: number) => void);
  93923. /**
  93924. * An event triggered after rendering the texture
  93925. */
  93926. onAfterRenderObservable: Observable<number>;
  93927. private _onAfterRenderObserver;
  93928. /**
  93929. * Set a after render callback in the texture.
  93930. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93931. */
  93932. set onAfterRender(callback: (faceIndex: number) => void);
  93933. /**
  93934. * An event triggered after the texture clear
  93935. */
  93936. onClearObservable: Observable<Engine>;
  93937. private _onClearObserver;
  93938. /**
  93939. * Set a clear callback in the texture.
  93940. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93941. */
  93942. set onClear(callback: (Engine: Engine) => void);
  93943. /**
  93944. * An event triggered when the texture is resized.
  93945. */
  93946. onResizeObservable: Observable<RenderTargetTexture>;
  93947. /**
  93948. * Define the clear color of the Render Target if it should be different from the scene.
  93949. */
  93950. clearColor: Color4;
  93951. protected _size: number | {
  93952. width: number;
  93953. height: number;
  93954. layers?: number;
  93955. };
  93956. protected _initialSizeParameter: number | {
  93957. width: number;
  93958. height: number;
  93959. } | {
  93960. ratio: number;
  93961. };
  93962. protected _sizeRatio: Nullable<number>;
  93963. /** @hidden */
  93964. _generateMipMaps: boolean;
  93965. protected _renderingManager: RenderingManager;
  93966. /** @hidden */
  93967. _waitingRenderList: string[];
  93968. protected _doNotChangeAspectRatio: boolean;
  93969. protected _currentRefreshId: number;
  93970. protected _refreshRate: number;
  93971. protected _textureMatrix: Matrix;
  93972. protected _samples: number;
  93973. protected _renderTargetOptions: RenderTargetCreationOptions;
  93974. /**
  93975. * Gets render target creation options that were used.
  93976. */
  93977. get renderTargetOptions(): RenderTargetCreationOptions;
  93978. protected _engine: Engine;
  93979. protected _onRatioRescale(): void;
  93980. /**
  93981. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93982. * It must define where the camera used to render the texture is set
  93983. */
  93984. boundingBoxPosition: Vector3;
  93985. private _boundingBoxSize;
  93986. /**
  93987. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93988. * When defined, the cubemap will switch to local mode
  93989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93990. * @example https://www.babylonjs-playground.com/#RNASML
  93991. */
  93992. set boundingBoxSize(value: Vector3);
  93993. get boundingBoxSize(): Vector3;
  93994. /**
  93995. * In case the RTT has been created with a depth texture, get the associated
  93996. * depth texture.
  93997. * Otherwise, return null.
  93998. */
  93999. get depthStencilTexture(): Nullable<InternalTexture>;
  94000. /**
  94001. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  94002. * or used a shadow, depth texture...
  94003. * @param name The friendly name of the texture
  94004. * @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)
  94005. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  94006. * @param generateMipMaps True if mip maps need to be generated after render.
  94007. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  94008. * @param type The type of the buffer in the RTT (int, half float, float...)
  94009. * @param isCube True if a cube texture needs to be created
  94010. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  94011. * @param generateDepthBuffer True to generate a depth buffer
  94012. * @param generateStencilBuffer True to generate a stencil buffer
  94013. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  94014. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  94015. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94016. */
  94017. constructor(name: string, size: number | {
  94018. width: number;
  94019. height: number;
  94020. layers?: number;
  94021. } | {
  94022. ratio: number;
  94023. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  94024. /**
  94025. * Creates a depth stencil texture.
  94026. * This is only available in WebGL 2 or with the depth texture extension available.
  94027. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  94028. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  94029. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  94030. */
  94031. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  94032. private _processSizeParameter;
  94033. /**
  94034. * Define the number of samples to use in case of MSAA.
  94035. * It defaults to one meaning no MSAA has been enabled.
  94036. */
  94037. get samples(): number;
  94038. set samples(value: number);
  94039. /**
  94040. * Resets the refresh counter of the texture and start bak from scratch.
  94041. * Could be useful to regenerate the texture if it is setup to render only once.
  94042. */
  94043. resetRefreshCounter(): void;
  94044. /**
  94045. * Define the refresh rate of the texture or the rendering frequency.
  94046. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  94047. */
  94048. get refreshRate(): number;
  94049. set refreshRate(value: number);
  94050. /**
  94051. * Adds a post process to the render target rendering passes.
  94052. * @param postProcess define the post process to add
  94053. */
  94054. addPostProcess(postProcess: PostProcess): void;
  94055. /**
  94056. * Clear all the post processes attached to the render target
  94057. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  94058. */
  94059. clearPostProcesses(dispose?: boolean): void;
  94060. /**
  94061. * Remove one of the post process from the list of attached post processes to the texture
  94062. * @param postProcess define the post process to remove from the list
  94063. */
  94064. removePostProcess(postProcess: PostProcess): void;
  94065. /** @hidden */
  94066. _shouldRender(): boolean;
  94067. /**
  94068. * Gets the actual render size of the texture.
  94069. * @returns the width of the render size
  94070. */
  94071. getRenderSize(): number;
  94072. /**
  94073. * Gets the actual render width of the texture.
  94074. * @returns the width of the render size
  94075. */
  94076. getRenderWidth(): number;
  94077. /**
  94078. * Gets the actual render height of the texture.
  94079. * @returns the height of the render size
  94080. */
  94081. getRenderHeight(): number;
  94082. /**
  94083. * Gets the actual number of layers of the texture.
  94084. * @returns the number of layers
  94085. */
  94086. getRenderLayers(): number;
  94087. /**
  94088. * Get if the texture can be rescaled or not.
  94089. */
  94090. get canRescale(): boolean;
  94091. /**
  94092. * Resize the texture using a ratio.
  94093. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  94094. */
  94095. scale(ratio: number): void;
  94096. /**
  94097. * Get the texture reflection matrix used to rotate/transform the reflection.
  94098. * @returns the reflection matrix
  94099. */
  94100. getReflectionTextureMatrix(): Matrix;
  94101. /**
  94102. * Resize the texture to a new desired size.
  94103. * Be carrefull as it will recreate all the data in the new texture.
  94104. * @param size Define the new size. It can be:
  94105. * - a number for squared texture,
  94106. * - an object containing { width: number, height: number }
  94107. * - or an object containing a ratio { ratio: number }
  94108. */
  94109. resize(size: number | {
  94110. width: number;
  94111. height: number;
  94112. } | {
  94113. ratio: number;
  94114. }): void;
  94115. private _defaultRenderListPrepared;
  94116. /**
  94117. * Renders all the objects from the render list into the texture.
  94118. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94119. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94120. */
  94121. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94122. private _bestReflectionRenderTargetDimension;
  94123. private _prepareRenderingManager;
  94124. /**
  94125. * @hidden
  94126. * @param faceIndex face index to bind to if this is a cubetexture
  94127. * @param layer defines the index of the texture to bind in the array
  94128. */
  94129. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94130. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94131. private renderToTarget;
  94132. /**
  94133. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94134. * This allowed control for front to back rendering or reversly depending of the special needs.
  94135. *
  94136. * @param renderingGroupId The rendering group id corresponding to its index
  94137. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94138. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94139. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94140. */
  94141. 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;
  94142. /**
  94143. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94144. *
  94145. * @param renderingGroupId The rendering group id corresponding to its index
  94146. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94147. */
  94148. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94149. /**
  94150. * Clones the texture.
  94151. * @returns the cloned texture
  94152. */
  94153. clone(): RenderTargetTexture;
  94154. /**
  94155. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94156. * @returns The JSON representation of the texture
  94157. */
  94158. serialize(): any;
  94159. /**
  94160. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94161. */
  94162. disposeFramebufferObjects(): void;
  94163. /**
  94164. * Dispose the texture and release its associated resources.
  94165. */
  94166. dispose(): void;
  94167. /** @hidden */
  94168. _rebuild(): void;
  94169. /**
  94170. * Clear the info related to rendering groups preventing retention point in material dispose.
  94171. */
  94172. freeRenderingGroups(): void;
  94173. /**
  94174. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94175. * @returns the view count
  94176. */
  94177. getViewCount(): number;
  94178. }
  94179. }
  94180. declare module BABYLON {
  94181. /**
  94182. * Options for compiling materials.
  94183. */
  94184. export interface IMaterialCompilationOptions {
  94185. /**
  94186. * Defines whether clip planes are enabled.
  94187. */
  94188. clipPlane: boolean;
  94189. /**
  94190. * Defines whether instances are enabled.
  94191. */
  94192. useInstances: boolean;
  94193. }
  94194. /**
  94195. * Base class for the main features of a material in Babylon.js
  94196. */
  94197. export class Material implements IAnimatable {
  94198. /**
  94199. * Returns the triangle fill mode
  94200. */
  94201. static readonly TriangleFillMode: number;
  94202. /**
  94203. * Returns the wireframe mode
  94204. */
  94205. static readonly WireFrameFillMode: number;
  94206. /**
  94207. * Returns the point fill mode
  94208. */
  94209. static readonly PointFillMode: number;
  94210. /**
  94211. * Returns the point list draw mode
  94212. */
  94213. static readonly PointListDrawMode: number;
  94214. /**
  94215. * Returns the line list draw mode
  94216. */
  94217. static readonly LineListDrawMode: number;
  94218. /**
  94219. * Returns the line loop draw mode
  94220. */
  94221. static readonly LineLoopDrawMode: number;
  94222. /**
  94223. * Returns the line strip draw mode
  94224. */
  94225. static readonly LineStripDrawMode: number;
  94226. /**
  94227. * Returns the triangle strip draw mode
  94228. */
  94229. static readonly TriangleStripDrawMode: number;
  94230. /**
  94231. * Returns the triangle fan draw mode
  94232. */
  94233. static readonly TriangleFanDrawMode: number;
  94234. /**
  94235. * Stores the clock-wise side orientation
  94236. */
  94237. static readonly ClockWiseSideOrientation: number;
  94238. /**
  94239. * Stores the counter clock-wise side orientation
  94240. */
  94241. static readonly CounterClockWiseSideOrientation: number;
  94242. /**
  94243. * The dirty texture flag value
  94244. */
  94245. static readonly TextureDirtyFlag: number;
  94246. /**
  94247. * The dirty light flag value
  94248. */
  94249. static readonly LightDirtyFlag: number;
  94250. /**
  94251. * The dirty fresnel flag value
  94252. */
  94253. static readonly FresnelDirtyFlag: number;
  94254. /**
  94255. * The dirty attribute flag value
  94256. */
  94257. static readonly AttributesDirtyFlag: number;
  94258. /**
  94259. * The dirty misc flag value
  94260. */
  94261. static readonly MiscDirtyFlag: number;
  94262. /**
  94263. * The all dirty flag value
  94264. */
  94265. static readonly AllDirtyFlag: number;
  94266. /**
  94267. * The ID of the material
  94268. */
  94269. id: string;
  94270. /**
  94271. * Gets or sets the unique id of the material
  94272. */
  94273. uniqueId: number;
  94274. /**
  94275. * The name of the material
  94276. */
  94277. name: string;
  94278. /**
  94279. * Gets or sets user defined metadata
  94280. */
  94281. metadata: any;
  94282. /**
  94283. * For internal use only. Please do not use.
  94284. */
  94285. reservedDataStore: any;
  94286. /**
  94287. * Specifies if the ready state should be checked on each call
  94288. */
  94289. checkReadyOnEveryCall: boolean;
  94290. /**
  94291. * Specifies if the ready state should be checked once
  94292. */
  94293. checkReadyOnlyOnce: boolean;
  94294. /**
  94295. * The state of the material
  94296. */
  94297. state: string;
  94298. /**
  94299. * The alpha value of the material
  94300. */
  94301. protected _alpha: number;
  94302. /**
  94303. * List of inspectable custom properties (used by the Inspector)
  94304. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94305. */
  94306. inspectableCustomProperties: IInspectable[];
  94307. /**
  94308. * Sets the alpha value of the material
  94309. */
  94310. set alpha(value: number);
  94311. /**
  94312. * Gets the alpha value of the material
  94313. */
  94314. get alpha(): number;
  94315. /**
  94316. * Specifies if back face culling is enabled
  94317. */
  94318. protected _backFaceCulling: boolean;
  94319. /**
  94320. * Sets the back-face culling state
  94321. */
  94322. set backFaceCulling(value: boolean);
  94323. /**
  94324. * Gets the back-face culling state
  94325. */
  94326. get backFaceCulling(): boolean;
  94327. /**
  94328. * Stores the value for side orientation
  94329. */
  94330. sideOrientation: number;
  94331. /**
  94332. * Callback triggered when the material is compiled
  94333. */
  94334. onCompiled: Nullable<(effect: Effect) => void>;
  94335. /**
  94336. * Callback triggered when an error occurs
  94337. */
  94338. onError: Nullable<(effect: Effect, errors: string) => void>;
  94339. /**
  94340. * Callback triggered to get the render target textures
  94341. */
  94342. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94343. /**
  94344. * Gets a boolean indicating that current material needs to register RTT
  94345. */
  94346. get hasRenderTargetTextures(): boolean;
  94347. /**
  94348. * Specifies if the material should be serialized
  94349. */
  94350. doNotSerialize: boolean;
  94351. /**
  94352. * @hidden
  94353. */
  94354. _storeEffectOnSubMeshes: boolean;
  94355. /**
  94356. * Stores the animations for the material
  94357. */
  94358. animations: Nullable<Array<Animation>>;
  94359. /**
  94360. * An event triggered when the material is disposed
  94361. */
  94362. onDisposeObservable: Observable<Material>;
  94363. /**
  94364. * An observer which watches for dispose events
  94365. */
  94366. private _onDisposeObserver;
  94367. private _onUnBindObservable;
  94368. /**
  94369. * Called during a dispose event
  94370. */
  94371. set onDispose(callback: () => void);
  94372. private _onBindObservable;
  94373. /**
  94374. * An event triggered when the material is bound
  94375. */
  94376. get onBindObservable(): Observable<AbstractMesh>;
  94377. /**
  94378. * An observer which watches for bind events
  94379. */
  94380. private _onBindObserver;
  94381. /**
  94382. * Called during a bind event
  94383. */
  94384. set onBind(callback: (Mesh: AbstractMesh) => void);
  94385. /**
  94386. * An event triggered when the material is unbound
  94387. */
  94388. get onUnBindObservable(): Observable<Material>;
  94389. /**
  94390. * Stores the value of the alpha mode
  94391. */
  94392. private _alphaMode;
  94393. /**
  94394. * Sets the value of the alpha mode.
  94395. *
  94396. * | Value | Type | Description |
  94397. * | --- | --- | --- |
  94398. * | 0 | ALPHA_DISABLE | |
  94399. * | 1 | ALPHA_ADD | |
  94400. * | 2 | ALPHA_COMBINE | |
  94401. * | 3 | ALPHA_SUBTRACT | |
  94402. * | 4 | ALPHA_MULTIPLY | |
  94403. * | 5 | ALPHA_MAXIMIZED | |
  94404. * | 6 | ALPHA_ONEONE | |
  94405. * | 7 | ALPHA_PREMULTIPLIED | |
  94406. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94407. * | 9 | ALPHA_INTERPOLATE | |
  94408. * | 10 | ALPHA_SCREENMODE | |
  94409. *
  94410. */
  94411. set alphaMode(value: number);
  94412. /**
  94413. * Gets the value of the alpha mode
  94414. */
  94415. get alphaMode(): number;
  94416. /**
  94417. * Stores the state of the need depth pre-pass value
  94418. */
  94419. private _needDepthPrePass;
  94420. /**
  94421. * Sets the need depth pre-pass value
  94422. */
  94423. set needDepthPrePass(value: boolean);
  94424. /**
  94425. * Gets the depth pre-pass value
  94426. */
  94427. get needDepthPrePass(): boolean;
  94428. /**
  94429. * Specifies if depth writing should be disabled
  94430. */
  94431. disableDepthWrite: boolean;
  94432. /**
  94433. * Specifies if depth writing should be forced
  94434. */
  94435. forceDepthWrite: boolean;
  94436. /**
  94437. * Specifies the depth function that should be used. 0 means the default engine function
  94438. */
  94439. depthFunction: number;
  94440. /**
  94441. * Specifies if there should be a separate pass for culling
  94442. */
  94443. separateCullingPass: boolean;
  94444. /**
  94445. * Stores the state specifing if fog should be enabled
  94446. */
  94447. private _fogEnabled;
  94448. /**
  94449. * Sets the state for enabling fog
  94450. */
  94451. set fogEnabled(value: boolean);
  94452. /**
  94453. * Gets the value of the fog enabled state
  94454. */
  94455. get fogEnabled(): boolean;
  94456. /**
  94457. * Stores the size of points
  94458. */
  94459. pointSize: number;
  94460. /**
  94461. * Stores the z offset value
  94462. */
  94463. zOffset: number;
  94464. /**
  94465. * Gets a value specifying if wireframe mode is enabled
  94466. */
  94467. get wireframe(): boolean;
  94468. /**
  94469. * Sets the state of wireframe mode
  94470. */
  94471. set wireframe(value: boolean);
  94472. /**
  94473. * Gets the value specifying if point clouds are enabled
  94474. */
  94475. get pointsCloud(): boolean;
  94476. /**
  94477. * Sets the state of point cloud mode
  94478. */
  94479. set pointsCloud(value: boolean);
  94480. /**
  94481. * Gets the material fill mode
  94482. */
  94483. get fillMode(): number;
  94484. /**
  94485. * Sets the material fill mode
  94486. */
  94487. set fillMode(value: number);
  94488. /**
  94489. * @hidden
  94490. * Stores the effects for the material
  94491. */
  94492. _effect: Nullable<Effect>;
  94493. /**
  94494. * Specifies if uniform buffers should be used
  94495. */
  94496. private _useUBO;
  94497. /**
  94498. * Stores a reference to the scene
  94499. */
  94500. private _scene;
  94501. /**
  94502. * Stores the fill mode state
  94503. */
  94504. private _fillMode;
  94505. /**
  94506. * Specifies if the depth write state should be cached
  94507. */
  94508. private _cachedDepthWriteState;
  94509. /**
  94510. * Specifies if the depth function state should be cached
  94511. */
  94512. private _cachedDepthFunctionState;
  94513. /**
  94514. * Stores the uniform buffer
  94515. */
  94516. protected _uniformBuffer: UniformBuffer;
  94517. /** @hidden */
  94518. _indexInSceneMaterialArray: number;
  94519. /** @hidden */
  94520. meshMap: Nullable<{
  94521. [id: string]: AbstractMesh | undefined;
  94522. }>;
  94523. /**
  94524. * Creates a material instance
  94525. * @param name defines the name of the material
  94526. * @param scene defines the scene to reference
  94527. * @param doNotAdd specifies if the material should be added to the scene
  94528. */
  94529. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94530. /**
  94531. * Returns a string representation of the current material
  94532. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94533. * @returns a string with material information
  94534. */
  94535. toString(fullDetails?: boolean): string;
  94536. /**
  94537. * Gets the class name of the material
  94538. * @returns a string with the class name of the material
  94539. */
  94540. getClassName(): string;
  94541. /**
  94542. * Specifies if updates for the material been locked
  94543. */
  94544. get isFrozen(): boolean;
  94545. /**
  94546. * Locks updates for the material
  94547. */
  94548. freeze(): void;
  94549. /**
  94550. * Unlocks updates for the material
  94551. */
  94552. unfreeze(): void;
  94553. /**
  94554. * Specifies if the material is ready to be used
  94555. * @param mesh defines the mesh to check
  94556. * @param useInstances specifies if instances should be used
  94557. * @returns a boolean indicating if the material is ready to be used
  94558. */
  94559. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94560. /**
  94561. * Specifies that the submesh is ready to be used
  94562. * @param mesh defines the mesh to check
  94563. * @param subMesh defines which submesh to check
  94564. * @param useInstances specifies that instances should be used
  94565. * @returns a boolean indicating that the submesh is ready or not
  94566. */
  94567. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94568. /**
  94569. * Returns the material effect
  94570. * @returns the effect associated with the material
  94571. */
  94572. getEffect(): Nullable<Effect>;
  94573. /**
  94574. * Returns the current scene
  94575. * @returns a Scene
  94576. */
  94577. getScene(): Scene;
  94578. /**
  94579. * Specifies if the material will require alpha blending
  94580. * @returns a boolean specifying if alpha blending is needed
  94581. */
  94582. needAlphaBlending(): boolean;
  94583. /**
  94584. * Specifies if the mesh will require alpha blending
  94585. * @param mesh defines the mesh to check
  94586. * @returns a boolean specifying if alpha blending is needed for the mesh
  94587. */
  94588. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94589. /**
  94590. * Specifies if this material should be rendered in alpha test mode
  94591. * @returns a boolean specifying if an alpha test is needed.
  94592. */
  94593. needAlphaTesting(): boolean;
  94594. /**
  94595. * Gets the texture used for the alpha test
  94596. * @returns the texture to use for alpha testing
  94597. */
  94598. getAlphaTestTexture(): Nullable<BaseTexture>;
  94599. /**
  94600. * Marks the material to indicate that it needs to be re-calculated
  94601. */
  94602. markDirty(): void;
  94603. /** @hidden */
  94604. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94605. /**
  94606. * Binds the material to the mesh
  94607. * @param world defines the world transformation matrix
  94608. * @param mesh defines the mesh to bind the material to
  94609. */
  94610. bind(world: Matrix, mesh?: Mesh): void;
  94611. /**
  94612. * Binds the submesh to the material
  94613. * @param world defines the world transformation matrix
  94614. * @param mesh defines the mesh containing the submesh
  94615. * @param subMesh defines the submesh to bind the material to
  94616. */
  94617. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94618. /**
  94619. * Binds the world matrix to the material
  94620. * @param world defines the world transformation matrix
  94621. */
  94622. bindOnlyWorldMatrix(world: Matrix): void;
  94623. /**
  94624. * Binds the scene's uniform buffer to the effect.
  94625. * @param effect defines the effect to bind to the scene uniform buffer
  94626. * @param sceneUbo defines the uniform buffer storing scene data
  94627. */
  94628. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94629. /**
  94630. * Binds the view matrix to the effect
  94631. * @param effect defines the effect to bind the view matrix to
  94632. */
  94633. bindView(effect: Effect): void;
  94634. /**
  94635. * Binds the view projection matrix to the effect
  94636. * @param effect defines the effect to bind the view projection matrix to
  94637. */
  94638. bindViewProjection(effect: Effect): void;
  94639. /**
  94640. * Specifies if material alpha testing should be turned on for the mesh
  94641. * @param mesh defines the mesh to check
  94642. */
  94643. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94644. /**
  94645. * Processes to execute after binding the material to a mesh
  94646. * @param mesh defines the rendered mesh
  94647. */
  94648. protected _afterBind(mesh?: Mesh): void;
  94649. /**
  94650. * Unbinds the material from the mesh
  94651. */
  94652. unbind(): void;
  94653. /**
  94654. * Gets the active textures from the material
  94655. * @returns an array of textures
  94656. */
  94657. getActiveTextures(): BaseTexture[];
  94658. /**
  94659. * Specifies if the material uses a texture
  94660. * @param texture defines the texture to check against the material
  94661. * @returns a boolean specifying if the material uses the texture
  94662. */
  94663. hasTexture(texture: BaseTexture): boolean;
  94664. /**
  94665. * Makes a duplicate of the material, and gives it a new name
  94666. * @param name defines the new name for the duplicated material
  94667. * @returns the cloned material
  94668. */
  94669. clone(name: string): Nullable<Material>;
  94670. /**
  94671. * Gets the meshes bound to the material
  94672. * @returns an array of meshes bound to the material
  94673. */
  94674. getBindedMeshes(): AbstractMesh[];
  94675. /**
  94676. * Force shader compilation
  94677. * @param mesh defines the mesh associated with this material
  94678. * @param onCompiled defines a function to execute once the material is compiled
  94679. * @param options defines the options to configure the compilation
  94680. * @param onError defines a function to execute if the material fails compiling
  94681. */
  94682. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94683. /**
  94684. * Force shader compilation
  94685. * @param mesh defines the mesh that will use this material
  94686. * @param options defines additional options for compiling the shaders
  94687. * @returns a promise that resolves when the compilation completes
  94688. */
  94689. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94690. private static readonly _AllDirtyCallBack;
  94691. private static readonly _ImageProcessingDirtyCallBack;
  94692. private static readonly _TextureDirtyCallBack;
  94693. private static readonly _FresnelDirtyCallBack;
  94694. private static readonly _MiscDirtyCallBack;
  94695. private static readonly _LightsDirtyCallBack;
  94696. private static readonly _AttributeDirtyCallBack;
  94697. private static _FresnelAndMiscDirtyCallBack;
  94698. private static _TextureAndMiscDirtyCallBack;
  94699. private static readonly _DirtyCallbackArray;
  94700. private static readonly _RunDirtyCallBacks;
  94701. /**
  94702. * Marks a define in the material to indicate that it needs to be re-computed
  94703. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94704. */
  94705. markAsDirty(flag: number): void;
  94706. /**
  94707. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94708. * @param func defines a function which checks material defines against the submeshes
  94709. */
  94710. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94711. /**
  94712. * Indicates that we need to re-calculated for all submeshes
  94713. */
  94714. protected _markAllSubMeshesAsAllDirty(): void;
  94715. /**
  94716. * Indicates that image processing needs to be re-calculated for all submeshes
  94717. */
  94718. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94719. /**
  94720. * Indicates that textures need to be re-calculated for all submeshes
  94721. */
  94722. protected _markAllSubMeshesAsTexturesDirty(): void;
  94723. /**
  94724. * Indicates that fresnel needs to be re-calculated for all submeshes
  94725. */
  94726. protected _markAllSubMeshesAsFresnelDirty(): void;
  94727. /**
  94728. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94729. */
  94730. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94731. /**
  94732. * Indicates that lights need to be re-calculated for all submeshes
  94733. */
  94734. protected _markAllSubMeshesAsLightsDirty(): void;
  94735. /**
  94736. * Indicates that attributes need to be re-calculated for all submeshes
  94737. */
  94738. protected _markAllSubMeshesAsAttributesDirty(): void;
  94739. /**
  94740. * Indicates that misc needs to be re-calculated for all submeshes
  94741. */
  94742. protected _markAllSubMeshesAsMiscDirty(): void;
  94743. /**
  94744. * Indicates that textures and misc need to be re-calculated for all submeshes
  94745. */
  94746. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94747. /**
  94748. * Disposes the material
  94749. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94750. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94751. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94752. */
  94753. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94754. /** @hidden */
  94755. private releaseVertexArrayObject;
  94756. /**
  94757. * Serializes this material
  94758. * @returns the serialized material object
  94759. */
  94760. serialize(): any;
  94761. /**
  94762. * Creates a material from parsed material data
  94763. * @param parsedMaterial defines parsed material data
  94764. * @param scene defines the hosting scene
  94765. * @param rootUrl defines the root URL to use to load textures
  94766. * @returns a new material
  94767. */
  94768. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94769. }
  94770. }
  94771. declare module BABYLON {
  94772. /**
  94773. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94774. * separate meshes. This can be use to improve performances.
  94775. * @see http://doc.babylonjs.com/how_to/multi_materials
  94776. */
  94777. export class MultiMaterial extends Material {
  94778. private _subMaterials;
  94779. /**
  94780. * Gets or Sets the list of Materials used within the multi material.
  94781. * They need to be ordered according to the submeshes order in the associated mesh
  94782. */
  94783. get subMaterials(): Nullable<Material>[];
  94784. set subMaterials(value: Nullable<Material>[]);
  94785. /**
  94786. * Function used to align with Node.getChildren()
  94787. * @returns the list of Materials used within the multi material
  94788. */
  94789. getChildren(): Nullable<Material>[];
  94790. /**
  94791. * Instantiates a new Multi Material
  94792. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94793. * separate meshes. This can be use to improve performances.
  94794. * @see http://doc.babylonjs.com/how_to/multi_materials
  94795. * @param name Define the name in the scene
  94796. * @param scene Define the scene the material belongs to
  94797. */
  94798. constructor(name: string, scene: Scene);
  94799. private _hookArray;
  94800. /**
  94801. * Get one of the submaterial by its index in the submaterials array
  94802. * @param index The index to look the sub material at
  94803. * @returns The Material if the index has been defined
  94804. */
  94805. getSubMaterial(index: number): Nullable<Material>;
  94806. /**
  94807. * Get the list of active textures for the whole sub materials list.
  94808. * @returns All the textures that will be used during the rendering
  94809. */
  94810. getActiveTextures(): BaseTexture[];
  94811. /**
  94812. * Gets the current class name of the material e.g. "MultiMaterial"
  94813. * Mainly use in serialization.
  94814. * @returns the class name
  94815. */
  94816. getClassName(): string;
  94817. /**
  94818. * Checks if the material is ready to render the requested sub mesh
  94819. * @param mesh Define the mesh the submesh belongs to
  94820. * @param subMesh Define the sub mesh to look readyness for
  94821. * @param useInstances Define whether or not the material is used with instances
  94822. * @returns true if ready, otherwise false
  94823. */
  94824. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94825. /**
  94826. * Clones the current material and its related sub materials
  94827. * @param name Define the name of the newly cloned material
  94828. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94829. * @returns the cloned material
  94830. */
  94831. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94832. /**
  94833. * Serializes the materials into a JSON representation.
  94834. * @returns the JSON representation
  94835. */
  94836. serialize(): any;
  94837. /**
  94838. * Dispose the material and release its associated resources
  94839. * @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)
  94840. * @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)
  94841. * @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)
  94842. */
  94843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94844. /**
  94845. * Creates a MultiMaterial from parsed MultiMaterial data.
  94846. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94847. * @param scene defines the hosting scene
  94848. * @returns a new MultiMaterial
  94849. */
  94850. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94851. }
  94852. }
  94853. declare module BABYLON {
  94854. /**
  94855. * Base class for submeshes
  94856. */
  94857. export class BaseSubMesh {
  94858. /** @hidden */
  94859. _materialDefines: Nullable<MaterialDefines>;
  94860. /** @hidden */
  94861. _materialEffect: Nullable<Effect>;
  94862. /**
  94863. * Gets material defines used by the effect associated to the sub mesh
  94864. */
  94865. get materialDefines(): Nullable<MaterialDefines>;
  94866. /**
  94867. * Sets material defines used by the effect associated to the sub mesh
  94868. */
  94869. set materialDefines(defines: Nullable<MaterialDefines>);
  94870. /**
  94871. * Gets associated effect
  94872. */
  94873. get effect(): Nullable<Effect>;
  94874. /**
  94875. * Sets associated effect (effect used to render this submesh)
  94876. * @param effect defines the effect to associate with
  94877. * @param defines defines the set of defines used to compile this effect
  94878. */
  94879. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94880. }
  94881. /**
  94882. * Defines a subdivision inside a mesh
  94883. */
  94884. export class SubMesh extends BaseSubMesh implements ICullable {
  94885. /** the material index to use */
  94886. materialIndex: number;
  94887. /** vertex index start */
  94888. verticesStart: number;
  94889. /** vertices count */
  94890. verticesCount: number;
  94891. /** index start */
  94892. indexStart: number;
  94893. /** indices count */
  94894. indexCount: number;
  94895. /** @hidden */
  94896. _linesIndexCount: number;
  94897. private _mesh;
  94898. private _renderingMesh;
  94899. private _boundingInfo;
  94900. private _linesIndexBuffer;
  94901. /** @hidden */
  94902. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94903. /** @hidden */
  94904. _trianglePlanes: Plane[];
  94905. /** @hidden */
  94906. _lastColliderTransformMatrix: Nullable<Matrix>;
  94907. /** @hidden */
  94908. _renderId: number;
  94909. /** @hidden */
  94910. _alphaIndex: number;
  94911. /** @hidden */
  94912. _distanceToCamera: number;
  94913. /** @hidden */
  94914. _id: number;
  94915. private _currentMaterial;
  94916. /**
  94917. * Add a new submesh to a mesh
  94918. * @param materialIndex defines the material index to use
  94919. * @param verticesStart defines vertex index start
  94920. * @param verticesCount defines vertices count
  94921. * @param indexStart defines index start
  94922. * @param indexCount defines indices count
  94923. * @param mesh defines the parent mesh
  94924. * @param renderingMesh defines an optional rendering mesh
  94925. * @param createBoundingBox defines if bounding box should be created for this submesh
  94926. * @returns the new submesh
  94927. */
  94928. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94929. /**
  94930. * Creates a new submesh
  94931. * @param materialIndex defines the material index to use
  94932. * @param verticesStart defines vertex index start
  94933. * @param verticesCount defines vertices count
  94934. * @param indexStart defines index start
  94935. * @param indexCount defines indices count
  94936. * @param mesh defines the parent mesh
  94937. * @param renderingMesh defines an optional rendering mesh
  94938. * @param createBoundingBox defines if bounding box should be created for this submesh
  94939. */
  94940. constructor(
  94941. /** the material index to use */
  94942. materialIndex: number,
  94943. /** vertex index start */
  94944. verticesStart: number,
  94945. /** vertices count */
  94946. verticesCount: number,
  94947. /** index start */
  94948. indexStart: number,
  94949. /** indices count */
  94950. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94951. /**
  94952. * Returns true if this submesh covers the entire parent mesh
  94953. * @ignorenaming
  94954. */
  94955. get IsGlobal(): boolean;
  94956. /**
  94957. * Returns the submesh BoudingInfo object
  94958. * @returns current bounding info (or mesh's one if the submesh is global)
  94959. */
  94960. getBoundingInfo(): BoundingInfo;
  94961. /**
  94962. * Sets the submesh BoundingInfo
  94963. * @param boundingInfo defines the new bounding info to use
  94964. * @returns the SubMesh
  94965. */
  94966. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94967. /**
  94968. * Returns the mesh of the current submesh
  94969. * @return the parent mesh
  94970. */
  94971. getMesh(): AbstractMesh;
  94972. /**
  94973. * Returns the rendering mesh of the submesh
  94974. * @returns the rendering mesh (could be different from parent mesh)
  94975. */
  94976. getRenderingMesh(): Mesh;
  94977. /**
  94978. * Returns the submesh material
  94979. * @returns null or the current material
  94980. */
  94981. getMaterial(): Nullable<Material>;
  94982. /**
  94983. * Sets a new updated BoundingInfo object to the submesh
  94984. * @param data defines an optional position array to use to determine the bounding info
  94985. * @returns the SubMesh
  94986. */
  94987. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94988. /** @hidden */
  94989. _checkCollision(collider: Collider): boolean;
  94990. /**
  94991. * Updates the submesh BoundingInfo
  94992. * @param world defines the world matrix to use to update the bounding info
  94993. * @returns the submesh
  94994. */
  94995. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94996. /**
  94997. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94998. * @param frustumPlanes defines the frustum planes
  94999. * @returns true if the submesh is intersecting with the frustum
  95000. */
  95001. isInFrustum(frustumPlanes: Plane[]): boolean;
  95002. /**
  95003. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  95004. * @param frustumPlanes defines the frustum planes
  95005. * @returns true if the submesh is inside the frustum
  95006. */
  95007. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95008. /**
  95009. * Renders the submesh
  95010. * @param enableAlphaMode defines if alpha needs to be used
  95011. * @returns the submesh
  95012. */
  95013. render(enableAlphaMode: boolean): SubMesh;
  95014. /**
  95015. * @hidden
  95016. */
  95017. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  95018. /**
  95019. * Checks if the submesh intersects with a ray
  95020. * @param ray defines the ray to test
  95021. * @returns true is the passed ray intersects the submesh bounding box
  95022. */
  95023. canIntersects(ray: Ray): boolean;
  95024. /**
  95025. * Intersects current submesh with a ray
  95026. * @param ray defines the ray to test
  95027. * @param positions defines mesh's positions array
  95028. * @param indices defines mesh's indices array
  95029. * @param fastCheck defines if only bounding info should be used
  95030. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95031. * @returns intersection info or null if no intersection
  95032. */
  95033. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  95034. /** @hidden */
  95035. private _intersectLines;
  95036. /** @hidden */
  95037. private _intersectUnIndexedLines;
  95038. /** @hidden */
  95039. private _intersectTriangles;
  95040. /** @hidden */
  95041. private _intersectUnIndexedTriangles;
  95042. /** @hidden */
  95043. _rebuild(): void;
  95044. /**
  95045. * Creates a new submesh from the passed mesh
  95046. * @param newMesh defines the new hosting mesh
  95047. * @param newRenderingMesh defines an optional rendering mesh
  95048. * @returns the new submesh
  95049. */
  95050. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  95051. /**
  95052. * Release associated resources
  95053. */
  95054. dispose(): void;
  95055. /**
  95056. * Gets the class name
  95057. * @returns the string "SubMesh".
  95058. */
  95059. getClassName(): string;
  95060. /**
  95061. * Creates a new submesh from indices data
  95062. * @param materialIndex the index of the main mesh material
  95063. * @param startIndex the index where to start the copy in the mesh indices array
  95064. * @param indexCount the number of indices to copy then from the startIndex
  95065. * @param mesh the main mesh to create the submesh from
  95066. * @param renderingMesh the optional rendering mesh
  95067. * @returns a new submesh
  95068. */
  95069. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  95070. }
  95071. }
  95072. declare module BABYLON {
  95073. /**
  95074. * Class used to represent data loading progression
  95075. */
  95076. export class SceneLoaderFlags {
  95077. private static _ForceFullSceneLoadingForIncremental;
  95078. private static _ShowLoadingScreen;
  95079. private static _CleanBoneMatrixWeights;
  95080. private static _loggingLevel;
  95081. /**
  95082. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  95083. */
  95084. static get ForceFullSceneLoadingForIncremental(): boolean;
  95085. static set ForceFullSceneLoadingForIncremental(value: boolean);
  95086. /**
  95087. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  95088. */
  95089. static get ShowLoadingScreen(): boolean;
  95090. static set ShowLoadingScreen(value: boolean);
  95091. /**
  95092. * Defines the current logging level (while loading the scene)
  95093. * @ignorenaming
  95094. */
  95095. static get loggingLevel(): number;
  95096. static set loggingLevel(value: number);
  95097. /**
  95098. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  95099. */
  95100. static get CleanBoneMatrixWeights(): boolean;
  95101. static set CleanBoneMatrixWeights(value: boolean);
  95102. }
  95103. }
  95104. declare module BABYLON {
  95105. /**
  95106. * Class used to store geometry data (vertex buffers + index buffer)
  95107. */
  95108. export class Geometry implements IGetSetVerticesData {
  95109. /**
  95110. * Gets or sets the ID of the geometry
  95111. */
  95112. id: string;
  95113. /**
  95114. * Gets or sets the unique ID of the geometry
  95115. */
  95116. uniqueId: number;
  95117. /**
  95118. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95119. */
  95120. delayLoadState: number;
  95121. /**
  95122. * Gets the file containing the data to load when running in delay load state
  95123. */
  95124. delayLoadingFile: Nullable<string>;
  95125. /**
  95126. * Callback called when the geometry is updated
  95127. */
  95128. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95129. private _scene;
  95130. private _engine;
  95131. private _meshes;
  95132. private _totalVertices;
  95133. /** @hidden */
  95134. _indices: IndicesArray;
  95135. /** @hidden */
  95136. _vertexBuffers: {
  95137. [key: string]: VertexBuffer;
  95138. };
  95139. private _isDisposed;
  95140. private _extend;
  95141. private _boundingBias;
  95142. /** @hidden */
  95143. _delayInfo: Array<string>;
  95144. private _indexBuffer;
  95145. private _indexBufferIsUpdatable;
  95146. /** @hidden */
  95147. _boundingInfo: Nullable<BoundingInfo>;
  95148. /** @hidden */
  95149. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95150. /** @hidden */
  95151. _softwareSkinningFrameId: number;
  95152. private _vertexArrayObjects;
  95153. private _updatable;
  95154. /** @hidden */
  95155. _positions: Nullable<Vector3[]>;
  95156. /**
  95157. * 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
  95158. */
  95159. get boundingBias(): Vector2;
  95160. /**
  95161. * 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
  95162. */
  95163. set boundingBias(value: Vector2);
  95164. /**
  95165. * Static function used to attach a new empty geometry to a mesh
  95166. * @param mesh defines the mesh to attach the geometry to
  95167. * @returns the new Geometry
  95168. */
  95169. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95170. /**
  95171. * Creates a new geometry
  95172. * @param id defines the unique ID
  95173. * @param scene defines the hosting scene
  95174. * @param vertexData defines the VertexData used to get geometry data
  95175. * @param updatable defines if geometry must be updatable (false by default)
  95176. * @param mesh defines the mesh that will be associated with the geometry
  95177. */
  95178. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95179. /**
  95180. * Gets the current extend of the geometry
  95181. */
  95182. get extend(): {
  95183. minimum: Vector3;
  95184. maximum: Vector3;
  95185. };
  95186. /**
  95187. * Gets the hosting scene
  95188. * @returns the hosting Scene
  95189. */
  95190. getScene(): Scene;
  95191. /**
  95192. * Gets the hosting engine
  95193. * @returns the hosting Engine
  95194. */
  95195. getEngine(): Engine;
  95196. /**
  95197. * Defines if the geometry is ready to use
  95198. * @returns true if the geometry is ready to be used
  95199. */
  95200. isReady(): boolean;
  95201. /**
  95202. * Gets a value indicating that the geometry should not be serialized
  95203. */
  95204. get doNotSerialize(): boolean;
  95205. /** @hidden */
  95206. _rebuild(): void;
  95207. /**
  95208. * Affects all geometry data in one call
  95209. * @param vertexData defines the geometry data
  95210. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95211. */
  95212. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95213. /**
  95214. * Set specific vertex data
  95215. * @param kind defines the data kind (Position, normal, etc...)
  95216. * @param data defines the vertex data to use
  95217. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95218. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95219. */
  95220. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95221. /**
  95222. * Removes a specific vertex data
  95223. * @param kind defines the data kind (Position, normal, etc...)
  95224. */
  95225. removeVerticesData(kind: string): void;
  95226. /**
  95227. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95228. * @param buffer defines the vertex buffer to use
  95229. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95230. */
  95231. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95232. /**
  95233. * Update a specific vertex buffer
  95234. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95235. * It will do nothing if the buffer is not updatable
  95236. * @param kind defines the data kind (Position, normal, etc...)
  95237. * @param data defines the data to use
  95238. * @param offset defines the offset in the target buffer where to store the data
  95239. * @param useBytes set to true if the offset is in bytes
  95240. */
  95241. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95242. /**
  95243. * Update a specific vertex buffer
  95244. * This function will create a new buffer if the current one is not updatable
  95245. * @param kind defines the data kind (Position, normal, etc...)
  95246. * @param data defines the data to use
  95247. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95248. */
  95249. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95250. private _updateBoundingInfo;
  95251. /** @hidden */
  95252. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95253. /**
  95254. * Gets total number of vertices
  95255. * @returns the total number of vertices
  95256. */
  95257. getTotalVertices(): number;
  95258. /**
  95259. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95260. * @param kind defines the data kind (Position, normal, etc...)
  95261. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95262. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95263. * @returns a float array containing vertex data
  95264. */
  95265. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95266. /**
  95267. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95268. * @param kind defines the data kind (Position, normal, etc...)
  95269. * @returns true if the vertex buffer with the specified kind is updatable
  95270. */
  95271. isVertexBufferUpdatable(kind: string): boolean;
  95272. /**
  95273. * Gets a specific vertex buffer
  95274. * @param kind defines the data kind (Position, normal, etc...)
  95275. * @returns a VertexBuffer
  95276. */
  95277. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95278. /**
  95279. * Returns all vertex buffers
  95280. * @return an object holding all vertex buffers indexed by kind
  95281. */
  95282. getVertexBuffers(): Nullable<{
  95283. [key: string]: VertexBuffer;
  95284. }>;
  95285. /**
  95286. * Gets a boolean indicating if specific vertex buffer is present
  95287. * @param kind defines the data kind (Position, normal, etc...)
  95288. * @returns true if data is present
  95289. */
  95290. isVerticesDataPresent(kind: string): boolean;
  95291. /**
  95292. * Gets a list of all attached data kinds (Position, normal, etc...)
  95293. * @returns a list of string containing all kinds
  95294. */
  95295. getVerticesDataKinds(): string[];
  95296. /**
  95297. * Update index buffer
  95298. * @param indices defines the indices to store in the index buffer
  95299. * @param offset defines the offset in the target buffer where to store the data
  95300. * @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)
  95301. */
  95302. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95303. /**
  95304. * Creates a new index buffer
  95305. * @param indices defines the indices to store in the index buffer
  95306. * @param totalVertices defines the total number of vertices (could be null)
  95307. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95308. */
  95309. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95310. /**
  95311. * Return the total number of indices
  95312. * @returns the total number of indices
  95313. */
  95314. getTotalIndices(): number;
  95315. /**
  95316. * Gets the index buffer array
  95317. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95318. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95319. * @returns the index buffer array
  95320. */
  95321. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95322. /**
  95323. * Gets the index buffer
  95324. * @return the index buffer
  95325. */
  95326. getIndexBuffer(): Nullable<DataBuffer>;
  95327. /** @hidden */
  95328. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95329. /**
  95330. * Release the associated resources for a specific mesh
  95331. * @param mesh defines the source mesh
  95332. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95333. */
  95334. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95335. /**
  95336. * Apply current geometry to a given mesh
  95337. * @param mesh defines the mesh to apply geometry to
  95338. */
  95339. applyToMesh(mesh: Mesh): void;
  95340. private _updateExtend;
  95341. private _applyToMesh;
  95342. private notifyUpdate;
  95343. /**
  95344. * Load the geometry if it was flagged as delay loaded
  95345. * @param scene defines the hosting scene
  95346. * @param onLoaded defines a callback called when the geometry is loaded
  95347. */
  95348. load(scene: Scene, onLoaded?: () => void): void;
  95349. private _queueLoad;
  95350. /**
  95351. * Invert the geometry to move from a right handed system to a left handed one.
  95352. */
  95353. toLeftHanded(): void;
  95354. /** @hidden */
  95355. _resetPointsArrayCache(): void;
  95356. /** @hidden */
  95357. _generatePointsArray(): boolean;
  95358. /**
  95359. * Gets a value indicating if the geometry is disposed
  95360. * @returns true if the geometry was disposed
  95361. */
  95362. isDisposed(): boolean;
  95363. private _disposeVertexArrayObjects;
  95364. /**
  95365. * Free all associated resources
  95366. */
  95367. dispose(): void;
  95368. /**
  95369. * Clone the current geometry into a new geometry
  95370. * @param id defines the unique ID of the new geometry
  95371. * @returns a new geometry object
  95372. */
  95373. copy(id: string): Geometry;
  95374. /**
  95375. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95376. * @return a JSON representation of the current geometry data (without the vertices data)
  95377. */
  95378. serialize(): any;
  95379. private toNumberArray;
  95380. /**
  95381. * Serialize all vertices data into a JSON oject
  95382. * @returns a JSON representation of the current geometry data
  95383. */
  95384. serializeVerticeData(): any;
  95385. /**
  95386. * Extracts a clone of a mesh geometry
  95387. * @param mesh defines the source mesh
  95388. * @param id defines the unique ID of the new geometry object
  95389. * @returns the new geometry object
  95390. */
  95391. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95392. /**
  95393. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95394. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95395. * Be aware Math.random() could cause collisions, but:
  95396. * "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"
  95397. * @returns a string containing a new GUID
  95398. */
  95399. static RandomId(): string;
  95400. /** @hidden */
  95401. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95402. private static _CleanMatricesWeights;
  95403. /**
  95404. * Create a new geometry from persisted data (Using .babylon file format)
  95405. * @param parsedVertexData defines the persisted data
  95406. * @param scene defines the hosting scene
  95407. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95408. * @returns the new geometry object
  95409. */
  95410. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95411. }
  95412. }
  95413. declare module BABYLON {
  95414. /**
  95415. * Define an interface for all classes that will get and set the data on vertices
  95416. */
  95417. export interface IGetSetVerticesData {
  95418. /**
  95419. * Gets a boolean indicating if specific vertex data is present
  95420. * @param kind defines the vertex data kind to use
  95421. * @returns true is data kind is present
  95422. */
  95423. isVerticesDataPresent(kind: string): boolean;
  95424. /**
  95425. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95426. * @param kind defines the data kind (Position, normal, etc...)
  95427. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95428. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95429. * @returns a float array containing vertex data
  95430. */
  95431. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95432. /**
  95433. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95434. * @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.
  95435. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95436. * @returns the indices array or an empty array if the mesh has no geometry
  95437. */
  95438. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95439. /**
  95440. * Set specific vertex data
  95441. * @param kind defines the data kind (Position, normal, etc...)
  95442. * @param data defines the vertex data to use
  95443. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95444. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95445. */
  95446. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95447. /**
  95448. * Update a specific associated vertex buffer
  95449. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95450. * - VertexBuffer.PositionKind
  95451. * - VertexBuffer.UVKind
  95452. * - VertexBuffer.UV2Kind
  95453. * - VertexBuffer.UV3Kind
  95454. * - VertexBuffer.UV4Kind
  95455. * - VertexBuffer.UV5Kind
  95456. * - VertexBuffer.UV6Kind
  95457. * - VertexBuffer.ColorKind
  95458. * - VertexBuffer.MatricesIndicesKind
  95459. * - VertexBuffer.MatricesIndicesExtraKind
  95460. * - VertexBuffer.MatricesWeightsKind
  95461. * - VertexBuffer.MatricesWeightsExtraKind
  95462. * @param data defines the data source
  95463. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95464. * @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)
  95465. */
  95466. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95467. /**
  95468. * Creates a new index buffer
  95469. * @param indices defines the indices to store in the index buffer
  95470. * @param totalVertices defines the total number of vertices (could be null)
  95471. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95472. */
  95473. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95474. }
  95475. /**
  95476. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95477. */
  95478. export class VertexData {
  95479. /**
  95480. * Mesh side orientation : usually the external or front surface
  95481. */
  95482. static readonly FRONTSIDE: number;
  95483. /**
  95484. * Mesh side orientation : usually the internal or back surface
  95485. */
  95486. static readonly BACKSIDE: number;
  95487. /**
  95488. * Mesh side orientation : both internal and external or front and back surfaces
  95489. */
  95490. static readonly DOUBLESIDE: number;
  95491. /**
  95492. * Mesh side orientation : by default, `FRONTSIDE`
  95493. */
  95494. static readonly DEFAULTSIDE: number;
  95495. /**
  95496. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95497. */
  95498. positions: Nullable<FloatArray>;
  95499. /**
  95500. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95501. */
  95502. normals: Nullable<FloatArray>;
  95503. /**
  95504. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95505. */
  95506. tangents: Nullable<FloatArray>;
  95507. /**
  95508. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95509. */
  95510. uvs: Nullable<FloatArray>;
  95511. /**
  95512. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95513. */
  95514. uvs2: Nullable<FloatArray>;
  95515. /**
  95516. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95517. */
  95518. uvs3: Nullable<FloatArray>;
  95519. /**
  95520. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95521. */
  95522. uvs4: Nullable<FloatArray>;
  95523. /**
  95524. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95525. */
  95526. uvs5: Nullable<FloatArray>;
  95527. /**
  95528. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95529. */
  95530. uvs6: Nullable<FloatArray>;
  95531. /**
  95532. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95533. */
  95534. colors: Nullable<FloatArray>;
  95535. /**
  95536. * 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).
  95537. */
  95538. matricesIndices: Nullable<FloatArray>;
  95539. /**
  95540. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95541. */
  95542. matricesWeights: Nullable<FloatArray>;
  95543. /**
  95544. * An array extending the number of possible indices
  95545. */
  95546. matricesIndicesExtra: Nullable<FloatArray>;
  95547. /**
  95548. * An array extending the number of possible weights when the number of indices is extended
  95549. */
  95550. matricesWeightsExtra: Nullable<FloatArray>;
  95551. /**
  95552. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95553. */
  95554. indices: Nullable<IndicesArray>;
  95555. /**
  95556. * Uses the passed data array to set the set the values for the specified kind of data
  95557. * @param data a linear array of floating numbers
  95558. * @param kind the type of data that is being set, eg positions, colors etc
  95559. */
  95560. set(data: FloatArray, kind: string): void;
  95561. /**
  95562. * Associates the vertexData to the passed Mesh.
  95563. * Sets it as updatable or not (default `false`)
  95564. * @param mesh the mesh the vertexData is applied to
  95565. * @param updatable when used and having the value true allows new data to update the vertexData
  95566. * @returns the VertexData
  95567. */
  95568. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95569. /**
  95570. * Associates the vertexData to the passed Geometry.
  95571. * Sets it as updatable or not (default `false`)
  95572. * @param geometry the geometry the vertexData is applied to
  95573. * @param updatable when used and having the value true allows new data to update the vertexData
  95574. * @returns VertexData
  95575. */
  95576. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95577. /**
  95578. * Updates the associated mesh
  95579. * @param mesh the mesh to be updated
  95580. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95581. * @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
  95582. * @returns VertexData
  95583. */
  95584. updateMesh(mesh: Mesh): VertexData;
  95585. /**
  95586. * Updates the associated geometry
  95587. * @param geometry the geometry to be updated
  95588. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95589. * @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
  95590. * @returns VertexData.
  95591. */
  95592. updateGeometry(geometry: Geometry): VertexData;
  95593. private _applyTo;
  95594. private _update;
  95595. /**
  95596. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95597. * @param matrix the transforming matrix
  95598. * @returns the VertexData
  95599. */
  95600. transform(matrix: Matrix): VertexData;
  95601. /**
  95602. * Merges the passed VertexData into the current one
  95603. * @param other the VertexData to be merged into the current one
  95604. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95605. * @returns the modified VertexData
  95606. */
  95607. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95608. private _mergeElement;
  95609. private _validate;
  95610. /**
  95611. * Serializes the VertexData
  95612. * @returns a serialized object
  95613. */
  95614. serialize(): any;
  95615. /**
  95616. * Extracts the vertexData from a mesh
  95617. * @param mesh the mesh from which to extract the VertexData
  95618. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95619. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95620. * @returns the object VertexData associated to the passed mesh
  95621. */
  95622. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95623. /**
  95624. * Extracts the vertexData from the geometry
  95625. * @param geometry the geometry from which to extract the VertexData
  95626. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95627. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95628. * @returns the object VertexData associated to the passed mesh
  95629. */
  95630. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95631. private static _ExtractFrom;
  95632. /**
  95633. * Creates the VertexData for a Ribbon
  95634. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95635. * * pathArray array of paths, each of which an array of successive Vector3
  95636. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95637. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95638. * * 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
  95639. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95640. * * 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)
  95641. * * 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)
  95642. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95643. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95644. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95645. * @returns the VertexData of the ribbon
  95646. */
  95647. static CreateRibbon(options: {
  95648. pathArray: Vector3[][];
  95649. closeArray?: boolean;
  95650. closePath?: boolean;
  95651. offset?: number;
  95652. sideOrientation?: number;
  95653. frontUVs?: Vector4;
  95654. backUVs?: Vector4;
  95655. invertUV?: boolean;
  95656. uvs?: Vector2[];
  95657. colors?: Color4[];
  95658. }): VertexData;
  95659. /**
  95660. * Creates the VertexData for a box
  95661. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95662. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95663. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95664. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95665. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95666. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95667. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95668. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95669. * * 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)
  95670. * * 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)
  95671. * @returns the VertexData of the box
  95672. */
  95673. static CreateBox(options: {
  95674. size?: number;
  95675. width?: number;
  95676. height?: number;
  95677. depth?: number;
  95678. faceUV?: Vector4[];
  95679. faceColors?: Color4[];
  95680. sideOrientation?: number;
  95681. frontUVs?: Vector4;
  95682. backUVs?: Vector4;
  95683. }): VertexData;
  95684. /**
  95685. * Creates the VertexData for a tiled box
  95686. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95687. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95688. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95689. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95690. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95691. * @returns the VertexData of the box
  95692. */
  95693. static CreateTiledBox(options: {
  95694. pattern?: number;
  95695. width?: number;
  95696. height?: number;
  95697. depth?: number;
  95698. tileSize?: number;
  95699. tileWidth?: number;
  95700. tileHeight?: number;
  95701. alignHorizontal?: number;
  95702. alignVertical?: number;
  95703. faceUV?: Vector4[];
  95704. faceColors?: Color4[];
  95705. sideOrientation?: number;
  95706. }): VertexData;
  95707. /**
  95708. * Creates the VertexData for a tiled plane
  95709. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95710. * * pattern a limited pattern arrangement depending on the number
  95711. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95712. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95713. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95715. * * 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)
  95716. * * 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)
  95717. * @returns the VertexData of the tiled plane
  95718. */
  95719. static CreateTiledPlane(options: {
  95720. pattern?: number;
  95721. tileSize?: number;
  95722. tileWidth?: number;
  95723. tileHeight?: number;
  95724. size?: number;
  95725. width?: number;
  95726. height?: number;
  95727. alignHorizontal?: number;
  95728. alignVertical?: number;
  95729. sideOrientation?: number;
  95730. frontUVs?: Vector4;
  95731. backUVs?: Vector4;
  95732. }): VertexData;
  95733. /**
  95734. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95735. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95736. * * segments sets the number of horizontal strips optional, default 32
  95737. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95738. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95739. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95740. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95741. * * 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
  95742. * * 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
  95743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95744. * * 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)
  95745. * * 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)
  95746. * @returns the VertexData of the ellipsoid
  95747. */
  95748. static CreateSphere(options: {
  95749. segments?: number;
  95750. diameter?: number;
  95751. diameterX?: number;
  95752. diameterY?: number;
  95753. diameterZ?: number;
  95754. arc?: number;
  95755. slice?: number;
  95756. sideOrientation?: number;
  95757. frontUVs?: Vector4;
  95758. backUVs?: Vector4;
  95759. }): VertexData;
  95760. /**
  95761. * Creates the VertexData for a cylinder, cone or prism
  95762. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95763. * * height sets the height (y direction) of the cylinder, optional, default 2
  95764. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95765. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95766. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95767. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95768. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95769. * * 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
  95770. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95771. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95772. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95773. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95775. * * 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)
  95776. * * 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)
  95777. * @returns the VertexData of the cylinder, cone or prism
  95778. */
  95779. static CreateCylinder(options: {
  95780. height?: number;
  95781. diameterTop?: number;
  95782. diameterBottom?: number;
  95783. diameter?: number;
  95784. tessellation?: number;
  95785. subdivisions?: number;
  95786. arc?: number;
  95787. faceColors?: Color4[];
  95788. faceUV?: Vector4[];
  95789. hasRings?: boolean;
  95790. enclose?: boolean;
  95791. sideOrientation?: number;
  95792. frontUVs?: Vector4;
  95793. backUVs?: Vector4;
  95794. }): VertexData;
  95795. /**
  95796. * Creates the VertexData for a torus
  95797. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95798. * * diameter the diameter of the torus, optional default 1
  95799. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95800. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95801. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95802. * * 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)
  95803. * * 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)
  95804. * @returns the VertexData of the torus
  95805. */
  95806. static CreateTorus(options: {
  95807. diameter?: number;
  95808. thickness?: number;
  95809. tessellation?: number;
  95810. sideOrientation?: number;
  95811. frontUVs?: Vector4;
  95812. backUVs?: Vector4;
  95813. }): VertexData;
  95814. /**
  95815. * Creates the VertexData of the LineSystem
  95816. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95817. * - lines an array of lines, each line being an array of successive Vector3
  95818. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95819. * @returns the VertexData of the LineSystem
  95820. */
  95821. static CreateLineSystem(options: {
  95822. lines: Vector3[][];
  95823. colors?: Nullable<Color4[][]>;
  95824. }): VertexData;
  95825. /**
  95826. * Create the VertexData for a DashedLines
  95827. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95828. * - points an array successive Vector3
  95829. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95830. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95831. * - dashNb the intended total number of dashes, optional, default 200
  95832. * @returns the VertexData for the DashedLines
  95833. */
  95834. static CreateDashedLines(options: {
  95835. points: Vector3[];
  95836. dashSize?: number;
  95837. gapSize?: number;
  95838. dashNb?: number;
  95839. }): VertexData;
  95840. /**
  95841. * Creates the VertexData for a Ground
  95842. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95843. * - width the width (x direction) of the ground, optional, default 1
  95844. * - height the height (z direction) of the ground, optional, default 1
  95845. * - subdivisions the number of subdivisions per side, optional, default 1
  95846. * @returns the VertexData of the Ground
  95847. */
  95848. static CreateGround(options: {
  95849. width?: number;
  95850. height?: number;
  95851. subdivisions?: number;
  95852. subdivisionsX?: number;
  95853. subdivisionsY?: number;
  95854. }): VertexData;
  95855. /**
  95856. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95857. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95858. * * xmin the ground minimum X coordinate, optional, default -1
  95859. * * zmin the ground minimum Z coordinate, optional, default -1
  95860. * * xmax the ground maximum X coordinate, optional, default 1
  95861. * * zmax the ground maximum Z coordinate, optional, default 1
  95862. * * 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}
  95863. * * 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}
  95864. * @returns the VertexData of the TiledGround
  95865. */
  95866. static CreateTiledGround(options: {
  95867. xmin: number;
  95868. zmin: number;
  95869. xmax: number;
  95870. zmax: number;
  95871. subdivisions?: {
  95872. w: number;
  95873. h: number;
  95874. };
  95875. precision?: {
  95876. w: number;
  95877. h: number;
  95878. };
  95879. }): VertexData;
  95880. /**
  95881. * Creates the VertexData of the Ground designed from a heightmap
  95882. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95883. * * width the width (x direction) of the ground
  95884. * * height the height (z direction) of the ground
  95885. * * subdivisions the number of subdivisions per side
  95886. * * minHeight the minimum altitude on the ground, optional, default 0
  95887. * * maxHeight the maximum altitude on the ground, optional default 1
  95888. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95889. * * buffer the array holding the image color data
  95890. * * bufferWidth the width of image
  95891. * * bufferHeight the height of image
  95892. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95893. * @returns the VertexData of the Ground designed from a heightmap
  95894. */
  95895. static CreateGroundFromHeightMap(options: {
  95896. width: number;
  95897. height: number;
  95898. subdivisions: number;
  95899. minHeight: number;
  95900. maxHeight: number;
  95901. colorFilter: Color3;
  95902. buffer: Uint8Array;
  95903. bufferWidth: number;
  95904. bufferHeight: number;
  95905. alphaFilter: number;
  95906. }): VertexData;
  95907. /**
  95908. * Creates the VertexData for a Plane
  95909. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95910. * * size sets the width and height of the plane to the value of size, optional default 1
  95911. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95912. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95914. * * 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)
  95915. * * 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)
  95916. * @returns the VertexData of the box
  95917. */
  95918. static CreatePlane(options: {
  95919. size?: number;
  95920. width?: number;
  95921. height?: number;
  95922. sideOrientation?: number;
  95923. frontUVs?: Vector4;
  95924. backUVs?: Vector4;
  95925. }): VertexData;
  95926. /**
  95927. * Creates the VertexData of the Disc or regular Polygon
  95928. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95929. * * radius the radius of the disc, optional default 0.5
  95930. * * tessellation the number of polygon sides, optional, default 64
  95931. * * 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
  95932. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95933. * * 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)
  95934. * * 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)
  95935. * @returns the VertexData of the box
  95936. */
  95937. static CreateDisc(options: {
  95938. radius?: number;
  95939. tessellation?: number;
  95940. arc?: number;
  95941. sideOrientation?: number;
  95942. frontUVs?: Vector4;
  95943. backUVs?: Vector4;
  95944. }): VertexData;
  95945. /**
  95946. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95947. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95948. * @param polygon a mesh built from polygonTriangulation.build()
  95949. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95950. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95951. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95952. * @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)
  95953. * @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)
  95954. * @returns the VertexData of the Polygon
  95955. */
  95956. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95957. /**
  95958. * Creates the VertexData of the IcoSphere
  95959. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95960. * * radius the radius of the IcoSphere, optional default 1
  95961. * * radiusX allows stretching in the x direction, optional, default radius
  95962. * * radiusY allows stretching in the y direction, optional, default radius
  95963. * * radiusZ allows stretching in the z direction, optional, default radius
  95964. * * flat when true creates a flat shaded mesh, optional, default true
  95965. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95966. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95967. * * 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)
  95968. * * 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)
  95969. * @returns the VertexData of the IcoSphere
  95970. */
  95971. static CreateIcoSphere(options: {
  95972. radius?: number;
  95973. radiusX?: number;
  95974. radiusY?: number;
  95975. radiusZ?: number;
  95976. flat?: boolean;
  95977. subdivisions?: number;
  95978. sideOrientation?: number;
  95979. frontUVs?: Vector4;
  95980. backUVs?: Vector4;
  95981. }): VertexData;
  95982. /**
  95983. * Creates the VertexData for a Polyhedron
  95984. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95985. * * type provided types are:
  95986. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95987. * * 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)
  95988. * * size the size of the IcoSphere, optional default 1
  95989. * * sizeX allows stretching in the x direction, optional, default size
  95990. * * sizeY allows stretching in the y direction, optional, default size
  95991. * * sizeZ allows stretching in the z direction, optional, default size
  95992. * * 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
  95993. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95994. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95995. * * flat when true creates a flat shaded mesh, optional, default true
  95996. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95998. * * 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)
  95999. * * 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)
  96000. * @returns the VertexData of the Polyhedron
  96001. */
  96002. static CreatePolyhedron(options: {
  96003. type?: number;
  96004. size?: number;
  96005. sizeX?: number;
  96006. sizeY?: number;
  96007. sizeZ?: number;
  96008. custom?: any;
  96009. faceUV?: Vector4[];
  96010. faceColors?: Color4[];
  96011. flat?: boolean;
  96012. sideOrientation?: number;
  96013. frontUVs?: Vector4;
  96014. backUVs?: Vector4;
  96015. }): VertexData;
  96016. /**
  96017. * Creates the VertexData for a TorusKnot
  96018. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  96019. * * radius the radius of the torus knot, optional, default 2
  96020. * * tube the thickness of the tube, optional, default 0.5
  96021. * * radialSegments the number of sides on each tube segments, optional, default 32
  96022. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  96023. * * p the number of windings around the z axis, optional, default 2
  96024. * * q the number of windings around the x axis, optional, default 3
  96025. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96026. * * 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)
  96027. * * 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)
  96028. * @returns the VertexData of the Torus Knot
  96029. */
  96030. static CreateTorusKnot(options: {
  96031. radius?: number;
  96032. tube?: number;
  96033. radialSegments?: number;
  96034. tubularSegments?: number;
  96035. p?: number;
  96036. q?: number;
  96037. sideOrientation?: number;
  96038. frontUVs?: Vector4;
  96039. backUVs?: Vector4;
  96040. }): VertexData;
  96041. /**
  96042. * Compute normals for given positions and indices
  96043. * @param positions an array of vertex positions, [...., x, y, z, ......]
  96044. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  96045. * @param normals an array of vertex normals, [...., x, y, z, ......]
  96046. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  96047. * * facetNormals : optional array of facet normals (vector3)
  96048. * * facetPositions : optional array of facet positions (vector3)
  96049. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  96050. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  96051. * * bInfo : optional bounding info, required for facetPartitioning computation
  96052. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  96053. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  96054. * * useRightHandedSystem: optional boolean to for right handed system computation
  96055. * * depthSort : optional boolean to enable the facet depth sort computation
  96056. * * distanceTo : optional Vector3 to compute the facet depth from this location
  96057. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  96058. */
  96059. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  96060. facetNormals?: any;
  96061. facetPositions?: any;
  96062. facetPartitioning?: any;
  96063. ratio?: number;
  96064. bInfo?: any;
  96065. bbSize?: Vector3;
  96066. subDiv?: any;
  96067. useRightHandedSystem?: boolean;
  96068. depthSort?: boolean;
  96069. distanceTo?: Vector3;
  96070. depthSortedFacets?: any;
  96071. }): void;
  96072. /** @hidden */
  96073. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  96074. /**
  96075. * Applies VertexData created from the imported parameters to the geometry
  96076. * @param parsedVertexData the parsed data from an imported file
  96077. * @param geometry the geometry to apply the VertexData to
  96078. */
  96079. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  96080. }
  96081. }
  96082. declare module BABYLON {
  96083. /**
  96084. * Defines a target to use with MorphTargetManager
  96085. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96086. */
  96087. export class MorphTarget implements IAnimatable {
  96088. /** defines the name of the target */
  96089. name: string;
  96090. /**
  96091. * Gets or sets the list of animations
  96092. */
  96093. animations: Animation[];
  96094. private _scene;
  96095. private _positions;
  96096. private _normals;
  96097. private _tangents;
  96098. private _uvs;
  96099. private _influence;
  96100. private _uniqueId;
  96101. /**
  96102. * Observable raised when the influence changes
  96103. */
  96104. onInfluenceChanged: Observable<boolean>;
  96105. /** @hidden */
  96106. _onDataLayoutChanged: Observable<void>;
  96107. /**
  96108. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96109. */
  96110. get influence(): number;
  96111. set influence(influence: number);
  96112. /**
  96113. * Gets or sets the id of the morph Target
  96114. */
  96115. id: string;
  96116. private _animationPropertiesOverride;
  96117. /**
  96118. * Gets or sets the animation properties override
  96119. */
  96120. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96121. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96122. /**
  96123. * Creates a new MorphTarget
  96124. * @param name defines the name of the target
  96125. * @param influence defines the influence to use
  96126. * @param scene defines the scene the morphtarget belongs to
  96127. */
  96128. constructor(
  96129. /** defines the name of the target */
  96130. name: string, influence?: number, scene?: Nullable<Scene>);
  96131. /**
  96132. * Gets the unique ID of this manager
  96133. */
  96134. get uniqueId(): number;
  96135. /**
  96136. * Gets a boolean defining if the target contains position data
  96137. */
  96138. get hasPositions(): boolean;
  96139. /**
  96140. * Gets a boolean defining if the target contains normal data
  96141. */
  96142. get hasNormals(): boolean;
  96143. /**
  96144. * Gets a boolean defining if the target contains tangent data
  96145. */
  96146. get hasTangents(): boolean;
  96147. /**
  96148. * Gets a boolean defining if the target contains texture coordinates data
  96149. */
  96150. get hasUVs(): boolean;
  96151. /**
  96152. * Affects position data to this target
  96153. * @param data defines the position data to use
  96154. */
  96155. setPositions(data: Nullable<FloatArray>): void;
  96156. /**
  96157. * Gets the position data stored in this target
  96158. * @returns a FloatArray containing the position data (or null if not present)
  96159. */
  96160. getPositions(): Nullable<FloatArray>;
  96161. /**
  96162. * Affects normal data to this target
  96163. * @param data defines the normal data to use
  96164. */
  96165. setNormals(data: Nullable<FloatArray>): void;
  96166. /**
  96167. * Gets the normal data stored in this target
  96168. * @returns a FloatArray containing the normal data (or null if not present)
  96169. */
  96170. getNormals(): Nullable<FloatArray>;
  96171. /**
  96172. * Affects tangent data to this target
  96173. * @param data defines the tangent data to use
  96174. */
  96175. setTangents(data: Nullable<FloatArray>): void;
  96176. /**
  96177. * Gets the tangent data stored in this target
  96178. * @returns a FloatArray containing the tangent data (or null if not present)
  96179. */
  96180. getTangents(): Nullable<FloatArray>;
  96181. /**
  96182. * Affects texture coordinates data to this target
  96183. * @param data defines the texture coordinates data to use
  96184. */
  96185. setUVs(data: Nullable<FloatArray>): void;
  96186. /**
  96187. * Gets the texture coordinates data stored in this target
  96188. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96189. */
  96190. getUVs(): Nullable<FloatArray>;
  96191. /**
  96192. * Clone the current target
  96193. * @returns a new MorphTarget
  96194. */
  96195. clone(): MorphTarget;
  96196. /**
  96197. * Serializes the current target into a Serialization object
  96198. * @returns the serialized object
  96199. */
  96200. serialize(): any;
  96201. /**
  96202. * Returns the string "MorphTarget"
  96203. * @returns "MorphTarget"
  96204. */
  96205. getClassName(): string;
  96206. /**
  96207. * Creates a new target from serialized data
  96208. * @param serializationObject defines the serialized data to use
  96209. * @returns a new MorphTarget
  96210. */
  96211. static Parse(serializationObject: any): MorphTarget;
  96212. /**
  96213. * Creates a MorphTarget from mesh data
  96214. * @param mesh defines the source mesh
  96215. * @param name defines the name to use for the new target
  96216. * @param influence defines the influence to attach to the target
  96217. * @returns a new MorphTarget
  96218. */
  96219. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96220. }
  96221. }
  96222. declare module BABYLON {
  96223. /**
  96224. * This class is used to deform meshes using morphing between different targets
  96225. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96226. */
  96227. export class MorphTargetManager {
  96228. private _targets;
  96229. private _targetInfluenceChangedObservers;
  96230. private _targetDataLayoutChangedObservers;
  96231. private _activeTargets;
  96232. private _scene;
  96233. private _influences;
  96234. private _supportsNormals;
  96235. private _supportsTangents;
  96236. private _supportsUVs;
  96237. private _vertexCount;
  96238. private _uniqueId;
  96239. private _tempInfluences;
  96240. /**
  96241. * Gets or sets a boolean indicating if normals must be morphed
  96242. */
  96243. enableNormalMorphing: boolean;
  96244. /**
  96245. * Gets or sets a boolean indicating if tangents must be morphed
  96246. */
  96247. enableTangentMorphing: boolean;
  96248. /**
  96249. * Gets or sets a boolean indicating if UV must be morphed
  96250. */
  96251. enableUVMorphing: boolean;
  96252. /**
  96253. * Creates a new MorphTargetManager
  96254. * @param scene defines the current scene
  96255. */
  96256. constructor(scene?: Nullable<Scene>);
  96257. /**
  96258. * Gets the unique ID of this manager
  96259. */
  96260. get uniqueId(): number;
  96261. /**
  96262. * Gets the number of vertices handled by this manager
  96263. */
  96264. get vertexCount(): number;
  96265. /**
  96266. * Gets a boolean indicating if this manager supports morphing of normals
  96267. */
  96268. get supportsNormals(): boolean;
  96269. /**
  96270. * Gets a boolean indicating if this manager supports morphing of tangents
  96271. */
  96272. get supportsTangents(): boolean;
  96273. /**
  96274. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96275. */
  96276. get supportsUVs(): boolean;
  96277. /**
  96278. * Gets the number of targets stored in this manager
  96279. */
  96280. get numTargets(): number;
  96281. /**
  96282. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96283. */
  96284. get numInfluencers(): number;
  96285. /**
  96286. * Gets the list of influences (one per target)
  96287. */
  96288. get influences(): Float32Array;
  96289. /**
  96290. * Gets the active target at specified index. An active target is a target with an influence > 0
  96291. * @param index defines the index to check
  96292. * @returns the requested target
  96293. */
  96294. getActiveTarget(index: number): MorphTarget;
  96295. /**
  96296. * Gets the target at specified index
  96297. * @param index defines the index to check
  96298. * @returns the requested target
  96299. */
  96300. getTarget(index: number): MorphTarget;
  96301. /**
  96302. * Add a new target to this manager
  96303. * @param target defines the target to add
  96304. */
  96305. addTarget(target: MorphTarget): void;
  96306. /**
  96307. * Removes a target from the manager
  96308. * @param target defines the target to remove
  96309. */
  96310. removeTarget(target: MorphTarget): void;
  96311. /**
  96312. * Clone the current manager
  96313. * @returns a new MorphTargetManager
  96314. */
  96315. clone(): MorphTargetManager;
  96316. /**
  96317. * Serializes the current manager into a Serialization object
  96318. * @returns the serialized object
  96319. */
  96320. serialize(): any;
  96321. private _syncActiveTargets;
  96322. /**
  96323. * Syncrhonize the targets with all the meshes using this morph target manager
  96324. */
  96325. synchronize(): void;
  96326. /**
  96327. * Creates a new MorphTargetManager from serialized data
  96328. * @param serializationObject defines the serialized data
  96329. * @param scene defines the hosting scene
  96330. * @returns the new MorphTargetManager
  96331. */
  96332. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96333. }
  96334. }
  96335. declare module BABYLON {
  96336. /**
  96337. * Class used to represent a specific level of detail of a mesh
  96338. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96339. */
  96340. export class MeshLODLevel {
  96341. /** Defines the distance where this level should start being displayed */
  96342. distance: number;
  96343. /** Defines the mesh to use to render this level */
  96344. mesh: Nullable<Mesh>;
  96345. /**
  96346. * Creates a new LOD level
  96347. * @param distance defines the distance where this level should star being displayed
  96348. * @param mesh defines the mesh to use to render this level
  96349. */
  96350. constructor(
  96351. /** Defines the distance where this level should start being displayed */
  96352. distance: number,
  96353. /** Defines the mesh to use to render this level */
  96354. mesh: Nullable<Mesh>);
  96355. }
  96356. }
  96357. declare module BABYLON {
  96358. /**
  96359. * Mesh representing the gorund
  96360. */
  96361. export class GroundMesh extends Mesh {
  96362. /** If octree should be generated */
  96363. generateOctree: boolean;
  96364. private _heightQuads;
  96365. /** @hidden */
  96366. _subdivisionsX: number;
  96367. /** @hidden */
  96368. _subdivisionsY: number;
  96369. /** @hidden */
  96370. _width: number;
  96371. /** @hidden */
  96372. _height: number;
  96373. /** @hidden */
  96374. _minX: number;
  96375. /** @hidden */
  96376. _maxX: number;
  96377. /** @hidden */
  96378. _minZ: number;
  96379. /** @hidden */
  96380. _maxZ: number;
  96381. constructor(name: string, scene: Scene);
  96382. /**
  96383. * "GroundMesh"
  96384. * @returns "GroundMesh"
  96385. */
  96386. getClassName(): string;
  96387. /**
  96388. * The minimum of x and y subdivisions
  96389. */
  96390. get subdivisions(): number;
  96391. /**
  96392. * X subdivisions
  96393. */
  96394. get subdivisionsX(): number;
  96395. /**
  96396. * Y subdivisions
  96397. */
  96398. get subdivisionsY(): number;
  96399. /**
  96400. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96401. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96402. * @param chunksCount the number of subdivisions for x and y
  96403. * @param octreeBlocksSize (Default: 32)
  96404. */
  96405. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96406. /**
  96407. * Returns a height (y) value in the Worl system :
  96408. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96409. * @param x x coordinate
  96410. * @param z z coordinate
  96411. * @returns the ground y position if (x, z) are outside the ground surface.
  96412. */
  96413. getHeightAtCoordinates(x: number, z: number): number;
  96414. /**
  96415. * Returns a normalized vector (Vector3) orthogonal to the ground
  96416. * at the ground coordinates (x, z) expressed in the World system.
  96417. * @param x x coordinate
  96418. * @param z z coordinate
  96419. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96420. */
  96421. getNormalAtCoordinates(x: number, z: number): Vector3;
  96422. /**
  96423. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96424. * at the ground coordinates (x, z) expressed in the World system.
  96425. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96426. * @param x x coordinate
  96427. * @param z z coordinate
  96428. * @param ref vector to store the result
  96429. * @returns the GroundMesh.
  96430. */
  96431. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96432. /**
  96433. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96434. * if the ground has been updated.
  96435. * This can be used in the render loop.
  96436. * @returns the GroundMesh.
  96437. */
  96438. updateCoordinateHeights(): GroundMesh;
  96439. private _getFacetAt;
  96440. private _initHeightQuads;
  96441. private _computeHeightQuads;
  96442. /**
  96443. * Serializes this ground mesh
  96444. * @param serializationObject object to write serialization to
  96445. */
  96446. serialize(serializationObject: any): void;
  96447. /**
  96448. * Parses a serialized ground mesh
  96449. * @param parsedMesh the serialized mesh
  96450. * @param scene the scene to create the ground mesh in
  96451. * @returns the created ground mesh
  96452. */
  96453. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96454. }
  96455. }
  96456. declare module BABYLON {
  96457. /**
  96458. * Interface for Physics-Joint data
  96459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96460. */
  96461. export interface PhysicsJointData {
  96462. /**
  96463. * The main pivot of the joint
  96464. */
  96465. mainPivot?: Vector3;
  96466. /**
  96467. * The connected pivot of the joint
  96468. */
  96469. connectedPivot?: Vector3;
  96470. /**
  96471. * The main axis of the joint
  96472. */
  96473. mainAxis?: Vector3;
  96474. /**
  96475. * The connected axis of the joint
  96476. */
  96477. connectedAxis?: Vector3;
  96478. /**
  96479. * The collision of the joint
  96480. */
  96481. collision?: boolean;
  96482. /**
  96483. * Native Oimo/Cannon/Energy data
  96484. */
  96485. nativeParams?: any;
  96486. }
  96487. /**
  96488. * This is a holder class for the physics joint created by the physics plugin
  96489. * It holds a set of functions to control the underlying joint
  96490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96491. */
  96492. export class PhysicsJoint {
  96493. /**
  96494. * The type of the physics joint
  96495. */
  96496. type: number;
  96497. /**
  96498. * The data for the physics joint
  96499. */
  96500. jointData: PhysicsJointData;
  96501. private _physicsJoint;
  96502. protected _physicsPlugin: IPhysicsEnginePlugin;
  96503. /**
  96504. * Initializes the physics joint
  96505. * @param type The type of the physics joint
  96506. * @param jointData The data for the physics joint
  96507. */
  96508. constructor(
  96509. /**
  96510. * The type of the physics joint
  96511. */
  96512. type: number,
  96513. /**
  96514. * The data for the physics joint
  96515. */
  96516. jointData: PhysicsJointData);
  96517. /**
  96518. * Gets the physics joint
  96519. */
  96520. get physicsJoint(): any;
  96521. /**
  96522. * Sets the physics joint
  96523. */
  96524. set physicsJoint(newJoint: any);
  96525. /**
  96526. * Sets the physics plugin
  96527. */
  96528. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96529. /**
  96530. * Execute a function that is physics-plugin specific.
  96531. * @param {Function} func the function that will be executed.
  96532. * It accepts two parameters: the physics world and the physics joint
  96533. */
  96534. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96535. /**
  96536. * Distance-Joint type
  96537. */
  96538. static DistanceJoint: number;
  96539. /**
  96540. * Hinge-Joint type
  96541. */
  96542. static HingeJoint: number;
  96543. /**
  96544. * Ball-and-Socket joint type
  96545. */
  96546. static BallAndSocketJoint: number;
  96547. /**
  96548. * Wheel-Joint type
  96549. */
  96550. static WheelJoint: number;
  96551. /**
  96552. * Slider-Joint type
  96553. */
  96554. static SliderJoint: number;
  96555. /**
  96556. * Prismatic-Joint type
  96557. */
  96558. static PrismaticJoint: number;
  96559. /**
  96560. * Universal-Joint type
  96561. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96562. */
  96563. static UniversalJoint: number;
  96564. /**
  96565. * Hinge-Joint 2 type
  96566. */
  96567. static Hinge2Joint: number;
  96568. /**
  96569. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96570. */
  96571. static PointToPointJoint: number;
  96572. /**
  96573. * Spring-Joint type
  96574. */
  96575. static SpringJoint: number;
  96576. /**
  96577. * Lock-Joint type
  96578. */
  96579. static LockJoint: number;
  96580. }
  96581. /**
  96582. * A class representing a physics distance joint
  96583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96584. */
  96585. export class DistanceJoint extends PhysicsJoint {
  96586. /**
  96587. *
  96588. * @param jointData The data for the Distance-Joint
  96589. */
  96590. constructor(jointData: DistanceJointData);
  96591. /**
  96592. * Update the predefined distance.
  96593. * @param maxDistance The maximum preferred distance
  96594. * @param minDistance The minimum preferred distance
  96595. */
  96596. updateDistance(maxDistance: number, minDistance?: number): void;
  96597. }
  96598. /**
  96599. * Represents a Motor-Enabled Joint
  96600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96601. */
  96602. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96603. /**
  96604. * Initializes the Motor-Enabled Joint
  96605. * @param type The type of the joint
  96606. * @param jointData The physica joint data for the joint
  96607. */
  96608. constructor(type: number, jointData: PhysicsJointData);
  96609. /**
  96610. * Set the motor values.
  96611. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96612. * @param force the force to apply
  96613. * @param maxForce max force for this motor.
  96614. */
  96615. setMotor(force?: number, maxForce?: number): void;
  96616. /**
  96617. * Set the motor's limits.
  96618. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96619. * @param upperLimit The upper limit of the motor
  96620. * @param lowerLimit The lower limit of the motor
  96621. */
  96622. setLimit(upperLimit: number, lowerLimit?: number): void;
  96623. }
  96624. /**
  96625. * This class represents a single physics Hinge-Joint
  96626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96627. */
  96628. export class HingeJoint extends MotorEnabledJoint {
  96629. /**
  96630. * Initializes the Hinge-Joint
  96631. * @param jointData The joint data for the Hinge-Joint
  96632. */
  96633. constructor(jointData: PhysicsJointData);
  96634. /**
  96635. * Set the motor values.
  96636. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96637. * @param {number} force the force to apply
  96638. * @param {number} maxForce max force for this motor.
  96639. */
  96640. setMotor(force?: number, maxForce?: number): void;
  96641. /**
  96642. * Set the motor's limits.
  96643. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96644. * @param upperLimit The upper limit of the motor
  96645. * @param lowerLimit The lower limit of the motor
  96646. */
  96647. setLimit(upperLimit: number, lowerLimit?: number): void;
  96648. }
  96649. /**
  96650. * This class represents a dual hinge physics joint (same as wheel joint)
  96651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96652. */
  96653. export class Hinge2Joint extends MotorEnabledJoint {
  96654. /**
  96655. * Initializes the Hinge2-Joint
  96656. * @param jointData The joint data for the Hinge2-Joint
  96657. */
  96658. constructor(jointData: PhysicsJointData);
  96659. /**
  96660. * Set the motor values.
  96661. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96662. * @param {number} targetSpeed the speed the motor is to reach
  96663. * @param {number} maxForce max force for this motor.
  96664. * @param {motorIndex} the motor's index, 0 or 1.
  96665. */
  96666. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96667. /**
  96668. * Set the motor limits.
  96669. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96670. * @param {number} upperLimit the upper limit
  96671. * @param {number} lowerLimit lower limit
  96672. * @param {motorIndex} the motor's index, 0 or 1.
  96673. */
  96674. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96675. }
  96676. /**
  96677. * Interface for a motor enabled joint
  96678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96679. */
  96680. export interface IMotorEnabledJoint {
  96681. /**
  96682. * Physics joint
  96683. */
  96684. physicsJoint: any;
  96685. /**
  96686. * Sets the motor of the motor-enabled joint
  96687. * @param force The force of the motor
  96688. * @param maxForce The maximum force of the motor
  96689. * @param motorIndex The index of the motor
  96690. */
  96691. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96692. /**
  96693. * Sets the limit of the motor
  96694. * @param upperLimit The upper limit of the motor
  96695. * @param lowerLimit The lower limit of the motor
  96696. * @param motorIndex The index of the motor
  96697. */
  96698. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96699. }
  96700. /**
  96701. * Joint data for a Distance-Joint
  96702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96703. */
  96704. export interface DistanceJointData extends PhysicsJointData {
  96705. /**
  96706. * Max distance the 2 joint objects can be apart
  96707. */
  96708. maxDistance: number;
  96709. }
  96710. /**
  96711. * Joint data from a spring joint
  96712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96713. */
  96714. export interface SpringJointData extends PhysicsJointData {
  96715. /**
  96716. * Length of the spring
  96717. */
  96718. length: number;
  96719. /**
  96720. * Stiffness of the spring
  96721. */
  96722. stiffness: number;
  96723. /**
  96724. * Damping of the spring
  96725. */
  96726. damping: number;
  96727. /** this callback will be called when applying the force to the impostors. */
  96728. forceApplicationCallback: () => void;
  96729. }
  96730. }
  96731. declare module BABYLON {
  96732. /**
  96733. * Holds the data for the raycast result
  96734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96735. */
  96736. export class PhysicsRaycastResult {
  96737. private _hasHit;
  96738. private _hitDistance;
  96739. private _hitNormalWorld;
  96740. private _hitPointWorld;
  96741. private _rayFromWorld;
  96742. private _rayToWorld;
  96743. /**
  96744. * Gets if there was a hit
  96745. */
  96746. get hasHit(): boolean;
  96747. /**
  96748. * Gets the distance from the hit
  96749. */
  96750. get hitDistance(): number;
  96751. /**
  96752. * Gets the hit normal/direction in the world
  96753. */
  96754. get hitNormalWorld(): Vector3;
  96755. /**
  96756. * Gets the hit point in the world
  96757. */
  96758. get hitPointWorld(): Vector3;
  96759. /**
  96760. * Gets the ray "start point" of the ray in the world
  96761. */
  96762. get rayFromWorld(): Vector3;
  96763. /**
  96764. * Gets the ray "end point" of the ray in the world
  96765. */
  96766. get rayToWorld(): Vector3;
  96767. /**
  96768. * Sets the hit data (normal & point in world space)
  96769. * @param hitNormalWorld defines the normal in world space
  96770. * @param hitPointWorld defines the point in world space
  96771. */
  96772. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96773. /**
  96774. * Sets the distance from the start point to the hit point
  96775. * @param distance
  96776. */
  96777. setHitDistance(distance: number): void;
  96778. /**
  96779. * Calculates the distance manually
  96780. */
  96781. calculateHitDistance(): void;
  96782. /**
  96783. * Resets all the values to default
  96784. * @param from The from point on world space
  96785. * @param to The to point on world space
  96786. */
  96787. reset(from?: Vector3, to?: Vector3): void;
  96788. }
  96789. /**
  96790. * Interface for the size containing width and height
  96791. */
  96792. interface IXYZ {
  96793. /**
  96794. * X
  96795. */
  96796. x: number;
  96797. /**
  96798. * Y
  96799. */
  96800. y: number;
  96801. /**
  96802. * Z
  96803. */
  96804. z: number;
  96805. }
  96806. }
  96807. declare module BABYLON {
  96808. /**
  96809. * Interface used to describe a physics joint
  96810. */
  96811. export interface PhysicsImpostorJoint {
  96812. /** Defines the main impostor to which the joint is linked */
  96813. mainImpostor: PhysicsImpostor;
  96814. /** Defines the impostor that is connected to the main impostor using this joint */
  96815. connectedImpostor: PhysicsImpostor;
  96816. /** Defines the joint itself */
  96817. joint: PhysicsJoint;
  96818. }
  96819. /** @hidden */
  96820. export interface IPhysicsEnginePlugin {
  96821. world: any;
  96822. name: string;
  96823. setGravity(gravity: Vector3): void;
  96824. setTimeStep(timeStep: number): void;
  96825. getTimeStep(): number;
  96826. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96827. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96828. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96829. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96830. removePhysicsBody(impostor: PhysicsImpostor): void;
  96831. generateJoint(joint: PhysicsImpostorJoint): void;
  96832. removeJoint(joint: PhysicsImpostorJoint): void;
  96833. isSupported(): boolean;
  96834. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96835. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96836. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96837. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96838. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96839. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96840. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96841. getBodyMass(impostor: PhysicsImpostor): number;
  96842. getBodyFriction(impostor: PhysicsImpostor): number;
  96843. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96844. getBodyRestitution(impostor: PhysicsImpostor): number;
  96845. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96846. getBodyPressure?(impostor: PhysicsImpostor): number;
  96847. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96848. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96849. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96850. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96851. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96852. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96853. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96854. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96855. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96856. sleepBody(impostor: PhysicsImpostor): void;
  96857. wakeUpBody(impostor: PhysicsImpostor): void;
  96858. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96859. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96860. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96861. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96862. getRadius(impostor: PhysicsImpostor): number;
  96863. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96864. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96865. dispose(): void;
  96866. }
  96867. /**
  96868. * Interface used to define a physics engine
  96869. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96870. */
  96871. export interface IPhysicsEngine {
  96872. /**
  96873. * Gets the gravity vector used by the simulation
  96874. */
  96875. gravity: Vector3;
  96876. /**
  96877. * Sets the gravity vector used by the simulation
  96878. * @param gravity defines the gravity vector to use
  96879. */
  96880. setGravity(gravity: Vector3): void;
  96881. /**
  96882. * Set the time step of the physics engine.
  96883. * Default is 1/60.
  96884. * To slow it down, enter 1/600 for example.
  96885. * To speed it up, 1/30
  96886. * @param newTimeStep the new timestep to apply to this world.
  96887. */
  96888. setTimeStep(newTimeStep: number): void;
  96889. /**
  96890. * Get the time step of the physics engine.
  96891. * @returns the current time step
  96892. */
  96893. getTimeStep(): number;
  96894. /**
  96895. * Set the sub time step of the physics engine.
  96896. * Default is 0 meaning there is no sub steps
  96897. * To increase physics resolution precision, set a small value (like 1 ms)
  96898. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96899. */
  96900. setSubTimeStep(subTimeStep: number): void;
  96901. /**
  96902. * Get the sub time step of the physics engine.
  96903. * @returns the current sub time step
  96904. */
  96905. getSubTimeStep(): number;
  96906. /**
  96907. * Release all resources
  96908. */
  96909. dispose(): void;
  96910. /**
  96911. * Gets the name of the current physics plugin
  96912. * @returns the name of the plugin
  96913. */
  96914. getPhysicsPluginName(): string;
  96915. /**
  96916. * Adding a new impostor for the impostor tracking.
  96917. * This will be done by the impostor itself.
  96918. * @param impostor the impostor to add
  96919. */
  96920. addImpostor(impostor: PhysicsImpostor): void;
  96921. /**
  96922. * Remove an impostor from the engine.
  96923. * This impostor and its mesh will not longer be updated by the physics engine.
  96924. * @param impostor the impostor to remove
  96925. */
  96926. removeImpostor(impostor: PhysicsImpostor): void;
  96927. /**
  96928. * Add a joint to the physics engine
  96929. * @param mainImpostor defines the main impostor to which the joint is added.
  96930. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96931. * @param joint defines the joint that will connect both impostors.
  96932. */
  96933. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96934. /**
  96935. * Removes a joint from the simulation
  96936. * @param mainImpostor defines the impostor used with the joint
  96937. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96938. * @param joint defines the joint to remove
  96939. */
  96940. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96941. /**
  96942. * Gets the current plugin used to run the simulation
  96943. * @returns current plugin
  96944. */
  96945. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96946. /**
  96947. * Gets the list of physic impostors
  96948. * @returns an array of PhysicsImpostor
  96949. */
  96950. getImpostors(): Array<PhysicsImpostor>;
  96951. /**
  96952. * Gets the impostor for a physics enabled object
  96953. * @param object defines the object impersonated by the impostor
  96954. * @returns the PhysicsImpostor or null if not found
  96955. */
  96956. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96957. /**
  96958. * Gets the impostor for a physics body object
  96959. * @param body defines physics body used by the impostor
  96960. * @returns the PhysicsImpostor or null if not found
  96961. */
  96962. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96963. /**
  96964. * Does a raycast in the physics world
  96965. * @param from when should the ray start?
  96966. * @param to when should the ray end?
  96967. * @returns PhysicsRaycastResult
  96968. */
  96969. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96970. /**
  96971. * Called by the scene. No need to call it.
  96972. * @param delta defines the timespam between frames
  96973. */
  96974. _step(delta: number): void;
  96975. }
  96976. }
  96977. declare module BABYLON {
  96978. /**
  96979. * The interface for the physics imposter parameters
  96980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96981. */
  96982. export interface PhysicsImpostorParameters {
  96983. /**
  96984. * The mass of the physics imposter
  96985. */
  96986. mass: number;
  96987. /**
  96988. * The friction of the physics imposter
  96989. */
  96990. friction?: number;
  96991. /**
  96992. * The coefficient of restitution of the physics imposter
  96993. */
  96994. restitution?: number;
  96995. /**
  96996. * The native options of the physics imposter
  96997. */
  96998. nativeOptions?: any;
  96999. /**
  97000. * Specifies if the parent should be ignored
  97001. */
  97002. ignoreParent?: boolean;
  97003. /**
  97004. * Specifies if bi-directional transformations should be disabled
  97005. */
  97006. disableBidirectionalTransformation?: boolean;
  97007. /**
  97008. * The pressure inside the physics imposter, soft object only
  97009. */
  97010. pressure?: number;
  97011. /**
  97012. * The stiffness the physics imposter, soft object only
  97013. */
  97014. stiffness?: number;
  97015. /**
  97016. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  97017. */
  97018. velocityIterations?: number;
  97019. /**
  97020. * The number of iterations used in maintaining consistent vertex positions, soft object only
  97021. */
  97022. positionIterations?: number;
  97023. /**
  97024. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  97025. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  97026. * Add to fix multiple points
  97027. */
  97028. fixedPoints?: number;
  97029. /**
  97030. * The collision margin around a soft object
  97031. */
  97032. margin?: number;
  97033. /**
  97034. * The collision margin around a soft object
  97035. */
  97036. damping?: number;
  97037. /**
  97038. * The path for a rope based on an extrusion
  97039. */
  97040. path?: any;
  97041. /**
  97042. * The shape of an extrusion used for a rope based on an extrusion
  97043. */
  97044. shape?: any;
  97045. }
  97046. /**
  97047. * Interface for a physics-enabled object
  97048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97049. */
  97050. export interface IPhysicsEnabledObject {
  97051. /**
  97052. * The position of the physics-enabled object
  97053. */
  97054. position: Vector3;
  97055. /**
  97056. * The rotation of the physics-enabled object
  97057. */
  97058. rotationQuaternion: Nullable<Quaternion>;
  97059. /**
  97060. * The scale of the physics-enabled object
  97061. */
  97062. scaling: Vector3;
  97063. /**
  97064. * The rotation of the physics-enabled object
  97065. */
  97066. rotation?: Vector3;
  97067. /**
  97068. * The parent of the physics-enabled object
  97069. */
  97070. parent?: any;
  97071. /**
  97072. * The bounding info of the physics-enabled object
  97073. * @returns The bounding info of the physics-enabled object
  97074. */
  97075. getBoundingInfo(): BoundingInfo;
  97076. /**
  97077. * Computes the world matrix
  97078. * @param force Specifies if the world matrix should be computed by force
  97079. * @returns A world matrix
  97080. */
  97081. computeWorldMatrix(force: boolean): Matrix;
  97082. /**
  97083. * Gets the world matrix
  97084. * @returns A world matrix
  97085. */
  97086. getWorldMatrix?(): Matrix;
  97087. /**
  97088. * Gets the child meshes
  97089. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  97090. * @returns An array of abstract meshes
  97091. */
  97092. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  97093. /**
  97094. * Gets the vertex data
  97095. * @param kind The type of vertex data
  97096. * @returns A nullable array of numbers, or a float32 array
  97097. */
  97098. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  97099. /**
  97100. * Gets the indices from the mesh
  97101. * @returns A nullable array of index arrays
  97102. */
  97103. getIndices?(): Nullable<IndicesArray>;
  97104. /**
  97105. * Gets the scene from the mesh
  97106. * @returns the indices array or null
  97107. */
  97108. getScene?(): Scene;
  97109. /**
  97110. * Gets the absolute position from the mesh
  97111. * @returns the absolute position
  97112. */
  97113. getAbsolutePosition(): Vector3;
  97114. /**
  97115. * Gets the absolute pivot point from the mesh
  97116. * @returns the absolute pivot point
  97117. */
  97118. getAbsolutePivotPoint(): Vector3;
  97119. /**
  97120. * Rotates the mesh
  97121. * @param axis The axis of rotation
  97122. * @param amount The amount of rotation
  97123. * @param space The space of the rotation
  97124. * @returns The rotation transform node
  97125. */
  97126. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97127. /**
  97128. * Translates the mesh
  97129. * @param axis The axis of translation
  97130. * @param distance The distance of translation
  97131. * @param space The space of the translation
  97132. * @returns The transform node
  97133. */
  97134. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97135. /**
  97136. * Sets the absolute position of the mesh
  97137. * @param absolutePosition The absolute position of the mesh
  97138. * @returns The transform node
  97139. */
  97140. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97141. /**
  97142. * Gets the class name of the mesh
  97143. * @returns The class name
  97144. */
  97145. getClassName(): string;
  97146. }
  97147. /**
  97148. * Represents a physics imposter
  97149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97150. */
  97151. export class PhysicsImpostor {
  97152. /**
  97153. * The physics-enabled object used as the physics imposter
  97154. */
  97155. object: IPhysicsEnabledObject;
  97156. /**
  97157. * The type of the physics imposter
  97158. */
  97159. type: number;
  97160. private _options;
  97161. private _scene?;
  97162. /**
  97163. * The default object size of the imposter
  97164. */
  97165. static DEFAULT_OBJECT_SIZE: Vector3;
  97166. /**
  97167. * The identity quaternion of the imposter
  97168. */
  97169. static IDENTITY_QUATERNION: Quaternion;
  97170. /** @hidden */
  97171. _pluginData: any;
  97172. private _physicsEngine;
  97173. private _physicsBody;
  97174. private _bodyUpdateRequired;
  97175. private _onBeforePhysicsStepCallbacks;
  97176. private _onAfterPhysicsStepCallbacks;
  97177. /** @hidden */
  97178. _onPhysicsCollideCallbacks: Array<{
  97179. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97180. otherImpostors: Array<PhysicsImpostor>;
  97181. }>;
  97182. private _deltaPosition;
  97183. private _deltaRotation;
  97184. private _deltaRotationConjugated;
  97185. /** @hidden */
  97186. _isFromLine: boolean;
  97187. private _parent;
  97188. private _isDisposed;
  97189. private static _tmpVecs;
  97190. private static _tmpQuat;
  97191. /**
  97192. * Specifies if the physics imposter is disposed
  97193. */
  97194. get isDisposed(): boolean;
  97195. /**
  97196. * Gets the mass of the physics imposter
  97197. */
  97198. get mass(): number;
  97199. set mass(value: number);
  97200. /**
  97201. * Gets the coefficient of friction
  97202. */
  97203. get friction(): number;
  97204. /**
  97205. * Sets the coefficient of friction
  97206. */
  97207. set friction(value: number);
  97208. /**
  97209. * Gets the coefficient of restitution
  97210. */
  97211. get restitution(): number;
  97212. /**
  97213. * Sets the coefficient of restitution
  97214. */
  97215. set restitution(value: number);
  97216. /**
  97217. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97218. */
  97219. get pressure(): number;
  97220. /**
  97221. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97222. */
  97223. set pressure(value: number);
  97224. /**
  97225. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97226. */
  97227. get stiffness(): number;
  97228. /**
  97229. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97230. */
  97231. set stiffness(value: number);
  97232. /**
  97233. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97234. */
  97235. get velocityIterations(): number;
  97236. /**
  97237. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97238. */
  97239. set velocityIterations(value: number);
  97240. /**
  97241. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97242. */
  97243. get positionIterations(): number;
  97244. /**
  97245. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97246. */
  97247. set positionIterations(value: number);
  97248. /**
  97249. * The unique id of the physics imposter
  97250. * set by the physics engine when adding this impostor to the array
  97251. */
  97252. uniqueId: number;
  97253. /**
  97254. * @hidden
  97255. */
  97256. soft: boolean;
  97257. /**
  97258. * @hidden
  97259. */
  97260. segments: number;
  97261. private _joints;
  97262. /**
  97263. * Initializes the physics imposter
  97264. * @param object The physics-enabled object used as the physics imposter
  97265. * @param type The type of the physics imposter
  97266. * @param _options The options for the physics imposter
  97267. * @param _scene The Babylon scene
  97268. */
  97269. constructor(
  97270. /**
  97271. * The physics-enabled object used as the physics imposter
  97272. */
  97273. object: IPhysicsEnabledObject,
  97274. /**
  97275. * The type of the physics imposter
  97276. */
  97277. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97278. /**
  97279. * This function will completly initialize this impostor.
  97280. * It will create a new body - but only if this mesh has no parent.
  97281. * If it has, this impostor will not be used other than to define the impostor
  97282. * of the child mesh.
  97283. * @hidden
  97284. */
  97285. _init(): void;
  97286. private _getPhysicsParent;
  97287. /**
  97288. * Should a new body be generated.
  97289. * @returns boolean specifying if body initialization is required
  97290. */
  97291. isBodyInitRequired(): boolean;
  97292. /**
  97293. * Sets the updated scaling
  97294. * @param updated Specifies if the scaling is updated
  97295. */
  97296. setScalingUpdated(): void;
  97297. /**
  97298. * Force a regeneration of this or the parent's impostor's body.
  97299. * Use under cautious - This will remove all joints already implemented.
  97300. */
  97301. forceUpdate(): void;
  97302. /**
  97303. * Gets the body that holds this impostor. Either its own, or its parent.
  97304. */
  97305. get physicsBody(): any;
  97306. /**
  97307. * Get the parent of the physics imposter
  97308. * @returns Physics imposter or null
  97309. */
  97310. get parent(): Nullable<PhysicsImpostor>;
  97311. /**
  97312. * Sets the parent of the physics imposter
  97313. */
  97314. set parent(value: Nullable<PhysicsImpostor>);
  97315. /**
  97316. * Set the physics body. Used mainly by the physics engine/plugin
  97317. */
  97318. set physicsBody(physicsBody: any);
  97319. /**
  97320. * Resets the update flags
  97321. */
  97322. resetUpdateFlags(): void;
  97323. /**
  97324. * Gets the object extend size
  97325. * @returns the object extend size
  97326. */
  97327. getObjectExtendSize(): Vector3;
  97328. /**
  97329. * Gets the object center
  97330. * @returns The object center
  97331. */
  97332. getObjectCenter(): Vector3;
  97333. /**
  97334. * Get a specific parameter from the options parameters
  97335. * @param paramName The object parameter name
  97336. * @returns The object parameter
  97337. */
  97338. getParam(paramName: string): any;
  97339. /**
  97340. * Sets a specific parameter in the options given to the physics plugin
  97341. * @param paramName The parameter name
  97342. * @param value The value of the parameter
  97343. */
  97344. setParam(paramName: string, value: number): void;
  97345. /**
  97346. * Specifically change the body's mass option. Won't recreate the physics body object
  97347. * @param mass The mass of the physics imposter
  97348. */
  97349. setMass(mass: number): void;
  97350. /**
  97351. * Gets the linear velocity
  97352. * @returns linear velocity or null
  97353. */
  97354. getLinearVelocity(): Nullable<Vector3>;
  97355. /**
  97356. * Sets the linear velocity
  97357. * @param velocity linear velocity or null
  97358. */
  97359. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97360. /**
  97361. * Gets the angular velocity
  97362. * @returns angular velocity or null
  97363. */
  97364. getAngularVelocity(): Nullable<Vector3>;
  97365. /**
  97366. * Sets the angular velocity
  97367. * @param velocity The velocity or null
  97368. */
  97369. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97370. /**
  97371. * Execute a function with the physics plugin native code
  97372. * Provide a function the will have two variables - the world object and the physics body object
  97373. * @param func The function to execute with the physics plugin native code
  97374. */
  97375. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97376. /**
  97377. * Register a function that will be executed before the physics world is stepping forward
  97378. * @param func The function to execute before the physics world is stepped forward
  97379. */
  97380. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97381. /**
  97382. * Unregister a function that will be executed before the physics world is stepping forward
  97383. * @param func The function to execute before the physics world is stepped forward
  97384. */
  97385. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97386. /**
  97387. * Register a function that will be executed after the physics step
  97388. * @param func The function to execute after physics step
  97389. */
  97390. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97391. /**
  97392. * Unregisters a function that will be executed after the physics step
  97393. * @param func The function to execute after physics step
  97394. */
  97395. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97396. /**
  97397. * register a function that will be executed when this impostor collides against a different body
  97398. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97399. * @param func Callback that is executed on collision
  97400. */
  97401. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97402. /**
  97403. * Unregisters the physics imposter on contact
  97404. * @param collideAgainst The physics object to collide against
  97405. * @param func Callback to execute on collision
  97406. */
  97407. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97408. private _tmpQuat;
  97409. private _tmpQuat2;
  97410. /**
  97411. * Get the parent rotation
  97412. * @returns The parent rotation
  97413. */
  97414. getParentsRotation(): Quaternion;
  97415. /**
  97416. * this function is executed by the physics engine.
  97417. */
  97418. beforeStep: () => void;
  97419. /**
  97420. * this function is executed by the physics engine
  97421. */
  97422. afterStep: () => void;
  97423. /**
  97424. * Legacy collision detection event support
  97425. */
  97426. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97427. /**
  97428. * event and body object due to cannon's event-based architecture.
  97429. */
  97430. onCollide: (e: {
  97431. body: any;
  97432. }) => void;
  97433. /**
  97434. * Apply a force
  97435. * @param force The force to apply
  97436. * @param contactPoint The contact point for the force
  97437. * @returns The physics imposter
  97438. */
  97439. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97440. /**
  97441. * Apply an impulse
  97442. * @param force The impulse force
  97443. * @param contactPoint The contact point for the impulse force
  97444. * @returns The physics imposter
  97445. */
  97446. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97447. /**
  97448. * A help function to create a joint
  97449. * @param otherImpostor A physics imposter used to create a joint
  97450. * @param jointType The type of joint
  97451. * @param jointData The data for the joint
  97452. * @returns The physics imposter
  97453. */
  97454. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97455. /**
  97456. * Add a joint to this impostor with a different impostor
  97457. * @param otherImpostor A physics imposter used to add a joint
  97458. * @param joint The joint to add
  97459. * @returns The physics imposter
  97460. */
  97461. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97462. /**
  97463. * Add an anchor to a cloth impostor
  97464. * @param otherImpostor rigid impostor to anchor to
  97465. * @param width ratio across width from 0 to 1
  97466. * @param height ratio up height from 0 to 1
  97467. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97468. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97469. * @returns impostor the soft imposter
  97470. */
  97471. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97472. /**
  97473. * Add a hook to a rope impostor
  97474. * @param otherImpostor rigid impostor to anchor to
  97475. * @param length ratio across rope from 0 to 1
  97476. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97477. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97478. * @returns impostor the rope imposter
  97479. */
  97480. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97481. /**
  97482. * Will keep this body still, in a sleep mode.
  97483. * @returns the physics imposter
  97484. */
  97485. sleep(): PhysicsImpostor;
  97486. /**
  97487. * Wake the body up.
  97488. * @returns The physics imposter
  97489. */
  97490. wakeUp(): PhysicsImpostor;
  97491. /**
  97492. * Clones the physics imposter
  97493. * @param newObject The physics imposter clones to this physics-enabled object
  97494. * @returns A nullable physics imposter
  97495. */
  97496. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97497. /**
  97498. * Disposes the physics imposter
  97499. */
  97500. dispose(): void;
  97501. /**
  97502. * Sets the delta position
  97503. * @param position The delta position amount
  97504. */
  97505. setDeltaPosition(position: Vector3): void;
  97506. /**
  97507. * Sets the delta rotation
  97508. * @param rotation The delta rotation amount
  97509. */
  97510. setDeltaRotation(rotation: Quaternion): void;
  97511. /**
  97512. * Gets the box size of the physics imposter and stores the result in the input parameter
  97513. * @param result Stores the box size
  97514. * @returns The physics imposter
  97515. */
  97516. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97517. /**
  97518. * Gets the radius of the physics imposter
  97519. * @returns Radius of the physics imposter
  97520. */
  97521. getRadius(): number;
  97522. /**
  97523. * Sync a bone with this impostor
  97524. * @param bone The bone to sync to the impostor.
  97525. * @param boneMesh The mesh that the bone is influencing.
  97526. * @param jointPivot The pivot of the joint / bone in local space.
  97527. * @param distToJoint Optional distance from the impostor to the joint.
  97528. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97529. */
  97530. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97531. /**
  97532. * Sync impostor to a bone
  97533. * @param bone The bone that the impostor will be synced to.
  97534. * @param boneMesh The mesh that the bone is influencing.
  97535. * @param jointPivot The pivot of the joint / bone in local space.
  97536. * @param distToJoint Optional distance from the impostor to the joint.
  97537. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97538. * @param boneAxis Optional vector3 axis the bone is aligned with
  97539. */
  97540. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97541. /**
  97542. * No-Imposter type
  97543. */
  97544. static NoImpostor: number;
  97545. /**
  97546. * Sphere-Imposter type
  97547. */
  97548. static SphereImpostor: number;
  97549. /**
  97550. * Box-Imposter type
  97551. */
  97552. static BoxImpostor: number;
  97553. /**
  97554. * Plane-Imposter type
  97555. */
  97556. static PlaneImpostor: number;
  97557. /**
  97558. * Mesh-imposter type
  97559. */
  97560. static MeshImpostor: number;
  97561. /**
  97562. * Capsule-Impostor type (Ammo.js plugin only)
  97563. */
  97564. static CapsuleImpostor: number;
  97565. /**
  97566. * Cylinder-Imposter type
  97567. */
  97568. static CylinderImpostor: number;
  97569. /**
  97570. * Particle-Imposter type
  97571. */
  97572. static ParticleImpostor: number;
  97573. /**
  97574. * Heightmap-Imposter type
  97575. */
  97576. static HeightmapImpostor: number;
  97577. /**
  97578. * ConvexHull-Impostor type (Ammo.js plugin only)
  97579. */
  97580. static ConvexHullImpostor: number;
  97581. /**
  97582. * Custom-Imposter type (Ammo.js plugin only)
  97583. */
  97584. static CustomImpostor: number;
  97585. /**
  97586. * Rope-Imposter type
  97587. */
  97588. static RopeImpostor: number;
  97589. /**
  97590. * Cloth-Imposter type
  97591. */
  97592. static ClothImpostor: number;
  97593. /**
  97594. * Softbody-Imposter type
  97595. */
  97596. static SoftbodyImpostor: number;
  97597. }
  97598. }
  97599. declare module BABYLON {
  97600. /**
  97601. * @hidden
  97602. **/
  97603. export class _CreationDataStorage {
  97604. closePath?: boolean;
  97605. closeArray?: boolean;
  97606. idx: number[];
  97607. dashSize: number;
  97608. gapSize: number;
  97609. path3D: Path3D;
  97610. pathArray: Vector3[][];
  97611. arc: number;
  97612. radius: number;
  97613. cap: number;
  97614. tessellation: number;
  97615. }
  97616. /**
  97617. * @hidden
  97618. **/
  97619. class _InstanceDataStorage {
  97620. visibleInstances: any;
  97621. batchCache: _InstancesBatch;
  97622. instancesBufferSize: number;
  97623. instancesBuffer: Nullable<Buffer>;
  97624. instancesData: Float32Array;
  97625. overridenInstanceCount: number;
  97626. isFrozen: boolean;
  97627. previousBatch: Nullable<_InstancesBatch>;
  97628. hardwareInstancedRendering: boolean;
  97629. sideOrientation: number;
  97630. manualUpdate: boolean;
  97631. }
  97632. /**
  97633. * @hidden
  97634. **/
  97635. export class _InstancesBatch {
  97636. mustReturn: boolean;
  97637. visibleInstances: Nullable<InstancedMesh[]>[];
  97638. renderSelf: boolean[];
  97639. hardwareInstancedRendering: boolean[];
  97640. }
  97641. /**
  97642. * Class used to represent renderable models
  97643. */
  97644. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97645. /**
  97646. * Mesh side orientation : usually the external or front surface
  97647. */
  97648. static readonly FRONTSIDE: number;
  97649. /**
  97650. * Mesh side orientation : usually the internal or back surface
  97651. */
  97652. static readonly BACKSIDE: number;
  97653. /**
  97654. * Mesh side orientation : both internal and external or front and back surfaces
  97655. */
  97656. static readonly DOUBLESIDE: number;
  97657. /**
  97658. * Mesh side orientation : by default, `FRONTSIDE`
  97659. */
  97660. static readonly DEFAULTSIDE: number;
  97661. /**
  97662. * Mesh cap setting : no cap
  97663. */
  97664. static readonly NO_CAP: number;
  97665. /**
  97666. * Mesh cap setting : one cap at the beginning of the mesh
  97667. */
  97668. static readonly CAP_START: number;
  97669. /**
  97670. * Mesh cap setting : one cap at the end of the mesh
  97671. */
  97672. static readonly CAP_END: number;
  97673. /**
  97674. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97675. */
  97676. static readonly CAP_ALL: number;
  97677. /**
  97678. * Mesh pattern setting : no flip or rotate
  97679. */
  97680. static readonly NO_FLIP: number;
  97681. /**
  97682. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97683. */
  97684. static readonly FLIP_TILE: number;
  97685. /**
  97686. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97687. */
  97688. static readonly ROTATE_TILE: number;
  97689. /**
  97690. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97691. */
  97692. static readonly FLIP_ROW: number;
  97693. /**
  97694. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97695. */
  97696. static readonly ROTATE_ROW: number;
  97697. /**
  97698. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97699. */
  97700. static readonly FLIP_N_ROTATE_TILE: number;
  97701. /**
  97702. * Mesh pattern setting : rotate pattern and rotate
  97703. */
  97704. static readonly FLIP_N_ROTATE_ROW: number;
  97705. /**
  97706. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97707. */
  97708. static readonly CENTER: number;
  97709. /**
  97710. * Mesh tile positioning : part tiles on left
  97711. */
  97712. static readonly LEFT: number;
  97713. /**
  97714. * Mesh tile positioning : part tiles on right
  97715. */
  97716. static readonly RIGHT: number;
  97717. /**
  97718. * Mesh tile positioning : part tiles on top
  97719. */
  97720. static readonly TOP: number;
  97721. /**
  97722. * Mesh tile positioning : part tiles on bottom
  97723. */
  97724. static readonly BOTTOM: number;
  97725. /**
  97726. * Gets the default side orientation.
  97727. * @param orientation the orientation to value to attempt to get
  97728. * @returns the default orientation
  97729. * @hidden
  97730. */
  97731. static _GetDefaultSideOrientation(orientation?: number): number;
  97732. private _internalMeshDataInfo;
  97733. /**
  97734. * An event triggered before rendering the mesh
  97735. */
  97736. get onBeforeRenderObservable(): Observable<Mesh>;
  97737. /**
  97738. * An event triggered before binding the mesh
  97739. */
  97740. get onBeforeBindObservable(): Observable<Mesh>;
  97741. /**
  97742. * An event triggered after rendering the mesh
  97743. */
  97744. get onAfterRenderObservable(): Observable<Mesh>;
  97745. /**
  97746. * An event triggered before drawing the mesh
  97747. */
  97748. get onBeforeDrawObservable(): Observable<Mesh>;
  97749. private _onBeforeDrawObserver;
  97750. /**
  97751. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97752. */
  97753. set onBeforeDraw(callback: () => void);
  97754. get hasInstances(): boolean;
  97755. /**
  97756. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97757. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97758. */
  97759. delayLoadState: number;
  97760. /**
  97761. * Gets the list of instances created from this mesh
  97762. * it is not supposed to be modified manually.
  97763. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97764. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97765. */
  97766. instances: InstancedMesh[];
  97767. /**
  97768. * Gets the file containing delay loading data for this mesh
  97769. */
  97770. delayLoadingFile: string;
  97771. /** @hidden */
  97772. _binaryInfo: any;
  97773. /**
  97774. * User defined function used to change how LOD level selection is done
  97775. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97776. */
  97777. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97778. /**
  97779. * Gets or sets the morph target manager
  97780. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97781. */
  97782. get morphTargetManager(): Nullable<MorphTargetManager>;
  97783. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97784. /** @hidden */
  97785. _creationDataStorage: Nullable<_CreationDataStorage>;
  97786. /** @hidden */
  97787. _geometry: Nullable<Geometry>;
  97788. /** @hidden */
  97789. _delayInfo: Array<string>;
  97790. /** @hidden */
  97791. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97792. /** @hidden */
  97793. _instanceDataStorage: _InstanceDataStorage;
  97794. private _effectiveMaterial;
  97795. /** @hidden */
  97796. _shouldGenerateFlatShading: boolean;
  97797. /** @hidden */
  97798. _originalBuilderSideOrientation: number;
  97799. /**
  97800. * Use this property to change the original side orientation defined at construction time
  97801. */
  97802. overrideMaterialSideOrientation: Nullable<number>;
  97803. /**
  97804. * Gets the source mesh (the one used to clone this one from)
  97805. */
  97806. get source(): Nullable<Mesh>;
  97807. /**
  97808. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97809. */
  97810. get isUnIndexed(): boolean;
  97811. set isUnIndexed(value: boolean);
  97812. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97813. get worldMatrixInstancedBuffer(): Float32Array;
  97814. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97815. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97816. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97817. /**
  97818. * @constructor
  97819. * @param name The value used by scene.getMeshByName() to do a lookup.
  97820. * @param scene The scene to add this mesh to.
  97821. * @param parent The parent of this mesh, if it has one
  97822. * @param source An optional Mesh from which geometry is shared, cloned.
  97823. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97824. * When false, achieved by calling a clone(), also passing False.
  97825. * This will make creation of children, recursive.
  97826. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97827. */
  97828. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97829. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97830. doNotInstantiate: boolean;
  97831. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97832. /**
  97833. * Gets the class name
  97834. * @returns the string "Mesh".
  97835. */
  97836. getClassName(): string;
  97837. /** @hidden */
  97838. get _isMesh(): boolean;
  97839. /**
  97840. * Returns a description of this mesh
  97841. * @param fullDetails define if full details about this mesh must be used
  97842. * @returns a descriptive string representing this mesh
  97843. */
  97844. toString(fullDetails?: boolean): string;
  97845. /** @hidden */
  97846. _unBindEffect(): void;
  97847. /**
  97848. * Gets a boolean indicating if this mesh has LOD
  97849. */
  97850. get hasLODLevels(): boolean;
  97851. /**
  97852. * Gets the list of MeshLODLevel associated with the current mesh
  97853. * @returns an array of MeshLODLevel
  97854. */
  97855. getLODLevels(): MeshLODLevel[];
  97856. private _sortLODLevels;
  97857. /**
  97858. * Add a mesh as LOD level triggered at the given distance.
  97859. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97860. * @param distance The distance from the center of the object to show this level
  97861. * @param mesh The mesh to be added as LOD level (can be null)
  97862. * @return This mesh (for chaining)
  97863. */
  97864. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97865. /**
  97866. * Returns the LOD level mesh at the passed distance or null if not found.
  97867. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97868. * @param distance The distance from the center of the object to show this level
  97869. * @returns a Mesh or `null`
  97870. */
  97871. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97872. /**
  97873. * Remove a mesh from the LOD array
  97874. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97875. * @param mesh defines the mesh to be removed
  97876. * @return This mesh (for chaining)
  97877. */
  97878. removeLODLevel(mesh: Mesh): Mesh;
  97879. /**
  97880. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97881. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97882. * @param camera defines the camera to use to compute distance
  97883. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97884. * @return This mesh (for chaining)
  97885. */
  97886. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97887. /**
  97888. * Gets the mesh internal Geometry object
  97889. */
  97890. get geometry(): Nullable<Geometry>;
  97891. /**
  97892. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97893. * @returns the total number of vertices
  97894. */
  97895. getTotalVertices(): number;
  97896. /**
  97897. * Returns the content of an associated vertex buffer
  97898. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97899. * - VertexBuffer.PositionKind
  97900. * - VertexBuffer.UVKind
  97901. * - VertexBuffer.UV2Kind
  97902. * - VertexBuffer.UV3Kind
  97903. * - VertexBuffer.UV4Kind
  97904. * - VertexBuffer.UV5Kind
  97905. * - VertexBuffer.UV6Kind
  97906. * - VertexBuffer.ColorKind
  97907. * - VertexBuffer.MatricesIndicesKind
  97908. * - VertexBuffer.MatricesIndicesExtraKind
  97909. * - VertexBuffer.MatricesWeightsKind
  97910. * - VertexBuffer.MatricesWeightsExtraKind
  97911. * @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
  97912. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97913. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97914. */
  97915. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97916. /**
  97917. * Returns the mesh VertexBuffer object from the requested `kind`
  97918. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97919. * - VertexBuffer.PositionKind
  97920. * - VertexBuffer.NormalKind
  97921. * - VertexBuffer.UVKind
  97922. * - VertexBuffer.UV2Kind
  97923. * - VertexBuffer.UV3Kind
  97924. * - VertexBuffer.UV4Kind
  97925. * - VertexBuffer.UV5Kind
  97926. * - VertexBuffer.UV6Kind
  97927. * - VertexBuffer.ColorKind
  97928. * - VertexBuffer.MatricesIndicesKind
  97929. * - VertexBuffer.MatricesIndicesExtraKind
  97930. * - VertexBuffer.MatricesWeightsKind
  97931. * - VertexBuffer.MatricesWeightsExtraKind
  97932. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97933. */
  97934. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97935. /**
  97936. * Tests if a specific vertex buffer is associated with this mesh
  97937. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97938. * - VertexBuffer.PositionKind
  97939. * - VertexBuffer.NormalKind
  97940. * - VertexBuffer.UVKind
  97941. * - VertexBuffer.UV2Kind
  97942. * - VertexBuffer.UV3Kind
  97943. * - VertexBuffer.UV4Kind
  97944. * - VertexBuffer.UV5Kind
  97945. * - VertexBuffer.UV6Kind
  97946. * - VertexBuffer.ColorKind
  97947. * - VertexBuffer.MatricesIndicesKind
  97948. * - VertexBuffer.MatricesIndicesExtraKind
  97949. * - VertexBuffer.MatricesWeightsKind
  97950. * - VertexBuffer.MatricesWeightsExtraKind
  97951. * @returns a boolean
  97952. */
  97953. isVerticesDataPresent(kind: string): boolean;
  97954. /**
  97955. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97956. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97957. * - VertexBuffer.PositionKind
  97958. * - VertexBuffer.UVKind
  97959. * - VertexBuffer.UV2Kind
  97960. * - VertexBuffer.UV3Kind
  97961. * - VertexBuffer.UV4Kind
  97962. * - VertexBuffer.UV5Kind
  97963. * - VertexBuffer.UV6Kind
  97964. * - VertexBuffer.ColorKind
  97965. * - VertexBuffer.MatricesIndicesKind
  97966. * - VertexBuffer.MatricesIndicesExtraKind
  97967. * - VertexBuffer.MatricesWeightsKind
  97968. * - VertexBuffer.MatricesWeightsExtraKind
  97969. * @returns a boolean
  97970. */
  97971. isVertexBufferUpdatable(kind: string): boolean;
  97972. /**
  97973. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97974. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97975. * - VertexBuffer.PositionKind
  97976. * - VertexBuffer.NormalKind
  97977. * - VertexBuffer.UVKind
  97978. * - VertexBuffer.UV2Kind
  97979. * - VertexBuffer.UV3Kind
  97980. * - VertexBuffer.UV4Kind
  97981. * - VertexBuffer.UV5Kind
  97982. * - VertexBuffer.UV6Kind
  97983. * - VertexBuffer.ColorKind
  97984. * - VertexBuffer.MatricesIndicesKind
  97985. * - VertexBuffer.MatricesIndicesExtraKind
  97986. * - VertexBuffer.MatricesWeightsKind
  97987. * - VertexBuffer.MatricesWeightsExtraKind
  97988. * @returns an array of strings
  97989. */
  97990. getVerticesDataKinds(): string[];
  97991. /**
  97992. * Returns a positive integer : the total number of indices in this mesh geometry.
  97993. * @returns the numner of indices or zero if the mesh has no geometry.
  97994. */
  97995. getTotalIndices(): number;
  97996. /**
  97997. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97998. * @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.
  97999. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98000. * @returns the indices array or an empty array if the mesh has no geometry
  98001. */
  98002. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98003. get isBlocked(): boolean;
  98004. /**
  98005. * Determine if the current mesh is ready to be rendered
  98006. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98007. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  98008. * @returns true if all associated assets are ready (material, textures, shaders)
  98009. */
  98010. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  98011. /**
  98012. * 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.
  98013. */
  98014. get areNormalsFrozen(): boolean;
  98015. /**
  98016. * 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.
  98017. * @returns the current mesh
  98018. */
  98019. freezeNormals(): Mesh;
  98020. /**
  98021. * 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
  98022. * @returns the current mesh
  98023. */
  98024. unfreezeNormals(): Mesh;
  98025. /**
  98026. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98027. */
  98028. set overridenInstanceCount(count: number);
  98029. /** @hidden */
  98030. _preActivate(): Mesh;
  98031. /** @hidden */
  98032. _preActivateForIntermediateRendering(renderId: number): Mesh;
  98033. /** @hidden */
  98034. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  98035. /**
  98036. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98037. * This means the mesh underlying bounding box and sphere are recomputed.
  98038. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98039. * @returns the current mesh
  98040. */
  98041. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  98042. /** @hidden */
  98043. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  98044. /**
  98045. * This function will subdivide the mesh into multiple submeshes
  98046. * @param count defines the expected number of submeshes
  98047. */
  98048. subdivide(count: number): void;
  98049. /**
  98050. * Copy a FloatArray into a specific associated vertex buffer
  98051. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98052. * - VertexBuffer.PositionKind
  98053. * - VertexBuffer.UVKind
  98054. * - VertexBuffer.UV2Kind
  98055. * - VertexBuffer.UV3Kind
  98056. * - VertexBuffer.UV4Kind
  98057. * - VertexBuffer.UV5Kind
  98058. * - VertexBuffer.UV6Kind
  98059. * - VertexBuffer.ColorKind
  98060. * - VertexBuffer.MatricesIndicesKind
  98061. * - VertexBuffer.MatricesIndicesExtraKind
  98062. * - VertexBuffer.MatricesWeightsKind
  98063. * - VertexBuffer.MatricesWeightsExtraKind
  98064. * @param data defines the data source
  98065. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98066. * @param stride defines the data stride size (can be null)
  98067. * @returns the current mesh
  98068. */
  98069. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98070. /**
  98071. * Delete a vertex buffer associated with this mesh
  98072. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  98073. * - VertexBuffer.PositionKind
  98074. * - VertexBuffer.UVKind
  98075. * - VertexBuffer.UV2Kind
  98076. * - VertexBuffer.UV3Kind
  98077. * - VertexBuffer.UV4Kind
  98078. * - VertexBuffer.UV5Kind
  98079. * - VertexBuffer.UV6Kind
  98080. * - VertexBuffer.ColorKind
  98081. * - VertexBuffer.MatricesIndicesKind
  98082. * - VertexBuffer.MatricesIndicesExtraKind
  98083. * - VertexBuffer.MatricesWeightsKind
  98084. * - VertexBuffer.MatricesWeightsExtraKind
  98085. */
  98086. removeVerticesData(kind: string): void;
  98087. /**
  98088. * Flags an associated vertex buffer as updatable
  98089. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  98090. * - VertexBuffer.PositionKind
  98091. * - VertexBuffer.UVKind
  98092. * - VertexBuffer.UV2Kind
  98093. * - VertexBuffer.UV3Kind
  98094. * - VertexBuffer.UV4Kind
  98095. * - VertexBuffer.UV5Kind
  98096. * - VertexBuffer.UV6Kind
  98097. * - VertexBuffer.ColorKind
  98098. * - VertexBuffer.MatricesIndicesKind
  98099. * - VertexBuffer.MatricesIndicesExtraKind
  98100. * - VertexBuffer.MatricesWeightsKind
  98101. * - VertexBuffer.MatricesWeightsExtraKind
  98102. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98103. */
  98104. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98105. /**
  98106. * Sets the mesh global Vertex Buffer
  98107. * @param buffer defines the buffer to use
  98108. * @returns the current mesh
  98109. */
  98110. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98111. /**
  98112. * Update a specific associated vertex buffer
  98113. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98114. * - VertexBuffer.PositionKind
  98115. * - VertexBuffer.UVKind
  98116. * - VertexBuffer.UV2Kind
  98117. * - VertexBuffer.UV3Kind
  98118. * - VertexBuffer.UV4Kind
  98119. * - VertexBuffer.UV5Kind
  98120. * - VertexBuffer.UV6Kind
  98121. * - VertexBuffer.ColorKind
  98122. * - VertexBuffer.MatricesIndicesKind
  98123. * - VertexBuffer.MatricesIndicesExtraKind
  98124. * - VertexBuffer.MatricesWeightsKind
  98125. * - VertexBuffer.MatricesWeightsExtraKind
  98126. * @param data defines the data source
  98127. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98128. * @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)
  98129. * @returns the current mesh
  98130. */
  98131. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98132. /**
  98133. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98134. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98135. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98136. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98137. * @returns the current mesh
  98138. */
  98139. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98140. /**
  98141. * Creates a un-shared specific occurence of the geometry for the mesh.
  98142. * @returns the current mesh
  98143. */
  98144. makeGeometryUnique(): Mesh;
  98145. /**
  98146. * Set the index buffer of this mesh
  98147. * @param indices defines the source data
  98148. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98149. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98150. * @returns the current mesh
  98151. */
  98152. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98153. /**
  98154. * Update the current index buffer
  98155. * @param indices defines the source data
  98156. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98157. * @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)
  98158. * @returns the current mesh
  98159. */
  98160. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98161. /**
  98162. * Invert the geometry to move from a right handed system to a left handed one.
  98163. * @returns the current mesh
  98164. */
  98165. toLeftHanded(): Mesh;
  98166. /** @hidden */
  98167. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98168. /** @hidden */
  98169. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98170. /**
  98171. * Registers for this mesh a javascript function called just before the rendering process
  98172. * @param func defines the function to call before rendering this mesh
  98173. * @returns the current mesh
  98174. */
  98175. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98176. /**
  98177. * Disposes a previously registered javascript function called before the rendering
  98178. * @param func defines the function to remove
  98179. * @returns the current mesh
  98180. */
  98181. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98182. /**
  98183. * Registers for this mesh a javascript function called just after the rendering is complete
  98184. * @param func defines the function to call after rendering this mesh
  98185. * @returns the current mesh
  98186. */
  98187. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98188. /**
  98189. * Disposes a previously registered javascript function called after the rendering.
  98190. * @param func defines the function to remove
  98191. * @returns the current mesh
  98192. */
  98193. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98194. /** @hidden */
  98195. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98196. /** @hidden */
  98197. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98198. /** @hidden */
  98199. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98200. /** @hidden */
  98201. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98202. /** @hidden */
  98203. _rebuild(): void;
  98204. /** @hidden */
  98205. _freeze(): void;
  98206. /** @hidden */
  98207. _unFreeze(): void;
  98208. /**
  98209. * 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
  98210. * @param subMesh defines the subMesh to render
  98211. * @param enableAlphaMode defines if alpha mode can be changed
  98212. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98213. * @returns the current mesh
  98214. */
  98215. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98216. private _onBeforeDraw;
  98217. /**
  98218. * Renormalize the mesh and patch it up if there are no weights
  98219. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98220. * However in the case of zero weights then we set just a single influence to 1.
  98221. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98222. */
  98223. cleanMatrixWeights(): void;
  98224. private normalizeSkinFourWeights;
  98225. private normalizeSkinWeightsAndExtra;
  98226. /**
  98227. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98228. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98229. * the user know there was an issue with importing the mesh
  98230. * @returns a validation object with skinned, valid and report string
  98231. */
  98232. validateSkinning(): {
  98233. skinned: boolean;
  98234. valid: boolean;
  98235. report: string;
  98236. };
  98237. /** @hidden */
  98238. _checkDelayState(): Mesh;
  98239. private _queueLoad;
  98240. /**
  98241. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98242. * A mesh is in the frustum if its bounding box intersects the frustum
  98243. * @param frustumPlanes defines the frustum to test
  98244. * @returns true if the mesh is in the frustum planes
  98245. */
  98246. isInFrustum(frustumPlanes: Plane[]): boolean;
  98247. /**
  98248. * Sets the mesh material by the material or multiMaterial `id` property
  98249. * @param id is a string identifying the material or the multiMaterial
  98250. * @returns the current mesh
  98251. */
  98252. setMaterialByID(id: string): Mesh;
  98253. /**
  98254. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98255. * @returns an array of IAnimatable
  98256. */
  98257. getAnimatables(): IAnimatable[];
  98258. /**
  98259. * Modifies the mesh geometry according to the passed transformation matrix.
  98260. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98261. * The mesh normals are modified using the same transformation.
  98262. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98263. * @param transform defines the transform matrix to use
  98264. * @see http://doc.babylonjs.com/resources/baking_transformations
  98265. * @returns the current mesh
  98266. */
  98267. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98268. /**
  98269. * Modifies the mesh geometry according to its own current World Matrix.
  98270. * The mesh World Matrix is then reset.
  98271. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98272. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98273. * @see http://doc.babylonjs.com/resources/baking_transformations
  98274. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98275. * @returns the current mesh
  98276. */
  98277. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98278. /** @hidden */
  98279. get _positions(): Nullable<Vector3[]>;
  98280. /** @hidden */
  98281. _resetPointsArrayCache(): Mesh;
  98282. /** @hidden */
  98283. _generatePointsArray(): boolean;
  98284. /**
  98285. * Returns a new Mesh object generated from the current mesh properties.
  98286. * This method must not get confused with createInstance()
  98287. * @param name is a string, the name given to the new mesh
  98288. * @param newParent can be any Node object (default `null`)
  98289. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98290. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98291. * @returns a new mesh
  98292. */
  98293. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98294. /**
  98295. * Releases resources associated with this mesh.
  98296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98298. */
  98299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98300. /** @hidden */
  98301. _disposeInstanceSpecificData(): void;
  98302. /**
  98303. * Modifies the mesh geometry according to a displacement map.
  98304. * 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.
  98305. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98306. * @param url is a string, the URL from the image file is to be downloaded.
  98307. * @param minHeight is the lower limit of the displacement.
  98308. * @param maxHeight is the upper limit of the displacement.
  98309. * @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.
  98310. * @param uvOffset is an optional vector2 used to offset UV.
  98311. * @param uvScale is an optional vector2 used to scale UV.
  98312. * @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.
  98313. * @returns the Mesh.
  98314. */
  98315. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98316. /**
  98317. * Modifies the mesh geometry according to a displacementMap buffer.
  98318. * 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.
  98319. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98320. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98321. * @param heightMapWidth is the width of the buffer image.
  98322. * @param heightMapHeight is the height of the buffer image.
  98323. * @param minHeight is the lower limit of the displacement.
  98324. * @param maxHeight is the upper limit of the displacement.
  98325. * @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.
  98326. * @param uvOffset is an optional vector2 used to offset UV.
  98327. * @param uvScale is an optional vector2 used to scale UV.
  98328. * @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.
  98329. * @returns the Mesh.
  98330. */
  98331. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98332. /**
  98333. * Modify the mesh to get a flat shading rendering.
  98334. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98335. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98336. * @returns current mesh
  98337. */
  98338. convertToFlatShadedMesh(): Mesh;
  98339. /**
  98340. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98341. * In other words, more vertices, no more indices and a single bigger VBO.
  98342. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98343. * @returns current mesh
  98344. */
  98345. convertToUnIndexedMesh(): Mesh;
  98346. /**
  98347. * Inverses facet orientations.
  98348. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98349. * @param flipNormals will also inverts the normals
  98350. * @returns current mesh
  98351. */
  98352. flipFaces(flipNormals?: boolean): Mesh;
  98353. /**
  98354. * Increase the number of facets and hence vertices in a mesh
  98355. * Vertex normals are interpolated from existing vertex normals
  98356. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98357. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98358. */
  98359. increaseVertices(numberPerEdge: number): void;
  98360. /**
  98361. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98362. * This will undo any application of covertToFlatShadedMesh
  98363. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98364. */
  98365. forceSharedVertices(): void;
  98366. /** @hidden */
  98367. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98368. /** @hidden */
  98369. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98370. /**
  98371. * Creates a new InstancedMesh object from the mesh model.
  98372. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98373. * @param name defines the name of the new instance
  98374. * @returns a new InstancedMesh
  98375. */
  98376. createInstance(name: string): InstancedMesh;
  98377. /**
  98378. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98379. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98380. * @returns the current mesh
  98381. */
  98382. synchronizeInstances(): Mesh;
  98383. /**
  98384. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98385. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98386. * This should be used together with the simplification to avoid disappearing triangles.
  98387. * @param successCallback an optional success callback to be called after the optimization finished.
  98388. * @returns the current mesh
  98389. */
  98390. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98391. /**
  98392. * Serialize current mesh
  98393. * @param serializationObject defines the object which will receive the serialization data
  98394. */
  98395. serialize(serializationObject: any): void;
  98396. /** @hidden */
  98397. _syncGeometryWithMorphTargetManager(): void;
  98398. /** @hidden */
  98399. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98400. /**
  98401. * Returns a new Mesh object parsed from the source provided.
  98402. * @param parsedMesh is the source
  98403. * @param scene defines the hosting scene
  98404. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98405. * @returns a new Mesh
  98406. */
  98407. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98408. /**
  98409. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98410. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98411. * @param name defines the name of the mesh to create
  98412. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98413. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98414. * @param closePath creates a seam between the first and the last points of each path of the path array
  98415. * @param offset is taken in account only if the `pathArray` is containing a single path
  98416. * @param scene defines the hosting scene
  98417. * @param updatable defines if the mesh must be flagged as updatable
  98418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98419. * @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)
  98420. * @returns a new Mesh
  98421. */
  98422. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98423. /**
  98424. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98425. * @param name defines the name of the mesh to create
  98426. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98427. * @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
  98428. * @param scene defines the hosting scene
  98429. * @param updatable defines if the mesh must be flagged as updatable
  98430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98431. * @returns a new Mesh
  98432. */
  98433. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98434. /**
  98435. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98436. * @param name defines the name of the mesh to create
  98437. * @param size sets the size (float) of each box side (default 1)
  98438. * @param scene defines the hosting scene
  98439. * @param updatable defines if the mesh must be flagged as updatable
  98440. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98441. * @returns a new Mesh
  98442. */
  98443. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98444. /**
  98445. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98446. * @param name defines the name of the mesh to create
  98447. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98448. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98449. * @param scene defines the hosting scene
  98450. * @param updatable defines if the mesh must be flagged as updatable
  98451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98452. * @returns a new Mesh
  98453. */
  98454. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98455. /**
  98456. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98457. * @param name defines the name of the mesh to create
  98458. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98459. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98460. * @param scene defines the hosting scene
  98461. * @returns a new Mesh
  98462. */
  98463. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98464. /**
  98465. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98466. * @param name defines the name of the mesh to create
  98467. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98468. * @param diameterTop set the top cap diameter (floats, default 1)
  98469. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98470. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98471. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98472. * @param scene defines the hosting scene
  98473. * @param updatable defines if the mesh must be flagged as updatable
  98474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98475. * @returns a new Mesh
  98476. */
  98477. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98478. /**
  98479. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98480. * @param name defines the name of the mesh to create
  98481. * @param diameter sets the diameter size (float) of the torus (default 1)
  98482. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98483. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98484. * @param scene defines the hosting scene
  98485. * @param updatable defines if the mesh must be flagged as updatable
  98486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98487. * @returns a new Mesh
  98488. */
  98489. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98490. /**
  98491. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98492. * @param name defines the name of the mesh to create
  98493. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98494. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98495. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98496. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98497. * @param p the number of windings on X axis (positive integers, default 2)
  98498. * @param q the number of windings on Y axis (positive integers, default 3)
  98499. * @param scene defines the hosting scene
  98500. * @param updatable defines if the mesh must be flagged as updatable
  98501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98502. * @returns a new Mesh
  98503. */
  98504. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98505. /**
  98506. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98507. * @param name defines the name of the mesh to create
  98508. * @param points is an array successive Vector3
  98509. * @param scene defines the hosting scene
  98510. * @param updatable defines if the mesh must be flagged as updatable
  98511. * @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).
  98512. * @returns a new Mesh
  98513. */
  98514. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98515. /**
  98516. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98517. * @param name defines the name of the mesh to create
  98518. * @param points is an array successive Vector3
  98519. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98520. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98521. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98522. * @param scene defines the hosting scene
  98523. * @param updatable defines if the mesh must be flagged as updatable
  98524. * @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)
  98525. * @returns a new Mesh
  98526. */
  98527. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98528. /**
  98529. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98530. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98531. * 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.
  98532. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98533. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98534. * Remember you can only change the shape positions, not their number when updating a polygon.
  98535. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98536. * @param name defines the name of the mesh to create
  98537. * @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
  98538. * @param scene defines the hosting scene
  98539. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98540. * @param updatable defines if the mesh must be flagged as updatable
  98541. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98542. * @param earcutInjection can be used to inject your own earcut reference
  98543. * @returns a new Mesh
  98544. */
  98545. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98546. /**
  98547. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98548. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98549. * @param name defines the name of the mesh to create
  98550. * @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
  98551. * @param depth defines the height of extrusion
  98552. * @param scene defines the hosting scene
  98553. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98554. * @param updatable defines if the mesh must be flagged as updatable
  98555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98556. * @param earcutInjection can be used to inject your own earcut reference
  98557. * @returns a new Mesh
  98558. */
  98559. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98560. /**
  98561. * Creates an extruded shape mesh.
  98562. * 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
  98563. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98564. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98565. * @param name defines the name of the mesh to create
  98566. * @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
  98567. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98568. * @param scale is the value to scale the shape
  98569. * @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
  98570. * @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
  98571. * @param scene defines the hosting scene
  98572. * @param updatable defines if the mesh must be flagged as updatable
  98573. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98574. * @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)
  98575. * @returns a new Mesh
  98576. */
  98577. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98578. /**
  98579. * Creates an custom extruded shape mesh.
  98580. * The custom extrusion is a parametric shape.
  98581. * It has no predefined shape. Its final shape will depend on the input parameters.
  98582. * Please consider using the same method from the MeshBuilder class instead
  98583. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98584. * @param name defines the name of the mesh to create
  98585. * @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
  98586. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98587. * @param scaleFunction is a custom Javascript function called on each path point
  98588. * @param rotationFunction is a custom Javascript function called on each path point
  98589. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98590. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98591. * @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
  98592. * @param scene defines the hosting scene
  98593. * @param updatable defines if the mesh must be flagged as updatable
  98594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98595. * @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)
  98596. * @returns a new Mesh
  98597. */
  98598. 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;
  98599. /**
  98600. * Creates lathe mesh.
  98601. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98602. * Please consider using the same method from the MeshBuilder class instead
  98603. * @param name defines the name of the mesh to create
  98604. * @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
  98605. * @param radius is the radius value of the lathe
  98606. * @param tessellation is the side number of the lathe.
  98607. * @param scene defines the hosting scene
  98608. * @param updatable defines if the mesh must be flagged as updatable
  98609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98610. * @returns a new Mesh
  98611. */
  98612. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98613. /**
  98614. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98615. * @param name defines the name of the mesh to create
  98616. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98617. * @param scene defines the hosting scene
  98618. * @param updatable defines if the mesh must be flagged as updatable
  98619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98620. * @returns a new Mesh
  98621. */
  98622. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98623. /**
  98624. * Creates a ground mesh.
  98625. * Please consider using the same method from the MeshBuilder class instead
  98626. * @param name defines the name of the mesh to create
  98627. * @param width set the width of the ground
  98628. * @param height set the height of the ground
  98629. * @param subdivisions sets the number of subdivisions per side
  98630. * @param scene defines the hosting scene
  98631. * @param updatable defines if the mesh must be flagged as updatable
  98632. * @returns a new Mesh
  98633. */
  98634. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98635. /**
  98636. * Creates a tiled ground mesh.
  98637. * Please consider using the same method from the MeshBuilder class instead
  98638. * @param name defines the name of the mesh to create
  98639. * @param xmin set the ground minimum X coordinate
  98640. * @param zmin set the ground minimum Y coordinate
  98641. * @param xmax set the ground maximum X coordinate
  98642. * @param zmax set the ground maximum Z coordinate
  98643. * @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
  98644. * @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
  98645. * @param scene defines the hosting scene
  98646. * @param updatable defines if the mesh must be flagged as updatable
  98647. * @returns a new Mesh
  98648. */
  98649. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98650. w: number;
  98651. h: number;
  98652. }, precision: {
  98653. w: number;
  98654. h: number;
  98655. }, scene: Scene, updatable?: boolean): Mesh;
  98656. /**
  98657. * Creates a ground mesh from a height map.
  98658. * Please consider using the same method from the MeshBuilder class instead
  98659. * @see http://doc.babylonjs.com/babylon101/height_map
  98660. * @param name defines the name of the mesh to create
  98661. * @param url sets the URL of the height map image resource
  98662. * @param width set the ground width size
  98663. * @param height set the ground height size
  98664. * @param subdivisions sets the number of subdivision per side
  98665. * @param minHeight is the minimum altitude on the ground
  98666. * @param maxHeight is the maximum altitude on the ground
  98667. * @param scene defines the hosting scene
  98668. * @param updatable defines if the mesh must be flagged as updatable
  98669. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98670. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98671. * @returns a new Mesh
  98672. */
  98673. 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;
  98674. /**
  98675. * Creates a tube mesh.
  98676. * The tube is a parametric shape.
  98677. * It has no predefined shape. Its final shape will depend on the input parameters.
  98678. * Please consider using the same method from the MeshBuilder class instead
  98679. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98680. * @param name defines the name of the mesh to create
  98681. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98682. * @param radius sets the tube radius size
  98683. * @param tessellation is the number of sides on the tubular surface
  98684. * @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
  98685. * @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
  98686. * @param scene defines the hosting scene
  98687. * @param updatable defines if the mesh must be flagged as updatable
  98688. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98689. * @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)
  98690. * @returns a new Mesh
  98691. */
  98692. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98693. (i: number, distance: number): number;
  98694. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98695. /**
  98696. * Creates a polyhedron mesh.
  98697. * Please consider using the same method from the MeshBuilder class instead.
  98698. * * 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
  98699. * * The parameter `size` (positive float, default 1) sets the polygon size
  98700. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98701. * * 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`
  98702. * * 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
  98703. * * 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)`)
  98704. * * 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
  98705. * * 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
  98706. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98707. * * If you create a double-sided mesh, you can choose what parts of 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
  98708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98709. * @param name defines the name of the mesh to create
  98710. * @param options defines the options used to create the mesh
  98711. * @param scene defines the hosting scene
  98712. * @returns a new Mesh
  98713. */
  98714. static CreatePolyhedron(name: string, options: {
  98715. type?: number;
  98716. size?: number;
  98717. sizeX?: number;
  98718. sizeY?: number;
  98719. sizeZ?: number;
  98720. custom?: any;
  98721. faceUV?: Vector4[];
  98722. faceColors?: Color4[];
  98723. updatable?: boolean;
  98724. sideOrientation?: number;
  98725. }, scene: Scene): Mesh;
  98726. /**
  98727. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98728. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98729. * * 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`)
  98730. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98731. * * 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
  98732. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98733. * * If you create a double-sided mesh, you can choose what parts of 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
  98734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98735. * @param name defines the name of the mesh
  98736. * @param options defines the options used to create the mesh
  98737. * @param scene defines the hosting scene
  98738. * @returns a new Mesh
  98739. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98740. */
  98741. static CreateIcoSphere(name: string, options: {
  98742. radius?: number;
  98743. flat?: boolean;
  98744. subdivisions?: number;
  98745. sideOrientation?: number;
  98746. updatable?: boolean;
  98747. }, scene: Scene): Mesh;
  98748. /**
  98749. * Creates a decal mesh.
  98750. * Please consider using the same method from the MeshBuilder class instead.
  98751. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98752. * @param name defines the name of the mesh
  98753. * @param sourceMesh defines the mesh receiving the decal
  98754. * @param position sets the position of the decal in world coordinates
  98755. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98756. * @param size sets the decal scaling
  98757. * @param angle sets the angle to rotate the decal
  98758. * @returns a new Mesh
  98759. */
  98760. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98761. /**
  98762. * Prepare internal position array for software CPU skinning
  98763. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98764. */
  98765. setPositionsForCPUSkinning(): Float32Array;
  98766. /**
  98767. * Prepare internal normal array for software CPU skinning
  98768. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98769. */
  98770. setNormalsForCPUSkinning(): Float32Array;
  98771. /**
  98772. * Updates the vertex buffer by applying transformation from the bones
  98773. * @param skeleton defines the skeleton to apply to current mesh
  98774. * @returns the current mesh
  98775. */
  98776. applySkeleton(skeleton: Skeleton): Mesh;
  98777. /**
  98778. * 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
  98779. * @param meshes defines the list of meshes to scan
  98780. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98781. */
  98782. static MinMax(meshes: AbstractMesh[]): {
  98783. min: Vector3;
  98784. max: Vector3;
  98785. };
  98786. /**
  98787. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98788. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98789. * @returns a vector3
  98790. */
  98791. static Center(meshesOrMinMaxVector: {
  98792. min: Vector3;
  98793. max: Vector3;
  98794. } | AbstractMesh[]): Vector3;
  98795. /**
  98796. * Merge the array of meshes into a single mesh for performance reasons.
  98797. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98798. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98799. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98800. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98801. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98802. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98803. * @returns a new mesh
  98804. */
  98805. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98806. /** @hidden */
  98807. addInstance(instance: InstancedMesh): void;
  98808. /** @hidden */
  98809. removeInstance(instance: InstancedMesh): void;
  98810. }
  98811. }
  98812. declare module BABYLON {
  98813. /**
  98814. * This is the base class of all the camera used in the application.
  98815. * @see http://doc.babylonjs.com/features/cameras
  98816. */
  98817. export class Camera extends Node {
  98818. /** @hidden */
  98819. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98820. /**
  98821. * This is the default projection mode used by the cameras.
  98822. * It helps recreating a feeling of perspective and better appreciate depth.
  98823. * This is the best way to simulate real life cameras.
  98824. */
  98825. static readonly PERSPECTIVE_CAMERA: number;
  98826. /**
  98827. * This helps creating camera with an orthographic mode.
  98828. * 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.
  98829. */
  98830. static readonly ORTHOGRAPHIC_CAMERA: number;
  98831. /**
  98832. * This is the default FOV mode for perspective cameras.
  98833. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98834. */
  98835. static readonly FOVMODE_VERTICAL_FIXED: number;
  98836. /**
  98837. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98838. */
  98839. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98840. /**
  98841. * This specifies ther is no need for a camera rig.
  98842. * Basically only one eye is rendered corresponding to the camera.
  98843. */
  98844. static readonly RIG_MODE_NONE: number;
  98845. /**
  98846. * Simulates a camera Rig with one blue eye and one red eye.
  98847. * This can be use with 3d blue and red glasses.
  98848. */
  98849. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98850. /**
  98851. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98852. */
  98853. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98854. /**
  98855. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98856. */
  98857. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98858. /**
  98859. * Defines that both eyes of the camera will be rendered over under each other.
  98860. */
  98861. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98862. /**
  98863. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98864. */
  98865. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98866. /**
  98867. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98868. */
  98869. static readonly RIG_MODE_VR: number;
  98870. /**
  98871. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98872. */
  98873. static readonly RIG_MODE_WEBVR: number;
  98874. /**
  98875. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98876. */
  98877. static readonly RIG_MODE_CUSTOM: number;
  98878. /**
  98879. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98880. */
  98881. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98882. /**
  98883. * Define the input manager associated with the camera.
  98884. */
  98885. inputs: CameraInputsManager<Camera>;
  98886. /** @hidden */
  98887. _position: Vector3;
  98888. /**
  98889. * Define the current local position of the camera in the scene
  98890. */
  98891. get position(): Vector3;
  98892. set position(newPosition: Vector3);
  98893. /**
  98894. * The vector the camera should consider as up.
  98895. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98896. */
  98897. upVector: Vector3;
  98898. /**
  98899. * Define the current limit on the left side for an orthographic camera
  98900. * In scene unit
  98901. */
  98902. orthoLeft: Nullable<number>;
  98903. /**
  98904. * Define the current limit on the right side for an orthographic camera
  98905. * In scene unit
  98906. */
  98907. orthoRight: Nullable<number>;
  98908. /**
  98909. * Define the current limit on the bottom side for an orthographic camera
  98910. * In scene unit
  98911. */
  98912. orthoBottom: Nullable<number>;
  98913. /**
  98914. * Define the current limit on the top side for an orthographic camera
  98915. * In scene unit
  98916. */
  98917. orthoTop: Nullable<number>;
  98918. /**
  98919. * Field Of View is set in Radians. (default is 0.8)
  98920. */
  98921. fov: number;
  98922. /**
  98923. * Define the minimum distance the camera can see from.
  98924. * This is important to note that the depth buffer are not infinite and the closer it starts
  98925. * the more your scene might encounter depth fighting issue.
  98926. */
  98927. minZ: number;
  98928. /**
  98929. * Define the maximum distance the camera can see to.
  98930. * This is important to note that the depth buffer are not infinite and the further it end
  98931. * the more your scene might encounter depth fighting issue.
  98932. */
  98933. maxZ: number;
  98934. /**
  98935. * Define the default inertia of the camera.
  98936. * This helps giving a smooth feeling to the camera movement.
  98937. */
  98938. inertia: number;
  98939. /**
  98940. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98941. */
  98942. mode: number;
  98943. /**
  98944. * Define whether the camera is intermediate.
  98945. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98946. */
  98947. isIntermediate: boolean;
  98948. /**
  98949. * Define the viewport of the camera.
  98950. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98951. */
  98952. viewport: Viewport;
  98953. /**
  98954. * Restricts the camera to viewing objects with the same layerMask.
  98955. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98956. */
  98957. layerMask: number;
  98958. /**
  98959. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98960. */
  98961. fovMode: number;
  98962. /**
  98963. * Rig mode of the camera.
  98964. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98965. * This is normally controlled byt the camera themselves as internal use.
  98966. */
  98967. cameraRigMode: number;
  98968. /**
  98969. * Defines the distance between both "eyes" in case of a RIG
  98970. */
  98971. interaxialDistance: number;
  98972. /**
  98973. * Defines if stereoscopic rendering is done side by side or over under.
  98974. */
  98975. isStereoscopicSideBySide: boolean;
  98976. /**
  98977. * 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
  98978. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98979. * else in the scene. (Eg. security camera)
  98980. *
  98981. * 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)
  98982. */
  98983. customRenderTargets: RenderTargetTexture[];
  98984. /**
  98985. * When set, the camera will render to this render target instead of the default canvas
  98986. *
  98987. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98988. */
  98989. outputRenderTarget: Nullable<RenderTargetTexture>;
  98990. /**
  98991. * Observable triggered when the camera view matrix has changed.
  98992. */
  98993. onViewMatrixChangedObservable: Observable<Camera>;
  98994. /**
  98995. * Observable triggered when the camera Projection matrix has changed.
  98996. */
  98997. onProjectionMatrixChangedObservable: Observable<Camera>;
  98998. /**
  98999. * Observable triggered when the inputs have been processed.
  99000. */
  99001. onAfterCheckInputsObservable: Observable<Camera>;
  99002. /**
  99003. * Observable triggered when reset has been called and applied to the camera.
  99004. */
  99005. onRestoreStateObservable: Observable<Camera>;
  99006. /**
  99007. * Is this camera a part of a rig system?
  99008. */
  99009. isRigCamera: boolean;
  99010. /**
  99011. * If isRigCamera set to true this will be set with the parent camera.
  99012. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  99013. */
  99014. rigParent?: Camera;
  99015. /** @hidden */
  99016. _cameraRigParams: any;
  99017. /** @hidden */
  99018. _rigCameras: Camera[];
  99019. /** @hidden */
  99020. _rigPostProcess: Nullable<PostProcess>;
  99021. protected _webvrViewMatrix: Matrix;
  99022. /** @hidden */
  99023. _skipRendering: boolean;
  99024. /** @hidden */
  99025. _projectionMatrix: Matrix;
  99026. /** @hidden */
  99027. _postProcesses: Nullable<PostProcess>[];
  99028. /** @hidden */
  99029. _activeMeshes: SmartArray<AbstractMesh>;
  99030. protected _globalPosition: Vector3;
  99031. /** @hidden */
  99032. _computedViewMatrix: Matrix;
  99033. private _doNotComputeProjectionMatrix;
  99034. private _transformMatrix;
  99035. private _frustumPlanes;
  99036. private _refreshFrustumPlanes;
  99037. private _storedFov;
  99038. private _stateStored;
  99039. /**
  99040. * Instantiates a new camera object.
  99041. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  99042. * @see http://doc.babylonjs.com/features/cameras
  99043. * @param name Defines the name of the camera in the scene
  99044. * @param position Defines the position of the camera
  99045. * @param scene Defines the scene the camera belongs too
  99046. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  99047. */
  99048. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99049. /**
  99050. * Store current camera state (fov, position, etc..)
  99051. * @returns the camera
  99052. */
  99053. storeState(): Camera;
  99054. /**
  99055. * Restores the camera state values if it has been stored. You must call storeState() first
  99056. */
  99057. protected _restoreStateValues(): boolean;
  99058. /**
  99059. * Restored camera state. You must call storeState() first.
  99060. * @returns true if restored and false otherwise
  99061. */
  99062. restoreState(): boolean;
  99063. /**
  99064. * Gets the class name of the camera.
  99065. * @returns the class name
  99066. */
  99067. getClassName(): string;
  99068. /** @hidden */
  99069. readonly _isCamera: boolean;
  99070. /**
  99071. * Gets a string representation of the camera useful for debug purpose.
  99072. * @param fullDetails Defines that a more verboe level of logging is required
  99073. * @returns the string representation
  99074. */
  99075. toString(fullDetails?: boolean): string;
  99076. /**
  99077. * Gets the current world space position of the camera.
  99078. */
  99079. get globalPosition(): Vector3;
  99080. /**
  99081. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  99082. * @returns the active meshe list
  99083. */
  99084. getActiveMeshes(): SmartArray<AbstractMesh>;
  99085. /**
  99086. * Check whether a mesh is part of the current active mesh list of the camera
  99087. * @param mesh Defines the mesh to check
  99088. * @returns true if active, false otherwise
  99089. */
  99090. isActiveMesh(mesh: Mesh): boolean;
  99091. /**
  99092. * Is this camera ready to be used/rendered
  99093. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  99094. * @return true if the camera is ready
  99095. */
  99096. isReady(completeCheck?: boolean): boolean;
  99097. /** @hidden */
  99098. _initCache(): void;
  99099. /** @hidden */
  99100. _updateCache(ignoreParentClass?: boolean): void;
  99101. /** @hidden */
  99102. _isSynchronized(): boolean;
  99103. /** @hidden */
  99104. _isSynchronizedViewMatrix(): boolean;
  99105. /** @hidden */
  99106. _isSynchronizedProjectionMatrix(): boolean;
  99107. /**
  99108. * Attach the input controls to a specific dom element to get the input from.
  99109. * @param element Defines the element the controls should be listened from
  99110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99111. */
  99112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99113. /**
  99114. * Detach the current controls from the specified dom element.
  99115. * @param element Defines the element to stop listening the inputs from
  99116. */
  99117. detachControl(element: HTMLElement): void;
  99118. /**
  99119. * Update the camera state according to the different inputs gathered during the frame.
  99120. */
  99121. update(): void;
  99122. /** @hidden */
  99123. _checkInputs(): void;
  99124. /** @hidden */
  99125. get rigCameras(): Camera[];
  99126. /**
  99127. * Gets the post process used by the rig cameras
  99128. */
  99129. get rigPostProcess(): Nullable<PostProcess>;
  99130. /**
  99131. * Internal, gets the first post proces.
  99132. * @returns the first post process to be run on this camera.
  99133. */
  99134. _getFirstPostProcess(): Nullable<PostProcess>;
  99135. private _cascadePostProcessesToRigCams;
  99136. /**
  99137. * Attach a post process to the camera.
  99138. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99139. * @param postProcess The post process to attach to the camera
  99140. * @param insertAt The position of the post process in case several of them are in use in the scene
  99141. * @returns the position the post process has been inserted at
  99142. */
  99143. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99144. /**
  99145. * Detach a post process to the camera.
  99146. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99147. * @param postProcess The post process to detach from the camera
  99148. */
  99149. detachPostProcess(postProcess: PostProcess): void;
  99150. /**
  99151. * Gets the current world matrix of the camera
  99152. */
  99153. getWorldMatrix(): Matrix;
  99154. /** @hidden */
  99155. _getViewMatrix(): Matrix;
  99156. /**
  99157. * Gets the current view matrix of the camera.
  99158. * @param force forces the camera to recompute the matrix without looking at the cached state
  99159. * @returns the view matrix
  99160. */
  99161. getViewMatrix(force?: boolean): Matrix;
  99162. /**
  99163. * Freeze the projection matrix.
  99164. * It will prevent the cache check of the camera projection compute and can speed up perf
  99165. * if no parameter of the camera are meant to change
  99166. * @param projection Defines manually a projection if necessary
  99167. */
  99168. freezeProjectionMatrix(projection?: Matrix): void;
  99169. /**
  99170. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99171. */
  99172. unfreezeProjectionMatrix(): void;
  99173. /**
  99174. * Gets the current projection matrix of the camera.
  99175. * @param force forces the camera to recompute the matrix without looking at the cached state
  99176. * @returns the projection matrix
  99177. */
  99178. getProjectionMatrix(force?: boolean): Matrix;
  99179. /**
  99180. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99181. * @returns a Matrix
  99182. */
  99183. getTransformationMatrix(): Matrix;
  99184. private _updateFrustumPlanes;
  99185. /**
  99186. * Checks if a cullable object (mesh...) is in the camera frustum
  99187. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99188. * @param target The object to check
  99189. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99190. * @returns true if the object is in frustum otherwise false
  99191. */
  99192. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99193. /**
  99194. * Checks if a cullable object (mesh...) is in the camera frustum
  99195. * Unlike isInFrustum this cheks the full bounding box
  99196. * @param target The object to check
  99197. * @returns true if the object is in frustum otherwise false
  99198. */
  99199. isCompletelyInFrustum(target: ICullable): boolean;
  99200. /**
  99201. * Gets a ray in the forward direction from the camera.
  99202. * @param length Defines the length of the ray to create
  99203. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99204. * @param origin Defines the start point of the ray which defaults to the camera position
  99205. * @returns the forward ray
  99206. */
  99207. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99208. /**
  99209. * Releases resources associated with this node.
  99210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99212. */
  99213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99214. /** @hidden */
  99215. _isLeftCamera: boolean;
  99216. /**
  99217. * Gets the left camera of a rig setup in case of Rigged Camera
  99218. */
  99219. get isLeftCamera(): boolean;
  99220. /** @hidden */
  99221. _isRightCamera: boolean;
  99222. /**
  99223. * Gets the right camera of a rig setup in case of Rigged Camera
  99224. */
  99225. get isRightCamera(): boolean;
  99226. /**
  99227. * Gets the left camera of a rig setup in case of Rigged Camera
  99228. */
  99229. get leftCamera(): Nullable<FreeCamera>;
  99230. /**
  99231. * Gets the right camera of a rig setup in case of Rigged Camera
  99232. */
  99233. get rightCamera(): Nullable<FreeCamera>;
  99234. /**
  99235. * Gets the left camera target of a rig setup in case of Rigged Camera
  99236. * @returns the target position
  99237. */
  99238. getLeftTarget(): Nullable<Vector3>;
  99239. /**
  99240. * Gets the right camera target of a rig setup in case of Rigged Camera
  99241. * @returns the target position
  99242. */
  99243. getRightTarget(): Nullable<Vector3>;
  99244. /**
  99245. * @hidden
  99246. */
  99247. setCameraRigMode(mode: number, rigParams: any): void;
  99248. /** @hidden */
  99249. static _setStereoscopicRigMode(camera: Camera): void;
  99250. /** @hidden */
  99251. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99252. /** @hidden */
  99253. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99254. /** @hidden */
  99255. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99256. /** @hidden */
  99257. _getVRProjectionMatrix(): Matrix;
  99258. protected _updateCameraRotationMatrix(): void;
  99259. protected _updateWebVRCameraRotationMatrix(): void;
  99260. /**
  99261. * This function MUST be overwritten by the different WebVR cameras available.
  99262. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99263. * @hidden
  99264. */
  99265. _getWebVRProjectionMatrix(): Matrix;
  99266. /**
  99267. * This function MUST be overwritten by the different WebVR cameras available.
  99268. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99269. * @hidden
  99270. */
  99271. _getWebVRViewMatrix(): Matrix;
  99272. /** @hidden */
  99273. setCameraRigParameter(name: string, value: any): void;
  99274. /**
  99275. * needs to be overridden by children so sub has required properties to be copied
  99276. * @hidden
  99277. */
  99278. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99279. /**
  99280. * May need to be overridden by children
  99281. * @hidden
  99282. */
  99283. _updateRigCameras(): void;
  99284. /** @hidden */
  99285. _setupInputs(): void;
  99286. /**
  99287. * Serialiaze the camera setup to a json represention
  99288. * @returns the JSON representation
  99289. */
  99290. serialize(): any;
  99291. /**
  99292. * Clones the current camera.
  99293. * @param name The cloned camera name
  99294. * @returns the cloned camera
  99295. */
  99296. clone(name: string): Camera;
  99297. /**
  99298. * Gets the direction of the camera relative to a given local axis.
  99299. * @param localAxis Defines the reference axis to provide a relative direction.
  99300. * @return the direction
  99301. */
  99302. getDirection(localAxis: Vector3): Vector3;
  99303. /**
  99304. * Returns the current camera absolute rotation
  99305. */
  99306. get absoluteRotation(): Quaternion;
  99307. /**
  99308. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99309. * @param localAxis Defines the reference axis to provide a relative direction.
  99310. * @param result Defines the vector to store the result in
  99311. */
  99312. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99313. /**
  99314. * Gets a camera constructor for a given camera type
  99315. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99316. * @param name The name of the camera the result will be able to instantiate
  99317. * @param scene The scene the result will construct the camera in
  99318. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99319. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99320. * @returns a factory method to construc the camera
  99321. */
  99322. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99323. /**
  99324. * Compute the world matrix of the camera.
  99325. * @returns the camera world matrix
  99326. */
  99327. computeWorldMatrix(): Matrix;
  99328. /**
  99329. * Parse a JSON and creates the camera from the parsed information
  99330. * @param parsedCamera The JSON to parse
  99331. * @param scene The scene to instantiate the camera in
  99332. * @returns the newly constructed camera
  99333. */
  99334. static Parse(parsedCamera: any, scene: Scene): Camera;
  99335. }
  99336. }
  99337. declare module BABYLON {
  99338. /**
  99339. * Class containing static functions to help procedurally build meshes
  99340. */
  99341. export class DiscBuilder {
  99342. /**
  99343. * Creates a plane polygonal mesh. By default, this is a disc
  99344. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99345. * * 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
  99346. * * 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
  99347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99350. * @param name defines the name of the mesh
  99351. * @param options defines the options used to create the mesh
  99352. * @param scene defines the hosting scene
  99353. * @returns the plane polygonal mesh
  99354. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99355. */
  99356. static CreateDisc(name: string, options: {
  99357. radius?: number;
  99358. tessellation?: number;
  99359. arc?: number;
  99360. updatable?: boolean;
  99361. sideOrientation?: number;
  99362. frontUVs?: Vector4;
  99363. backUVs?: Vector4;
  99364. }, scene?: Nullable<Scene>): Mesh;
  99365. }
  99366. }
  99367. declare module BABYLON {
  99368. /**
  99369. * This represents all the required information to add a fresnel effect on a material:
  99370. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99371. */
  99372. export class FresnelParameters {
  99373. private _isEnabled;
  99374. /**
  99375. * Define if the fresnel effect is enable or not.
  99376. */
  99377. get isEnabled(): boolean;
  99378. set isEnabled(value: boolean);
  99379. /**
  99380. * Define the color used on edges (grazing angle)
  99381. */
  99382. leftColor: Color3;
  99383. /**
  99384. * Define the color used on center
  99385. */
  99386. rightColor: Color3;
  99387. /**
  99388. * Define bias applied to computed fresnel term
  99389. */
  99390. bias: number;
  99391. /**
  99392. * Defined the power exponent applied to fresnel term
  99393. */
  99394. power: number;
  99395. /**
  99396. * Clones the current fresnel and its valuues
  99397. * @returns a clone fresnel configuration
  99398. */
  99399. clone(): FresnelParameters;
  99400. /**
  99401. * Serializes the current fresnel parameters to a JSON representation.
  99402. * @return the JSON serialization
  99403. */
  99404. serialize(): any;
  99405. /**
  99406. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99407. * @param parsedFresnelParameters Define the JSON representation
  99408. * @returns the parsed parameters
  99409. */
  99410. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99411. }
  99412. }
  99413. declare module BABYLON {
  99414. /**
  99415. * Base class of materials working in push mode in babylon JS
  99416. * @hidden
  99417. */
  99418. export class PushMaterial extends Material {
  99419. protected _activeEffect: Effect;
  99420. protected _normalMatrix: Matrix;
  99421. /**
  99422. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99423. * This means that the material can keep using a previous shader while a new one is being compiled.
  99424. * This is mostly used when shader parallel compilation is supported (true by default)
  99425. */
  99426. allowShaderHotSwapping: boolean;
  99427. constructor(name: string, scene: Scene);
  99428. getEffect(): Effect;
  99429. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99430. /**
  99431. * Binds the given world matrix to the active effect
  99432. *
  99433. * @param world the matrix to bind
  99434. */
  99435. bindOnlyWorldMatrix(world: Matrix): void;
  99436. /**
  99437. * Binds the given normal matrix to the active effect
  99438. *
  99439. * @param normalMatrix the matrix to bind
  99440. */
  99441. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99442. bind(world: Matrix, mesh?: Mesh): void;
  99443. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99444. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99445. }
  99446. }
  99447. declare module BABYLON {
  99448. /**
  99449. * This groups all the flags used to control the materials channel.
  99450. */
  99451. export class MaterialFlags {
  99452. private static _DiffuseTextureEnabled;
  99453. /**
  99454. * Are diffuse textures enabled in the application.
  99455. */
  99456. static get DiffuseTextureEnabled(): boolean;
  99457. static set DiffuseTextureEnabled(value: boolean);
  99458. private static _AmbientTextureEnabled;
  99459. /**
  99460. * Are ambient textures enabled in the application.
  99461. */
  99462. static get AmbientTextureEnabled(): boolean;
  99463. static set AmbientTextureEnabled(value: boolean);
  99464. private static _OpacityTextureEnabled;
  99465. /**
  99466. * Are opacity textures enabled in the application.
  99467. */
  99468. static get OpacityTextureEnabled(): boolean;
  99469. static set OpacityTextureEnabled(value: boolean);
  99470. private static _ReflectionTextureEnabled;
  99471. /**
  99472. * Are reflection textures enabled in the application.
  99473. */
  99474. static get ReflectionTextureEnabled(): boolean;
  99475. static set ReflectionTextureEnabled(value: boolean);
  99476. private static _EmissiveTextureEnabled;
  99477. /**
  99478. * Are emissive textures enabled in the application.
  99479. */
  99480. static get EmissiveTextureEnabled(): boolean;
  99481. static set EmissiveTextureEnabled(value: boolean);
  99482. private static _SpecularTextureEnabled;
  99483. /**
  99484. * Are specular textures enabled in the application.
  99485. */
  99486. static get SpecularTextureEnabled(): boolean;
  99487. static set SpecularTextureEnabled(value: boolean);
  99488. private static _BumpTextureEnabled;
  99489. /**
  99490. * Are bump textures enabled in the application.
  99491. */
  99492. static get BumpTextureEnabled(): boolean;
  99493. static set BumpTextureEnabled(value: boolean);
  99494. private static _LightmapTextureEnabled;
  99495. /**
  99496. * Are lightmap textures enabled in the application.
  99497. */
  99498. static get LightmapTextureEnabled(): boolean;
  99499. static set LightmapTextureEnabled(value: boolean);
  99500. private static _RefractionTextureEnabled;
  99501. /**
  99502. * Are refraction textures enabled in the application.
  99503. */
  99504. static get RefractionTextureEnabled(): boolean;
  99505. static set RefractionTextureEnabled(value: boolean);
  99506. private static _ColorGradingTextureEnabled;
  99507. /**
  99508. * Are color grading textures enabled in the application.
  99509. */
  99510. static get ColorGradingTextureEnabled(): boolean;
  99511. static set ColorGradingTextureEnabled(value: boolean);
  99512. private static _FresnelEnabled;
  99513. /**
  99514. * Are fresnels enabled in the application.
  99515. */
  99516. static get FresnelEnabled(): boolean;
  99517. static set FresnelEnabled(value: boolean);
  99518. private static _ClearCoatTextureEnabled;
  99519. /**
  99520. * Are clear coat textures enabled in the application.
  99521. */
  99522. static get ClearCoatTextureEnabled(): boolean;
  99523. static set ClearCoatTextureEnabled(value: boolean);
  99524. private static _ClearCoatBumpTextureEnabled;
  99525. /**
  99526. * Are clear coat bump textures enabled in the application.
  99527. */
  99528. static get ClearCoatBumpTextureEnabled(): boolean;
  99529. static set ClearCoatBumpTextureEnabled(value: boolean);
  99530. private static _ClearCoatTintTextureEnabled;
  99531. /**
  99532. * Are clear coat tint textures enabled in the application.
  99533. */
  99534. static get ClearCoatTintTextureEnabled(): boolean;
  99535. static set ClearCoatTintTextureEnabled(value: boolean);
  99536. private static _SheenTextureEnabled;
  99537. /**
  99538. * Are sheen textures enabled in the application.
  99539. */
  99540. static get SheenTextureEnabled(): boolean;
  99541. static set SheenTextureEnabled(value: boolean);
  99542. private static _AnisotropicTextureEnabled;
  99543. /**
  99544. * Are anisotropic textures enabled in the application.
  99545. */
  99546. static get AnisotropicTextureEnabled(): boolean;
  99547. static set AnisotropicTextureEnabled(value: boolean);
  99548. private static _ThicknessTextureEnabled;
  99549. /**
  99550. * Are thickness textures enabled in the application.
  99551. */
  99552. static get ThicknessTextureEnabled(): boolean;
  99553. static set ThicknessTextureEnabled(value: boolean);
  99554. }
  99555. }
  99556. declare module BABYLON {
  99557. /** @hidden */
  99558. export var defaultFragmentDeclaration: {
  99559. name: string;
  99560. shader: string;
  99561. };
  99562. }
  99563. declare module BABYLON {
  99564. /** @hidden */
  99565. export var defaultUboDeclaration: {
  99566. name: string;
  99567. shader: string;
  99568. };
  99569. }
  99570. declare module BABYLON {
  99571. /** @hidden */
  99572. export var lightFragmentDeclaration: {
  99573. name: string;
  99574. shader: string;
  99575. };
  99576. }
  99577. declare module BABYLON {
  99578. /** @hidden */
  99579. export var lightUboDeclaration: {
  99580. name: string;
  99581. shader: string;
  99582. };
  99583. }
  99584. declare module BABYLON {
  99585. /** @hidden */
  99586. export var lightsFragmentFunctions: {
  99587. name: string;
  99588. shader: string;
  99589. };
  99590. }
  99591. declare module BABYLON {
  99592. /** @hidden */
  99593. export var shadowsFragmentFunctions: {
  99594. name: string;
  99595. shader: string;
  99596. };
  99597. }
  99598. declare module BABYLON {
  99599. /** @hidden */
  99600. export var fresnelFunction: {
  99601. name: string;
  99602. shader: string;
  99603. };
  99604. }
  99605. declare module BABYLON {
  99606. /** @hidden */
  99607. export var reflectionFunction: {
  99608. name: string;
  99609. shader: string;
  99610. };
  99611. }
  99612. declare module BABYLON {
  99613. /** @hidden */
  99614. export var bumpFragmentFunctions: {
  99615. name: string;
  99616. shader: string;
  99617. };
  99618. }
  99619. declare module BABYLON {
  99620. /** @hidden */
  99621. export var logDepthDeclaration: {
  99622. name: string;
  99623. shader: string;
  99624. };
  99625. }
  99626. declare module BABYLON {
  99627. /** @hidden */
  99628. export var bumpFragment: {
  99629. name: string;
  99630. shader: string;
  99631. };
  99632. }
  99633. declare module BABYLON {
  99634. /** @hidden */
  99635. export var depthPrePass: {
  99636. name: string;
  99637. shader: string;
  99638. };
  99639. }
  99640. declare module BABYLON {
  99641. /** @hidden */
  99642. export var lightFragment: {
  99643. name: string;
  99644. shader: string;
  99645. };
  99646. }
  99647. declare module BABYLON {
  99648. /** @hidden */
  99649. export var logDepthFragment: {
  99650. name: string;
  99651. shader: string;
  99652. };
  99653. }
  99654. declare module BABYLON {
  99655. /** @hidden */
  99656. export var defaultPixelShader: {
  99657. name: string;
  99658. shader: string;
  99659. };
  99660. }
  99661. declare module BABYLON {
  99662. /** @hidden */
  99663. export var defaultVertexDeclaration: {
  99664. name: string;
  99665. shader: string;
  99666. };
  99667. }
  99668. declare module BABYLON {
  99669. /** @hidden */
  99670. export var bumpVertexDeclaration: {
  99671. name: string;
  99672. shader: string;
  99673. };
  99674. }
  99675. declare module BABYLON {
  99676. /** @hidden */
  99677. export var bumpVertex: {
  99678. name: string;
  99679. shader: string;
  99680. };
  99681. }
  99682. declare module BABYLON {
  99683. /** @hidden */
  99684. export var fogVertex: {
  99685. name: string;
  99686. shader: string;
  99687. };
  99688. }
  99689. declare module BABYLON {
  99690. /** @hidden */
  99691. export var shadowsVertex: {
  99692. name: string;
  99693. shader: string;
  99694. };
  99695. }
  99696. declare module BABYLON {
  99697. /** @hidden */
  99698. export var pointCloudVertex: {
  99699. name: string;
  99700. shader: string;
  99701. };
  99702. }
  99703. declare module BABYLON {
  99704. /** @hidden */
  99705. export var logDepthVertex: {
  99706. name: string;
  99707. shader: string;
  99708. };
  99709. }
  99710. declare module BABYLON {
  99711. /** @hidden */
  99712. export var defaultVertexShader: {
  99713. name: string;
  99714. shader: string;
  99715. };
  99716. }
  99717. declare module BABYLON {
  99718. /** @hidden */
  99719. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99720. MAINUV1: boolean;
  99721. MAINUV2: boolean;
  99722. DIFFUSE: boolean;
  99723. DIFFUSEDIRECTUV: number;
  99724. AMBIENT: boolean;
  99725. AMBIENTDIRECTUV: number;
  99726. OPACITY: boolean;
  99727. OPACITYDIRECTUV: number;
  99728. OPACITYRGB: boolean;
  99729. REFLECTION: boolean;
  99730. EMISSIVE: boolean;
  99731. EMISSIVEDIRECTUV: number;
  99732. SPECULAR: boolean;
  99733. SPECULARDIRECTUV: number;
  99734. BUMP: boolean;
  99735. BUMPDIRECTUV: number;
  99736. PARALLAX: boolean;
  99737. PARALLAXOCCLUSION: boolean;
  99738. SPECULAROVERALPHA: boolean;
  99739. CLIPPLANE: boolean;
  99740. CLIPPLANE2: boolean;
  99741. CLIPPLANE3: boolean;
  99742. CLIPPLANE4: boolean;
  99743. CLIPPLANE5: boolean;
  99744. CLIPPLANE6: boolean;
  99745. ALPHATEST: boolean;
  99746. DEPTHPREPASS: boolean;
  99747. ALPHAFROMDIFFUSE: boolean;
  99748. POINTSIZE: boolean;
  99749. FOG: boolean;
  99750. SPECULARTERM: boolean;
  99751. DIFFUSEFRESNEL: boolean;
  99752. OPACITYFRESNEL: boolean;
  99753. REFLECTIONFRESNEL: boolean;
  99754. REFRACTIONFRESNEL: boolean;
  99755. EMISSIVEFRESNEL: boolean;
  99756. FRESNEL: boolean;
  99757. NORMAL: boolean;
  99758. UV1: boolean;
  99759. UV2: boolean;
  99760. VERTEXCOLOR: boolean;
  99761. VERTEXALPHA: boolean;
  99762. NUM_BONE_INFLUENCERS: number;
  99763. BonesPerMesh: number;
  99764. BONETEXTURE: boolean;
  99765. INSTANCES: boolean;
  99766. GLOSSINESS: boolean;
  99767. ROUGHNESS: boolean;
  99768. EMISSIVEASILLUMINATION: boolean;
  99769. LINKEMISSIVEWITHDIFFUSE: boolean;
  99770. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99771. LIGHTMAP: boolean;
  99772. LIGHTMAPDIRECTUV: number;
  99773. OBJECTSPACE_NORMALMAP: boolean;
  99774. USELIGHTMAPASSHADOWMAP: boolean;
  99775. REFLECTIONMAP_3D: boolean;
  99776. REFLECTIONMAP_SPHERICAL: boolean;
  99777. REFLECTIONMAP_PLANAR: boolean;
  99778. REFLECTIONMAP_CUBIC: boolean;
  99779. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99780. REFLECTIONMAP_PROJECTION: boolean;
  99781. REFLECTIONMAP_SKYBOX: boolean;
  99782. REFLECTIONMAP_EXPLICIT: boolean;
  99783. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99784. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99785. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99786. INVERTCUBICMAP: boolean;
  99787. LOGARITHMICDEPTH: boolean;
  99788. REFRACTION: boolean;
  99789. REFRACTIONMAP_3D: boolean;
  99790. REFLECTIONOVERALPHA: boolean;
  99791. TWOSIDEDLIGHTING: boolean;
  99792. SHADOWFLOAT: boolean;
  99793. MORPHTARGETS: boolean;
  99794. MORPHTARGETS_NORMAL: boolean;
  99795. MORPHTARGETS_TANGENT: boolean;
  99796. MORPHTARGETS_UV: boolean;
  99797. NUM_MORPH_INFLUENCERS: number;
  99798. NONUNIFORMSCALING: boolean;
  99799. PREMULTIPLYALPHA: boolean;
  99800. IMAGEPROCESSING: boolean;
  99801. VIGNETTE: boolean;
  99802. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99803. VIGNETTEBLENDMODEOPAQUE: boolean;
  99804. TONEMAPPING: boolean;
  99805. TONEMAPPING_ACES: boolean;
  99806. CONTRAST: boolean;
  99807. COLORCURVES: boolean;
  99808. COLORGRADING: boolean;
  99809. COLORGRADING3D: boolean;
  99810. SAMPLER3DGREENDEPTH: boolean;
  99811. SAMPLER3DBGRMAP: boolean;
  99812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99813. MULTIVIEW: boolean;
  99814. /**
  99815. * If the reflection texture on this material is in linear color space
  99816. * @hidden
  99817. */
  99818. IS_REFLECTION_LINEAR: boolean;
  99819. /**
  99820. * If the refraction texture on this material is in linear color space
  99821. * @hidden
  99822. */
  99823. IS_REFRACTION_LINEAR: boolean;
  99824. EXPOSURE: boolean;
  99825. constructor();
  99826. setReflectionMode(modeToEnable: string): void;
  99827. }
  99828. /**
  99829. * This is the default material used in Babylon. It is the best trade off between quality
  99830. * and performances.
  99831. * @see http://doc.babylonjs.com/babylon101/materials
  99832. */
  99833. export class StandardMaterial extends PushMaterial {
  99834. private _diffuseTexture;
  99835. /**
  99836. * The basic texture of the material as viewed under a light.
  99837. */
  99838. diffuseTexture: Nullable<BaseTexture>;
  99839. private _ambientTexture;
  99840. /**
  99841. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99842. */
  99843. ambientTexture: Nullable<BaseTexture>;
  99844. private _opacityTexture;
  99845. /**
  99846. * Define the transparency of the material from a texture.
  99847. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99848. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99849. */
  99850. opacityTexture: Nullable<BaseTexture>;
  99851. private _reflectionTexture;
  99852. /**
  99853. * Define the texture used to display the reflection.
  99854. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99855. */
  99856. reflectionTexture: Nullable<BaseTexture>;
  99857. private _emissiveTexture;
  99858. /**
  99859. * Define texture of the material as if self lit.
  99860. * This will be mixed in the final result even in the absence of light.
  99861. */
  99862. emissiveTexture: Nullable<BaseTexture>;
  99863. private _specularTexture;
  99864. /**
  99865. * Define how the color and intensity of the highlight given by the light in the material.
  99866. */
  99867. specularTexture: Nullable<BaseTexture>;
  99868. private _bumpTexture;
  99869. /**
  99870. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99871. * 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.
  99872. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99873. */
  99874. bumpTexture: Nullable<BaseTexture>;
  99875. private _lightmapTexture;
  99876. /**
  99877. * Complex lighting can be computationally expensive to compute at runtime.
  99878. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99879. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99880. */
  99881. lightmapTexture: Nullable<BaseTexture>;
  99882. private _refractionTexture;
  99883. /**
  99884. * Define the texture used to display the refraction.
  99885. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99886. */
  99887. refractionTexture: Nullable<BaseTexture>;
  99888. /**
  99889. * The color of the material lit by the environmental background lighting.
  99890. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99891. */
  99892. ambientColor: Color3;
  99893. /**
  99894. * The basic color of the material as viewed under a light.
  99895. */
  99896. diffuseColor: Color3;
  99897. /**
  99898. * Define how the color and intensity of the highlight given by the light in the material.
  99899. */
  99900. specularColor: Color3;
  99901. /**
  99902. * Define the color of the material as if self lit.
  99903. * This will be mixed in the final result even in the absence of light.
  99904. */
  99905. emissiveColor: Color3;
  99906. /**
  99907. * Defines how sharp are the highlights in the material.
  99908. * The bigger the value the sharper giving a more glossy feeling to the result.
  99909. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99910. */
  99911. specularPower: number;
  99912. private _useAlphaFromDiffuseTexture;
  99913. /**
  99914. * Does the transparency come from the diffuse texture alpha channel.
  99915. */
  99916. useAlphaFromDiffuseTexture: boolean;
  99917. private _useEmissiveAsIllumination;
  99918. /**
  99919. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99920. */
  99921. useEmissiveAsIllumination: boolean;
  99922. private _linkEmissiveWithDiffuse;
  99923. /**
  99924. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99925. * the emissive level when the final color is close to one.
  99926. */
  99927. linkEmissiveWithDiffuse: boolean;
  99928. private _useSpecularOverAlpha;
  99929. /**
  99930. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99931. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99932. */
  99933. useSpecularOverAlpha: boolean;
  99934. private _useReflectionOverAlpha;
  99935. /**
  99936. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99937. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99938. */
  99939. useReflectionOverAlpha: boolean;
  99940. private _disableLighting;
  99941. /**
  99942. * Does lights from the scene impacts this material.
  99943. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99944. */
  99945. disableLighting: boolean;
  99946. private _useObjectSpaceNormalMap;
  99947. /**
  99948. * Allows using an object space normal map (instead of tangent space).
  99949. */
  99950. useObjectSpaceNormalMap: boolean;
  99951. private _useParallax;
  99952. /**
  99953. * Is parallax enabled or not.
  99954. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99955. */
  99956. useParallax: boolean;
  99957. private _useParallaxOcclusion;
  99958. /**
  99959. * Is parallax occlusion enabled or not.
  99960. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99961. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99962. */
  99963. useParallaxOcclusion: boolean;
  99964. /**
  99965. * 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.
  99966. */
  99967. parallaxScaleBias: number;
  99968. private _roughness;
  99969. /**
  99970. * Helps to define how blurry the reflections should appears in the material.
  99971. */
  99972. roughness: number;
  99973. /**
  99974. * In case of refraction, define the value of the index of refraction.
  99975. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99976. */
  99977. indexOfRefraction: number;
  99978. /**
  99979. * Invert the refraction texture alongside the y axis.
  99980. * It can be useful with procedural textures or probe for instance.
  99981. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99982. */
  99983. invertRefractionY: boolean;
  99984. /**
  99985. * Defines the alpha limits in alpha test mode.
  99986. */
  99987. alphaCutOff: number;
  99988. private _useLightmapAsShadowmap;
  99989. /**
  99990. * In case of light mapping, define whether the map contains light or shadow informations.
  99991. */
  99992. useLightmapAsShadowmap: boolean;
  99993. private _diffuseFresnelParameters;
  99994. /**
  99995. * Define the diffuse fresnel parameters of the material.
  99996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99997. */
  99998. diffuseFresnelParameters: FresnelParameters;
  99999. private _opacityFresnelParameters;
  100000. /**
  100001. * Define the opacity fresnel parameters of the material.
  100002. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100003. */
  100004. opacityFresnelParameters: FresnelParameters;
  100005. private _reflectionFresnelParameters;
  100006. /**
  100007. * Define the reflection fresnel parameters of the material.
  100008. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100009. */
  100010. reflectionFresnelParameters: FresnelParameters;
  100011. private _refractionFresnelParameters;
  100012. /**
  100013. * Define the refraction fresnel parameters of the material.
  100014. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100015. */
  100016. refractionFresnelParameters: FresnelParameters;
  100017. private _emissiveFresnelParameters;
  100018. /**
  100019. * Define the emissive fresnel parameters of the material.
  100020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100021. */
  100022. emissiveFresnelParameters: FresnelParameters;
  100023. private _useReflectionFresnelFromSpecular;
  100024. /**
  100025. * If true automatically deducts the fresnels values from the material specularity.
  100026. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100027. */
  100028. useReflectionFresnelFromSpecular: boolean;
  100029. private _useGlossinessFromSpecularMapAlpha;
  100030. /**
  100031. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100032. */
  100033. useGlossinessFromSpecularMapAlpha: boolean;
  100034. private _maxSimultaneousLights;
  100035. /**
  100036. * Defines the maximum number of lights that can be used in the material
  100037. */
  100038. maxSimultaneousLights: number;
  100039. private _invertNormalMapX;
  100040. /**
  100041. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100042. */
  100043. invertNormalMapX: boolean;
  100044. private _invertNormalMapY;
  100045. /**
  100046. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100047. */
  100048. invertNormalMapY: boolean;
  100049. private _twoSidedLighting;
  100050. /**
  100051. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100052. */
  100053. twoSidedLighting: boolean;
  100054. /**
  100055. * Default configuration related to image processing available in the standard Material.
  100056. */
  100057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100058. /**
  100059. * Gets the image processing configuration used either in this material.
  100060. */
  100061. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100062. /**
  100063. * Sets the Default image processing configuration used either in the this material.
  100064. *
  100065. * If sets to null, the scene one is in use.
  100066. */
  100067. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100068. /**
  100069. * Keep track of the image processing observer to allow dispose and replace.
  100070. */
  100071. private _imageProcessingObserver;
  100072. /**
  100073. * Attaches a new image processing configuration to the Standard Material.
  100074. * @param configuration
  100075. */
  100076. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100077. /**
  100078. * Gets wether the color curves effect is enabled.
  100079. */
  100080. get cameraColorCurvesEnabled(): boolean;
  100081. /**
  100082. * Sets wether the color curves effect is enabled.
  100083. */
  100084. set cameraColorCurvesEnabled(value: boolean);
  100085. /**
  100086. * Gets wether the color grading effect is enabled.
  100087. */
  100088. get cameraColorGradingEnabled(): boolean;
  100089. /**
  100090. * Gets wether the color grading effect is enabled.
  100091. */
  100092. set cameraColorGradingEnabled(value: boolean);
  100093. /**
  100094. * Gets wether tonemapping is enabled or not.
  100095. */
  100096. get cameraToneMappingEnabled(): boolean;
  100097. /**
  100098. * Sets wether tonemapping is enabled or not
  100099. */
  100100. set cameraToneMappingEnabled(value: boolean);
  100101. /**
  100102. * The camera exposure used on this material.
  100103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100104. * This corresponds to a photographic exposure.
  100105. */
  100106. get cameraExposure(): number;
  100107. /**
  100108. * The camera exposure used on this material.
  100109. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100110. * This corresponds to a photographic exposure.
  100111. */
  100112. set cameraExposure(value: number);
  100113. /**
  100114. * Gets The camera contrast used on this material.
  100115. */
  100116. get cameraContrast(): number;
  100117. /**
  100118. * Sets The camera contrast used on this material.
  100119. */
  100120. set cameraContrast(value: number);
  100121. /**
  100122. * Gets the Color Grading 2D Lookup Texture.
  100123. */
  100124. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100125. /**
  100126. * Sets the Color Grading 2D Lookup Texture.
  100127. */
  100128. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100129. /**
  100130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100132. * 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;
  100133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100134. */
  100135. get cameraColorCurves(): Nullable<ColorCurves>;
  100136. /**
  100137. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100138. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100139. * 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;
  100140. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100141. */
  100142. set cameraColorCurves(value: Nullable<ColorCurves>);
  100143. /**
  100144. * Custom callback helping to override the default shader used in the material.
  100145. */
  100146. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100147. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100148. protected _worldViewProjectionMatrix: Matrix;
  100149. protected _globalAmbientColor: Color3;
  100150. protected _useLogarithmicDepth: boolean;
  100151. protected _rebuildInParallel: boolean;
  100152. /**
  100153. * Instantiates a new standard material.
  100154. * This is the default material used in Babylon. It is the best trade off between quality
  100155. * and performances.
  100156. * @see http://doc.babylonjs.com/babylon101/materials
  100157. * @param name Define the name of the material in the scene
  100158. * @param scene Define the scene the material belong to
  100159. */
  100160. constructor(name: string, scene: Scene);
  100161. /**
  100162. * Gets a boolean indicating that current material needs to register RTT
  100163. */
  100164. get hasRenderTargetTextures(): boolean;
  100165. /**
  100166. * Gets the current class name of the material e.g. "StandardMaterial"
  100167. * Mainly use in serialization.
  100168. * @returns the class name
  100169. */
  100170. getClassName(): string;
  100171. /**
  100172. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100173. * You can try switching to logarithmic depth.
  100174. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100175. */
  100176. get useLogarithmicDepth(): boolean;
  100177. set useLogarithmicDepth(value: boolean);
  100178. /**
  100179. * Specifies if the material will require alpha blending
  100180. * @returns a boolean specifying if alpha blending is needed
  100181. */
  100182. needAlphaBlending(): boolean;
  100183. /**
  100184. * Specifies if this material should be rendered in alpha test mode
  100185. * @returns a boolean specifying if an alpha test is needed.
  100186. */
  100187. needAlphaTesting(): boolean;
  100188. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100189. /**
  100190. * Get the texture used for alpha test purpose.
  100191. * @returns the diffuse texture in case of the standard material.
  100192. */
  100193. getAlphaTestTexture(): Nullable<BaseTexture>;
  100194. /**
  100195. * Get if the submesh is ready to be used and all its information available.
  100196. * Child classes can use it to update shaders
  100197. * @param mesh defines the mesh to check
  100198. * @param subMesh defines which submesh to check
  100199. * @param useInstances specifies that instances should be used
  100200. * @returns a boolean indicating that the submesh is ready or not
  100201. */
  100202. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100203. /**
  100204. * Builds the material UBO layouts.
  100205. * Used internally during the effect preparation.
  100206. */
  100207. buildUniformLayout(): void;
  100208. /**
  100209. * Unbinds the material from the mesh
  100210. */
  100211. unbind(): void;
  100212. /**
  100213. * Binds the submesh to this material by preparing the effect and shader to draw
  100214. * @param world defines the world transformation matrix
  100215. * @param mesh defines the mesh containing the submesh
  100216. * @param subMesh defines the submesh to bind the material to
  100217. */
  100218. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100219. /**
  100220. * Get the list of animatables in the material.
  100221. * @returns the list of animatables object used in the material
  100222. */
  100223. getAnimatables(): IAnimatable[];
  100224. /**
  100225. * Gets the active textures from the material
  100226. * @returns an array of textures
  100227. */
  100228. getActiveTextures(): BaseTexture[];
  100229. /**
  100230. * Specifies if the material uses a texture
  100231. * @param texture defines the texture to check against the material
  100232. * @returns a boolean specifying if the material uses the texture
  100233. */
  100234. hasTexture(texture: BaseTexture): boolean;
  100235. /**
  100236. * Disposes the material
  100237. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100238. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100239. */
  100240. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100241. /**
  100242. * Makes a duplicate of the material, and gives it a new name
  100243. * @param name defines the new name for the duplicated material
  100244. * @returns the cloned material
  100245. */
  100246. clone(name: string): StandardMaterial;
  100247. /**
  100248. * Serializes this material in a JSON representation
  100249. * @returns the serialized material object
  100250. */
  100251. serialize(): any;
  100252. /**
  100253. * Creates a standard material from parsed material data
  100254. * @param source defines the JSON representation of the material
  100255. * @param scene defines the hosting scene
  100256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100257. * @returns a new standard material
  100258. */
  100259. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100260. /**
  100261. * Are diffuse textures enabled in the application.
  100262. */
  100263. static get DiffuseTextureEnabled(): boolean;
  100264. static set DiffuseTextureEnabled(value: boolean);
  100265. /**
  100266. * Are ambient textures enabled in the application.
  100267. */
  100268. static get AmbientTextureEnabled(): boolean;
  100269. static set AmbientTextureEnabled(value: boolean);
  100270. /**
  100271. * Are opacity textures enabled in the application.
  100272. */
  100273. static get OpacityTextureEnabled(): boolean;
  100274. static set OpacityTextureEnabled(value: boolean);
  100275. /**
  100276. * Are reflection textures enabled in the application.
  100277. */
  100278. static get ReflectionTextureEnabled(): boolean;
  100279. static set ReflectionTextureEnabled(value: boolean);
  100280. /**
  100281. * Are emissive textures enabled in the application.
  100282. */
  100283. static get EmissiveTextureEnabled(): boolean;
  100284. static set EmissiveTextureEnabled(value: boolean);
  100285. /**
  100286. * Are specular textures enabled in the application.
  100287. */
  100288. static get SpecularTextureEnabled(): boolean;
  100289. static set SpecularTextureEnabled(value: boolean);
  100290. /**
  100291. * Are bump textures enabled in the application.
  100292. */
  100293. static get BumpTextureEnabled(): boolean;
  100294. static set BumpTextureEnabled(value: boolean);
  100295. /**
  100296. * Are lightmap textures enabled in the application.
  100297. */
  100298. static get LightmapTextureEnabled(): boolean;
  100299. static set LightmapTextureEnabled(value: boolean);
  100300. /**
  100301. * Are refraction textures enabled in the application.
  100302. */
  100303. static get RefractionTextureEnabled(): boolean;
  100304. static set RefractionTextureEnabled(value: boolean);
  100305. /**
  100306. * Are color grading textures enabled in the application.
  100307. */
  100308. static get ColorGradingTextureEnabled(): boolean;
  100309. static set ColorGradingTextureEnabled(value: boolean);
  100310. /**
  100311. * Are fresnels enabled in the application.
  100312. */
  100313. static get FresnelEnabled(): boolean;
  100314. static set FresnelEnabled(value: boolean);
  100315. }
  100316. }
  100317. declare module BABYLON {
  100318. /**
  100319. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100320. *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.
  100321. * The SPS is also a particle system. It provides some methods to manage the particles.
  100322. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100323. *
  100324. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100325. */
  100326. export class SolidParticleSystem implements IDisposable {
  100327. /**
  100328. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100329. * Example : var p = SPS.particles[i];
  100330. */
  100331. particles: SolidParticle[];
  100332. /**
  100333. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100334. */
  100335. nbParticles: number;
  100336. /**
  100337. * If the particles must ever face the camera (default false). Useful for planar particles.
  100338. */
  100339. billboard: boolean;
  100340. /**
  100341. * Recompute normals when adding a shape
  100342. */
  100343. recomputeNormals: boolean;
  100344. /**
  100345. * This a counter ofr your own usage. It's not set by any SPS functions.
  100346. */
  100347. counter: number;
  100348. /**
  100349. * The SPS name. This name is also given to the underlying mesh.
  100350. */
  100351. name: string;
  100352. /**
  100353. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100354. */
  100355. mesh: Mesh;
  100356. /**
  100357. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100358. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100359. */
  100360. vars: any;
  100361. /**
  100362. * This array is populated when the SPS is set as 'pickable'.
  100363. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100364. * Each element of this array is an object `{idx: int, faceId: int}`.
  100365. * `idx` is the picked particle index in the `SPS.particles` array
  100366. * `faceId` is the picked face index counted within this particle.
  100367. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100368. */
  100369. pickedParticles: {
  100370. idx: number;
  100371. faceId: number;
  100372. }[];
  100373. /**
  100374. * This array is populated when `enableDepthSort` is set to true.
  100375. * Each element of this array is an instance of the class DepthSortedParticle.
  100376. */
  100377. depthSortedParticles: DepthSortedParticle[];
  100378. /**
  100379. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100380. * @hidden
  100381. */
  100382. _bSphereOnly: boolean;
  100383. /**
  100384. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100385. * @hidden
  100386. */
  100387. _bSphereRadiusFactor: number;
  100388. private _scene;
  100389. private _positions;
  100390. private _indices;
  100391. private _normals;
  100392. private _colors;
  100393. private _uvs;
  100394. private _indices32;
  100395. private _positions32;
  100396. private _normals32;
  100397. private _fixedNormal32;
  100398. private _colors32;
  100399. private _uvs32;
  100400. private _index;
  100401. private _updatable;
  100402. private _pickable;
  100403. private _isVisibilityBoxLocked;
  100404. private _alwaysVisible;
  100405. private _depthSort;
  100406. private _expandable;
  100407. private _shapeCounter;
  100408. private _copy;
  100409. private _color;
  100410. private _computeParticleColor;
  100411. private _computeParticleTexture;
  100412. private _computeParticleRotation;
  100413. private _computeParticleVertex;
  100414. private _computeBoundingBox;
  100415. private _depthSortParticles;
  100416. private _camera;
  100417. private _mustUnrotateFixedNormals;
  100418. private _particlesIntersect;
  100419. private _needs32Bits;
  100420. private _isNotBuilt;
  100421. private _lastParticleId;
  100422. private _idxOfId;
  100423. private _multimaterialEnabled;
  100424. private _useModelMaterial;
  100425. private _indicesByMaterial;
  100426. private _materialIndexes;
  100427. private _depthSortFunction;
  100428. private _materialSortFunction;
  100429. private _materials;
  100430. private _multimaterial;
  100431. private _materialIndexesById;
  100432. private _defaultMaterial;
  100433. private _autoUpdateSubMeshes;
  100434. /**
  100435. * Creates a SPS (Solid Particle System) object.
  100436. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100437. * @param scene (Scene) is the scene in which the SPS is added.
  100438. * @param options defines the options of the sps e.g.
  100439. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100440. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100441. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100442. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  100443. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100444. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100445. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100446. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100447. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100448. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100449. */
  100450. constructor(name: string, scene: Scene, options?: {
  100451. updatable?: boolean;
  100452. isPickable?: boolean;
  100453. enableDepthSort?: boolean;
  100454. particleIntersection?: boolean;
  100455. boundingSphereOnly?: boolean;
  100456. bSphereRadiusFactor?: number;
  100457. expandable?: boolean;
  100458. useModelMaterial?: boolean;
  100459. enableMultiMaterial?: boolean;
  100460. });
  100461. /**
  100462. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100463. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100464. * @returns the created mesh
  100465. */
  100466. buildMesh(): Mesh;
  100467. /**
  100468. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100469. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100470. * Thus the particles generated from `digest()` have their property `position` set yet.
  100471. * @param mesh ( Mesh ) is the mesh to be digested
  100472. * @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
  100473. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100474. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100475. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100476. * @returns the current SPS
  100477. */
  100478. digest(mesh: Mesh, options?: {
  100479. facetNb?: number;
  100480. number?: number;
  100481. delta?: number;
  100482. storage?: [];
  100483. }): SolidParticleSystem;
  100484. /**
  100485. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100486. * @hidden
  100487. */
  100488. private _unrotateFixedNormals;
  100489. /**
  100490. * Resets the temporary working copy particle
  100491. * @hidden
  100492. */
  100493. private _resetCopy;
  100494. /**
  100495. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100496. * @param p the current index in the positions array to be updated
  100497. * @param ind the current index in the indices array
  100498. * @param shape a Vector3 array, the shape geometry
  100499. * @param positions the positions array to be updated
  100500. * @param meshInd the shape indices array
  100501. * @param indices the indices array to be updated
  100502. * @param meshUV the shape uv array
  100503. * @param uvs the uv array to be updated
  100504. * @param meshCol the shape color array
  100505. * @param colors the color array to be updated
  100506. * @param meshNor the shape normals array
  100507. * @param normals the normals array to be updated
  100508. * @param idx the particle index
  100509. * @param idxInShape the particle index in its shape
  100510. * @param options the addShape() method passed options
  100511. * @model the particle model
  100512. * @hidden
  100513. */
  100514. private _meshBuilder;
  100515. /**
  100516. * Returns a shape Vector3 array from positions float array
  100517. * @param positions float array
  100518. * @returns a vector3 array
  100519. * @hidden
  100520. */
  100521. private _posToShape;
  100522. /**
  100523. * Returns a shapeUV array from a float uvs (array deep copy)
  100524. * @param uvs as a float array
  100525. * @returns a shapeUV array
  100526. * @hidden
  100527. */
  100528. private _uvsToShapeUV;
  100529. /**
  100530. * Adds a new particle object in the particles array
  100531. * @param idx particle index in particles array
  100532. * @param id particle id
  100533. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100534. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100535. * @param model particle ModelShape object
  100536. * @param shapeId model shape identifier
  100537. * @param idxInShape index of the particle in the current model
  100538. * @param bInfo model bounding info object
  100539. * @param storage target storage array, if any
  100540. * @hidden
  100541. */
  100542. private _addParticle;
  100543. /**
  100544. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100545. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100546. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100547. * @param nb (positive integer) the number of particles to be created from this model
  100548. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100549. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100550. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100551. * @returns the number of shapes in the system
  100552. */
  100553. addShape(mesh: Mesh, nb: number, options?: {
  100554. positionFunction?: any;
  100555. vertexFunction?: any;
  100556. storage?: [];
  100557. }): number;
  100558. /**
  100559. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100560. * @hidden
  100561. */
  100562. private _rebuildParticle;
  100563. /**
  100564. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100565. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  100566. * @returns the SPS.
  100567. */
  100568. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100569. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100570. * Returns an array with the removed particles.
  100571. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  100572. * The SPS can't be empty so at least one particle needs to remain in place.
  100573. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100574. * @param start index of the first particle to remove
  100575. * @param end index of the last particle to remove (included)
  100576. * @returns an array populated with the removed particles
  100577. */
  100578. removeParticles(start: number, end: number): SolidParticle[];
  100579. /**
  100580. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100581. * @param solidParticleArray an array populated with Solid Particles objects
  100582. * @returns the SPS
  100583. */
  100584. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100585. /**
  100586. * Creates a new particle and modifies the SPS mesh geometry :
  100587. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100588. * - calls _addParticle() to populate the particle array
  100589. * factorized code from addShape() and insertParticlesFromArray()
  100590. * @param idx particle index in the particles array
  100591. * @param i particle index in its shape
  100592. * @param modelShape particle ModelShape object
  100593. * @param shape shape vertex array
  100594. * @param meshInd shape indices array
  100595. * @param meshUV shape uv array
  100596. * @param meshCol shape color array
  100597. * @param meshNor shape normals array
  100598. * @param bbInfo shape bounding info
  100599. * @param storage target particle storage
  100600. * @options addShape() passed options
  100601. * @hidden
  100602. */
  100603. private _insertNewParticle;
  100604. /**
  100605. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100606. * This method calls `updateParticle()` for each particle of the SPS.
  100607. * For an animated SPS, it is usually called within the render loop.
  100608. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  100609. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100610. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100611. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100612. * @returns the SPS.
  100613. */
  100614. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100615. /**
  100616. * Disposes the SPS.
  100617. */
  100618. dispose(): void;
  100619. /**
  100620. * Returns a SolidParticle object from its identifier : particle.id
  100621. * @param id (integer) the particle Id
  100622. * @returns the searched particle or null if not found in the SPS.
  100623. */
  100624. getParticleById(id: number): Nullable<SolidParticle>;
  100625. /**
  100626. * Returns a new array populated with the particles having the passed shapeId.
  100627. * @param shapeId (integer) the shape identifier
  100628. * @returns a new solid particle array
  100629. */
  100630. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100631. /**
  100632. * Populates the passed array "ref" with the particles having the passed shapeId.
  100633. * @param shapeId the shape identifier
  100634. * @returns the SPS
  100635. * @param ref
  100636. */
  100637. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100638. /**
  100639. * Computes the required SubMeshes according the materials assigned to the particles.
  100640. * @returns the solid particle system.
  100641. * Does nothing if called before the SPS mesh is built.
  100642. */
  100643. computeSubMeshes(): SolidParticleSystem;
  100644. /**
  100645. * Sorts the solid particles by material when MultiMaterial is enabled.
  100646. * Updates the indices32 array.
  100647. * Updates the indicesByMaterial array.
  100648. * Updates the mesh indices array.
  100649. * @returns the SPS
  100650. * @hidden
  100651. */
  100652. private _sortParticlesByMaterial;
  100653. /**
  100654. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100655. * @hidden
  100656. */
  100657. private _setMaterialIndexesById;
  100658. /**
  100659. * Returns an array with unique values of Materials from the passed array
  100660. * @param array the material array to be checked and filtered
  100661. * @hidden
  100662. */
  100663. private _filterUniqueMaterialId;
  100664. /**
  100665. * Sets a new Standard Material as _defaultMaterial if not already set.
  100666. * @hidden
  100667. */
  100668. private _setDefaultMaterial;
  100669. /**
  100670. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100671. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100672. * @returns the SPS.
  100673. */
  100674. refreshVisibleSize(): SolidParticleSystem;
  100675. /**
  100676. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100677. * @param size the size (float) of the visibility box
  100678. * note : this doesn't lock the SPS mesh bounding box.
  100679. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100680. */
  100681. setVisibilityBox(size: number): void;
  100682. /**
  100683. * Gets whether the SPS as always visible or not
  100684. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100685. */
  100686. get isAlwaysVisible(): boolean;
  100687. /**
  100688. * Sets the SPS as always visible or not
  100689. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100690. */
  100691. set isAlwaysVisible(val: boolean);
  100692. /**
  100693. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100694. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100695. */
  100696. set isVisibilityBoxLocked(val: boolean);
  100697. /**
  100698. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100699. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100700. */
  100701. get isVisibilityBoxLocked(): boolean;
  100702. /**
  100703. * Tells to `setParticles()` to compute the particle rotations or not.
  100704. * Default value : true. The SPS is faster when it's set to false.
  100705. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100706. */
  100707. set computeParticleRotation(val: boolean);
  100708. /**
  100709. * Tells to `setParticles()` to compute the particle colors or not.
  100710. * Default value : true. The SPS is faster when it's set to false.
  100711. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100712. */
  100713. set computeParticleColor(val: boolean);
  100714. set computeParticleTexture(val: boolean);
  100715. /**
  100716. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100717. * Default value : false. The SPS is faster when it's set to false.
  100718. * Note : the particle custom vertex positions aren't stored values.
  100719. */
  100720. set computeParticleVertex(val: boolean);
  100721. /**
  100722. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100723. */
  100724. set computeBoundingBox(val: boolean);
  100725. /**
  100726. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100727. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100728. * Default : `true`
  100729. */
  100730. set depthSortParticles(val: boolean);
  100731. /**
  100732. * Gets if `setParticles()` computes the particle rotations or not.
  100733. * Default value : true. The SPS is faster when it's set to false.
  100734. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100735. */
  100736. get computeParticleRotation(): boolean;
  100737. /**
  100738. * Gets if `setParticles()` computes the particle colors or not.
  100739. * Default value : true. The SPS is faster when it's set to false.
  100740. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100741. */
  100742. get computeParticleColor(): boolean;
  100743. /**
  100744. * Gets if `setParticles()` computes the particle textures or not.
  100745. * Default value : true. The SPS is faster when it's set to false.
  100746. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100747. */
  100748. get computeParticleTexture(): boolean;
  100749. /**
  100750. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100751. * Default value : false. The SPS is faster when it's set to false.
  100752. * Note : the particle custom vertex positions aren't stored values.
  100753. */
  100754. get computeParticleVertex(): boolean;
  100755. /**
  100756. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100757. */
  100758. get computeBoundingBox(): boolean;
  100759. /**
  100760. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100761. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100762. * Default : `true`
  100763. */
  100764. get depthSortParticles(): boolean;
  100765. /**
  100766. * Gets if the SPS is created as expandable at construction time.
  100767. * Default : `false`
  100768. */
  100769. get expandable(): boolean;
  100770. /**
  100771. * Gets if the SPS supports the Multi Materials
  100772. */
  100773. get multimaterialEnabled(): boolean;
  100774. /**
  100775. * Gets if the SPS uses the model materials for its own multimaterial.
  100776. */
  100777. get useModelMaterial(): boolean;
  100778. /**
  100779. * The SPS used material array.
  100780. */
  100781. get materials(): Material[];
  100782. /**
  100783. * Sets the SPS MultiMaterial from the passed materials.
  100784. * Note : the passed array is internally copied and not used then by reference.
  100785. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100786. */
  100787. setMultiMaterial(materials: Material[]): void;
  100788. /**
  100789. * The SPS computed multimaterial object
  100790. */
  100791. get multimaterial(): MultiMaterial;
  100792. set multimaterial(mm: MultiMaterial);
  100793. /**
  100794. * If the subMeshes must be updated on the next call to setParticles()
  100795. */
  100796. get autoUpdateSubMeshes(): boolean;
  100797. set autoUpdateSubMeshes(val: boolean);
  100798. /**
  100799. * This function does nothing. It may be overwritten to set all the particle first values.
  100800. * The SPS doesn't call this function, you may have to call it by your own.
  100801. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100802. */
  100803. initParticles(): void;
  100804. /**
  100805. * This function does nothing. It may be overwritten to recycle a particle.
  100806. * The SPS doesn't call this function, you may have to call it by your own.
  100807. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100808. * @param particle The particle to recycle
  100809. * @returns the recycled particle
  100810. */
  100811. recycleParticle(particle: SolidParticle): SolidParticle;
  100812. /**
  100813. * Updates a particle : this function should be overwritten by the user.
  100814. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100815. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100816. * @example : just set a particle position or velocity and recycle conditions
  100817. * @param particle The particle to update
  100818. * @returns the updated particle
  100819. */
  100820. updateParticle(particle: SolidParticle): SolidParticle;
  100821. /**
  100822. * Updates a vertex of a particle : it can be overwritten by the user.
  100823. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100824. * @param particle the current particle
  100825. * @param vertex the current index of the current particle
  100826. * @param pt the index of the current vertex in the particle shape
  100827. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100828. * @example : just set a vertex particle position
  100829. * @returns the updated vertex
  100830. */
  100831. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100832. /**
  100833. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100834. * This does nothing and may be overwritten by the user.
  100835. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100836. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100837. * @param update the boolean update value actually passed to setParticles()
  100838. */
  100839. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100840. /**
  100841. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100842. * This will be passed three parameters.
  100843. * This does nothing and may be overwritten by the user.
  100844. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100845. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100846. * @param update the boolean update value actually passed to setParticles()
  100847. */
  100848. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100849. }
  100850. }
  100851. declare module BABYLON {
  100852. /**
  100853. * Represents one particle of a solid particle system.
  100854. */
  100855. export class SolidParticle {
  100856. /**
  100857. * particle global index
  100858. */
  100859. idx: number;
  100860. /**
  100861. * particle identifier
  100862. */
  100863. id: number;
  100864. /**
  100865. * The color of the particle
  100866. */
  100867. color: Nullable<Color4>;
  100868. /**
  100869. * The world space position of the particle.
  100870. */
  100871. position: Vector3;
  100872. /**
  100873. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100874. */
  100875. rotation: Vector3;
  100876. /**
  100877. * The world space rotation quaternion of the particle.
  100878. */
  100879. rotationQuaternion: Nullable<Quaternion>;
  100880. /**
  100881. * The scaling of the particle.
  100882. */
  100883. scaling: Vector3;
  100884. /**
  100885. * The uvs of the particle.
  100886. */
  100887. uvs: Vector4;
  100888. /**
  100889. * The current speed of the particle.
  100890. */
  100891. velocity: Vector3;
  100892. /**
  100893. * The pivot point in the particle local space.
  100894. */
  100895. pivot: Vector3;
  100896. /**
  100897. * Must the particle be translated from its pivot point in its local space ?
  100898. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100899. * Default : false
  100900. */
  100901. translateFromPivot: boolean;
  100902. /**
  100903. * Is the particle active or not ?
  100904. */
  100905. alive: boolean;
  100906. /**
  100907. * Is the particle visible or not ?
  100908. */
  100909. isVisible: boolean;
  100910. /**
  100911. * Index of this particle in the global "positions" array (Internal use)
  100912. * @hidden
  100913. */
  100914. _pos: number;
  100915. /**
  100916. * @hidden Index of this particle in the global "indices" array (Internal use)
  100917. */
  100918. _ind: number;
  100919. /**
  100920. * @hidden ModelShape of this particle (Internal use)
  100921. */
  100922. _model: ModelShape;
  100923. /**
  100924. * ModelShape id of this particle
  100925. */
  100926. shapeId: number;
  100927. /**
  100928. * Index of the particle in its shape id
  100929. */
  100930. idxInShape: number;
  100931. /**
  100932. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100933. */
  100934. _modelBoundingInfo: BoundingInfo;
  100935. /**
  100936. * @hidden Particle BoundingInfo object (Internal use)
  100937. */
  100938. _boundingInfo: BoundingInfo;
  100939. /**
  100940. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100941. */
  100942. _sps: SolidParticleSystem;
  100943. /**
  100944. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100945. */
  100946. _stillInvisible: boolean;
  100947. /**
  100948. * @hidden Last computed particle rotation matrix
  100949. */
  100950. _rotationMatrix: number[];
  100951. /**
  100952. * Parent particle Id, if any.
  100953. * Default null.
  100954. */
  100955. parentId: Nullable<number>;
  100956. /**
  100957. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100958. */
  100959. materialIndex: Nullable<number>;
  100960. /**
  100961. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100962. * The possible values are :
  100963. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100964. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100965. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100967. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100968. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100969. * */
  100970. cullingStrategy: number;
  100971. /**
  100972. * @hidden Internal global position in the SPS.
  100973. */
  100974. _globalPosition: Vector3;
  100975. /**
  100976. * Creates a Solid Particle object.
  100977. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100978. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100979. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100980. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100981. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100982. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100983. * @param shapeId (integer) is the model shape identifier in the SPS.
  100984. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100985. * @param sps defines the sps it is associated to
  100986. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100987. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100988. */
  100989. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100990. /**
  100991. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100992. * @param target the particle target
  100993. * @returns the current particle
  100994. */
  100995. copyToRef(target: SolidParticle): SolidParticle;
  100996. /**
  100997. * Legacy support, changed scale to scaling
  100998. */
  100999. get scale(): Vector3;
  101000. /**
  101001. * Legacy support, changed scale to scaling
  101002. */
  101003. set scale(scale: Vector3);
  101004. /**
  101005. * Legacy support, changed quaternion to rotationQuaternion
  101006. */
  101007. get quaternion(): Nullable<Quaternion>;
  101008. /**
  101009. * Legacy support, changed quaternion to rotationQuaternion
  101010. */
  101011. set quaternion(q: Nullable<Quaternion>);
  101012. /**
  101013. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  101014. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  101015. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  101016. * @returns true if it intersects
  101017. */
  101018. intersectsMesh(target: Mesh | SolidParticle): boolean;
  101019. /**
  101020. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  101021. * A particle is in the frustum if its bounding box intersects the frustum
  101022. * @param frustumPlanes defines the frustum to test
  101023. * @returns true if the particle is in the frustum planes
  101024. */
  101025. isInFrustum(frustumPlanes: Plane[]): boolean;
  101026. /**
  101027. * get the rotation matrix of the particle
  101028. * @hidden
  101029. */
  101030. getRotationMatrix(m: Matrix): void;
  101031. }
  101032. /**
  101033. * Represents the shape of the model used by one particle of a solid particle system.
  101034. * SPS internal tool, don't use it manually.
  101035. */
  101036. export class ModelShape {
  101037. /**
  101038. * The shape id
  101039. * @hidden
  101040. */
  101041. shapeID: number;
  101042. /**
  101043. * flat array of model positions (internal use)
  101044. * @hidden
  101045. */
  101046. _shape: Vector3[];
  101047. /**
  101048. * flat array of model UVs (internal use)
  101049. * @hidden
  101050. */
  101051. _shapeUV: number[];
  101052. /**
  101053. * color array of the model
  101054. * @hidden
  101055. */
  101056. _shapeColors: number[];
  101057. /**
  101058. * indices array of the model
  101059. * @hidden
  101060. */
  101061. _indices: number[];
  101062. /**
  101063. * normals array of the model
  101064. * @hidden
  101065. */
  101066. _normals: number[];
  101067. /**
  101068. * length of the shape in the model indices array (internal use)
  101069. * @hidden
  101070. */
  101071. _indicesLength: number;
  101072. /**
  101073. * Custom position function (internal use)
  101074. * @hidden
  101075. */
  101076. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  101077. /**
  101078. * Custom vertex function (internal use)
  101079. * @hidden
  101080. */
  101081. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  101082. /**
  101083. * Model material (internal use)
  101084. * @hidden
  101085. */
  101086. _material: Nullable<Material>;
  101087. /**
  101088. * 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.
  101089. * SPS internal tool, don't use it manually.
  101090. * @hidden
  101091. */
  101092. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  101093. }
  101094. /**
  101095. * Represents a Depth Sorted Particle in the solid particle system.
  101096. * @hidden
  101097. */
  101098. export class DepthSortedParticle {
  101099. /**
  101100. * Index of the particle in the "indices" array
  101101. */
  101102. ind: number;
  101103. /**
  101104. * Length of the particle shape in the "indices" array
  101105. */
  101106. indicesLength: number;
  101107. /**
  101108. * Squared distance from the particle to the camera
  101109. */
  101110. sqDistance: number;
  101111. /**
  101112. * Material index when used with MultiMaterials
  101113. */
  101114. materialIndex: number;
  101115. /**
  101116. * Creates a new sorted particle
  101117. * @param materialIndex
  101118. */
  101119. constructor(ind: number, indLength: number, materialIndex: number);
  101120. }
  101121. }
  101122. declare module BABYLON {
  101123. /**
  101124. * @hidden
  101125. */
  101126. export class _MeshCollisionData {
  101127. _checkCollisions: boolean;
  101128. _collisionMask: number;
  101129. _collisionGroup: number;
  101130. _collider: Nullable<Collider>;
  101131. _oldPositionForCollisions: Vector3;
  101132. _diffPositionForCollisions: Vector3;
  101133. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101134. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101135. }
  101136. }
  101137. declare module BABYLON {
  101138. /** @hidden */
  101139. class _FacetDataStorage {
  101140. facetPositions: Vector3[];
  101141. facetNormals: Vector3[];
  101142. facetPartitioning: number[][];
  101143. facetNb: number;
  101144. partitioningSubdivisions: number;
  101145. partitioningBBoxRatio: number;
  101146. facetDataEnabled: boolean;
  101147. facetParameters: any;
  101148. bbSize: Vector3;
  101149. subDiv: {
  101150. max: number;
  101151. X: number;
  101152. Y: number;
  101153. Z: number;
  101154. };
  101155. facetDepthSort: boolean;
  101156. facetDepthSortEnabled: boolean;
  101157. depthSortedIndices: IndicesArray;
  101158. depthSortedFacets: {
  101159. ind: number;
  101160. sqDistance: number;
  101161. }[];
  101162. facetDepthSortFunction: (f1: {
  101163. ind: number;
  101164. sqDistance: number;
  101165. }, f2: {
  101166. ind: number;
  101167. sqDistance: number;
  101168. }) => number;
  101169. facetDepthSortFrom: Vector3;
  101170. facetDepthSortOrigin: Vector3;
  101171. invertedMatrix: Matrix;
  101172. }
  101173. /**
  101174. * @hidden
  101175. **/
  101176. class _InternalAbstractMeshDataInfo {
  101177. _hasVertexAlpha: boolean;
  101178. _useVertexColors: boolean;
  101179. _numBoneInfluencers: number;
  101180. _applyFog: boolean;
  101181. _receiveShadows: boolean;
  101182. _facetData: _FacetDataStorage;
  101183. _visibility: number;
  101184. _skeleton: Nullable<Skeleton>;
  101185. _layerMask: number;
  101186. _computeBonesUsingShaders: boolean;
  101187. _isActive: boolean;
  101188. _onlyForInstances: boolean;
  101189. _isActiveIntermediate: boolean;
  101190. _onlyForInstancesIntermediate: boolean;
  101191. _actAsRegularMesh: boolean;
  101192. }
  101193. /**
  101194. * Class used to store all common mesh properties
  101195. */
  101196. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101197. /** No occlusion */
  101198. static OCCLUSION_TYPE_NONE: number;
  101199. /** Occlusion set to optimisitic */
  101200. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101201. /** Occlusion set to strict */
  101202. static OCCLUSION_TYPE_STRICT: number;
  101203. /** Use an accurante occlusion algorithm */
  101204. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101205. /** Use a conservative occlusion algorithm */
  101206. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101207. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101208. * Test order :
  101209. * Is the bounding sphere outside the frustum ?
  101210. * If not, are the bounding box vertices outside the frustum ?
  101211. * It not, then the cullable object is in the frustum.
  101212. */
  101213. static readonly CULLINGSTRATEGY_STANDARD: number;
  101214. /** Culling strategy : Bounding Sphere Only.
  101215. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101216. * It's also less accurate than the standard because some not visible objects can still be selected.
  101217. * Test : is the bounding sphere outside the frustum ?
  101218. * If not, then the cullable object is in the frustum.
  101219. */
  101220. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101221. /** Culling strategy : Optimistic Inclusion.
  101222. * This in an inclusion test first, then the standard exclusion test.
  101223. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101224. * 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.
  101225. * Anyway, it's as accurate as the standard strategy.
  101226. * Test :
  101227. * Is the cullable object bounding sphere center in the frustum ?
  101228. * If not, apply the default culling strategy.
  101229. */
  101230. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101231. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101232. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101233. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101234. * 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.
  101235. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101236. * Test :
  101237. * Is the cullable object bounding sphere center in the frustum ?
  101238. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101239. */
  101240. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101241. /**
  101242. * No billboard
  101243. */
  101244. static get BILLBOARDMODE_NONE(): number;
  101245. /** Billboard on X axis */
  101246. static get BILLBOARDMODE_X(): number;
  101247. /** Billboard on Y axis */
  101248. static get BILLBOARDMODE_Y(): number;
  101249. /** Billboard on Z axis */
  101250. static get BILLBOARDMODE_Z(): number;
  101251. /** Billboard on all axes */
  101252. static get BILLBOARDMODE_ALL(): number;
  101253. /** Billboard on using position instead of orientation */
  101254. static get BILLBOARDMODE_USE_POSITION(): number;
  101255. /** @hidden */
  101256. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101257. /**
  101258. * The culling strategy to use to check whether the mesh must be rendered or not.
  101259. * This value can be changed at any time and will be used on the next render mesh selection.
  101260. * The possible values are :
  101261. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101262. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101263. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101264. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101265. * Please read each static variable documentation to get details about the culling process.
  101266. * */
  101267. cullingStrategy: number;
  101268. /**
  101269. * Gets the number of facets in the mesh
  101270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101271. */
  101272. get facetNb(): number;
  101273. /**
  101274. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101276. */
  101277. get partitioningSubdivisions(): number;
  101278. set partitioningSubdivisions(nb: number);
  101279. /**
  101280. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101281. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101282. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101283. */
  101284. get partitioningBBoxRatio(): number;
  101285. set partitioningBBoxRatio(ratio: number);
  101286. /**
  101287. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101288. * Works only for updatable meshes.
  101289. * Doesn't work with multi-materials
  101290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101291. */
  101292. get mustDepthSortFacets(): boolean;
  101293. set mustDepthSortFacets(sort: boolean);
  101294. /**
  101295. * The location (Vector3) where the facet depth sort must be computed from.
  101296. * By default, the active camera position.
  101297. * Used only when facet depth sort is enabled
  101298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101299. */
  101300. get facetDepthSortFrom(): Vector3;
  101301. set facetDepthSortFrom(location: Vector3);
  101302. /**
  101303. * gets a boolean indicating if facetData is enabled
  101304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101305. */
  101306. get isFacetDataEnabled(): boolean;
  101307. /** @hidden */
  101308. _updateNonUniformScalingState(value: boolean): boolean;
  101309. /**
  101310. * An event triggered when this mesh collides with another one
  101311. */
  101312. onCollideObservable: Observable<AbstractMesh>;
  101313. /** Set a function to call when this mesh collides with another one */
  101314. set onCollide(callback: () => void);
  101315. /**
  101316. * An event triggered when the collision's position changes
  101317. */
  101318. onCollisionPositionChangeObservable: Observable<Vector3>;
  101319. /** Set a function to call when the collision's position changes */
  101320. set onCollisionPositionChange(callback: () => void);
  101321. /**
  101322. * An event triggered when material is changed
  101323. */
  101324. onMaterialChangedObservable: Observable<AbstractMesh>;
  101325. /**
  101326. * Gets or sets the orientation for POV movement & rotation
  101327. */
  101328. definedFacingForward: boolean;
  101329. /** @hidden */
  101330. _occlusionQuery: Nullable<WebGLQuery>;
  101331. /** @hidden */
  101332. _renderingGroup: Nullable<RenderingGroup>;
  101333. /**
  101334. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101335. */
  101336. get visibility(): number;
  101337. /**
  101338. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101339. */
  101340. set visibility(value: number);
  101341. /** Gets or sets the alpha index used to sort transparent meshes
  101342. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101343. */
  101344. alphaIndex: number;
  101345. /**
  101346. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101347. */
  101348. isVisible: boolean;
  101349. /**
  101350. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101351. */
  101352. isPickable: boolean;
  101353. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101354. showSubMeshesBoundingBox: boolean;
  101355. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101356. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101357. */
  101358. isBlocker: boolean;
  101359. /**
  101360. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101361. */
  101362. enablePointerMoveEvents: boolean;
  101363. /**
  101364. * Specifies the rendering group id for this mesh (0 by default)
  101365. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101366. */
  101367. renderingGroupId: number;
  101368. private _material;
  101369. /** Gets or sets current material */
  101370. get material(): Nullable<Material>;
  101371. set material(value: Nullable<Material>);
  101372. /**
  101373. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101374. * @see http://doc.babylonjs.com/babylon101/shadows
  101375. */
  101376. get receiveShadows(): boolean;
  101377. set receiveShadows(value: boolean);
  101378. /** Defines color to use when rendering outline */
  101379. outlineColor: Color3;
  101380. /** Define width to use when rendering outline */
  101381. outlineWidth: number;
  101382. /** Defines color to use when rendering overlay */
  101383. overlayColor: Color3;
  101384. /** Defines alpha to use when rendering overlay */
  101385. overlayAlpha: number;
  101386. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101387. get hasVertexAlpha(): boolean;
  101388. set hasVertexAlpha(value: boolean);
  101389. /** 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) */
  101390. get useVertexColors(): boolean;
  101391. set useVertexColors(value: boolean);
  101392. /**
  101393. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101394. */
  101395. get computeBonesUsingShaders(): boolean;
  101396. set computeBonesUsingShaders(value: boolean);
  101397. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101398. get numBoneInfluencers(): number;
  101399. set numBoneInfluencers(value: number);
  101400. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101401. get applyFog(): boolean;
  101402. set applyFog(value: boolean);
  101403. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101404. useOctreeForRenderingSelection: boolean;
  101405. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101406. useOctreeForPicking: boolean;
  101407. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101408. useOctreeForCollisions: boolean;
  101409. /**
  101410. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101411. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101412. */
  101413. get layerMask(): number;
  101414. set layerMask(value: number);
  101415. /**
  101416. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101417. */
  101418. alwaysSelectAsActiveMesh: boolean;
  101419. /**
  101420. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101421. */
  101422. doNotSyncBoundingInfo: boolean;
  101423. /**
  101424. * Gets or sets the current action manager
  101425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101426. */
  101427. actionManager: Nullable<AbstractActionManager>;
  101428. private _meshCollisionData;
  101429. /**
  101430. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101432. */
  101433. ellipsoid: Vector3;
  101434. /**
  101435. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101436. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101437. */
  101438. ellipsoidOffset: Vector3;
  101439. /**
  101440. * Gets or sets a collision mask used to mask collisions (default is -1).
  101441. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101442. */
  101443. get collisionMask(): number;
  101444. set collisionMask(mask: number);
  101445. /**
  101446. * Gets or sets the current collision group mask (-1 by default).
  101447. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101448. */
  101449. get collisionGroup(): number;
  101450. set collisionGroup(mask: number);
  101451. /**
  101452. * Defines edge width used when edgesRenderer is enabled
  101453. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101454. */
  101455. edgesWidth: number;
  101456. /**
  101457. * Defines edge color used when edgesRenderer is enabled
  101458. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101459. */
  101460. edgesColor: Color4;
  101461. /** @hidden */
  101462. _edgesRenderer: Nullable<IEdgesRenderer>;
  101463. /** @hidden */
  101464. _masterMesh: Nullable<AbstractMesh>;
  101465. /** @hidden */
  101466. _boundingInfo: Nullable<BoundingInfo>;
  101467. /** @hidden */
  101468. _renderId: number;
  101469. /**
  101470. * Gets or sets the list of subMeshes
  101471. * @see http://doc.babylonjs.com/how_to/multi_materials
  101472. */
  101473. subMeshes: SubMesh[];
  101474. /** @hidden */
  101475. _intersectionsInProgress: AbstractMesh[];
  101476. /** @hidden */
  101477. _unIndexed: boolean;
  101478. /** @hidden */
  101479. _lightSources: Light[];
  101480. /** Gets the list of lights affecting that mesh */
  101481. get lightSources(): Light[];
  101482. /** @hidden */
  101483. get _positions(): Nullable<Vector3[]>;
  101484. /** @hidden */
  101485. _waitingData: {
  101486. lods: Nullable<any>;
  101487. actions: Nullable<any>;
  101488. freezeWorldMatrix: Nullable<boolean>;
  101489. };
  101490. /** @hidden */
  101491. _bonesTransformMatrices: Nullable<Float32Array>;
  101492. /** @hidden */
  101493. _transformMatrixTexture: Nullable<RawTexture>;
  101494. /**
  101495. * Gets or sets a skeleton to apply skining transformations
  101496. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101497. */
  101498. set skeleton(value: Nullable<Skeleton>);
  101499. get skeleton(): Nullable<Skeleton>;
  101500. /**
  101501. * An event triggered when the mesh is rebuilt.
  101502. */
  101503. onRebuildObservable: Observable<AbstractMesh>;
  101504. /**
  101505. * Creates a new AbstractMesh
  101506. * @param name defines the name of the mesh
  101507. * @param scene defines the hosting scene
  101508. */
  101509. constructor(name: string, scene?: Nullable<Scene>);
  101510. /**
  101511. * Returns the string "AbstractMesh"
  101512. * @returns "AbstractMesh"
  101513. */
  101514. getClassName(): string;
  101515. /**
  101516. * Gets a string representation of the current mesh
  101517. * @param fullDetails defines a boolean indicating if full details must be included
  101518. * @returns a string representation of the current mesh
  101519. */
  101520. toString(fullDetails?: boolean): string;
  101521. /**
  101522. * @hidden
  101523. */
  101524. protected _getEffectiveParent(): Nullable<Node>;
  101525. /** @hidden */
  101526. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101527. /** @hidden */
  101528. _rebuild(): void;
  101529. /** @hidden */
  101530. _resyncLightSources(): void;
  101531. /** @hidden */
  101532. _resyncLightSource(light: Light): void;
  101533. /** @hidden */
  101534. _unBindEffect(): void;
  101535. /** @hidden */
  101536. _removeLightSource(light: Light, dispose: boolean): void;
  101537. private _markSubMeshesAsDirty;
  101538. /** @hidden */
  101539. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101540. /** @hidden */
  101541. _markSubMeshesAsAttributesDirty(): void;
  101542. /** @hidden */
  101543. _markSubMeshesAsMiscDirty(): void;
  101544. /**
  101545. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101546. */
  101547. get scaling(): Vector3;
  101548. set scaling(newScaling: Vector3);
  101549. /**
  101550. * Returns true if the mesh is blocked. Implemented by child classes
  101551. */
  101552. get isBlocked(): boolean;
  101553. /**
  101554. * Returns the mesh itself by default. Implemented by child classes
  101555. * @param camera defines the camera to use to pick the right LOD level
  101556. * @returns the currentAbstractMesh
  101557. */
  101558. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101559. /**
  101560. * Returns 0 by default. Implemented by child classes
  101561. * @returns an integer
  101562. */
  101563. getTotalVertices(): number;
  101564. /**
  101565. * Returns a positive integer : the total number of indices in this mesh geometry.
  101566. * @returns the numner of indices or zero if the mesh has no geometry.
  101567. */
  101568. getTotalIndices(): number;
  101569. /**
  101570. * Returns null by default. Implemented by child classes
  101571. * @returns null
  101572. */
  101573. getIndices(): Nullable<IndicesArray>;
  101574. /**
  101575. * Returns the array of the requested vertex data kind. Implemented by child classes
  101576. * @param kind defines the vertex data kind to use
  101577. * @returns null
  101578. */
  101579. getVerticesData(kind: string): Nullable<FloatArray>;
  101580. /**
  101581. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101582. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101583. * Note that a new underlying VertexBuffer object is created each call.
  101584. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101585. * @param kind defines vertex data kind:
  101586. * * VertexBuffer.PositionKind
  101587. * * VertexBuffer.UVKind
  101588. * * VertexBuffer.UV2Kind
  101589. * * VertexBuffer.UV3Kind
  101590. * * VertexBuffer.UV4Kind
  101591. * * VertexBuffer.UV5Kind
  101592. * * VertexBuffer.UV6Kind
  101593. * * VertexBuffer.ColorKind
  101594. * * VertexBuffer.MatricesIndicesKind
  101595. * * VertexBuffer.MatricesIndicesExtraKind
  101596. * * VertexBuffer.MatricesWeightsKind
  101597. * * VertexBuffer.MatricesWeightsExtraKind
  101598. * @param data defines the data source
  101599. * @param updatable defines if the data must be flagged as updatable (or static)
  101600. * @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
  101601. * @returns the current mesh
  101602. */
  101603. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101604. /**
  101605. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101606. * If the mesh has no geometry, it is simply returned as it is.
  101607. * @param kind defines vertex data kind:
  101608. * * VertexBuffer.PositionKind
  101609. * * VertexBuffer.UVKind
  101610. * * VertexBuffer.UV2Kind
  101611. * * VertexBuffer.UV3Kind
  101612. * * VertexBuffer.UV4Kind
  101613. * * VertexBuffer.UV5Kind
  101614. * * VertexBuffer.UV6Kind
  101615. * * VertexBuffer.ColorKind
  101616. * * VertexBuffer.MatricesIndicesKind
  101617. * * VertexBuffer.MatricesIndicesExtraKind
  101618. * * VertexBuffer.MatricesWeightsKind
  101619. * * VertexBuffer.MatricesWeightsExtraKind
  101620. * @param data defines the data source
  101621. * @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
  101622. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101623. * @returns the current mesh
  101624. */
  101625. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101626. /**
  101627. * Sets the mesh indices,
  101628. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101629. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101630. * @param totalVertices Defines the total number of vertices
  101631. * @returns the current mesh
  101632. */
  101633. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101634. /**
  101635. * Gets a boolean indicating if specific vertex data is present
  101636. * @param kind defines the vertex data kind to use
  101637. * @returns true is data kind is present
  101638. */
  101639. isVerticesDataPresent(kind: string): boolean;
  101640. /**
  101641. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101642. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101643. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101644. * @returns a BoundingInfo
  101645. */
  101646. getBoundingInfo(): BoundingInfo;
  101647. /**
  101648. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101649. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101650. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101651. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101652. * @returns the current mesh
  101653. */
  101654. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101655. /**
  101656. * Overwrite the current bounding info
  101657. * @param boundingInfo defines the new bounding info
  101658. * @returns the current mesh
  101659. */
  101660. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101661. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101662. get useBones(): boolean;
  101663. /** @hidden */
  101664. _preActivate(): void;
  101665. /** @hidden */
  101666. _preActivateForIntermediateRendering(renderId: number): void;
  101667. /** @hidden */
  101668. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101669. /** @hidden */
  101670. _postActivate(): void;
  101671. /** @hidden */
  101672. _freeze(): void;
  101673. /** @hidden */
  101674. _unFreeze(): void;
  101675. /**
  101676. * Gets the current world matrix
  101677. * @returns a Matrix
  101678. */
  101679. getWorldMatrix(): Matrix;
  101680. /** @hidden */
  101681. _getWorldMatrixDeterminant(): number;
  101682. /**
  101683. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101684. */
  101685. get isAnInstance(): boolean;
  101686. /**
  101687. * Gets a boolean indicating if this mesh has instances
  101688. */
  101689. get hasInstances(): boolean;
  101690. /**
  101691. * Perform relative position change from the point of view of behind the front of the mesh.
  101692. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101693. * Supports definition of mesh facing forward or backward
  101694. * @param amountRight defines the distance on the right axis
  101695. * @param amountUp defines the distance on the up axis
  101696. * @param amountForward defines the distance on the forward axis
  101697. * @returns the current mesh
  101698. */
  101699. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101700. /**
  101701. * Calculate relative position change from the point of view of behind the front of the mesh.
  101702. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101703. * Supports definition of mesh facing forward or backward
  101704. * @param amountRight defines the distance on the right axis
  101705. * @param amountUp defines the distance on the up axis
  101706. * @param amountForward defines the distance on the forward axis
  101707. * @returns the new displacement vector
  101708. */
  101709. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101710. /**
  101711. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101712. * Supports definition of mesh facing forward or backward
  101713. * @param flipBack defines the flip
  101714. * @param twirlClockwise defines the twirl
  101715. * @param tiltRight defines the tilt
  101716. * @returns the current mesh
  101717. */
  101718. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101719. /**
  101720. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101721. * Supports definition of mesh facing forward or backward.
  101722. * @param flipBack defines the flip
  101723. * @param twirlClockwise defines the twirl
  101724. * @param tiltRight defines the tilt
  101725. * @returns the new rotation vector
  101726. */
  101727. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101728. /**
  101729. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101730. * This means the mesh underlying bounding box and sphere are recomputed.
  101731. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101732. * @returns the current mesh
  101733. */
  101734. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101735. /** @hidden */
  101736. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101737. /** @hidden */
  101738. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101739. /** @hidden */
  101740. _updateBoundingInfo(): AbstractMesh;
  101741. /** @hidden */
  101742. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101743. /** @hidden */
  101744. protected _afterComputeWorldMatrix(): void;
  101745. /** @hidden */
  101746. get _effectiveMesh(): AbstractMesh;
  101747. /**
  101748. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101749. * A mesh is in the frustum if its bounding box intersects the frustum
  101750. * @param frustumPlanes defines the frustum to test
  101751. * @returns true if the mesh is in the frustum planes
  101752. */
  101753. isInFrustum(frustumPlanes: Plane[]): boolean;
  101754. /**
  101755. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101756. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101757. * @param frustumPlanes defines the frustum to test
  101758. * @returns true if the mesh is completely in the frustum planes
  101759. */
  101760. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101761. /**
  101762. * True if the mesh intersects another mesh or a SolidParticle object
  101763. * @param mesh defines a target mesh or SolidParticle to test
  101764. * @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)
  101765. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101766. * @returns true if there is an intersection
  101767. */
  101768. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101769. /**
  101770. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101771. * @param point defines the point to test
  101772. * @returns true if there is an intersection
  101773. */
  101774. intersectsPoint(point: Vector3): boolean;
  101775. /**
  101776. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101777. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101778. */
  101779. get checkCollisions(): boolean;
  101780. set checkCollisions(collisionEnabled: boolean);
  101781. /**
  101782. * Gets Collider object used to compute collisions (not physics)
  101783. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101784. */
  101785. get collider(): Nullable<Collider>;
  101786. /**
  101787. * Move the mesh using collision engine
  101788. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101789. * @param displacement defines the requested displacement vector
  101790. * @returns the current mesh
  101791. */
  101792. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101793. private _onCollisionPositionChange;
  101794. /** @hidden */
  101795. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101796. /** @hidden */
  101797. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101798. /** @hidden */
  101799. _checkCollision(collider: Collider): AbstractMesh;
  101800. /** @hidden */
  101801. _generatePointsArray(): boolean;
  101802. /**
  101803. * Checks if the passed Ray intersects with the mesh
  101804. * @param ray defines the ray to use
  101805. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101806. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101807. * @returns the picking info
  101808. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101809. */
  101810. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101811. /**
  101812. * Clones the current mesh
  101813. * @param name defines the mesh name
  101814. * @param newParent defines the new mesh parent
  101815. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101816. * @returns the new mesh
  101817. */
  101818. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101819. /**
  101820. * Disposes all the submeshes of the current meshnp
  101821. * @returns the current mesh
  101822. */
  101823. releaseSubMeshes(): AbstractMesh;
  101824. /**
  101825. * Releases resources associated with this abstract mesh.
  101826. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101827. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101828. */
  101829. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101830. /**
  101831. * Adds the passed mesh as a child to the current mesh
  101832. * @param mesh defines the child mesh
  101833. * @returns the current mesh
  101834. */
  101835. addChild(mesh: AbstractMesh): AbstractMesh;
  101836. /**
  101837. * Removes the passed mesh from the current mesh children list
  101838. * @param mesh defines the child mesh
  101839. * @returns the current mesh
  101840. */
  101841. removeChild(mesh: AbstractMesh): AbstractMesh;
  101842. /** @hidden */
  101843. private _initFacetData;
  101844. /**
  101845. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101846. * This method can be called within the render loop.
  101847. * 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
  101848. * @returns the current mesh
  101849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101850. */
  101851. updateFacetData(): AbstractMesh;
  101852. /**
  101853. * Returns the facetLocalNormals array.
  101854. * The normals are expressed in the mesh local spac
  101855. * @returns an array of Vector3
  101856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101857. */
  101858. getFacetLocalNormals(): Vector3[];
  101859. /**
  101860. * Returns the facetLocalPositions array.
  101861. * The facet positions are expressed in the mesh local space
  101862. * @returns an array of Vector3
  101863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101864. */
  101865. getFacetLocalPositions(): Vector3[];
  101866. /**
  101867. * Returns the facetLocalPartioning array
  101868. * @returns an array of array of numbers
  101869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101870. */
  101871. getFacetLocalPartitioning(): number[][];
  101872. /**
  101873. * Returns the i-th facet position in the world system.
  101874. * This method allocates a new Vector3 per call
  101875. * @param i defines the facet index
  101876. * @returns a new Vector3
  101877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101878. */
  101879. getFacetPosition(i: number): Vector3;
  101880. /**
  101881. * Sets the reference Vector3 with the i-th facet position in the world system
  101882. * @param i defines the facet index
  101883. * @param ref defines the target vector
  101884. * @returns the current mesh
  101885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101886. */
  101887. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101888. /**
  101889. * Returns the i-th facet normal in the world system.
  101890. * This method allocates a new Vector3 per call
  101891. * @param i defines the facet index
  101892. * @returns a new Vector3
  101893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101894. */
  101895. getFacetNormal(i: number): Vector3;
  101896. /**
  101897. * Sets the reference Vector3 with the i-th facet normal in the world system
  101898. * @param i defines the facet index
  101899. * @param ref defines the target vector
  101900. * @returns the current mesh
  101901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101902. */
  101903. getFacetNormalToRef(i: number, ref: Vector3): this;
  101904. /**
  101905. * 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)
  101906. * @param x defines x coordinate
  101907. * @param y defines y coordinate
  101908. * @param z defines z coordinate
  101909. * @returns the array of facet indexes
  101910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101911. */
  101912. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101913. /**
  101914. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101915. * @param projected sets as the (x,y,z) world projection on the facet
  101916. * @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
  101917. * @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
  101918. * @param x defines x coordinate
  101919. * @param y defines y coordinate
  101920. * @param z defines z coordinate
  101921. * @returns the face index if found (or null instead)
  101922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101923. */
  101924. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101925. /**
  101926. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101927. * @param projected sets as the (x,y,z) local projection on the facet
  101928. * @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
  101929. * @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
  101930. * @param x defines x coordinate
  101931. * @param y defines y coordinate
  101932. * @param z defines z coordinate
  101933. * @returns the face index if found (or null instead)
  101934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101935. */
  101936. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101937. /**
  101938. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101939. * @returns the parameters
  101940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101941. */
  101942. getFacetDataParameters(): any;
  101943. /**
  101944. * Disables the feature FacetData and frees the related memory
  101945. * @returns the current mesh
  101946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101947. */
  101948. disableFacetData(): AbstractMesh;
  101949. /**
  101950. * Updates the AbstractMesh indices array
  101951. * @param indices defines the data source
  101952. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101953. * @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)
  101954. * @returns the current mesh
  101955. */
  101956. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101957. /**
  101958. * Creates new normals data for the mesh
  101959. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101960. * @returns the current mesh
  101961. */
  101962. createNormals(updatable: boolean): AbstractMesh;
  101963. /**
  101964. * Align the mesh with a normal
  101965. * @param normal defines the normal to use
  101966. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101967. * @returns the current mesh
  101968. */
  101969. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101970. /** @hidden */
  101971. _checkOcclusionQuery(): boolean;
  101972. /**
  101973. * Disables the mesh edge rendering mode
  101974. * @returns the currentAbstractMesh
  101975. */
  101976. disableEdgesRendering(): AbstractMesh;
  101977. /**
  101978. * Enables the edge rendering mode on the mesh.
  101979. * This mode makes the mesh edges visible
  101980. * @param epsilon defines the maximal distance between two angles to detect a face
  101981. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101982. * @returns the currentAbstractMesh
  101983. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101984. */
  101985. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101986. }
  101987. }
  101988. declare module BABYLON {
  101989. /**
  101990. * Interface used to define ActionEvent
  101991. */
  101992. export interface IActionEvent {
  101993. /** The mesh or sprite that triggered the action */
  101994. source: any;
  101995. /** The X mouse cursor position at the time of the event */
  101996. pointerX: number;
  101997. /** The Y mouse cursor position at the time of the event */
  101998. pointerY: number;
  101999. /** The mesh that is currently pointed at (can be null) */
  102000. meshUnderPointer: Nullable<AbstractMesh>;
  102001. /** the original (browser) event that triggered the ActionEvent */
  102002. sourceEvent?: any;
  102003. /** additional data for the event */
  102004. additionalData?: any;
  102005. }
  102006. /**
  102007. * ActionEvent is the event being sent when an action is triggered.
  102008. */
  102009. export class ActionEvent implements IActionEvent {
  102010. /** The mesh or sprite that triggered the action */
  102011. source: any;
  102012. /** The X mouse cursor position at the time of the event */
  102013. pointerX: number;
  102014. /** The Y mouse cursor position at the time of the event */
  102015. pointerY: number;
  102016. /** The mesh that is currently pointed at (can be null) */
  102017. meshUnderPointer: Nullable<AbstractMesh>;
  102018. /** the original (browser) event that triggered the ActionEvent */
  102019. sourceEvent?: any;
  102020. /** additional data for the event */
  102021. additionalData?: any;
  102022. /**
  102023. * Creates a new ActionEvent
  102024. * @param source The mesh or sprite that triggered the action
  102025. * @param pointerX The X mouse cursor position at the time of the event
  102026. * @param pointerY The Y mouse cursor position at the time of the event
  102027. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  102028. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  102029. * @param additionalData additional data for the event
  102030. */
  102031. constructor(
  102032. /** The mesh or sprite that triggered the action */
  102033. source: any,
  102034. /** The X mouse cursor position at the time of the event */
  102035. pointerX: number,
  102036. /** The Y mouse cursor position at the time of the event */
  102037. pointerY: number,
  102038. /** The mesh that is currently pointed at (can be null) */
  102039. meshUnderPointer: Nullable<AbstractMesh>,
  102040. /** the original (browser) event that triggered the ActionEvent */
  102041. sourceEvent?: any,
  102042. /** additional data for the event */
  102043. additionalData?: any);
  102044. /**
  102045. * Helper function to auto-create an ActionEvent from a source mesh.
  102046. * @param source The source mesh that triggered the event
  102047. * @param evt The original (browser) event
  102048. * @param additionalData additional data for the event
  102049. * @returns the new ActionEvent
  102050. */
  102051. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  102052. /**
  102053. * Helper function to auto-create an ActionEvent from a source sprite
  102054. * @param source The source sprite that triggered the event
  102055. * @param scene Scene associated with the sprite
  102056. * @param evt The original (browser) event
  102057. * @param additionalData additional data for the event
  102058. * @returns the new ActionEvent
  102059. */
  102060. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  102061. /**
  102062. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  102063. * @param scene the scene where the event occurred
  102064. * @param evt The original (browser) event
  102065. * @returns the new ActionEvent
  102066. */
  102067. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  102068. /**
  102069. * Helper function to auto-create an ActionEvent from a primitive
  102070. * @param prim defines the target primitive
  102071. * @param pointerPos defines the pointer position
  102072. * @param evt The original (browser) event
  102073. * @param additionalData additional data for the event
  102074. * @returns the new ActionEvent
  102075. */
  102076. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  102077. }
  102078. }
  102079. declare module BABYLON {
  102080. /**
  102081. * Abstract class used to decouple action Manager from scene and meshes.
  102082. * Do not instantiate.
  102083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102084. */
  102085. export abstract class AbstractActionManager implements IDisposable {
  102086. /** Gets the list of active triggers */
  102087. static Triggers: {
  102088. [key: string]: number;
  102089. };
  102090. /** Gets the cursor to use when hovering items */
  102091. hoverCursor: string;
  102092. /** Gets the list of actions */
  102093. actions: IAction[];
  102094. /**
  102095. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  102096. */
  102097. isRecursive: boolean;
  102098. /**
  102099. * Releases all associated resources
  102100. */
  102101. abstract dispose(): void;
  102102. /**
  102103. * Does this action manager has pointer triggers
  102104. */
  102105. abstract get hasPointerTriggers(): boolean;
  102106. /**
  102107. * Does this action manager has pick triggers
  102108. */
  102109. abstract get hasPickTriggers(): boolean;
  102110. /**
  102111. * Process a specific trigger
  102112. * @param trigger defines the trigger to process
  102113. * @param evt defines the event details to be processed
  102114. */
  102115. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102116. /**
  102117. * Does this action manager handles actions of any of the given triggers
  102118. * @param triggers defines the triggers to be tested
  102119. * @return a boolean indicating whether one (or more) of the triggers is handled
  102120. */
  102121. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102122. /**
  102123. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102124. * speed.
  102125. * @param triggerA defines the trigger to be tested
  102126. * @param triggerB defines the trigger to be tested
  102127. * @return a boolean indicating whether one (or more) of the triggers is handled
  102128. */
  102129. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102130. /**
  102131. * Does this action manager handles actions of a given trigger
  102132. * @param trigger defines the trigger to be tested
  102133. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102134. * @return whether the trigger is handled
  102135. */
  102136. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102137. /**
  102138. * Serialize this manager to a JSON object
  102139. * @param name defines the property name to store this manager
  102140. * @returns a JSON representation of this manager
  102141. */
  102142. abstract serialize(name: string): any;
  102143. /**
  102144. * Registers an action to this action manager
  102145. * @param action defines the action to be registered
  102146. * @return the action amended (prepared) after registration
  102147. */
  102148. abstract registerAction(action: IAction): Nullable<IAction>;
  102149. /**
  102150. * Unregisters an action to this action manager
  102151. * @param action defines the action to be unregistered
  102152. * @return a boolean indicating whether the action has been unregistered
  102153. */
  102154. abstract unregisterAction(action: IAction): Boolean;
  102155. /**
  102156. * Does exist one action manager with at least one trigger
  102157. **/
  102158. static get HasTriggers(): boolean;
  102159. /**
  102160. * Does exist one action manager with at least one pick trigger
  102161. **/
  102162. static get HasPickTriggers(): boolean;
  102163. /**
  102164. * Does exist one action manager that handles actions of a given trigger
  102165. * @param trigger defines the trigger to be tested
  102166. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102167. **/
  102168. static HasSpecificTrigger(trigger: number): boolean;
  102169. }
  102170. }
  102171. declare module BABYLON {
  102172. /**
  102173. * Defines how a node can be built from a string name.
  102174. */
  102175. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102176. /**
  102177. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102178. */
  102179. export class Node implements IBehaviorAware<Node> {
  102180. /** @hidden */
  102181. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102182. private static _NodeConstructors;
  102183. /**
  102184. * Add a new node constructor
  102185. * @param type defines the type name of the node to construct
  102186. * @param constructorFunc defines the constructor function
  102187. */
  102188. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102189. /**
  102190. * Returns a node constructor based on type name
  102191. * @param type defines the type name
  102192. * @param name defines the new node name
  102193. * @param scene defines the hosting scene
  102194. * @param options defines optional options to transmit to constructors
  102195. * @returns the new constructor or null
  102196. */
  102197. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102198. /**
  102199. * Gets or sets the name of the node
  102200. */
  102201. name: string;
  102202. /**
  102203. * Gets or sets the id of the node
  102204. */
  102205. id: string;
  102206. /**
  102207. * Gets or sets the unique id of the node
  102208. */
  102209. uniqueId: number;
  102210. /**
  102211. * Gets or sets a string used to store user defined state for the node
  102212. */
  102213. state: string;
  102214. /**
  102215. * Gets or sets an object used to store user defined information for the node
  102216. */
  102217. metadata: any;
  102218. /**
  102219. * For internal use only. Please do not use.
  102220. */
  102221. reservedDataStore: any;
  102222. /**
  102223. * List of inspectable custom properties (used by the Inspector)
  102224. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102225. */
  102226. inspectableCustomProperties: IInspectable[];
  102227. private _doNotSerialize;
  102228. /**
  102229. * Gets or sets a boolean used to define if the node must be serialized
  102230. */
  102231. get doNotSerialize(): boolean;
  102232. set doNotSerialize(value: boolean);
  102233. /** @hidden */
  102234. _isDisposed: boolean;
  102235. /**
  102236. * Gets a list of Animations associated with the node
  102237. */
  102238. animations: Animation[];
  102239. protected _ranges: {
  102240. [name: string]: Nullable<AnimationRange>;
  102241. };
  102242. /**
  102243. * Callback raised when the node is ready to be used
  102244. */
  102245. onReady: Nullable<(node: Node) => void>;
  102246. private _isEnabled;
  102247. private _isParentEnabled;
  102248. private _isReady;
  102249. /** @hidden */
  102250. _currentRenderId: number;
  102251. private _parentUpdateId;
  102252. /** @hidden */
  102253. _childUpdateId: number;
  102254. /** @hidden */
  102255. _waitingParentId: Nullable<string>;
  102256. /** @hidden */
  102257. _scene: Scene;
  102258. /** @hidden */
  102259. _cache: any;
  102260. private _parentNode;
  102261. private _children;
  102262. /** @hidden */
  102263. _worldMatrix: Matrix;
  102264. /** @hidden */
  102265. _worldMatrixDeterminant: number;
  102266. /** @hidden */
  102267. _worldMatrixDeterminantIsDirty: boolean;
  102268. /** @hidden */
  102269. private _sceneRootNodesIndex;
  102270. /**
  102271. * Gets a boolean indicating if the node has been disposed
  102272. * @returns true if the node was disposed
  102273. */
  102274. isDisposed(): boolean;
  102275. /**
  102276. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102277. * @see https://doc.babylonjs.com/how_to/parenting
  102278. */
  102279. set parent(parent: Nullable<Node>);
  102280. get parent(): Nullable<Node>;
  102281. /** @hidden */
  102282. _addToSceneRootNodes(): void;
  102283. /** @hidden */
  102284. _removeFromSceneRootNodes(): void;
  102285. private _animationPropertiesOverride;
  102286. /**
  102287. * Gets or sets the animation properties override
  102288. */
  102289. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102290. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102291. /**
  102292. * Gets a string idenfifying the name of the class
  102293. * @returns "Node" string
  102294. */
  102295. getClassName(): string;
  102296. /** @hidden */
  102297. readonly _isNode: boolean;
  102298. /**
  102299. * An event triggered when the mesh is disposed
  102300. */
  102301. onDisposeObservable: Observable<Node>;
  102302. private _onDisposeObserver;
  102303. /**
  102304. * Sets a callback that will be raised when the node will be disposed
  102305. */
  102306. set onDispose(callback: () => void);
  102307. /**
  102308. * Creates a new Node
  102309. * @param name the name and id to be given to this node
  102310. * @param scene the scene this node will be added to
  102311. */
  102312. constructor(name: string, scene?: Nullable<Scene>);
  102313. /**
  102314. * Gets the scene of the node
  102315. * @returns a scene
  102316. */
  102317. getScene(): Scene;
  102318. /**
  102319. * Gets the engine of the node
  102320. * @returns a Engine
  102321. */
  102322. getEngine(): Engine;
  102323. private _behaviors;
  102324. /**
  102325. * Attach a behavior to the node
  102326. * @see http://doc.babylonjs.com/features/behaviour
  102327. * @param behavior defines the behavior to attach
  102328. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102329. * @returns the current Node
  102330. */
  102331. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102332. /**
  102333. * Remove an attached behavior
  102334. * @see http://doc.babylonjs.com/features/behaviour
  102335. * @param behavior defines the behavior to attach
  102336. * @returns the current Node
  102337. */
  102338. removeBehavior(behavior: Behavior<Node>): Node;
  102339. /**
  102340. * Gets the list of attached behaviors
  102341. * @see http://doc.babylonjs.com/features/behaviour
  102342. */
  102343. get behaviors(): Behavior<Node>[];
  102344. /**
  102345. * Gets an attached behavior by name
  102346. * @param name defines the name of the behavior to look for
  102347. * @see http://doc.babylonjs.com/features/behaviour
  102348. * @returns null if behavior was not found else the requested behavior
  102349. */
  102350. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102351. /**
  102352. * Returns the latest update of the World matrix
  102353. * @returns a Matrix
  102354. */
  102355. getWorldMatrix(): Matrix;
  102356. /** @hidden */
  102357. _getWorldMatrixDeterminant(): number;
  102358. /**
  102359. * Returns directly the latest state of the mesh World matrix.
  102360. * A Matrix is returned.
  102361. */
  102362. get worldMatrixFromCache(): Matrix;
  102363. /** @hidden */
  102364. _initCache(): void;
  102365. /** @hidden */
  102366. updateCache(force?: boolean): void;
  102367. /** @hidden */
  102368. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102369. /** @hidden */
  102370. _updateCache(ignoreParentClass?: boolean): void;
  102371. /** @hidden */
  102372. _isSynchronized(): boolean;
  102373. /** @hidden */
  102374. _markSyncedWithParent(): void;
  102375. /** @hidden */
  102376. isSynchronizedWithParent(): boolean;
  102377. /** @hidden */
  102378. isSynchronized(): boolean;
  102379. /**
  102380. * Is this node ready to be used/rendered
  102381. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102382. * @return true if the node is ready
  102383. */
  102384. isReady(completeCheck?: boolean): boolean;
  102385. /**
  102386. * Is this node enabled?
  102387. * 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
  102388. * @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
  102389. * @return whether this node (and its parent) is enabled
  102390. */
  102391. isEnabled(checkAncestors?: boolean): boolean;
  102392. /** @hidden */
  102393. protected _syncParentEnabledState(): void;
  102394. /**
  102395. * Set the enabled state of this node
  102396. * @param value defines the new enabled state
  102397. */
  102398. setEnabled(value: boolean): void;
  102399. /**
  102400. * Is this node a descendant of the given node?
  102401. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102402. * @param ancestor defines the parent node to inspect
  102403. * @returns a boolean indicating if this node is a descendant of the given node
  102404. */
  102405. isDescendantOf(ancestor: Node): boolean;
  102406. /** @hidden */
  102407. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102408. /**
  102409. * Will return all nodes that have this node as ascendant
  102410. * @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
  102411. * @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
  102412. * @return all children nodes of all types
  102413. */
  102414. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102415. /**
  102416. * Get all child-meshes of this node
  102417. * @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)
  102418. * @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
  102419. * @returns an array of AbstractMesh
  102420. */
  102421. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102422. /**
  102423. * Get all direct children of this node
  102424. * @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
  102425. * @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)
  102426. * @returns an array of Node
  102427. */
  102428. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102429. /** @hidden */
  102430. _setReady(state: boolean): void;
  102431. /**
  102432. * Get an animation by name
  102433. * @param name defines the name of the animation to look for
  102434. * @returns null if not found else the requested animation
  102435. */
  102436. getAnimationByName(name: string): Nullable<Animation>;
  102437. /**
  102438. * Creates an animation range for this node
  102439. * @param name defines the name of the range
  102440. * @param from defines the starting key
  102441. * @param to defines the end key
  102442. */
  102443. createAnimationRange(name: string, from: number, to: number): void;
  102444. /**
  102445. * Delete a specific animation range
  102446. * @param name defines the name of the range to delete
  102447. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102448. */
  102449. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102450. /**
  102451. * Get an animation range by name
  102452. * @param name defines the name of the animation range to look for
  102453. * @returns null if not found else the requested animation range
  102454. */
  102455. getAnimationRange(name: string): Nullable<AnimationRange>;
  102456. /**
  102457. * Gets the list of all animation ranges defined on this node
  102458. * @returns an array
  102459. */
  102460. getAnimationRanges(): Nullable<AnimationRange>[];
  102461. /**
  102462. * Will start the animation sequence
  102463. * @param name defines the range frames for animation sequence
  102464. * @param loop defines if the animation should loop (false by default)
  102465. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102466. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102467. * @returns the object created for this animation. If range does not exist, it will return null
  102468. */
  102469. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102470. /**
  102471. * Serialize animation ranges into a JSON compatible object
  102472. * @returns serialization object
  102473. */
  102474. serializeAnimationRanges(): any;
  102475. /**
  102476. * Computes the world matrix of the node
  102477. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102478. * @returns the world matrix
  102479. */
  102480. computeWorldMatrix(force?: boolean): Matrix;
  102481. /**
  102482. * Releases resources associated with this node.
  102483. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102484. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102485. */
  102486. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102487. /**
  102488. * Parse animation range data from a serialization object and store them into a given node
  102489. * @param node defines where to store the animation ranges
  102490. * @param parsedNode defines the serialization object to read data from
  102491. * @param scene defines the hosting scene
  102492. */
  102493. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102494. /**
  102495. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102496. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102497. * @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
  102498. * @returns the new bounding vectors
  102499. */
  102500. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102501. min: Vector3;
  102502. max: Vector3;
  102503. };
  102504. }
  102505. }
  102506. declare module BABYLON {
  102507. /**
  102508. * @hidden
  102509. */
  102510. export class _IAnimationState {
  102511. key: number;
  102512. repeatCount: number;
  102513. workValue?: any;
  102514. loopMode?: number;
  102515. offsetValue?: any;
  102516. highLimitValue?: any;
  102517. }
  102518. /**
  102519. * Class used to store any kind of animation
  102520. */
  102521. export class Animation {
  102522. /**Name of the animation */
  102523. name: string;
  102524. /**Property to animate */
  102525. targetProperty: string;
  102526. /**The frames per second of the animation */
  102527. framePerSecond: number;
  102528. /**The data type of the animation */
  102529. dataType: number;
  102530. /**The loop mode of the animation */
  102531. loopMode?: number | undefined;
  102532. /**Specifies if blending should be enabled */
  102533. enableBlending?: boolean | undefined;
  102534. /**
  102535. * Use matrix interpolation instead of using direct key value when animating matrices
  102536. */
  102537. static AllowMatricesInterpolation: boolean;
  102538. /**
  102539. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102540. */
  102541. static AllowMatrixDecomposeForInterpolation: boolean;
  102542. /**
  102543. * Stores the key frames of the animation
  102544. */
  102545. private _keys;
  102546. /**
  102547. * Stores the easing function of the animation
  102548. */
  102549. private _easingFunction;
  102550. /**
  102551. * @hidden Internal use only
  102552. */
  102553. _runtimeAnimations: RuntimeAnimation[];
  102554. /**
  102555. * The set of event that will be linked to this animation
  102556. */
  102557. private _events;
  102558. /**
  102559. * Stores an array of target property paths
  102560. */
  102561. targetPropertyPath: string[];
  102562. /**
  102563. * Stores the blending speed of the animation
  102564. */
  102565. blendingSpeed: number;
  102566. /**
  102567. * Stores the animation ranges for the animation
  102568. */
  102569. private _ranges;
  102570. /**
  102571. * @hidden Internal use
  102572. */
  102573. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102574. /**
  102575. * Sets up an animation
  102576. * @param property The property to animate
  102577. * @param animationType The animation type to apply
  102578. * @param framePerSecond The frames per second of the animation
  102579. * @param easingFunction The easing function used in the animation
  102580. * @returns The created animation
  102581. */
  102582. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102583. /**
  102584. * Create and start an animation on a node
  102585. * @param name defines the name of the global animation that will be run on all nodes
  102586. * @param node defines the root node where the animation will take place
  102587. * @param targetProperty defines property to animate
  102588. * @param framePerSecond defines the number of frame per second yo use
  102589. * @param totalFrame defines the number of frames in total
  102590. * @param from defines the initial value
  102591. * @param to defines the final value
  102592. * @param loopMode defines which loop mode you want to use (off by default)
  102593. * @param easingFunction defines the easing function to use (linear by default)
  102594. * @param onAnimationEnd defines the callback to call when animation end
  102595. * @returns the animatable created for this animation
  102596. */
  102597. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102598. /**
  102599. * Create and start an animation on a node and its descendants
  102600. * @param name defines the name of the global animation that will be run on all nodes
  102601. * @param node defines the root node where the animation will take place
  102602. * @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
  102603. * @param targetProperty defines property to animate
  102604. * @param framePerSecond defines the number of frame per second to use
  102605. * @param totalFrame defines the number of frames in total
  102606. * @param from defines the initial value
  102607. * @param to defines the final value
  102608. * @param loopMode defines which loop mode you want to use (off by default)
  102609. * @param easingFunction defines the easing function to use (linear by default)
  102610. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102611. * @returns the list of animatables created for all nodes
  102612. * @example https://www.babylonjs-playground.com/#MH0VLI
  102613. */
  102614. 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[]>;
  102615. /**
  102616. * Creates a new animation, merges it with the existing animations and starts it
  102617. * @param name Name of the animation
  102618. * @param node Node which contains the scene that begins the animations
  102619. * @param targetProperty Specifies which property to animate
  102620. * @param framePerSecond The frames per second of the animation
  102621. * @param totalFrame The total number of frames
  102622. * @param from The frame at the beginning of the animation
  102623. * @param to The frame at the end of the animation
  102624. * @param loopMode Specifies the loop mode of the animation
  102625. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102626. * @param onAnimationEnd Callback to run once the animation is complete
  102627. * @returns Nullable animation
  102628. */
  102629. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102630. /**
  102631. * Transition property of an host to the target Value
  102632. * @param property The property to transition
  102633. * @param targetValue The target Value of the property
  102634. * @param host The object where the property to animate belongs
  102635. * @param scene Scene used to run the animation
  102636. * @param frameRate Framerate (in frame/s) to use
  102637. * @param transition The transition type we want to use
  102638. * @param duration The duration of the animation, in milliseconds
  102639. * @param onAnimationEnd Callback trigger at the end of the animation
  102640. * @returns Nullable animation
  102641. */
  102642. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102643. /**
  102644. * Return the array of runtime animations currently using this animation
  102645. */
  102646. get runtimeAnimations(): RuntimeAnimation[];
  102647. /**
  102648. * Specifies if any of the runtime animations are currently running
  102649. */
  102650. get hasRunningRuntimeAnimations(): boolean;
  102651. /**
  102652. * Initializes the animation
  102653. * @param name Name of the animation
  102654. * @param targetProperty Property to animate
  102655. * @param framePerSecond The frames per second of the animation
  102656. * @param dataType The data type of the animation
  102657. * @param loopMode The loop mode of the animation
  102658. * @param enableBlending Specifies if blending should be enabled
  102659. */
  102660. constructor(
  102661. /**Name of the animation */
  102662. name: string,
  102663. /**Property to animate */
  102664. targetProperty: string,
  102665. /**The frames per second of the animation */
  102666. framePerSecond: number,
  102667. /**The data type of the animation */
  102668. dataType: number,
  102669. /**The loop mode of the animation */
  102670. loopMode?: number | undefined,
  102671. /**Specifies if blending should be enabled */
  102672. enableBlending?: boolean | undefined);
  102673. /**
  102674. * Converts the animation to a string
  102675. * @param fullDetails support for multiple levels of logging within scene loading
  102676. * @returns String form of the animation
  102677. */
  102678. toString(fullDetails?: boolean): string;
  102679. /**
  102680. * Add an event to this animation
  102681. * @param event Event to add
  102682. */
  102683. addEvent(event: AnimationEvent): void;
  102684. /**
  102685. * Remove all events found at the given frame
  102686. * @param frame The frame to remove events from
  102687. */
  102688. removeEvents(frame: number): void;
  102689. /**
  102690. * Retrieves all the events from the animation
  102691. * @returns Events from the animation
  102692. */
  102693. getEvents(): AnimationEvent[];
  102694. /**
  102695. * Creates an animation range
  102696. * @param name Name of the animation range
  102697. * @param from Starting frame of the animation range
  102698. * @param to Ending frame of the animation
  102699. */
  102700. createRange(name: string, from: number, to: number): void;
  102701. /**
  102702. * Deletes an animation range by name
  102703. * @param name Name of the animation range to delete
  102704. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102705. */
  102706. deleteRange(name: string, deleteFrames?: boolean): void;
  102707. /**
  102708. * Gets the animation range by name, or null if not defined
  102709. * @param name Name of the animation range
  102710. * @returns Nullable animation range
  102711. */
  102712. getRange(name: string): Nullable<AnimationRange>;
  102713. /**
  102714. * Gets the key frames from the animation
  102715. * @returns The key frames of the animation
  102716. */
  102717. getKeys(): Array<IAnimationKey>;
  102718. /**
  102719. * Gets the highest frame rate of the animation
  102720. * @returns Highest frame rate of the animation
  102721. */
  102722. getHighestFrame(): number;
  102723. /**
  102724. * Gets the easing function of the animation
  102725. * @returns Easing function of the animation
  102726. */
  102727. getEasingFunction(): IEasingFunction;
  102728. /**
  102729. * Sets the easing function of the animation
  102730. * @param easingFunction A custom mathematical formula for animation
  102731. */
  102732. setEasingFunction(easingFunction: EasingFunction): void;
  102733. /**
  102734. * Interpolates a scalar linearly
  102735. * @param startValue Start value of the animation curve
  102736. * @param endValue End value of the animation curve
  102737. * @param gradient Scalar amount to interpolate
  102738. * @returns Interpolated scalar value
  102739. */
  102740. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102741. /**
  102742. * Interpolates a scalar cubically
  102743. * @param startValue Start value of the animation curve
  102744. * @param outTangent End tangent of the animation
  102745. * @param endValue End value of the animation curve
  102746. * @param inTangent Start tangent of the animation curve
  102747. * @param gradient Scalar amount to interpolate
  102748. * @returns Interpolated scalar value
  102749. */
  102750. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102751. /**
  102752. * Interpolates a quaternion using a spherical linear interpolation
  102753. * @param startValue Start value of the animation curve
  102754. * @param endValue End value of the animation curve
  102755. * @param gradient Scalar amount to interpolate
  102756. * @returns Interpolated quaternion value
  102757. */
  102758. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102759. /**
  102760. * Interpolates a quaternion cubically
  102761. * @param startValue Start value of the animation curve
  102762. * @param outTangent End tangent of the animation curve
  102763. * @param endValue End value of the animation curve
  102764. * @param inTangent Start tangent of the animation curve
  102765. * @param gradient Scalar amount to interpolate
  102766. * @returns Interpolated quaternion value
  102767. */
  102768. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102769. /**
  102770. * Interpolates a Vector3 linearl
  102771. * @param startValue Start value of the animation curve
  102772. * @param endValue End value of the animation curve
  102773. * @param gradient Scalar amount to interpolate
  102774. * @returns Interpolated scalar value
  102775. */
  102776. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102777. /**
  102778. * Interpolates a Vector3 cubically
  102779. * @param startValue Start value of the animation curve
  102780. * @param outTangent End tangent of the animation
  102781. * @param endValue End value of the animation curve
  102782. * @param inTangent Start tangent of the animation curve
  102783. * @param gradient Scalar amount to interpolate
  102784. * @returns InterpolatedVector3 value
  102785. */
  102786. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102787. /**
  102788. * Interpolates a Vector2 linearly
  102789. * @param startValue Start value of the animation curve
  102790. * @param endValue End value of the animation curve
  102791. * @param gradient Scalar amount to interpolate
  102792. * @returns Interpolated Vector2 value
  102793. */
  102794. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102795. /**
  102796. * Interpolates a Vector2 cubically
  102797. * @param startValue Start value of the animation curve
  102798. * @param outTangent End tangent of the animation
  102799. * @param endValue End value of the animation curve
  102800. * @param inTangent Start tangent of the animation curve
  102801. * @param gradient Scalar amount to interpolate
  102802. * @returns Interpolated Vector2 value
  102803. */
  102804. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102805. /**
  102806. * Interpolates a size linearly
  102807. * @param startValue Start value of the animation curve
  102808. * @param endValue End value of the animation curve
  102809. * @param gradient Scalar amount to interpolate
  102810. * @returns Interpolated Size value
  102811. */
  102812. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102813. /**
  102814. * Interpolates a Color3 linearly
  102815. * @param startValue Start value of the animation curve
  102816. * @param endValue End value of the animation curve
  102817. * @param gradient Scalar amount to interpolate
  102818. * @returns Interpolated Color3 value
  102819. */
  102820. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102821. /**
  102822. * Interpolates a Color4 linearly
  102823. * @param startValue Start value of the animation curve
  102824. * @param endValue End value of the animation curve
  102825. * @param gradient Scalar amount to interpolate
  102826. * @returns Interpolated Color3 value
  102827. */
  102828. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102829. /**
  102830. * @hidden Internal use only
  102831. */
  102832. _getKeyValue(value: any): any;
  102833. /**
  102834. * @hidden Internal use only
  102835. */
  102836. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102837. /**
  102838. * Defines the function to use to interpolate matrices
  102839. * @param startValue defines the start matrix
  102840. * @param endValue defines the end matrix
  102841. * @param gradient defines the gradient between both matrices
  102842. * @param result defines an optional target matrix where to store the interpolation
  102843. * @returns the interpolated matrix
  102844. */
  102845. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102846. /**
  102847. * Makes a copy of the animation
  102848. * @returns Cloned animation
  102849. */
  102850. clone(): Animation;
  102851. /**
  102852. * Sets the key frames of the animation
  102853. * @param values The animation key frames to set
  102854. */
  102855. setKeys(values: Array<IAnimationKey>): void;
  102856. /**
  102857. * Serializes the animation to an object
  102858. * @returns Serialized object
  102859. */
  102860. serialize(): any;
  102861. /**
  102862. * Float animation type
  102863. */
  102864. static readonly ANIMATIONTYPE_FLOAT: number;
  102865. /**
  102866. * Vector3 animation type
  102867. */
  102868. static readonly ANIMATIONTYPE_VECTOR3: number;
  102869. /**
  102870. * Quaternion animation type
  102871. */
  102872. static readonly ANIMATIONTYPE_QUATERNION: number;
  102873. /**
  102874. * Matrix animation type
  102875. */
  102876. static readonly ANIMATIONTYPE_MATRIX: number;
  102877. /**
  102878. * Color3 animation type
  102879. */
  102880. static readonly ANIMATIONTYPE_COLOR3: number;
  102881. /**
  102882. * Color3 animation type
  102883. */
  102884. static readonly ANIMATIONTYPE_COLOR4: number;
  102885. /**
  102886. * Vector2 animation type
  102887. */
  102888. static readonly ANIMATIONTYPE_VECTOR2: number;
  102889. /**
  102890. * Size animation type
  102891. */
  102892. static readonly ANIMATIONTYPE_SIZE: number;
  102893. /**
  102894. * Relative Loop Mode
  102895. */
  102896. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102897. /**
  102898. * Cycle Loop Mode
  102899. */
  102900. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102901. /**
  102902. * Constant Loop Mode
  102903. */
  102904. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102905. /** @hidden */
  102906. static _UniversalLerp(left: any, right: any, amount: number): any;
  102907. /**
  102908. * Parses an animation object and creates an animation
  102909. * @param parsedAnimation Parsed animation object
  102910. * @returns Animation object
  102911. */
  102912. static Parse(parsedAnimation: any): Animation;
  102913. /**
  102914. * Appends the serialized animations from the source animations
  102915. * @param source Source containing the animations
  102916. * @param destination Target to store the animations
  102917. */
  102918. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102919. }
  102920. }
  102921. declare module BABYLON {
  102922. /**
  102923. * Interface containing an array of animations
  102924. */
  102925. export interface IAnimatable {
  102926. /**
  102927. * Array of animations
  102928. */
  102929. animations: Nullable<Array<Animation>>;
  102930. }
  102931. }
  102932. declare module BABYLON {
  102933. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102934. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102935. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102936. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102937. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102938. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102939. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102940. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102941. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102942. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102943. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102944. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102945. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102946. /**
  102947. * Decorator used to define property that can be serialized as reference to a camera
  102948. * @param sourceName defines the name of the property to decorate
  102949. */
  102950. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102951. /**
  102952. * Class used to help serialization objects
  102953. */
  102954. export class SerializationHelper {
  102955. /** @hidden */
  102956. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102957. /** @hidden */
  102958. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102959. /** @hidden */
  102960. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102961. /** @hidden */
  102962. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102963. /**
  102964. * Appends the serialized animations from the source animations
  102965. * @param source Source containing the animations
  102966. * @param destination Target to store the animations
  102967. */
  102968. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102969. /**
  102970. * Static function used to serialized a specific entity
  102971. * @param entity defines the entity to serialize
  102972. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102973. * @returns a JSON compatible object representing the serialization of the entity
  102974. */
  102975. static Serialize<T>(entity: T, serializationObject?: any): any;
  102976. /**
  102977. * Creates a new entity from a serialization data object
  102978. * @param creationFunction defines a function used to instanciated the new entity
  102979. * @param source defines the source serialization data
  102980. * @param scene defines the hosting scene
  102981. * @param rootUrl defines the root url for resources
  102982. * @returns a new entity
  102983. */
  102984. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102985. /**
  102986. * Clones an object
  102987. * @param creationFunction defines the function used to instanciate the new object
  102988. * @param source defines the source object
  102989. * @returns the cloned object
  102990. */
  102991. static Clone<T>(creationFunction: () => T, source: T): T;
  102992. /**
  102993. * Instanciates a new object based on a source one (some data will be shared between both object)
  102994. * @param creationFunction defines the function used to instanciate the new object
  102995. * @param source defines the source object
  102996. * @returns the new object
  102997. */
  102998. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102999. }
  103000. }
  103001. declare module BABYLON {
  103002. /**
  103003. * Class used to manipulate GUIDs
  103004. */
  103005. export class GUID {
  103006. /**
  103007. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103008. * Be aware Math.random() could cause collisions, but:
  103009. * "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"
  103010. * @returns a pseudo random id
  103011. */
  103012. static RandomId(): string;
  103013. }
  103014. }
  103015. declare module BABYLON {
  103016. /**
  103017. * Base class of all the textures in babylon.
  103018. * It groups all the common properties the materials, post process, lights... might need
  103019. * in order to make a correct use of the texture.
  103020. */
  103021. export class BaseTexture implements IAnimatable {
  103022. /**
  103023. * Default anisotropic filtering level for the application.
  103024. * It is set to 4 as a good tradeoff between perf and quality.
  103025. */
  103026. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  103027. /**
  103028. * Gets or sets the unique id of the texture
  103029. */
  103030. uniqueId: number;
  103031. /**
  103032. * Define the name of the texture.
  103033. */
  103034. name: string;
  103035. /**
  103036. * Gets or sets an object used to store user defined information.
  103037. */
  103038. metadata: any;
  103039. /**
  103040. * For internal use only. Please do not use.
  103041. */
  103042. reservedDataStore: any;
  103043. private _hasAlpha;
  103044. /**
  103045. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  103046. */
  103047. set hasAlpha(value: boolean);
  103048. get hasAlpha(): boolean;
  103049. /**
  103050. * Defines if the alpha value should be determined via the rgb values.
  103051. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  103052. */
  103053. getAlphaFromRGB: boolean;
  103054. /**
  103055. * Intensity or strength of the texture.
  103056. * It is commonly used by materials to fine tune the intensity of the texture
  103057. */
  103058. level: number;
  103059. /**
  103060. * Define the UV chanel to use starting from 0 and defaulting to 0.
  103061. * This is part of the texture as textures usually maps to one uv set.
  103062. */
  103063. coordinatesIndex: number;
  103064. private _coordinatesMode;
  103065. /**
  103066. * How a texture is mapped.
  103067. *
  103068. * | Value | Type | Description |
  103069. * | ----- | ----------------------------------- | ----------- |
  103070. * | 0 | EXPLICIT_MODE | |
  103071. * | 1 | SPHERICAL_MODE | |
  103072. * | 2 | PLANAR_MODE | |
  103073. * | 3 | CUBIC_MODE | |
  103074. * | 4 | PROJECTION_MODE | |
  103075. * | 5 | SKYBOX_MODE | |
  103076. * | 6 | INVCUBIC_MODE | |
  103077. * | 7 | EQUIRECTANGULAR_MODE | |
  103078. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  103079. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  103080. */
  103081. set coordinatesMode(value: number);
  103082. get coordinatesMode(): number;
  103083. /**
  103084. * | Value | Type | Description |
  103085. * | ----- | ------------------ | ----------- |
  103086. * | 0 | CLAMP_ADDRESSMODE | |
  103087. * | 1 | WRAP_ADDRESSMODE | |
  103088. * | 2 | MIRROR_ADDRESSMODE | |
  103089. */
  103090. wrapU: number;
  103091. /**
  103092. * | Value | Type | Description |
  103093. * | ----- | ------------------ | ----------- |
  103094. * | 0 | CLAMP_ADDRESSMODE | |
  103095. * | 1 | WRAP_ADDRESSMODE | |
  103096. * | 2 | MIRROR_ADDRESSMODE | |
  103097. */
  103098. wrapV: number;
  103099. /**
  103100. * | Value | Type | Description |
  103101. * | ----- | ------------------ | ----------- |
  103102. * | 0 | CLAMP_ADDRESSMODE | |
  103103. * | 1 | WRAP_ADDRESSMODE | |
  103104. * | 2 | MIRROR_ADDRESSMODE | |
  103105. */
  103106. wrapR: number;
  103107. /**
  103108. * With compliant hardware and browser (supporting anisotropic filtering)
  103109. * this defines the level of anisotropic filtering in the texture.
  103110. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  103111. */
  103112. anisotropicFilteringLevel: number;
  103113. /**
  103114. * Define if the texture is a cube texture or if false a 2d texture.
  103115. */
  103116. get isCube(): boolean;
  103117. set isCube(value: boolean);
  103118. /**
  103119. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103120. */
  103121. get is3D(): boolean;
  103122. set is3D(value: boolean);
  103123. /**
  103124. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103125. */
  103126. get is2DArray(): boolean;
  103127. set is2DArray(value: boolean);
  103128. /**
  103129. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103130. * HDR texture are usually stored in linear space.
  103131. * This only impacts the PBR and Background materials
  103132. */
  103133. gammaSpace: boolean;
  103134. /**
  103135. * Gets or sets whether or not the texture contains RGBD data.
  103136. */
  103137. get isRGBD(): boolean;
  103138. set isRGBD(value: boolean);
  103139. /**
  103140. * Is Z inverted in the texture (useful in a cube texture).
  103141. */
  103142. invertZ: boolean;
  103143. /**
  103144. * Are mip maps generated for this texture or not.
  103145. */
  103146. get noMipmap(): boolean;
  103147. /**
  103148. * @hidden
  103149. */
  103150. lodLevelInAlpha: boolean;
  103151. /**
  103152. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103153. */
  103154. get lodGenerationOffset(): number;
  103155. set lodGenerationOffset(value: number);
  103156. /**
  103157. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103158. */
  103159. get lodGenerationScale(): number;
  103160. set lodGenerationScale(value: number);
  103161. /**
  103162. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103163. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103164. * average roughness values.
  103165. */
  103166. get linearSpecularLOD(): boolean;
  103167. set linearSpecularLOD(value: boolean);
  103168. /**
  103169. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103170. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103171. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103172. */
  103173. get irradianceTexture(): Nullable<BaseTexture>;
  103174. set irradianceTexture(value: Nullable<BaseTexture>);
  103175. /**
  103176. * Define if the texture is a render target.
  103177. */
  103178. isRenderTarget: boolean;
  103179. /**
  103180. * Define the unique id of the texture in the scene.
  103181. */
  103182. get uid(): string;
  103183. /**
  103184. * Return a string representation of the texture.
  103185. * @returns the texture as a string
  103186. */
  103187. toString(): string;
  103188. /**
  103189. * Get the class name of the texture.
  103190. * @returns "BaseTexture"
  103191. */
  103192. getClassName(): string;
  103193. /**
  103194. * Define the list of animation attached to the texture.
  103195. */
  103196. animations: Animation[];
  103197. /**
  103198. * An event triggered when the texture is disposed.
  103199. */
  103200. onDisposeObservable: Observable<BaseTexture>;
  103201. private _onDisposeObserver;
  103202. /**
  103203. * Callback triggered when the texture has been disposed.
  103204. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103205. */
  103206. set onDispose(callback: () => void);
  103207. /**
  103208. * Define the current state of the loading sequence when in delayed load mode.
  103209. */
  103210. delayLoadState: number;
  103211. private _scene;
  103212. /** @hidden */
  103213. _texture: Nullable<InternalTexture>;
  103214. private _uid;
  103215. /**
  103216. * Define if the texture is preventinga material to render or not.
  103217. * If not and the texture is not ready, the engine will use a default black texture instead.
  103218. */
  103219. get isBlocking(): boolean;
  103220. /**
  103221. * Instantiates a new BaseTexture.
  103222. * Base class of all the textures in babylon.
  103223. * It groups all the common properties the materials, post process, lights... might need
  103224. * in order to make a correct use of the texture.
  103225. * @param scene Define the scene the texture blongs to
  103226. */
  103227. constructor(scene: Nullable<Scene>);
  103228. /**
  103229. * Get the scene the texture belongs to.
  103230. * @returns the scene or null if undefined
  103231. */
  103232. getScene(): Nullable<Scene>;
  103233. /**
  103234. * Get the texture transform matrix used to offset tile the texture for istance.
  103235. * @returns the transformation matrix
  103236. */
  103237. getTextureMatrix(): Matrix;
  103238. /**
  103239. * Get the texture reflection matrix used to rotate/transform the reflection.
  103240. * @returns the reflection matrix
  103241. */
  103242. getReflectionTextureMatrix(): Matrix;
  103243. /**
  103244. * Get the underlying lower level texture from Babylon.
  103245. * @returns the insternal texture
  103246. */
  103247. getInternalTexture(): Nullable<InternalTexture>;
  103248. /**
  103249. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103250. * @returns true if ready or not blocking
  103251. */
  103252. isReadyOrNotBlocking(): boolean;
  103253. /**
  103254. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103255. * @returns true if fully ready
  103256. */
  103257. isReady(): boolean;
  103258. private _cachedSize;
  103259. /**
  103260. * Get the size of the texture.
  103261. * @returns the texture size.
  103262. */
  103263. getSize(): ISize;
  103264. /**
  103265. * Get the base size of the texture.
  103266. * It can be different from the size if the texture has been resized for POT for instance
  103267. * @returns the base size
  103268. */
  103269. getBaseSize(): ISize;
  103270. /**
  103271. * Update the sampling mode of the texture.
  103272. * Default is Trilinear mode.
  103273. *
  103274. * | Value | Type | Description |
  103275. * | ----- | ------------------ | ----------- |
  103276. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103277. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103278. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103279. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103280. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103281. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103282. * | 7 | NEAREST_LINEAR | |
  103283. * | 8 | NEAREST_NEAREST | |
  103284. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103285. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103286. * | 11 | LINEAR_LINEAR | |
  103287. * | 12 | LINEAR_NEAREST | |
  103288. *
  103289. * > _mag_: magnification filter (close to the viewer)
  103290. * > _min_: minification filter (far from the viewer)
  103291. * > _mip_: filter used between mip map levels
  103292. *@param samplingMode Define the new sampling mode of the texture
  103293. */
  103294. updateSamplingMode(samplingMode: number): void;
  103295. /**
  103296. * Scales the texture if is `canRescale()`
  103297. * @param ratio the resize factor we want to use to rescale
  103298. */
  103299. scale(ratio: number): void;
  103300. /**
  103301. * Get if the texture can rescale.
  103302. */
  103303. get canRescale(): boolean;
  103304. /** @hidden */
  103305. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103306. /** @hidden */
  103307. _rebuild(): void;
  103308. /**
  103309. * Triggers the load sequence in delayed load mode.
  103310. */
  103311. delayLoad(): void;
  103312. /**
  103313. * Clones the texture.
  103314. * @returns the cloned texture
  103315. */
  103316. clone(): Nullable<BaseTexture>;
  103317. /**
  103318. * Get the texture underlying type (INT, FLOAT...)
  103319. */
  103320. get textureType(): number;
  103321. /**
  103322. * Get the texture underlying format (RGB, RGBA...)
  103323. */
  103324. get textureFormat(): number;
  103325. /**
  103326. * Indicates that textures need to be re-calculated for all materials
  103327. */
  103328. protected _markAllSubMeshesAsTexturesDirty(): void;
  103329. /**
  103330. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103331. * This will returns an RGBA array buffer containing either in values (0-255) or
  103332. * float values (0-1) depending of the underlying buffer type.
  103333. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103334. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103335. * @param buffer defines a user defined buffer to fill with data (can be null)
  103336. * @returns The Array buffer containing the pixels data.
  103337. */
  103338. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103339. /**
  103340. * Release and destroy the underlying lower level texture aka internalTexture.
  103341. */
  103342. releaseInternalTexture(): void;
  103343. /** @hidden */
  103344. get _lodTextureHigh(): Nullable<BaseTexture>;
  103345. /** @hidden */
  103346. get _lodTextureMid(): Nullable<BaseTexture>;
  103347. /** @hidden */
  103348. get _lodTextureLow(): Nullable<BaseTexture>;
  103349. /**
  103350. * Dispose the texture and release its associated resources.
  103351. */
  103352. dispose(): void;
  103353. /**
  103354. * Serialize the texture into a JSON representation that can be parsed later on.
  103355. * @returns the JSON representation of the texture
  103356. */
  103357. serialize(): any;
  103358. /**
  103359. * Helper function to be called back once a list of texture contains only ready textures.
  103360. * @param textures Define the list of textures to wait for
  103361. * @param callback Define the callback triggered once the entire list will be ready
  103362. */
  103363. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103364. }
  103365. }
  103366. declare module BABYLON {
  103367. /**
  103368. * Options to be used when creating an effect.
  103369. */
  103370. export interface IEffectCreationOptions {
  103371. /**
  103372. * Atrributes that will be used in the shader.
  103373. */
  103374. attributes: string[];
  103375. /**
  103376. * Uniform varible names that will be set in the shader.
  103377. */
  103378. uniformsNames: string[];
  103379. /**
  103380. * Uniform buffer variable names that will be set in the shader.
  103381. */
  103382. uniformBuffersNames: string[];
  103383. /**
  103384. * Sampler texture variable names that will be set in the shader.
  103385. */
  103386. samplers: string[];
  103387. /**
  103388. * Define statements that will be set in the shader.
  103389. */
  103390. defines: any;
  103391. /**
  103392. * Possible fallbacks for this effect to improve performance when needed.
  103393. */
  103394. fallbacks: Nullable<IEffectFallbacks>;
  103395. /**
  103396. * Callback that will be called when the shader is compiled.
  103397. */
  103398. onCompiled: Nullable<(effect: Effect) => void>;
  103399. /**
  103400. * Callback that will be called if an error occurs during shader compilation.
  103401. */
  103402. onError: Nullable<(effect: Effect, errors: string) => void>;
  103403. /**
  103404. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103405. */
  103406. indexParameters?: any;
  103407. /**
  103408. * Max number of lights that can be used in the shader.
  103409. */
  103410. maxSimultaneousLights?: number;
  103411. /**
  103412. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103413. */
  103414. transformFeedbackVaryings?: Nullable<string[]>;
  103415. }
  103416. /**
  103417. * Effect containing vertex and fragment shader that can be executed on an object.
  103418. */
  103419. export class Effect implements IDisposable {
  103420. /**
  103421. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103422. */
  103423. static ShadersRepository: string;
  103424. /**
  103425. * Enable logging of the shader code when a compilation error occurs
  103426. */
  103427. static LogShaderCodeOnCompilationError: boolean;
  103428. /**
  103429. * Name of the effect.
  103430. */
  103431. name: any;
  103432. /**
  103433. * String container all the define statements that should be set on the shader.
  103434. */
  103435. defines: string;
  103436. /**
  103437. * Callback that will be called when the shader is compiled.
  103438. */
  103439. onCompiled: Nullable<(effect: Effect) => void>;
  103440. /**
  103441. * Callback that will be called if an error occurs during shader compilation.
  103442. */
  103443. onError: Nullable<(effect: Effect, errors: string) => void>;
  103444. /**
  103445. * Callback that will be called when effect is bound.
  103446. */
  103447. onBind: Nullable<(effect: Effect) => void>;
  103448. /**
  103449. * Unique ID of the effect.
  103450. */
  103451. uniqueId: number;
  103452. /**
  103453. * Observable that will be called when the shader is compiled.
  103454. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103455. */
  103456. onCompileObservable: Observable<Effect>;
  103457. /**
  103458. * Observable that will be called if an error occurs during shader compilation.
  103459. */
  103460. onErrorObservable: Observable<Effect>;
  103461. /** @hidden */
  103462. _onBindObservable: Nullable<Observable<Effect>>;
  103463. /**
  103464. * @hidden
  103465. * Specifies if the effect was previously ready
  103466. */
  103467. _wasPreviouslyReady: boolean;
  103468. /**
  103469. * Observable that will be called when effect is bound.
  103470. */
  103471. get onBindObservable(): Observable<Effect>;
  103472. /** @hidden */
  103473. _bonesComputationForcedToCPU: boolean;
  103474. private static _uniqueIdSeed;
  103475. private _engine;
  103476. private _uniformBuffersNames;
  103477. private _uniformsNames;
  103478. private _samplerList;
  103479. private _samplers;
  103480. private _isReady;
  103481. private _compilationError;
  103482. private _allFallbacksProcessed;
  103483. private _attributesNames;
  103484. private _attributes;
  103485. private _attributeLocationByName;
  103486. private _uniforms;
  103487. /**
  103488. * Key for the effect.
  103489. * @hidden
  103490. */
  103491. _key: string;
  103492. private _indexParameters;
  103493. private _fallbacks;
  103494. private _vertexSourceCode;
  103495. private _fragmentSourceCode;
  103496. private _vertexSourceCodeOverride;
  103497. private _fragmentSourceCodeOverride;
  103498. private _transformFeedbackVaryings;
  103499. /**
  103500. * Compiled shader to webGL program.
  103501. * @hidden
  103502. */
  103503. _pipelineContext: Nullable<IPipelineContext>;
  103504. private _valueCache;
  103505. private static _baseCache;
  103506. /**
  103507. * Instantiates an effect.
  103508. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103509. * @param baseName Name of the effect.
  103510. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103511. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103512. * @param samplers List of sampler variables that will be passed to the shader.
  103513. * @param engine Engine to be used to render the effect
  103514. * @param defines Define statements to be added to the shader.
  103515. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103516. * @param onCompiled Callback that will be called when the shader is compiled.
  103517. * @param onError Callback that will be called if an error occurs during shader compilation.
  103518. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103519. */
  103520. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  103521. private _useFinalCode;
  103522. /**
  103523. * Unique key for this effect
  103524. */
  103525. get key(): string;
  103526. /**
  103527. * If the effect has been compiled and prepared.
  103528. * @returns if the effect is compiled and prepared.
  103529. */
  103530. isReady(): boolean;
  103531. private _isReadyInternal;
  103532. /**
  103533. * The engine the effect was initialized with.
  103534. * @returns the engine.
  103535. */
  103536. getEngine(): Engine;
  103537. /**
  103538. * The pipeline context for this effect
  103539. * @returns the associated pipeline context
  103540. */
  103541. getPipelineContext(): Nullable<IPipelineContext>;
  103542. /**
  103543. * The set of names of attribute variables for the shader.
  103544. * @returns An array of attribute names.
  103545. */
  103546. getAttributesNames(): string[];
  103547. /**
  103548. * Returns the attribute at the given index.
  103549. * @param index The index of the attribute.
  103550. * @returns The location of the attribute.
  103551. */
  103552. getAttributeLocation(index: number): number;
  103553. /**
  103554. * Returns the attribute based on the name of the variable.
  103555. * @param name of the attribute to look up.
  103556. * @returns the attribute location.
  103557. */
  103558. getAttributeLocationByName(name: string): number;
  103559. /**
  103560. * The number of attributes.
  103561. * @returns the numnber of attributes.
  103562. */
  103563. getAttributesCount(): number;
  103564. /**
  103565. * Gets the index of a uniform variable.
  103566. * @param uniformName of the uniform to look up.
  103567. * @returns the index.
  103568. */
  103569. getUniformIndex(uniformName: string): number;
  103570. /**
  103571. * Returns the attribute based on the name of the variable.
  103572. * @param uniformName of the uniform to look up.
  103573. * @returns the location of the uniform.
  103574. */
  103575. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103576. /**
  103577. * Returns an array of sampler variable names
  103578. * @returns The array of sampler variable neames.
  103579. */
  103580. getSamplers(): string[];
  103581. /**
  103582. * The error from the last compilation.
  103583. * @returns the error string.
  103584. */
  103585. getCompilationError(): string;
  103586. /**
  103587. * Gets a boolean indicating that all fallbacks were used during compilation
  103588. * @returns true if all fallbacks were used
  103589. */
  103590. allFallbacksProcessed(): boolean;
  103591. /**
  103592. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103593. * @param func The callback to be used.
  103594. */
  103595. executeWhenCompiled(func: (effect: Effect) => void): void;
  103596. private _checkIsReady;
  103597. private _loadShader;
  103598. /**
  103599. * Recompiles the webGL program
  103600. * @param vertexSourceCode The source code for the vertex shader.
  103601. * @param fragmentSourceCode The source code for the fragment shader.
  103602. * @param onCompiled Callback called when completed.
  103603. * @param onError Callback called on error.
  103604. * @hidden
  103605. */
  103606. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103607. /**
  103608. * Prepares the effect
  103609. * @hidden
  103610. */
  103611. _prepareEffect(): void;
  103612. private _getShaderCodeAndErrorLine;
  103613. private _processCompilationErrors;
  103614. /**
  103615. * Checks if the effect is supported. (Must be called after compilation)
  103616. */
  103617. get isSupported(): boolean;
  103618. /**
  103619. * Binds a texture to the engine to be used as output of the shader.
  103620. * @param channel Name of the output variable.
  103621. * @param texture Texture to bind.
  103622. * @hidden
  103623. */
  103624. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103625. /**
  103626. * Sets a texture on the engine to be used in the shader.
  103627. * @param channel Name of the sampler variable.
  103628. * @param texture Texture to set.
  103629. */
  103630. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103631. /**
  103632. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103633. * @param channel Name of the sampler variable.
  103634. * @param texture Texture to set.
  103635. */
  103636. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103637. /**
  103638. * Sets an array of textures on the engine to be used in the shader.
  103639. * @param channel Name of the variable.
  103640. * @param textures Textures to set.
  103641. */
  103642. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103643. /**
  103644. * 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)
  103645. * @param channel Name of the sampler variable.
  103646. * @param postProcess Post process to get the input texture from.
  103647. */
  103648. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103649. /**
  103650. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103651. * 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)
  103652. * @param channel Name of the sampler variable.
  103653. * @param postProcess Post process to get the output texture from.
  103654. */
  103655. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103656. /** @hidden */
  103657. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103658. /** @hidden */
  103659. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103660. /** @hidden */
  103661. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103662. /** @hidden */
  103663. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103664. /**
  103665. * Binds a buffer to a uniform.
  103666. * @param buffer Buffer to bind.
  103667. * @param name Name of the uniform variable to bind to.
  103668. */
  103669. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103670. /**
  103671. * Binds block to a uniform.
  103672. * @param blockName Name of the block to bind.
  103673. * @param index Index to bind.
  103674. */
  103675. bindUniformBlock(blockName: string, index: number): void;
  103676. /**
  103677. * Sets an interger value on a uniform variable.
  103678. * @param uniformName Name of the variable.
  103679. * @param value Value to be set.
  103680. * @returns this effect.
  103681. */
  103682. setInt(uniformName: string, value: number): Effect;
  103683. /**
  103684. * Sets an int array on a uniform variable.
  103685. * @param uniformName Name of the variable.
  103686. * @param array array to be set.
  103687. * @returns this effect.
  103688. */
  103689. setIntArray(uniformName: string, array: Int32Array): Effect;
  103690. /**
  103691. * 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)
  103692. * @param uniformName Name of the variable.
  103693. * @param array array to be set.
  103694. * @returns this effect.
  103695. */
  103696. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103697. /**
  103698. * 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)
  103699. * @param uniformName Name of the variable.
  103700. * @param array array to be set.
  103701. * @returns this effect.
  103702. */
  103703. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103704. /**
  103705. * 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)
  103706. * @param uniformName Name of the variable.
  103707. * @param array array to be set.
  103708. * @returns this effect.
  103709. */
  103710. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103711. /**
  103712. * Sets an float array on a uniform variable.
  103713. * @param uniformName Name of the variable.
  103714. * @param array array to be set.
  103715. * @returns this effect.
  103716. */
  103717. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103718. /**
  103719. * 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)
  103720. * @param uniformName Name of the variable.
  103721. * @param array array to be set.
  103722. * @returns this effect.
  103723. */
  103724. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103725. /**
  103726. * 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)
  103727. * @param uniformName Name of the variable.
  103728. * @param array array to be set.
  103729. * @returns this effect.
  103730. */
  103731. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103732. /**
  103733. * 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)
  103734. * @param uniformName Name of the variable.
  103735. * @param array array to be set.
  103736. * @returns this effect.
  103737. */
  103738. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103739. /**
  103740. * Sets an array on a uniform variable.
  103741. * @param uniformName Name of the variable.
  103742. * @param array array to be set.
  103743. * @returns this effect.
  103744. */
  103745. setArray(uniformName: string, array: number[]): Effect;
  103746. /**
  103747. * 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)
  103748. * @param uniformName Name of the variable.
  103749. * @param array array to be set.
  103750. * @returns this effect.
  103751. */
  103752. setArray2(uniformName: string, array: number[]): Effect;
  103753. /**
  103754. * 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)
  103755. * @param uniformName Name of the variable.
  103756. * @param array array to be set.
  103757. * @returns this effect.
  103758. */
  103759. setArray3(uniformName: string, array: number[]): Effect;
  103760. /**
  103761. * 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)
  103762. * @param uniformName Name of the variable.
  103763. * @param array array to be set.
  103764. * @returns this effect.
  103765. */
  103766. setArray4(uniformName: string, array: number[]): Effect;
  103767. /**
  103768. * Sets matrices on a uniform variable.
  103769. * @param uniformName Name of the variable.
  103770. * @param matrices matrices to be set.
  103771. * @returns this effect.
  103772. */
  103773. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103774. /**
  103775. * Sets matrix on a uniform variable.
  103776. * @param uniformName Name of the variable.
  103777. * @param matrix matrix to be set.
  103778. * @returns this effect.
  103779. */
  103780. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103781. /**
  103782. * 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)
  103783. * @param uniformName Name of the variable.
  103784. * @param matrix matrix to be set.
  103785. * @returns this effect.
  103786. */
  103787. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103788. /**
  103789. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103790. * @param uniformName Name of the variable.
  103791. * @param matrix matrix to be set.
  103792. * @returns this effect.
  103793. */
  103794. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103795. /**
  103796. * Sets a float on a uniform variable.
  103797. * @param uniformName Name of the variable.
  103798. * @param value value to be set.
  103799. * @returns this effect.
  103800. */
  103801. setFloat(uniformName: string, value: number): Effect;
  103802. /**
  103803. * Sets a boolean on a uniform variable.
  103804. * @param uniformName Name of the variable.
  103805. * @param bool value to be set.
  103806. * @returns this effect.
  103807. */
  103808. setBool(uniformName: string, bool: boolean): Effect;
  103809. /**
  103810. * Sets a Vector2 on a uniform variable.
  103811. * @param uniformName Name of the variable.
  103812. * @param vector2 vector2 to be set.
  103813. * @returns this effect.
  103814. */
  103815. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103816. /**
  103817. * Sets a float2 on a uniform variable.
  103818. * @param uniformName Name of the variable.
  103819. * @param x First float in float2.
  103820. * @param y Second float in float2.
  103821. * @returns this effect.
  103822. */
  103823. setFloat2(uniformName: string, x: number, y: number): Effect;
  103824. /**
  103825. * Sets a Vector3 on a uniform variable.
  103826. * @param uniformName Name of the variable.
  103827. * @param vector3 Value to be set.
  103828. * @returns this effect.
  103829. */
  103830. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103831. /**
  103832. * Sets a float3 on a uniform variable.
  103833. * @param uniformName Name of the variable.
  103834. * @param x First float in float3.
  103835. * @param y Second float in float3.
  103836. * @param z Third float in float3.
  103837. * @returns this effect.
  103838. */
  103839. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103840. /**
  103841. * Sets a Vector4 on a uniform variable.
  103842. * @param uniformName Name of the variable.
  103843. * @param vector4 Value to be set.
  103844. * @returns this effect.
  103845. */
  103846. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103847. /**
  103848. * Sets a float4 on a uniform variable.
  103849. * @param uniformName Name of the variable.
  103850. * @param x First float in float4.
  103851. * @param y Second float in float4.
  103852. * @param z Third float in float4.
  103853. * @param w Fourth float in float4.
  103854. * @returns this effect.
  103855. */
  103856. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103857. /**
  103858. * Sets a Color3 on a uniform variable.
  103859. * @param uniformName Name of the variable.
  103860. * @param color3 Value to be set.
  103861. * @returns this effect.
  103862. */
  103863. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103864. /**
  103865. * Sets a Color4 on a uniform variable.
  103866. * @param uniformName Name of the variable.
  103867. * @param color3 Value to be set.
  103868. * @param alpha Alpha value to be set.
  103869. * @returns this effect.
  103870. */
  103871. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103872. /**
  103873. * Sets a Color4 on a uniform variable
  103874. * @param uniformName defines the name of the variable
  103875. * @param color4 defines the value to be set
  103876. * @returns this effect.
  103877. */
  103878. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103879. /** Release all associated resources */
  103880. dispose(): void;
  103881. /**
  103882. * This function will add a new shader to the shader store
  103883. * @param name the name of the shader
  103884. * @param pixelShader optional pixel shader content
  103885. * @param vertexShader optional vertex shader content
  103886. */
  103887. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103888. /**
  103889. * Store of each shader (The can be looked up using effect.key)
  103890. */
  103891. static ShadersStore: {
  103892. [key: string]: string;
  103893. };
  103894. /**
  103895. * Store of each included file for a shader (The can be looked up using effect.key)
  103896. */
  103897. static IncludesShadersStore: {
  103898. [key: string]: string;
  103899. };
  103900. /**
  103901. * Resets the cache of effects.
  103902. */
  103903. static ResetCache(): void;
  103904. }
  103905. }
  103906. declare module BABYLON {
  103907. /**
  103908. * Interface used to describe the capabilities of the engine relatively to the current browser
  103909. */
  103910. export interface EngineCapabilities {
  103911. /** Maximum textures units per fragment shader */
  103912. maxTexturesImageUnits: number;
  103913. /** Maximum texture units per vertex shader */
  103914. maxVertexTextureImageUnits: number;
  103915. /** Maximum textures units in the entire pipeline */
  103916. maxCombinedTexturesImageUnits: number;
  103917. /** Maximum texture size */
  103918. maxTextureSize: number;
  103919. /** Maximum texture samples */
  103920. maxSamples?: number;
  103921. /** Maximum cube texture size */
  103922. maxCubemapTextureSize: number;
  103923. /** Maximum render texture size */
  103924. maxRenderTextureSize: number;
  103925. /** Maximum number of vertex attributes */
  103926. maxVertexAttribs: number;
  103927. /** Maximum number of varyings */
  103928. maxVaryingVectors: number;
  103929. /** Maximum number of uniforms per vertex shader */
  103930. maxVertexUniformVectors: number;
  103931. /** Maximum number of uniforms per fragment shader */
  103932. maxFragmentUniformVectors: number;
  103933. /** Defines if standard derivates (dx/dy) are supported */
  103934. standardDerivatives: boolean;
  103935. /** Defines if s3tc texture compression is supported */
  103936. s3tc?: WEBGL_compressed_texture_s3tc;
  103937. /** Defines if pvrtc texture compression is supported */
  103938. pvrtc: any;
  103939. /** Defines if etc1 texture compression is supported */
  103940. etc1: any;
  103941. /** Defines if etc2 texture compression is supported */
  103942. etc2: any;
  103943. /** Defines if astc texture compression is supported */
  103944. astc: any;
  103945. /** Defines if float textures are supported */
  103946. textureFloat: boolean;
  103947. /** Defines if vertex array objects are supported */
  103948. vertexArrayObject: boolean;
  103949. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103950. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103951. /** Gets the maximum level of anisotropy supported */
  103952. maxAnisotropy: number;
  103953. /** Defines if instancing is supported */
  103954. instancedArrays: boolean;
  103955. /** Defines if 32 bits indices are supported */
  103956. uintIndices: boolean;
  103957. /** Defines if high precision shaders are supported */
  103958. highPrecisionShaderSupported: boolean;
  103959. /** Defines if depth reading in the fragment shader is supported */
  103960. fragmentDepthSupported: boolean;
  103961. /** Defines if float texture linear filtering is supported*/
  103962. textureFloatLinearFiltering: boolean;
  103963. /** Defines if rendering to float textures is supported */
  103964. textureFloatRender: boolean;
  103965. /** Defines if half float textures are supported*/
  103966. textureHalfFloat: boolean;
  103967. /** Defines if half float texture linear filtering is supported*/
  103968. textureHalfFloatLinearFiltering: boolean;
  103969. /** Defines if rendering to half float textures is supported */
  103970. textureHalfFloatRender: boolean;
  103971. /** Defines if textureLOD shader command is supported */
  103972. textureLOD: boolean;
  103973. /** Defines if draw buffers extension is supported */
  103974. drawBuffersExtension: boolean;
  103975. /** Defines if depth textures are supported */
  103976. depthTextureExtension: boolean;
  103977. /** Defines if float color buffer are supported */
  103978. colorBufferFloat: boolean;
  103979. /** Gets disjoint timer query extension (null if not supported) */
  103980. timerQuery?: EXT_disjoint_timer_query;
  103981. /** Defines if timestamp can be used with timer query */
  103982. canUseTimestampForTimerQuery: boolean;
  103983. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103984. multiview?: any;
  103985. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103986. oculusMultiview?: any;
  103987. /** Function used to let the system compiles shaders in background */
  103988. parallelShaderCompile?: {
  103989. COMPLETION_STATUS_KHR: number;
  103990. };
  103991. /** Max number of texture samples for MSAA */
  103992. maxMSAASamples: number;
  103993. /** Defines if the blend min max extension is supported */
  103994. blendMinMax: boolean;
  103995. }
  103996. }
  103997. declare module BABYLON {
  103998. /**
  103999. * @hidden
  104000. **/
  104001. export class DepthCullingState {
  104002. private _isDepthTestDirty;
  104003. private _isDepthMaskDirty;
  104004. private _isDepthFuncDirty;
  104005. private _isCullFaceDirty;
  104006. private _isCullDirty;
  104007. private _isZOffsetDirty;
  104008. private _isFrontFaceDirty;
  104009. private _depthTest;
  104010. private _depthMask;
  104011. private _depthFunc;
  104012. private _cull;
  104013. private _cullFace;
  104014. private _zOffset;
  104015. private _frontFace;
  104016. /**
  104017. * Initializes the state.
  104018. */
  104019. constructor();
  104020. get isDirty(): boolean;
  104021. get zOffset(): number;
  104022. set zOffset(value: number);
  104023. get cullFace(): Nullable<number>;
  104024. set cullFace(value: Nullable<number>);
  104025. get cull(): Nullable<boolean>;
  104026. set cull(value: Nullable<boolean>);
  104027. get depthFunc(): Nullable<number>;
  104028. set depthFunc(value: Nullable<number>);
  104029. get depthMask(): boolean;
  104030. set depthMask(value: boolean);
  104031. get depthTest(): boolean;
  104032. set depthTest(value: boolean);
  104033. get frontFace(): Nullable<number>;
  104034. set frontFace(value: Nullable<number>);
  104035. reset(): void;
  104036. apply(gl: WebGLRenderingContext): void;
  104037. }
  104038. }
  104039. declare module BABYLON {
  104040. /**
  104041. * @hidden
  104042. **/
  104043. export class StencilState {
  104044. /** 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 */
  104045. static readonly ALWAYS: number;
  104046. /** Passed to stencilOperation to specify that stencil value must be kept */
  104047. static readonly KEEP: number;
  104048. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104049. static readonly REPLACE: number;
  104050. private _isStencilTestDirty;
  104051. private _isStencilMaskDirty;
  104052. private _isStencilFuncDirty;
  104053. private _isStencilOpDirty;
  104054. private _stencilTest;
  104055. private _stencilMask;
  104056. private _stencilFunc;
  104057. private _stencilFuncRef;
  104058. private _stencilFuncMask;
  104059. private _stencilOpStencilFail;
  104060. private _stencilOpDepthFail;
  104061. private _stencilOpStencilDepthPass;
  104062. get isDirty(): boolean;
  104063. get stencilFunc(): number;
  104064. set stencilFunc(value: number);
  104065. get stencilFuncRef(): number;
  104066. set stencilFuncRef(value: number);
  104067. get stencilFuncMask(): number;
  104068. set stencilFuncMask(value: number);
  104069. get stencilOpStencilFail(): number;
  104070. set stencilOpStencilFail(value: number);
  104071. get stencilOpDepthFail(): number;
  104072. set stencilOpDepthFail(value: number);
  104073. get stencilOpStencilDepthPass(): number;
  104074. set stencilOpStencilDepthPass(value: number);
  104075. get stencilMask(): number;
  104076. set stencilMask(value: number);
  104077. get stencilTest(): boolean;
  104078. set stencilTest(value: boolean);
  104079. constructor();
  104080. reset(): void;
  104081. apply(gl: WebGLRenderingContext): void;
  104082. }
  104083. }
  104084. declare module BABYLON {
  104085. /**
  104086. * @hidden
  104087. **/
  104088. export class AlphaState {
  104089. private _isAlphaBlendDirty;
  104090. private _isBlendFunctionParametersDirty;
  104091. private _isBlendEquationParametersDirty;
  104092. private _isBlendConstantsDirty;
  104093. private _alphaBlend;
  104094. private _blendFunctionParameters;
  104095. private _blendEquationParameters;
  104096. private _blendConstants;
  104097. /**
  104098. * Initializes the state.
  104099. */
  104100. constructor();
  104101. get isDirty(): boolean;
  104102. get alphaBlend(): boolean;
  104103. set alphaBlend(value: boolean);
  104104. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  104105. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  104106. setAlphaEquationParameters(rgb: number, alpha: number): void;
  104107. reset(): void;
  104108. apply(gl: WebGLRenderingContext): void;
  104109. }
  104110. }
  104111. declare module BABYLON {
  104112. /** @hidden */
  104113. export class WebGL2ShaderProcessor implements IShaderProcessor {
  104114. attributeProcessor(attribute: string): string;
  104115. varyingProcessor(varying: string, isFragment: boolean): string;
  104116. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  104117. }
  104118. }
  104119. declare module BABYLON {
  104120. /**
  104121. * Interface for attribute information associated with buffer instanciation
  104122. */
  104123. export interface InstancingAttributeInfo {
  104124. /**
  104125. * Name of the GLSL attribute
  104126. * if attribute index is not specified, this is used to retrieve the index from the effect
  104127. */
  104128. attributeName: string;
  104129. /**
  104130. * Index/offset of the attribute in the vertex shader
  104131. * if not specified, this will be computes from the name.
  104132. */
  104133. index?: number;
  104134. /**
  104135. * size of the attribute, 1, 2, 3 or 4
  104136. */
  104137. attributeSize: number;
  104138. /**
  104139. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104140. */
  104141. offset: number;
  104142. /**
  104143. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104144. * default to 1
  104145. */
  104146. divisor?: number;
  104147. /**
  104148. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104149. * default is FLOAT
  104150. */
  104151. attributeType?: number;
  104152. /**
  104153. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104154. */
  104155. normalized?: boolean;
  104156. }
  104157. }
  104158. declare module BABYLON {
  104159. interface ThinEngine {
  104160. /**
  104161. * Update a video texture
  104162. * @param texture defines the texture to update
  104163. * @param video defines the video element to use
  104164. * @param invertY defines if data must be stored with Y axis inverted
  104165. */
  104166. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104167. }
  104168. }
  104169. declare module BABYLON {
  104170. /**
  104171. * Settings for finer control over video usage
  104172. */
  104173. export interface VideoTextureSettings {
  104174. /**
  104175. * Applies `autoplay` to video, if specified
  104176. */
  104177. autoPlay?: boolean;
  104178. /**
  104179. * Applies `loop` to video, if specified
  104180. */
  104181. loop?: boolean;
  104182. /**
  104183. * Automatically updates internal texture from video at every frame in the render loop
  104184. */
  104185. autoUpdateTexture: boolean;
  104186. /**
  104187. * Image src displayed during the video loading or until the user interacts with the video.
  104188. */
  104189. poster?: string;
  104190. }
  104191. /**
  104192. * If you want to display a video in your scene, this is the special texture for that.
  104193. * This special texture works similar to other textures, with the exception of a few parameters.
  104194. * @see https://doc.babylonjs.com/how_to/video_texture
  104195. */
  104196. export class VideoTexture extends Texture {
  104197. /**
  104198. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104199. */
  104200. readonly autoUpdateTexture: boolean;
  104201. /**
  104202. * The video instance used by the texture internally
  104203. */
  104204. readonly video: HTMLVideoElement;
  104205. private _onUserActionRequestedObservable;
  104206. /**
  104207. * Event triggerd when a dom action is required by the user to play the video.
  104208. * This happens due to recent changes in browser policies preventing video to auto start.
  104209. */
  104210. get onUserActionRequestedObservable(): Observable<Texture>;
  104211. private _generateMipMaps;
  104212. private _engine;
  104213. private _stillImageCaptured;
  104214. private _displayingPosterTexture;
  104215. private _settings;
  104216. private _createInternalTextureOnEvent;
  104217. private _frameId;
  104218. private _currentSrc;
  104219. /**
  104220. * Creates a video texture.
  104221. * If you want to display a video in your scene, this is the special texture for that.
  104222. * This special texture works similar to other textures, with the exception of a few parameters.
  104223. * @see https://doc.babylonjs.com/how_to/video_texture
  104224. * @param name optional name, will detect from video source, if not defined
  104225. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104226. * @param scene is obviously the current scene.
  104227. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104228. * @param invertY is false by default but can be used to invert video on Y axis
  104229. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104230. * @param settings allows finer control over video usage
  104231. */
  104232. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104233. private _getName;
  104234. private _getVideo;
  104235. private _createInternalTexture;
  104236. private reset;
  104237. /**
  104238. * @hidden Internal method to initiate `update`.
  104239. */
  104240. _rebuild(): void;
  104241. /**
  104242. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104243. */
  104244. update(): void;
  104245. /**
  104246. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104247. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104248. */
  104249. updateTexture(isVisible: boolean): void;
  104250. protected _updateInternalTexture: () => void;
  104251. /**
  104252. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104253. * @param url New url.
  104254. */
  104255. updateURL(url: string): void;
  104256. /**
  104257. * Clones the texture.
  104258. * @returns the cloned texture
  104259. */
  104260. clone(): VideoTexture;
  104261. /**
  104262. * Dispose the texture and release its associated resources.
  104263. */
  104264. dispose(): void;
  104265. /**
  104266. * Creates a video texture straight from a stream.
  104267. * @param scene Define the scene the texture should be created in
  104268. * @param stream Define the stream the texture should be created from
  104269. * @returns The created video texture as a promise
  104270. */
  104271. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104272. /**
  104273. * Creates a video texture straight from your WebCam video feed.
  104274. * @param scene Define the scene the texture should be created in
  104275. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104276. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104277. * @returns The created video texture as a promise
  104278. */
  104279. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104280. minWidth: number;
  104281. maxWidth: number;
  104282. minHeight: number;
  104283. maxHeight: number;
  104284. deviceId: string;
  104285. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104286. /**
  104287. * Creates a video texture straight from your WebCam video feed.
  104288. * @param scene Define the scene the texture should be created in
  104289. * @param onReady Define a callback to triggered once the texture will be ready
  104290. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104291. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104292. */
  104293. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104294. minWidth: number;
  104295. maxWidth: number;
  104296. minHeight: number;
  104297. maxHeight: number;
  104298. deviceId: string;
  104299. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104300. }
  104301. }
  104302. declare module BABYLON {
  104303. /**
  104304. * Defines the interface used by objects working like Scene
  104305. * @hidden
  104306. */
  104307. export interface ISceneLike {
  104308. _addPendingData(data: any): void;
  104309. _removePendingData(data: any): void;
  104310. offlineProvider: IOfflineProvider;
  104311. }
  104312. /** Interface defining initialization parameters for Engine class */
  104313. export interface EngineOptions extends WebGLContextAttributes {
  104314. /**
  104315. * Defines if the engine should no exceed a specified device ratio
  104316. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104317. */
  104318. limitDeviceRatio?: number;
  104319. /**
  104320. * Defines if webvr should be enabled automatically
  104321. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104322. */
  104323. autoEnableWebVR?: boolean;
  104324. /**
  104325. * Defines if webgl2 should be turned off even if supported
  104326. * @see http://doc.babylonjs.com/features/webgl2
  104327. */
  104328. disableWebGL2Support?: boolean;
  104329. /**
  104330. * Defines if webaudio should be initialized as well
  104331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104332. */
  104333. audioEngine?: boolean;
  104334. /**
  104335. * Defines if animations should run using a deterministic lock step
  104336. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104337. */
  104338. deterministicLockstep?: boolean;
  104339. /** Defines the maximum steps to use with deterministic lock step mode */
  104340. lockstepMaxSteps?: number;
  104341. /** Defines the seconds between each deterministic lock step */
  104342. timeStep?: number;
  104343. /**
  104344. * Defines that engine should ignore context lost events
  104345. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104346. */
  104347. doNotHandleContextLost?: boolean;
  104348. /**
  104349. * Defines that engine should ignore modifying touch action attribute and style
  104350. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104351. */
  104352. doNotHandleTouchAction?: boolean;
  104353. /**
  104354. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104355. */
  104356. useHighPrecisionFloats?: boolean;
  104357. }
  104358. /**
  104359. * The base engine class (root of all engines)
  104360. */
  104361. export class ThinEngine {
  104362. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104363. static ExceptionList: ({
  104364. key: string;
  104365. capture: string;
  104366. captureConstraint: number;
  104367. targets: string[];
  104368. } | {
  104369. key: string;
  104370. capture: null;
  104371. captureConstraint: null;
  104372. targets: string[];
  104373. })[];
  104374. /** @hidden */
  104375. static _TextureLoaders: IInternalTextureLoader[];
  104376. /**
  104377. * Returns the current npm package of the sdk
  104378. */
  104379. static get NpmPackage(): string;
  104380. /**
  104381. * Returns the current version of the framework
  104382. */
  104383. static get Version(): string;
  104384. /**
  104385. * Returns a string describing the current engine
  104386. */
  104387. get description(): string;
  104388. /**
  104389. * Gets or sets the epsilon value used by collision engine
  104390. */
  104391. static CollisionsEpsilon: number;
  104392. /**
  104393. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104394. */
  104395. static get ShadersRepository(): string;
  104396. static set ShadersRepository(value: string);
  104397. /** @hidden */
  104398. _shaderProcessor: IShaderProcessor;
  104399. /**
  104400. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104401. */
  104402. forcePOTTextures: boolean;
  104403. /**
  104404. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104405. */
  104406. isFullscreen: boolean;
  104407. /**
  104408. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104409. */
  104410. cullBackFaces: boolean;
  104411. /**
  104412. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104413. */
  104414. renderEvenInBackground: boolean;
  104415. /**
  104416. * Gets or sets a boolean indicating that cache can be kept between frames
  104417. */
  104418. preventCacheWipeBetweenFrames: boolean;
  104419. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104420. validateShaderPrograms: boolean;
  104421. /**
  104422. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104423. * This can provide greater z depth for distant objects.
  104424. */
  104425. useReverseDepthBuffer: boolean;
  104426. /**
  104427. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104428. */
  104429. disableUniformBuffers: boolean;
  104430. /** @hidden */
  104431. _uniformBuffers: UniformBuffer[];
  104432. /**
  104433. * Gets a boolean indicating that the engine supports uniform buffers
  104434. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104435. */
  104436. get supportsUniformBuffers(): boolean;
  104437. /** @hidden */
  104438. _gl: WebGLRenderingContext;
  104439. /** @hidden */
  104440. _webGLVersion: number;
  104441. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104442. protected _windowIsBackground: boolean;
  104443. protected _creationOptions: EngineOptions;
  104444. protected _highPrecisionShadersAllowed: boolean;
  104445. /** @hidden */
  104446. get _shouldUseHighPrecisionShader(): boolean;
  104447. /**
  104448. * Gets a boolean indicating that only power of 2 textures are supported
  104449. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104450. */
  104451. get needPOTTextures(): boolean;
  104452. /** @hidden */
  104453. _badOS: boolean;
  104454. /** @hidden */
  104455. _badDesktopOS: boolean;
  104456. private _hardwareScalingLevel;
  104457. /** @hidden */
  104458. _caps: EngineCapabilities;
  104459. private _isStencilEnable;
  104460. private _glVersion;
  104461. private _glRenderer;
  104462. private _glVendor;
  104463. /** @hidden */
  104464. _videoTextureSupported: boolean;
  104465. protected _renderingQueueLaunched: boolean;
  104466. protected _activeRenderLoops: (() => void)[];
  104467. /**
  104468. * Observable signaled when a context lost event is raised
  104469. */
  104470. onContextLostObservable: Observable<ThinEngine>;
  104471. /**
  104472. * Observable signaled when a context restored event is raised
  104473. */
  104474. onContextRestoredObservable: Observable<ThinEngine>;
  104475. private _onContextLost;
  104476. private _onContextRestored;
  104477. protected _contextWasLost: boolean;
  104478. /** @hidden */
  104479. _doNotHandleContextLost: boolean;
  104480. /**
  104481. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104483. */
  104484. get doNotHandleContextLost(): boolean;
  104485. set doNotHandleContextLost(value: boolean);
  104486. /**
  104487. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104488. */
  104489. disableVertexArrayObjects: boolean;
  104490. /** @hidden */
  104491. protected _colorWrite: boolean;
  104492. /** @hidden */
  104493. protected _colorWriteChanged: boolean;
  104494. /** @hidden */
  104495. protected _depthCullingState: DepthCullingState;
  104496. /** @hidden */
  104497. protected _stencilState: StencilState;
  104498. /** @hidden */
  104499. _alphaState: AlphaState;
  104500. /** @hidden */
  104501. _alphaMode: number;
  104502. /** @hidden */
  104503. _alphaEquation: number;
  104504. /** @hidden */
  104505. _internalTexturesCache: InternalTexture[];
  104506. /** @hidden */
  104507. protected _activeChannel: number;
  104508. private _currentTextureChannel;
  104509. /** @hidden */
  104510. protected _boundTexturesCache: {
  104511. [key: string]: Nullable<InternalTexture>;
  104512. };
  104513. /** @hidden */
  104514. protected _currentEffect: Nullable<Effect>;
  104515. /** @hidden */
  104516. protected _currentProgram: Nullable<WebGLProgram>;
  104517. private _compiledEffects;
  104518. private _vertexAttribArraysEnabled;
  104519. /** @hidden */
  104520. protected _cachedViewport: Nullable<IViewportLike>;
  104521. private _cachedVertexArrayObject;
  104522. /** @hidden */
  104523. protected _cachedVertexBuffers: any;
  104524. /** @hidden */
  104525. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104526. /** @hidden */
  104527. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104528. /** @hidden */
  104529. _currentRenderTarget: Nullable<InternalTexture>;
  104530. private _uintIndicesCurrentlySet;
  104531. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104532. /** @hidden */
  104533. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104534. private _currentBufferPointers;
  104535. private _currentInstanceLocations;
  104536. private _currentInstanceBuffers;
  104537. private _textureUnits;
  104538. /** @hidden */
  104539. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104540. /** @hidden */
  104541. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104542. /** @hidden */
  104543. _boundRenderFunction: any;
  104544. private _vaoRecordInProgress;
  104545. private _mustWipeVertexAttributes;
  104546. private _emptyTexture;
  104547. private _emptyCubeTexture;
  104548. private _emptyTexture3D;
  104549. private _emptyTexture2DArray;
  104550. /** @hidden */
  104551. _frameHandler: number;
  104552. private _nextFreeTextureSlots;
  104553. private _maxSimultaneousTextures;
  104554. private _activeRequests;
  104555. protected _texturesSupported: string[];
  104556. /** @hidden */
  104557. _textureFormatInUse: Nullable<string>;
  104558. protected get _supportsHardwareTextureRescaling(): boolean;
  104559. private _framebufferDimensionsObject;
  104560. /**
  104561. * sets the object from which width and height will be taken from when getting render width and height
  104562. * Will fallback to the gl object
  104563. * @param dimensions the framebuffer width and height that will be used.
  104564. */
  104565. set framebufferDimensionsObject(dimensions: Nullable<{
  104566. framebufferWidth: number;
  104567. framebufferHeight: number;
  104568. }>);
  104569. /**
  104570. * Gets the list of texture formats supported
  104571. */
  104572. get texturesSupported(): Array<string>;
  104573. /**
  104574. * Gets the list of texture formats in use
  104575. */
  104576. get textureFormatInUse(): Nullable<string>;
  104577. /**
  104578. * Gets the current viewport
  104579. */
  104580. get currentViewport(): Nullable<IViewportLike>;
  104581. /**
  104582. * Gets the default empty texture
  104583. */
  104584. get emptyTexture(): InternalTexture;
  104585. /**
  104586. * Gets the default empty 3D texture
  104587. */
  104588. get emptyTexture3D(): InternalTexture;
  104589. /**
  104590. * Gets the default empty 2D array texture
  104591. */
  104592. get emptyTexture2DArray(): InternalTexture;
  104593. /**
  104594. * Gets the default empty cube texture
  104595. */
  104596. get emptyCubeTexture(): InternalTexture;
  104597. /**
  104598. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104599. */
  104600. readonly premultipliedAlpha: boolean;
  104601. /**
  104602. * Observable event triggered before each texture is initialized
  104603. */
  104604. onBeforeTextureInitObservable: Observable<Texture>;
  104605. /**
  104606. * Creates a new engine
  104607. * @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
  104608. * @param antialias defines enable antialiasing (default: false)
  104609. * @param options defines further options to be sent to the getContext() function
  104610. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104611. */
  104612. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104613. private _rebuildInternalTextures;
  104614. private _rebuildEffects;
  104615. /**
  104616. * Gets a boolean indicating if all created effects are ready
  104617. * @returns true if all effects are ready
  104618. */
  104619. areAllEffectsReady(): boolean;
  104620. protected _rebuildBuffers(): void;
  104621. private _initGLContext;
  104622. /**
  104623. * Gets version of the current webGL context
  104624. */
  104625. get webGLVersion(): number;
  104626. /**
  104627. * Gets a string idenfifying the name of the class
  104628. * @returns "Engine" string
  104629. */
  104630. getClassName(): string;
  104631. /**
  104632. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104633. */
  104634. get isStencilEnable(): boolean;
  104635. /** @hidden */
  104636. _prepareWorkingCanvas(): void;
  104637. /**
  104638. * Reset the texture cache to empty state
  104639. */
  104640. resetTextureCache(): void;
  104641. /**
  104642. * Gets an object containing information about the current webGL context
  104643. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104644. */
  104645. getGlInfo(): {
  104646. vendor: string;
  104647. renderer: string;
  104648. version: string;
  104649. };
  104650. /**
  104651. * Defines the hardware scaling level.
  104652. * By default the hardware scaling level is computed from the window device ratio.
  104653. * 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.
  104654. * @param level defines the level to use
  104655. */
  104656. setHardwareScalingLevel(level: number): void;
  104657. /**
  104658. * Gets the current hardware scaling level.
  104659. * By default the hardware scaling level is computed from the window device ratio.
  104660. * 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.
  104661. * @returns a number indicating the current hardware scaling level
  104662. */
  104663. getHardwareScalingLevel(): number;
  104664. /**
  104665. * Gets the list of loaded textures
  104666. * @returns an array containing all loaded textures
  104667. */
  104668. getLoadedTexturesCache(): InternalTexture[];
  104669. /**
  104670. * Gets the object containing all engine capabilities
  104671. * @returns the EngineCapabilities object
  104672. */
  104673. getCaps(): EngineCapabilities;
  104674. /**
  104675. * stop executing a render loop function and remove it from the execution array
  104676. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104677. */
  104678. stopRenderLoop(renderFunction?: () => void): void;
  104679. /** @hidden */
  104680. _renderLoop(): void;
  104681. /**
  104682. * Gets the HTML canvas attached with the current webGL context
  104683. * @returns a HTML canvas
  104684. */
  104685. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104686. /**
  104687. * Gets host window
  104688. * @returns the host window object
  104689. */
  104690. getHostWindow(): Nullable<Window>;
  104691. /**
  104692. * Gets the current render width
  104693. * @param useScreen defines if screen size must be used (or the current render target if any)
  104694. * @returns a number defining the current render width
  104695. */
  104696. getRenderWidth(useScreen?: boolean): number;
  104697. /**
  104698. * Gets the current render height
  104699. * @param useScreen defines if screen size must be used (or the current render target if any)
  104700. * @returns a number defining the current render height
  104701. */
  104702. getRenderHeight(useScreen?: boolean): number;
  104703. /**
  104704. * Can be used to override the current requestAnimationFrame requester.
  104705. * @hidden
  104706. */
  104707. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104708. /**
  104709. * Register and execute a render loop. The engine can have more than one render function
  104710. * @param renderFunction defines the function to continuously execute
  104711. */
  104712. runRenderLoop(renderFunction: () => void): void;
  104713. /**
  104714. * Clear the current render buffer or the current render target (if any is set up)
  104715. * @param color defines the color to use
  104716. * @param backBuffer defines if the back buffer must be cleared
  104717. * @param depth defines if the depth buffer must be cleared
  104718. * @param stencil defines if the stencil buffer must be cleared
  104719. */
  104720. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104721. private _viewportCached;
  104722. /** @hidden */
  104723. _viewport(x: number, y: number, width: number, height: number): void;
  104724. /**
  104725. * Set the WebGL's viewport
  104726. * @param viewport defines the viewport element to be used
  104727. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104728. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104729. */
  104730. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104731. /**
  104732. * Begin a new frame
  104733. */
  104734. beginFrame(): void;
  104735. /**
  104736. * Enf the current frame
  104737. */
  104738. endFrame(): void;
  104739. /**
  104740. * Resize the view according to the canvas' size
  104741. */
  104742. resize(): void;
  104743. /**
  104744. * Force a specific size of the canvas
  104745. * @param width defines the new canvas' width
  104746. * @param height defines the new canvas' height
  104747. */
  104748. setSize(width: number, height: number): void;
  104749. /**
  104750. * Binds the frame buffer to the specified texture.
  104751. * @param texture The texture to render to or null for the default canvas
  104752. * @param faceIndex The face of the texture to render to in case of cube texture
  104753. * @param requiredWidth The width of the target to render to
  104754. * @param requiredHeight The height of the target to render to
  104755. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104756. * @param lodLevel defines the lod level to bind to the frame buffer
  104757. * @param layer defines the 2d array index to bind to frame buffer to
  104758. */
  104759. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104760. /** @hidden */
  104761. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104762. /**
  104763. * Unbind the current render target texture from the webGL context
  104764. * @param texture defines the render target texture to unbind
  104765. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104766. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104767. */
  104768. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104769. /**
  104770. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104771. */
  104772. flushFramebuffer(): void;
  104773. /**
  104774. * Unbind the current render target and bind the default framebuffer
  104775. */
  104776. restoreDefaultFramebuffer(): void;
  104777. /** @hidden */
  104778. protected _resetVertexBufferBinding(): void;
  104779. /**
  104780. * Creates a vertex buffer
  104781. * @param data the data for the vertex buffer
  104782. * @returns the new WebGL static buffer
  104783. */
  104784. createVertexBuffer(data: DataArray): DataBuffer;
  104785. private _createVertexBuffer;
  104786. /**
  104787. * Creates a dynamic vertex buffer
  104788. * @param data the data for the dynamic vertex buffer
  104789. * @returns the new WebGL dynamic buffer
  104790. */
  104791. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104792. protected _resetIndexBufferBinding(): void;
  104793. /**
  104794. * Creates a new index buffer
  104795. * @param indices defines the content of the index buffer
  104796. * @param updatable defines if the index buffer must be updatable
  104797. * @returns a new webGL buffer
  104798. */
  104799. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104800. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104801. /**
  104802. * Bind a webGL buffer to the webGL context
  104803. * @param buffer defines the buffer to bind
  104804. */
  104805. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104806. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104807. private bindBuffer;
  104808. /**
  104809. * update the bound buffer with the given data
  104810. * @param data defines the data to update
  104811. */
  104812. updateArrayBuffer(data: Float32Array): void;
  104813. private _vertexAttribPointer;
  104814. /** @hidden */
  104815. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104816. private _bindVertexBuffersAttributes;
  104817. /**
  104818. * Records a vertex array object
  104819. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104820. * @param vertexBuffers defines the list of vertex buffers to store
  104821. * @param indexBuffer defines the index buffer to store
  104822. * @param effect defines the effect to store
  104823. * @returns the new vertex array object
  104824. */
  104825. recordVertexArrayObject(vertexBuffers: {
  104826. [key: string]: VertexBuffer;
  104827. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104828. /**
  104829. * Bind a specific vertex array object
  104830. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104831. * @param vertexArrayObject defines the vertex array object to bind
  104832. * @param indexBuffer defines the index buffer to bind
  104833. */
  104834. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104835. /**
  104836. * Bind webGl buffers directly to the webGL context
  104837. * @param vertexBuffer defines the vertex buffer to bind
  104838. * @param indexBuffer defines the index buffer to bind
  104839. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104840. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104841. * @param effect defines the effect associated with the vertex buffer
  104842. */
  104843. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104844. private _unbindVertexArrayObject;
  104845. /**
  104846. * Bind a list of vertex buffers to the webGL context
  104847. * @param vertexBuffers defines the list of vertex buffers to bind
  104848. * @param indexBuffer defines the index buffer to bind
  104849. * @param effect defines the effect associated with the vertex buffers
  104850. */
  104851. bindBuffers(vertexBuffers: {
  104852. [key: string]: Nullable<VertexBuffer>;
  104853. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104854. /**
  104855. * Unbind all instance attributes
  104856. */
  104857. unbindInstanceAttributes(): void;
  104858. /**
  104859. * Release and free the memory of a vertex array object
  104860. * @param vao defines the vertex array object to delete
  104861. */
  104862. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104863. /** @hidden */
  104864. _releaseBuffer(buffer: DataBuffer): boolean;
  104865. protected _deleteBuffer(buffer: DataBuffer): void;
  104866. /**
  104867. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104868. * @param instancesBuffer defines the webGL buffer to update and bind
  104869. * @param data defines the data to store in the buffer
  104870. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104871. */
  104872. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104873. /**
  104874. * Bind the content of a webGL buffer used with instantiation
  104875. * @param instancesBuffer defines the webGL buffer to bind
  104876. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104877. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104878. */
  104879. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104880. /**
  104881. * Disable the instance attribute corresponding to the name in parameter
  104882. * @param name defines the name of the attribute to disable
  104883. */
  104884. disableInstanceAttributeByName(name: string): void;
  104885. /**
  104886. * Disable the instance attribute corresponding to the location in parameter
  104887. * @param attributeLocation defines the attribute location of the attribute to disable
  104888. */
  104889. disableInstanceAttribute(attributeLocation: number): void;
  104890. /**
  104891. * Disable the attribute corresponding to the location in parameter
  104892. * @param attributeLocation defines the attribute location of the attribute to disable
  104893. */
  104894. disableAttributeByIndex(attributeLocation: number): void;
  104895. /**
  104896. * Send a draw order
  104897. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104898. * @param indexStart defines the starting index
  104899. * @param indexCount defines the number of index to draw
  104900. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104901. */
  104902. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104903. /**
  104904. * Draw a list of points
  104905. * @param verticesStart defines the index of first vertex to draw
  104906. * @param verticesCount defines the count of vertices to draw
  104907. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104908. */
  104909. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104910. /**
  104911. * Draw a list of unindexed primitives
  104912. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104913. * @param verticesStart defines the index of first vertex to draw
  104914. * @param verticesCount defines the count of vertices to draw
  104915. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104916. */
  104917. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104918. /**
  104919. * Draw a list of indexed primitives
  104920. * @param fillMode defines the primitive to use
  104921. * @param indexStart defines the starting index
  104922. * @param indexCount defines the number of index to draw
  104923. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104924. */
  104925. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104926. /**
  104927. * Draw a list of unindexed primitives
  104928. * @param fillMode defines the primitive to use
  104929. * @param verticesStart defines the index of first vertex to draw
  104930. * @param verticesCount defines the count of vertices to draw
  104931. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104932. */
  104933. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104934. private _drawMode;
  104935. /** @hidden */
  104936. protected _reportDrawCall(): void;
  104937. /** @hidden */
  104938. _releaseEffect(effect: Effect): void;
  104939. /** @hidden */
  104940. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104941. /**
  104942. * Create a new effect (used to store vertex/fragment shaders)
  104943. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104944. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104945. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104946. * @param samplers defines an array of string used to represent textures
  104947. * @param defines defines the string containing the defines to use to compile the shaders
  104948. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104949. * @param onCompiled defines a function to call when the effect creation is successful
  104950. * @param onError defines a function to call when the effect creation has failed
  104951. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104952. * @returns the new Effect
  104953. */
  104954. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  104955. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104956. private _compileShader;
  104957. private _compileRawShader;
  104958. /** @hidden */
  104959. _getShaderSource(shader: WebGLShader): Nullable<string>;
  104960. /**
  104961. * Directly creates a webGL program
  104962. * @param pipelineContext defines the pipeline context to attach to
  104963. * @param vertexCode defines the vertex shader code to use
  104964. * @param fragmentCode defines the fragment shader code to use
  104965. * @param context defines the webGL context to use (if not set, the current one will be used)
  104966. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104967. * @returns the new webGL program
  104968. */
  104969. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104970. /**
  104971. * Creates a webGL program
  104972. * @param pipelineContext defines the pipeline context to attach to
  104973. * @param vertexCode defines the vertex shader code to use
  104974. * @param fragmentCode defines the fragment shader code to use
  104975. * @param defines defines the string containing the defines to use to compile the shaders
  104976. * @param context defines the webGL context to use (if not set, the current one will be used)
  104977. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104978. * @returns the new webGL program
  104979. */
  104980. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104981. /**
  104982. * Creates a new pipeline context
  104983. * @returns the new pipeline
  104984. */
  104985. createPipelineContext(): IPipelineContext;
  104986. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104987. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104988. /** @hidden */
  104989. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104990. /** @hidden */
  104991. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104992. /** @hidden */
  104993. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104994. /**
  104995. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104996. * @param pipelineContext defines the pipeline context to use
  104997. * @param uniformsNames defines the list of uniform names
  104998. * @returns an array of webGL uniform locations
  104999. */
  105000. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  105001. /**
  105002. * Gets the lsit of active attributes for a given webGL program
  105003. * @param pipelineContext defines the pipeline context to use
  105004. * @param attributesNames defines the list of attribute names to get
  105005. * @returns an array of indices indicating the offset of each attribute
  105006. */
  105007. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  105008. /**
  105009. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  105010. * @param effect defines the effect to activate
  105011. */
  105012. enableEffect(effect: Nullable<Effect>): void;
  105013. /**
  105014. * Set the value of an uniform to a number (int)
  105015. * @param uniform defines the webGL uniform location where to store the value
  105016. * @param value defines the int number to store
  105017. */
  105018. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105019. /**
  105020. * Set the value of an uniform to an array of int32
  105021. * @param uniform defines the webGL uniform location where to store the value
  105022. * @param array defines the array of int32 to store
  105023. */
  105024. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105025. /**
  105026. * Set the value of an uniform to an array of int32 (stored as vec2)
  105027. * @param uniform defines the webGL uniform location where to store the value
  105028. * @param array defines the array of int32 to store
  105029. */
  105030. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105031. /**
  105032. * Set the value of an uniform to an array of int32 (stored as vec3)
  105033. * @param uniform defines the webGL uniform location where to store the value
  105034. * @param array defines the array of int32 to store
  105035. */
  105036. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105037. /**
  105038. * Set the value of an uniform to an array of int32 (stored as vec4)
  105039. * @param uniform defines the webGL uniform location where to store the value
  105040. * @param array defines the array of int32 to store
  105041. */
  105042. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105043. /**
  105044. * Set the value of an uniform to an array of number
  105045. * @param uniform defines the webGL uniform location where to store the value
  105046. * @param array defines the array of number to store
  105047. */
  105048. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105049. /**
  105050. * Set the value of an uniform to an array of number (stored as vec2)
  105051. * @param uniform defines the webGL uniform location where to store the value
  105052. * @param array defines the array of number to store
  105053. */
  105054. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105055. /**
  105056. * Set the value of an uniform to an array of number (stored as vec3)
  105057. * @param uniform defines the webGL uniform location where to store the value
  105058. * @param array defines the array of number to store
  105059. */
  105060. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105061. /**
  105062. * Set the value of an uniform to an array of number (stored as vec4)
  105063. * @param uniform defines the webGL uniform location where to store the value
  105064. * @param array defines the array of number to store
  105065. */
  105066. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  105067. /**
  105068. * Set the value of an uniform to an array of float32 (stored as matrices)
  105069. * @param uniform defines the webGL uniform location where to store the value
  105070. * @param matrices defines the array of float32 to store
  105071. */
  105072. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  105073. /**
  105074. * Set the value of an uniform to a matrix (3x3)
  105075. * @param uniform defines the webGL uniform location where to store the value
  105076. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  105077. */
  105078. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105079. /**
  105080. * Set the value of an uniform to a matrix (2x2)
  105081. * @param uniform defines the webGL uniform location where to store the value
  105082. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  105083. */
  105084. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  105085. /**
  105086. * Set the value of an uniform to a number (float)
  105087. * @param uniform defines the webGL uniform location where to store the value
  105088. * @param value defines the float number to store
  105089. */
  105090. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105091. /**
  105092. * Set the value of an uniform to a vec2
  105093. * @param uniform defines the webGL uniform location where to store the value
  105094. * @param x defines the 1st component of the value
  105095. * @param y defines the 2nd component of the value
  105096. */
  105097. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  105098. /**
  105099. * Set the value of an uniform to a vec3
  105100. * @param uniform defines the webGL uniform location where to store the value
  105101. * @param x defines the 1st component of the value
  105102. * @param y defines the 2nd component of the value
  105103. * @param z defines the 3rd component of the value
  105104. */
  105105. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  105106. /**
  105107. * Set the value of an uniform to a vec4
  105108. * @param uniform defines the webGL uniform location where to store the value
  105109. * @param x defines the 1st component of the value
  105110. * @param y defines the 2nd component of the value
  105111. * @param z defines the 3rd component of the value
  105112. * @param w defines the 4th component of the value
  105113. */
  105114. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  105115. /**
  105116. * Apply all cached states (depth, culling, stencil and alpha)
  105117. */
  105118. applyStates(): void;
  105119. /**
  105120. * Enable or disable color writing
  105121. * @param enable defines the state to set
  105122. */
  105123. setColorWrite(enable: boolean): void;
  105124. /**
  105125. * Gets a boolean indicating if color writing is enabled
  105126. * @returns the current color writing state
  105127. */
  105128. getColorWrite(): boolean;
  105129. /**
  105130. * Gets the depth culling state manager
  105131. */
  105132. get depthCullingState(): DepthCullingState;
  105133. /**
  105134. * Gets the alpha state manager
  105135. */
  105136. get alphaState(): AlphaState;
  105137. /**
  105138. * Gets the stencil state manager
  105139. */
  105140. get stencilState(): StencilState;
  105141. /**
  105142. * Clears the list of texture accessible through engine.
  105143. * This can help preventing texture load conflict due to name collision.
  105144. */
  105145. clearInternalTexturesCache(): void;
  105146. /**
  105147. * Force the entire cache to be cleared
  105148. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105149. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105150. */
  105151. wipeCaches(bruteForce?: boolean): void;
  105152. /** @hidden */
  105153. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105154. min: number;
  105155. mag: number;
  105156. };
  105157. /** @hidden */
  105158. _createTexture(): WebGLTexture;
  105159. /**
  105160. * Usually called from Texture.ts.
  105161. * Passed information to create a WebGLTexture
  105162. * @param urlArg defines a value which contains one of the following:
  105163. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105164. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105165. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105166. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105167. * @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)
  105168. * @param scene needed for loading to the correct scene
  105169. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105170. * @param onLoad optional callback to be called upon successful completion
  105171. * @param onError optional callback to be called upon failure
  105172. * @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
  105173. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105174. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105175. * @param forcedExtension defines the extension to use to pick the right loader
  105176. * @param mimeType defines an optional mime type
  105177. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105178. */
  105179. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  105180. /**
  105181. * Loads an image as an HTMLImageElement.
  105182. * @param input url string, ArrayBuffer, or Blob to load
  105183. * @param onLoad callback called when the image successfully loads
  105184. * @param onError callback called when the image fails to load
  105185. * @param offlineProvider offline provider for caching
  105186. * @param mimeType optional mime type
  105187. * @returns the HTMLImageElement of the loaded image
  105188. * @hidden
  105189. */
  105190. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  105191. /**
  105192. * @hidden
  105193. */
  105194. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105195. /**
  105196. * Creates a raw texture
  105197. * @param data defines the data to store in the texture
  105198. * @param width defines the width of the texture
  105199. * @param height defines the height of the texture
  105200. * @param format defines the format of the data
  105201. * @param generateMipMaps defines if the engine should generate the mip levels
  105202. * @param invertY defines if data must be stored with Y axis inverted
  105203. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105204. * @param compression defines the compression used (null by default)
  105205. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105206. * @returns the raw texture inside an InternalTexture
  105207. */
  105208. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105209. /**
  105210. * Creates a new raw cube texture
  105211. * @param data defines the array of data to use to create each face
  105212. * @param size defines the size of the textures
  105213. * @param format defines the format of the data
  105214. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105215. * @param generateMipMaps defines if the engine should generate the mip levels
  105216. * @param invertY defines if data must be stored with Y axis inverted
  105217. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105218. * @param compression defines the compression used (null by default)
  105219. * @returns the cube texture as an InternalTexture
  105220. */
  105221. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105222. /**
  105223. * Creates a new raw 3D texture
  105224. * @param data defines the data used to create the texture
  105225. * @param width defines the width of the texture
  105226. * @param height defines the height of the texture
  105227. * @param depth defines the depth of the texture
  105228. * @param format defines the format of the texture
  105229. * @param generateMipMaps defines if the engine must generate mip levels
  105230. * @param invertY defines if data must be stored with Y axis inverted
  105231. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105232. * @param compression defines the compressed used (can be null)
  105233. * @param textureType defines the compressed used (can be null)
  105234. * @returns a new raw 3D texture (stored in an InternalTexture)
  105235. */
  105236. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105237. /**
  105238. * Creates a new raw 2D array texture
  105239. * @param data defines the data used to create the texture
  105240. * @param width defines the width of the texture
  105241. * @param height defines the height of the texture
  105242. * @param depth defines the number of layers of the texture
  105243. * @param format defines the format of the texture
  105244. * @param generateMipMaps defines if the engine must generate mip levels
  105245. * @param invertY defines if data must be stored with Y axis inverted
  105246. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105247. * @param compression defines the compressed used (can be null)
  105248. * @param textureType defines the compressed used (can be null)
  105249. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105250. */
  105251. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105252. private _unpackFlipYCached;
  105253. /**
  105254. * In case you are sharing the context with other applications, it might
  105255. * be interested to not cache the unpack flip y state to ensure a consistent
  105256. * value would be set.
  105257. */
  105258. enableUnpackFlipYCached: boolean;
  105259. /** @hidden */
  105260. _unpackFlipY(value: boolean): void;
  105261. /** @hidden */
  105262. _getUnpackAlignement(): number;
  105263. private _getTextureTarget;
  105264. /**
  105265. * Update the sampling mode of a given texture
  105266. * @param samplingMode defines the required sampling mode
  105267. * @param texture defines the texture to update
  105268. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105269. */
  105270. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105271. /**
  105272. * Update the sampling mode of a given texture
  105273. * @param texture defines the texture to update
  105274. * @param wrapU defines the texture wrap mode of the u coordinates
  105275. * @param wrapV defines the texture wrap mode of the v coordinates
  105276. * @param wrapR defines the texture wrap mode of the r coordinates
  105277. */
  105278. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105279. /** @hidden */
  105280. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105281. width: number;
  105282. height: number;
  105283. layers?: number;
  105284. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105285. /** @hidden */
  105286. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105287. /** @hidden */
  105288. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105289. /**
  105290. * Update a portion of an internal texture
  105291. * @param texture defines the texture to update
  105292. * @param imageData defines the data to store into the texture
  105293. * @param xOffset defines the x coordinates of the update rectangle
  105294. * @param yOffset defines the y coordinates of the update rectangle
  105295. * @param width defines the width of the update rectangle
  105296. * @param height defines the height of the update rectangle
  105297. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105298. * @param lod defines the lod level to update (0 by default)
  105299. */
  105300. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105301. /** @hidden */
  105302. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105303. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105304. private _prepareWebGLTexture;
  105305. /** @hidden */
  105306. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105307. private _getDepthStencilBuffer;
  105308. /** @hidden */
  105309. _releaseFramebufferObjects(texture: InternalTexture): void;
  105310. /** @hidden */
  105311. _releaseTexture(texture: InternalTexture): void;
  105312. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105313. protected _setProgram(program: WebGLProgram): void;
  105314. protected _boundUniforms: {
  105315. [key: number]: WebGLUniformLocation;
  105316. };
  105317. /**
  105318. * Binds an effect to the webGL context
  105319. * @param effect defines the effect to bind
  105320. */
  105321. bindSamplers(effect: Effect): void;
  105322. private _activateCurrentTexture;
  105323. /** @hidden */
  105324. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105325. /** @hidden */
  105326. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105327. /**
  105328. * Unbind all textures from the webGL context
  105329. */
  105330. unbindAllTextures(): void;
  105331. /**
  105332. * Sets a texture to the according uniform.
  105333. * @param channel The texture channel
  105334. * @param uniform The uniform to set
  105335. * @param texture The texture to apply
  105336. */
  105337. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105338. private _bindSamplerUniformToChannel;
  105339. private _getTextureWrapMode;
  105340. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105341. /**
  105342. * Sets an array of texture to the webGL context
  105343. * @param channel defines the channel where the texture array must be set
  105344. * @param uniform defines the associated uniform location
  105345. * @param textures defines the array of textures to bind
  105346. */
  105347. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105348. /** @hidden */
  105349. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105350. private _setTextureParameterFloat;
  105351. private _setTextureParameterInteger;
  105352. /**
  105353. * Unbind all vertex attributes from the webGL context
  105354. */
  105355. unbindAllAttributes(): void;
  105356. /**
  105357. * 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
  105358. */
  105359. releaseEffects(): void;
  105360. /**
  105361. * Dispose and release all associated resources
  105362. */
  105363. dispose(): void;
  105364. /**
  105365. * Attach a new callback raised when context lost event is fired
  105366. * @param callback defines the callback to call
  105367. */
  105368. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105369. /**
  105370. * Attach a new callback raised when context restored event is fired
  105371. * @param callback defines the callback to call
  105372. */
  105373. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105374. /**
  105375. * Get the current error code of the webGL context
  105376. * @returns the error code
  105377. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105378. */
  105379. getError(): number;
  105380. private _canRenderToFloatFramebuffer;
  105381. private _canRenderToHalfFloatFramebuffer;
  105382. private _canRenderToFramebuffer;
  105383. /** @hidden */
  105384. _getWebGLTextureType(type: number): number;
  105385. /** @hidden */
  105386. _getInternalFormat(format: number): number;
  105387. /** @hidden */
  105388. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105389. /** @hidden */
  105390. _getRGBAMultiSampleBufferFormat(type: number): number;
  105391. /** @hidden */
  105392. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  105393. /**
  105394. * Loads a file from a url
  105395. * @param url url to load
  105396. * @param onSuccess callback called when the file successfully loads
  105397. * @param onProgress callback called while file is loading (if the server supports this mode)
  105398. * @param offlineProvider defines the offline provider for caching
  105399. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105400. * @param onError callback called when the file fails to load
  105401. * @returns a file request object
  105402. * @hidden
  105403. */
  105404. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  105405. /**
  105406. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105407. * @param x defines the x coordinate of the rectangle where pixels must be read
  105408. * @param y defines the y coordinate of the rectangle where pixels must be read
  105409. * @param width defines the width of the rectangle where pixels must be read
  105410. * @param height defines the height of the rectangle where pixels must be read
  105411. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105412. * @returns a Uint8Array containing RGBA colors
  105413. */
  105414. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105415. private static _isSupported;
  105416. /**
  105417. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105418. * @returns true if the engine can be created
  105419. * @ignorenaming
  105420. */
  105421. static isSupported(): boolean;
  105422. /**
  105423. * Find the next highest power of two.
  105424. * @param x Number to start search from.
  105425. * @return Next highest power of two.
  105426. */
  105427. static CeilingPOT(x: number): number;
  105428. /**
  105429. * Find the next lowest power of two.
  105430. * @param x Number to start search from.
  105431. * @return Next lowest power of two.
  105432. */
  105433. static FloorPOT(x: number): number;
  105434. /**
  105435. * Find the nearest power of two.
  105436. * @param x Number to start search from.
  105437. * @return Next nearest power of two.
  105438. */
  105439. static NearestPOT(x: number): number;
  105440. /**
  105441. * Get the closest exponent of two
  105442. * @param value defines the value to approximate
  105443. * @param max defines the maximum value to return
  105444. * @param mode defines how to define the closest value
  105445. * @returns closest exponent of two of the given value
  105446. */
  105447. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105448. /**
  105449. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105450. * @param func - the function to be called
  105451. * @param requester - the object that will request the next frame. Falls back to window.
  105452. * @returns frame number
  105453. */
  105454. static QueueNewFrame(func: () => void, requester?: any): number;
  105455. /**
  105456. * Gets host document
  105457. * @returns the host document object
  105458. */
  105459. getHostDocument(): Nullable<Document>;
  105460. }
  105461. }
  105462. declare module BABYLON {
  105463. /**
  105464. * Class representing spherical harmonics coefficients to the 3rd degree
  105465. */
  105466. export class SphericalHarmonics {
  105467. /**
  105468. * Defines whether or not the harmonics have been prescaled for rendering.
  105469. */
  105470. preScaled: boolean;
  105471. /**
  105472. * The l0,0 coefficients of the spherical harmonics
  105473. */
  105474. l00: Vector3;
  105475. /**
  105476. * The l1,-1 coefficients of the spherical harmonics
  105477. */
  105478. l1_1: Vector3;
  105479. /**
  105480. * The l1,0 coefficients of the spherical harmonics
  105481. */
  105482. l10: Vector3;
  105483. /**
  105484. * The l1,1 coefficients of the spherical harmonics
  105485. */
  105486. l11: Vector3;
  105487. /**
  105488. * The l2,-2 coefficients of the spherical harmonics
  105489. */
  105490. l2_2: Vector3;
  105491. /**
  105492. * The l2,-1 coefficients of the spherical harmonics
  105493. */
  105494. l2_1: Vector3;
  105495. /**
  105496. * The l2,0 coefficients of the spherical harmonics
  105497. */
  105498. l20: Vector3;
  105499. /**
  105500. * The l2,1 coefficients of the spherical harmonics
  105501. */
  105502. l21: Vector3;
  105503. /**
  105504. * The l2,2 coefficients of the spherical harmonics
  105505. */
  105506. l22: Vector3;
  105507. /**
  105508. * Adds a light to the spherical harmonics
  105509. * @param direction the direction of the light
  105510. * @param color the color of the light
  105511. * @param deltaSolidAngle the delta solid angle of the light
  105512. */
  105513. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105514. /**
  105515. * Scales the spherical harmonics by the given amount
  105516. * @param scale the amount to scale
  105517. */
  105518. scaleInPlace(scale: number): void;
  105519. /**
  105520. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105521. *
  105522. * ```
  105523. * E_lm = A_l * L_lm
  105524. * ```
  105525. *
  105526. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105527. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105528. * the scaling factors are given in equation 9.
  105529. */
  105530. convertIncidentRadianceToIrradiance(): void;
  105531. /**
  105532. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105533. *
  105534. * ```
  105535. * L = (1/pi) * E * rho
  105536. * ```
  105537. *
  105538. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105539. */
  105540. convertIrradianceToLambertianRadiance(): void;
  105541. /**
  105542. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105543. * required operations at run time.
  105544. *
  105545. * This is simply done by scaling back the SH with Ylm constants parameter.
  105546. * The trigonometric part being applied by the shader at run time.
  105547. */
  105548. preScaleForRendering(): void;
  105549. /**
  105550. * Constructs a spherical harmonics from an array.
  105551. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105552. * @returns the spherical harmonics
  105553. */
  105554. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105555. /**
  105556. * Gets the spherical harmonics from polynomial
  105557. * @param polynomial the spherical polynomial
  105558. * @returns the spherical harmonics
  105559. */
  105560. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105561. }
  105562. /**
  105563. * Class representing spherical polynomial coefficients to the 3rd degree
  105564. */
  105565. export class SphericalPolynomial {
  105566. private _harmonics;
  105567. /**
  105568. * The spherical harmonics used to create the polynomials.
  105569. */
  105570. get preScaledHarmonics(): SphericalHarmonics;
  105571. /**
  105572. * The x coefficients of the spherical polynomial
  105573. */
  105574. x: Vector3;
  105575. /**
  105576. * The y coefficients of the spherical polynomial
  105577. */
  105578. y: Vector3;
  105579. /**
  105580. * The z coefficients of the spherical polynomial
  105581. */
  105582. z: Vector3;
  105583. /**
  105584. * The xx coefficients of the spherical polynomial
  105585. */
  105586. xx: Vector3;
  105587. /**
  105588. * The yy coefficients of the spherical polynomial
  105589. */
  105590. yy: Vector3;
  105591. /**
  105592. * The zz coefficients of the spherical polynomial
  105593. */
  105594. zz: Vector3;
  105595. /**
  105596. * The xy coefficients of the spherical polynomial
  105597. */
  105598. xy: Vector3;
  105599. /**
  105600. * The yz coefficients of the spherical polynomial
  105601. */
  105602. yz: Vector3;
  105603. /**
  105604. * The zx coefficients of the spherical polynomial
  105605. */
  105606. zx: Vector3;
  105607. /**
  105608. * Adds an ambient color to the spherical polynomial
  105609. * @param color the color to add
  105610. */
  105611. addAmbient(color: Color3): void;
  105612. /**
  105613. * Scales the spherical polynomial by the given amount
  105614. * @param scale the amount to scale
  105615. */
  105616. scaleInPlace(scale: number): void;
  105617. /**
  105618. * Gets the spherical polynomial from harmonics
  105619. * @param harmonics the spherical harmonics
  105620. * @returns the spherical polynomial
  105621. */
  105622. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105623. /**
  105624. * Constructs a spherical polynomial from an array.
  105625. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105626. * @returns the spherical polynomial
  105627. */
  105628. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105629. }
  105630. }
  105631. declare module BABYLON {
  105632. /**
  105633. * Defines the source of the internal texture
  105634. */
  105635. export enum InternalTextureSource {
  105636. /**
  105637. * The source of the texture data is unknown
  105638. */
  105639. Unknown = 0,
  105640. /**
  105641. * Texture data comes from an URL
  105642. */
  105643. Url = 1,
  105644. /**
  105645. * Texture data is only used for temporary storage
  105646. */
  105647. Temp = 2,
  105648. /**
  105649. * Texture data comes from raw data (ArrayBuffer)
  105650. */
  105651. Raw = 3,
  105652. /**
  105653. * Texture content is dynamic (video or dynamic texture)
  105654. */
  105655. Dynamic = 4,
  105656. /**
  105657. * Texture content is generated by rendering to it
  105658. */
  105659. RenderTarget = 5,
  105660. /**
  105661. * Texture content is part of a multi render target process
  105662. */
  105663. MultiRenderTarget = 6,
  105664. /**
  105665. * Texture data comes from a cube data file
  105666. */
  105667. Cube = 7,
  105668. /**
  105669. * Texture data comes from a raw cube data
  105670. */
  105671. CubeRaw = 8,
  105672. /**
  105673. * Texture data come from a prefiltered cube data file
  105674. */
  105675. CubePrefiltered = 9,
  105676. /**
  105677. * Texture content is raw 3D data
  105678. */
  105679. Raw3D = 10,
  105680. /**
  105681. * Texture content is raw 2D array data
  105682. */
  105683. Raw2DArray = 11,
  105684. /**
  105685. * Texture content is a depth texture
  105686. */
  105687. Depth = 12,
  105688. /**
  105689. * Texture data comes from a raw cube data encoded with RGBD
  105690. */
  105691. CubeRawRGBD = 13
  105692. }
  105693. /**
  105694. * Class used to store data associated with WebGL texture data for the engine
  105695. * This class should not be used directly
  105696. */
  105697. export class InternalTexture {
  105698. /** @hidden */
  105699. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105700. /**
  105701. * Defines if the texture is ready
  105702. */
  105703. isReady: boolean;
  105704. /**
  105705. * Defines if the texture is a cube texture
  105706. */
  105707. isCube: boolean;
  105708. /**
  105709. * Defines if the texture contains 3D data
  105710. */
  105711. is3D: boolean;
  105712. /**
  105713. * Defines if the texture contains 2D array data
  105714. */
  105715. is2DArray: boolean;
  105716. /**
  105717. * Defines if the texture contains multiview data
  105718. */
  105719. isMultiview: boolean;
  105720. /**
  105721. * Gets the URL used to load this texture
  105722. */
  105723. url: string;
  105724. /**
  105725. * Gets the sampling mode of the texture
  105726. */
  105727. samplingMode: number;
  105728. /**
  105729. * Gets a boolean indicating if the texture needs mipmaps generation
  105730. */
  105731. generateMipMaps: boolean;
  105732. /**
  105733. * Gets the number of samples used by the texture (WebGL2+ only)
  105734. */
  105735. samples: number;
  105736. /**
  105737. * Gets the type of the texture (int, float...)
  105738. */
  105739. type: number;
  105740. /**
  105741. * Gets the format of the texture (RGB, RGBA...)
  105742. */
  105743. format: number;
  105744. /**
  105745. * Observable called when the texture is loaded
  105746. */
  105747. onLoadedObservable: Observable<InternalTexture>;
  105748. /**
  105749. * Gets the width of the texture
  105750. */
  105751. width: number;
  105752. /**
  105753. * Gets the height of the texture
  105754. */
  105755. height: number;
  105756. /**
  105757. * Gets the depth of the texture
  105758. */
  105759. depth: number;
  105760. /**
  105761. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105762. */
  105763. baseWidth: number;
  105764. /**
  105765. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105766. */
  105767. baseHeight: number;
  105768. /**
  105769. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105770. */
  105771. baseDepth: number;
  105772. /**
  105773. * Gets a boolean indicating if the texture is inverted on Y axis
  105774. */
  105775. invertY: boolean;
  105776. /** @hidden */
  105777. _invertVScale: boolean;
  105778. /** @hidden */
  105779. _associatedChannel: number;
  105780. /** @hidden */
  105781. _source: InternalTextureSource;
  105782. /** @hidden */
  105783. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105784. /** @hidden */
  105785. _bufferView: Nullable<ArrayBufferView>;
  105786. /** @hidden */
  105787. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105788. /** @hidden */
  105789. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105790. /** @hidden */
  105791. _size: number;
  105792. /** @hidden */
  105793. _extension: string;
  105794. /** @hidden */
  105795. _files: Nullable<string[]>;
  105796. /** @hidden */
  105797. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105798. /** @hidden */
  105799. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105800. /** @hidden */
  105801. _framebuffer: Nullable<WebGLFramebuffer>;
  105802. /** @hidden */
  105803. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105804. /** @hidden */
  105805. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105806. /** @hidden */
  105807. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105808. /** @hidden */
  105809. _attachments: Nullable<number[]>;
  105810. /** @hidden */
  105811. _cachedCoordinatesMode: Nullable<number>;
  105812. /** @hidden */
  105813. _cachedWrapU: Nullable<number>;
  105814. /** @hidden */
  105815. _cachedWrapV: Nullable<number>;
  105816. /** @hidden */
  105817. _cachedWrapR: Nullable<number>;
  105818. /** @hidden */
  105819. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105820. /** @hidden */
  105821. _isDisabled: boolean;
  105822. /** @hidden */
  105823. _compression: Nullable<string>;
  105824. /** @hidden */
  105825. _generateStencilBuffer: boolean;
  105826. /** @hidden */
  105827. _generateDepthBuffer: boolean;
  105828. /** @hidden */
  105829. _comparisonFunction: number;
  105830. /** @hidden */
  105831. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105832. /** @hidden */
  105833. _lodGenerationScale: number;
  105834. /** @hidden */
  105835. _lodGenerationOffset: number;
  105836. /** @hidden */
  105837. _depthStencilTexture: Nullable<InternalTexture>;
  105838. /** @hidden */
  105839. _colorTextureArray: Nullable<WebGLTexture>;
  105840. /** @hidden */
  105841. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105842. /** @hidden */
  105843. _lodTextureHigh: Nullable<BaseTexture>;
  105844. /** @hidden */
  105845. _lodTextureMid: Nullable<BaseTexture>;
  105846. /** @hidden */
  105847. _lodTextureLow: Nullable<BaseTexture>;
  105848. /** @hidden */
  105849. _isRGBD: boolean;
  105850. /** @hidden */
  105851. _linearSpecularLOD: boolean;
  105852. /** @hidden */
  105853. _irradianceTexture: Nullable<BaseTexture>;
  105854. /** @hidden */
  105855. _webGLTexture: Nullable<WebGLTexture>;
  105856. /** @hidden */
  105857. _references: number;
  105858. private _engine;
  105859. /**
  105860. * Gets the Engine the texture belongs to.
  105861. * @returns The babylon engine
  105862. */
  105863. getEngine(): ThinEngine;
  105864. /**
  105865. * Gets the data source type of the texture
  105866. */
  105867. get source(): InternalTextureSource;
  105868. /**
  105869. * Creates a new InternalTexture
  105870. * @param engine defines the engine to use
  105871. * @param source defines the type of data that will be used
  105872. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105873. */
  105874. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105875. /**
  105876. * Increments the number of references (ie. the number of Texture that point to it)
  105877. */
  105878. incrementReferences(): void;
  105879. /**
  105880. * Change the size of the texture (not the size of the content)
  105881. * @param width defines the new width
  105882. * @param height defines the new height
  105883. * @param depth defines the new depth (1 by default)
  105884. */
  105885. updateSize(width: int, height: int, depth?: int): void;
  105886. /** @hidden */
  105887. _rebuild(): void;
  105888. /** @hidden */
  105889. _swapAndDie(target: InternalTexture): void;
  105890. /**
  105891. * Dispose the current allocated resources
  105892. */
  105893. dispose(): void;
  105894. }
  105895. }
  105896. declare module BABYLON {
  105897. /**
  105898. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105900. */
  105901. export class Analyser {
  105902. /**
  105903. * Gets or sets the smoothing
  105904. * @ignorenaming
  105905. */
  105906. SMOOTHING: number;
  105907. /**
  105908. * Gets or sets the FFT table size
  105909. * @ignorenaming
  105910. */
  105911. FFT_SIZE: number;
  105912. /**
  105913. * Gets or sets the bar graph amplitude
  105914. * @ignorenaming
  105915. */
  105916. BARGRAPHAMPLITUDE: number;
  105917. /**
  105918. * Gets or sets the position of the debug canvas
  105919. * @ignorenaming
  105920. */
  105921. DEBUGCANVASPOS: {
  105922. x: number;
  105923. y: number;
  105924. };
  105925. /**
  105926. * Gets or sets the debug canvas size
  105927. * @ignorenaming
  105928. */
  105929. DEBUGCANVASSIZE: {
  105930. width: number;
  105931. height: number;
  105932. };
  105933. private _byteFreqs;
  105934. private _byteTime;
  105935. private _floatFreqs;
  105936. private _webAudioAnalyser;
  105937. private _debugCanvas;
  105938. private _debugCanvasContext;
  105939. private _scene;
  105940. private _registerFunc;
  105941. private _audioEngine;
  105942. /**
  105943. * Creates a new analyser
  105944. * @param scene defines hosting scene
  105945. */
  105946. constructor(scene: Scene);
  105947. /**
  105948. * Get the number of data values you will have to play with for the visualization
  105949. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105950. * @returns a number
  105951. */
  105952. getFrequencyBinCount(): number;
  105953. /**
  105954. * Gets the current frequency data as a byte array
  105955. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105956. * @returns a Uint8Array
  105957. */
  105958. getByteFrequencyData(): Uint8Array;
  105959. /**
  105960. * Gets the current waveform as a byte array
  105961. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105962. * @returns a Uint8Array
  105963. */
  105964. getByteTimeDomainData(): Uint8Array;
  105965. /**
  105966. * Gets the current frequency data as a float array
  105967. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105968. * @returns a Float32Array
  105969. */
  105970. getFloatFrequencyData(): Float32Array;
  105971. /**
  105972. * Renders the debug canvas
  105973. */
  105974. drawDebugCanvas(): void;
  105975. /**
  105976. * Stops rendering the debug canvas and removes it
  105977. */
  105978. stopDebugCanvas(): void;
  105979. /**
  105980. * Connects two audio nodes
  105981. * @param inputAudioNode defines first node to connect
  105982. * @param outputAudioNode defines second node to connect
  105983. */
  105984. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105985. /**
  105986. * Releases all associated resources
  105987. */
  105988. dispose(): void;
  105989. }
  105990. }
  105991. declare module BABYLON {
  105992. /**
  105993. * This represents an audio engine and it is responsible
  105994. * to play, synchronize and analyse sounds throughout the application.
  105995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105996. */
  105997. export interface IAudioEngine extends IDisposable {
  105998. /**
  105999. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106000. */
  106001. readonly canUseWebAudio: boolean;
  106002. /**
  106003. * Gets the current AudioContext if available.
  106004. */
  106005. readonly audioContext: Nullable<AudioContext>;
  106006. /**
  106007. * The master gain node defines the global audio volume of your audio engine.
  106008. */
  106009. readonly masterGain: GainNode;
  106010. /**
  106011. * Gets whether or not mp3 are supported by your browser.
  106012. */
  106013. readonly isMP3supported: boolean;
  106014. /**
  106015. * Gets whether or not ogg are supported by your browser.
  106016. */
  106017. readonly isOGGsupported: boolean;
  106018. /**
  106019. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106020. * @ignoreNaming
  106021. */
  106022. WarnedWebAudioUnsupported: boolean;
  106023. /**
  106024. * Defines if the audio engine relies on a custom unlocked button.
  106025. * In this case, the embedded button will not be displayed.
  106026. */
  106027. useCustomUnlockedButton: boolean;
  106028. /**
  106029. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  106030. */
  106031. readonly unlocked: boolean;
  106032. /**
  106033. * Event raised when audio has been unlocked on the browser.
  106034. */
  106035. onAudioUnlockedObservable: Observable<AudioEngine>;
  106036. /**
  106037. * Event raised when audio has been locked on the browser.
  106038. */
  106039. onAudioLockedObservable: Observable<AudioEngine>;
  106040. /**
  106041. * Flags the audio engine in Locked state.
  106042. * This happens due to new browser policies preventing audio to autoplay.
  106043. */
  106044. lock(): void;
  106045. /**
  106046. * Unlocks the audio engine once a user action has been done on the dom.
  106047. * This is helpful to resume play once browser policies have been satisfied.
  106048. */
  106049. unlock(): void;
  106050. /**
  106051. * Gets the global volume sets on the master gain.
  106052. * @returns the global volume if set or -1 otherwise
  106053. */
  106054. getGlobalVolume(): number;
  106055. /**
  106056. * Sets the global volume of your experience (sets on the master gain).
  106057. * @param newVolume Defines the new global volume of the application
  106058. */
  106059. setGlobalVolume(newVolume: number): void;
  106060. /**
  106061. * Connect the audio engine to an audio analyser allowing some amazing
  106062. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106064. * @param analyser The analyser to connect to the engine
  106065. */
  106066. connectToAnalyser(analyser: Analyser): void;
  106067. }
  106068. /**
  106069. * This represents the default audio engine used in babylon.
  106070. * It is responsible to play, synchronize and analyse sounds throughout the application.
  106071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106072. */
  106073. export class AudioEngine implements IAudioEngine {
  106074. private _audioContext;
  106075. private _audioContextInitialized;
  106076. private _muteButton;
  106077. private _hostElement;
  106078. /**
  106079. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106080. */
  106081. canUseWebAudio: boolean;
  106082. /**
  106083. * The master gain node defines the global audio volume of your audio engine.
  106084. */
  106085. masterGain: GainNode;
  106086. /**
  106087. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106088. * @ignoreNaming
  106089. */
  106090. WarnedWebAudioUnsupported: boolean;
  106091. /**
  106092. * Gets whether or not mp3 are supported by your browser.
  106093. */
  106094. isMP3supported: boolean;
  106095. /**
  106096. * Gets whether or not ogg are supported by your browser.
  106097. */
  106098. isOGGsupported: boolean;
  106099. /**
  106100. * Gets whether audio has been unlocked on the device.
  106101. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  106102. * a user interaction has happened.
  106103. */
  106104. unlocked: boolean;
  106105. /**
  106106. * Defines if the audio engine relies on a custom unlocked button.
  106107. * In this case, the embedded button will not be displayed.
  106108. */
  106109. useCustomUnlockedButton: boolean;
  106110. /**
  106111. * Event raised when audio has been unlocked on the browser.
  106112. */
  106113. onAudioUnlockedObservable: Observable<AudioEngine>;
  106114. /**
  106115. * Event raised when audio has been locked on the browser.
  106116. */
  106117. onAudioLockedObservable: Observable<AudioEngine>;
  106118. /**
  106119. * Gets the current AudioContext if available.
  106120. */
  106121. get audioContext(): Nullable<AudioContext>;
  106122. private _connectedAnalyser;
  106123. /**
  106124. * Instantiates a new audio engine.
  106125. *
  106126. * There should be only one per page as some browsers restrict the number
  106127. * of audio contexts you can create.
  106128. * @param hostElement defines the host element where to display the mute icon if necessary
  106129. */
  106130. constructor(hostElement?: Nullable<HTMLElement>);
  106131. /**
  106132. * Flags the audio engine in Locked state.
  106133. * This happens due to new browser policies preventing audio to autoplay.
  106134. */
  106135. lock(): void;
  106136. /**
  106137. * Unlocks the audio engine once a user action has been done on the dom.
  106138. * This is helpful to resume play once browser policies have been satisfied.
  106139. */
  106140. unlock(): void;
  106141. private _resumeAudioContext;
  106142. private _initializeAudioContext;
  106143. private _tryToRun;
  106144. private _triggerRunningState;
  106145. private _triggerSuspendedState;
  106146. private _displayMuteButton;
  106147. private _moveButtonToTopLeft;
  106148. private _onResize;
  106149. private _hideMuteButton;
  106150. /**
  106151. * Destroy and release the resources associated with the audio ccontext.
  106152. */
  106153. dispose(): void;
  106154. /**
  106155. * Gets the global volume sets on the master gain.
  106156. * @returns the global volume if set or -1 otherwise
  106157. */
  106158. getGlobalVolume(): number;
  106159. /**
  106160. * Sets the global volume of your experience (sets on the master gain).
  106161. * @param newVolume Defines the new global volume of the application
  106162. */
  106163. setGlobalVolume(newVolume: number): void;
  106164. /**
  106165. * Connect the audio engine to an audio analyser allowing some amazing
  106166. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106168. * @param analyser The analyser to connect to the engine
  106169. */
  106170. connectToAnalyser(analyser: Analyser): void;
  106171. }
  106172. }
  106173. declare module BABYLON {
  106174. /**
  106175. * Interface used to present a loading screen while loading a scene
  106176. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106177. */
  106178. export interface ILoadingScreen {
  106179. /**
  106180. * Function called to display the loading screen
  106181. */
  106182. displayLoadingUI: () => void;
  106183. /**
  106184. * Function called to hide the loading screen
  106185. */
  106186. hideLoadingUI: () => void;
  106187. /**
  106188. * Gets or sets the color to use for the background
  106189. */
  106190. loadingUIBackgroundColor: string;
  106191. /**
  106192. * Gets or sets the text to display while loading
  106193. */
  106194. loadingUIText: string;
  106195. }
  106196. /**
  106197. * Class used for the default loading screen
  106198. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106199. */
  106200. export class DefaultLoadingScreen implements ILoadingScreen {
  106201. private _renderingCanvas;
  106202. private _loadingText;
  106203. private _loadingDivBackgroundColor;
  106204. private _loadingDiv;
  106205. private _loadingTextDiv;
  106206. /** Gets or sets the logo url to use for the default loading screen */
  106207. static DefaultLogoUrl: string;
  106208. /** Gets or sets the spinner url to use for the default loading screen */
  106209. static DefaultSpinnerUrl: string;
  106210. /**
  106211. * Creates a new default loading screen
  106212. * @param _renderingCanvas defines the canvas used to render the scene
  106213. * @param _loadingText defines the default text to display
  106214. * @param _loadingDivBackgroundColor defines the default background color
  106215. */
  106216. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106217. /**
  106218. * Function called to display the loading screen
  106219. */
  106220. displayLoadingUI(): void;
  106221. /**
  106222. * Function called to hide the loading screen
  106223. */
  106224. hideLoadingUI(): void;
  106225. /**
  106226. * Gets or sets the text to display while loading
  106227. */
  106228. set loadingUIText(text: string);
  106229. get loadingUIText(): string;
  106230. /**
  106231. * Gets or sets the color to use for the background
  106232. */
  106233. get loadingUIBackgroundColor(): string;
  106234. set loadingUIBackgroundColor(color: string);
  106235. private _resizeLoadingUI;
  106236. }
  106237. }
  106238. declare module BABYLON {
  106239. /**
  106240. * Interface for any object that can request an animation frame
  106241. */
  106242. export interface ICustomAnimationFrameRequester {
  106243. /**
  106244. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106245. */
  106246. renderFunction?: Function;
  106247. /**
  106248. * Called to request the next frame to render to
  106249. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106250. */
  106251. requestAnimationFrame: Function;
  106252. /**
  106253. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106254. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106255. */
  106256. requestID?: number;
  106257. }
  106258. }
  106259. declare module BABYLON {
  106260. /**
  106261. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106262. */
  106263. export class PerformanceMonitor {
  106264. private _enabled;
  106265. private _rollingFrameTime;
  106266. private _lastFrameTimeMs;
  106267. /**
  106268. * constructor
  106269. * @param frameSampleSize The number of samples required to saturate the sliding window
  106270. */
  106271. constructor(frameSampleSize?: number);
  106272. /**
  106273. * Samples current frame
  106274. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106275. */
  106276. sampleFrame(timeMs?: number): void;
  106277. /**
  106278. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106279. */
  106280. get averageFrameTime(): number;
  106281. /**
  106282. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106283. */
  106284. get averageFrameTimeVariance(): number;
  106285. /**
  106286. * Returns the frame time of the most recent frame
  106287. */
  106288. get instantaneousFrameTime(): number;
  106289. /**
  106290. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106291. */
  106292. get averageFPS(): number;
  106293. /**
  106294. * Returns the average framerate in frames per second using the most recent frame time
  106295. */
  106296. get instantaneousFPS(): number;
  106297. /**
  106298. * Returns true if enough samples have been taken to completely fill the sliding window
  106299. */
  106300. get isSaturated(): boolean;
  106301. /**
  106302. * Enables contributions to the sliding window sample set
  106303. */
  106304. enable(): void;
  106305. /**
  106306. * Disables contributions to the sliding window sample set
  106307. * Samples will not be interpolated over the disabled period
  106308. */
  106309. disable(): void;
  106310. /**
  106311. * Returns true if sampling is enabled
  106312. */
  106313. get isEnabled(): boolean;
  106314. /**
  106315. * Resets performance monitor
  106316. */
  106317. reset(): void;
  106318. }
  106319. /**
  106320. * RollingAverage
  106321. *
  106322. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106323. */
  106324. export class RollingAverage {
  106325. /**
  106326. * Current average
  106327. */
  106328. average: number;
  106329. /**
  106330. * Current variance
  106331. */
  106332. variance: number;
  106333. protected _samples: Array<number>;
  106334. protected _sampleCount: number;
  106335. protected _pos: number;
  106336. protected _m2: number;
  106337. /**
  106338. * constructor
  106339. * @param length The number of samples required to saturate the sliding window
  106340. */
  106341. constructor(length: number);
  106342. /**
  106343. * Adds a sample to the sample set
  106344. * @param v The sample value
  106345. */
  106346. add(v: number): void;
  106347. /**
  106348. * Returns previously added values or null if outside of history or outside the sliding window domain
  106349. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106350. * @return Value previously recorded with add() or null if outside of range
  106351. */
  106352. history(i: number): number;
  106353. /**
  106354. * Returns true if enough samples have been taken to completely fill the sliding window
  106355. * @return true if sample-set saturated
  106356. */
  106357. isSaturated(): boolean;
  106358. /**
  106359. * Resets the rolling average (equivalent to 0 samples taken so far)
  106360. */
  106361. reset(): void;
  106362. /**
  106363. * Wraps a value around the sample range boundaries
  106364. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106365. * @return Wrapped position in sample range
  106366. */
  106367. protected _wrapPosition(i: number): number;
  106368. }
  106369. }
  106370. declare module BABYLON {
  106371. /**
  106372. * This class is used to track a performance counter which is number based.
  106373. * The user has access to many properties which give statistics of different nature.
  106374. *
  106375. * The implementer can track two kinds of Performance Counter: time and count.
  106376. * 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.
  106377. * 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.
  106378. */
  106379. export class PerfCounter {
  106380. /**
  106381. * Gets or sets a global boolean to turn on and off all the counters
  106382. */
  106383. static Enabled: boolean;
  106384. /**
  106385. * Returns the smallest value ever
  106386. */
  106387. get min(): number;
  106388. /**
  106389. * Returns the biggest value ever
  106390. */
  106391. get max(): number;
  106392. /**
  106393. * Returns the average value since the performance counter is running
  106394. */
  106395. get average(): number;
  106396. /**
  106397. * Returns the average value of the last second the counter was monitored
  106398. */
  106399. get lastSecAverage(): number;
  106400. /**
  106401. * Returns the current value
  106402. */
  106403. get current(): number;
  106404. /**
  106405. * Gets the accumulated total
  106406. */
  106407. get total(): number;
  106408. /**
  106409. * Gets the total value count
  106410. */
  106411. get count(): number;
  106412. /**
  106413. * Creates a new counter
  106414. */
  106415. constructor();
  106416. /**
  106417. * Call this method to start monitoring a new frame.
  106418. * 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.
  106419. */
  106420. fetchNewFrame(): void;
  106421. /**
  106422. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106423. * @param newCount the count value to add to the monitored count
  106424. * @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.
  106425. */
  106426. addCount(newCount: number, fetchResult: boolean): void;
  106427. /**
  106428. * Start monitoring this performance counter
  106429. */
  106430. beginMonitoring(): void;
  106431. /**
  106432. * Compute the time lapsed since the previous beginMonitoring() call.
  106433. * @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
  106434. */
  106435. endMonitoring(newFrame?: boolean): void;
  106436. private _fetchResult;
  106437. private _startMonitoringTime;
  106438. private _min;
  106439. private _max;
  106440. private _average;
  106441. private _current;
  106442. private _totalValueCount;
  106443. private _totalAccumulated;
  106444. private _lastSecAverage;
  106445. private _lastSecAccumulated;
  106446. private _lastSecTime;
  106447. private _lastSecValueCount;
  106448. }
  106449. }
  106450. declare module BABYLON {
  106451. interface ThinEngine {
  106452. /**
  106453. * Sets alpha constants used by some alpha blending modes
  106454. * @param r defines the red component
  106455. * @param g defines the green component
  106456. * @param b defines the blue component
  106457. * @param a defines the alpha component
  106458. */
  106459. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106460. /**
  106461. * Sets the current alpha mode
  106462. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106463. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106464. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106465. */
  106466. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106467. /**
  106468. * Gets the current alpha mode
  106469. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106470. * @returns the current alpha mode
  106471. */
  106472. getAlphaMode(): number;
  106473. /**
  106474. * Sets the current alpha equation
  106475. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106476. */
  106477. setAlphaEquation(equation: number): void;
  106478. /**
  106479. * Gets the current alpha equation.
  106480. * @returns the current alpha equation
  106481. */
  106482. getAlphaEquation(): number;
  106483. }
  106484. }
  106485. declare module BABYLON {
  106486. /**
  106487. * Defines the interface used by display changed events
  106488. */
  106489. export interface IDisplayChangedEventArgs {
  106490. /** Gets the vrDisplay object (if any) */
  106491. vrDisplay: Nullable<any>;
  106492. /** Gets a boolean indicating if webVR is supported */
  106493. vrSupported: boolean;
  106494. }
  106495. /**
  106496. * Defines the interface used by objects containing a viewport (like a camera)
  106497. */
  106498. interface IViewportOwnerLike {
  106499. /**
  106500. * Gets or sets the viewport
  106501. */
  106502. viewport: IViewportLike;
  106503. }
  106504. /**
  106505. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106506. */
  106507. export class Engine extends ThinEngine {
  106508. /** Defines that alpha blending is disabled */
  106509. static readonly ALPHA_DISABLE: number;
  106510. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106511. static readonly ALPHA_ADD: number;
  106512. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106513. static readonly ALPHA_COMBINE: number;
  106514. /** Defines that alpha blending to DEST - SRC * DEST */
  106515. static readonly ALPHA_SUBTRACT: number;
  106516. /** Defines that alpha blending to SRC * DEST */
  106517. static readonly ALPHA_MULTIPLY: number;
  106518. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106519. static readonly ALPHA_MAXIMIZED: number;
  106520. /** Defines that alpha blending to SRC + DEST */
  106521. static readonly ALPHA_ONEONE: number;
  106522. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106523. static readonly ALPHA_PREMULTIPLIED: number;
  106524. /**
  106525. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106526. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106527. */
  106528. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106529. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106530. static readonly ALPHA_INTERPOLATE: number;
  106531. /**
  106532. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106533. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106534. */
  106535. static readonly ALPHA_SCREENMODE: number;
  106536. /** Defines that the ressource is not delayed*/
  106537. static readonly DELAYLOADSTATE_NONE: number;
  106538. /** Defines that the ressource was successfully delay loaded */
  106539. static readonly DELAYLOADSTATE_LOADED: number;
  106540. /** Defines that the ressource is currently delay loading */
  106541. static readonly DELAYLOADSTATE_LOADING: number;
  106542. /** Defines that the ressource is delayed and has not started loading */
  106543. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106544. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106545. static readonly NEVER: number;
  106546. /** 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 */
  106547. static readonly ALWAYS: number;
  106548. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106549. static readonly LESS: number;
  106550. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106551. static readonly EQUAL: number;
  106552. /** 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 */
  106553. static readonly LEQUAL: number;
  106554. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106555. static readonly GREATER: number;
  106556. /** 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 */
  106557. static readonly GEQUAL: number;
  106558. /** 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 */
  106559. static readonly NOTEQUAL: number;
  106560. /** Passed to stencilOperation to specify that stencil value must be kept */
  106561. static readonly KEEP: number;
  106562. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106563. static readonly REPLACE: number;
  106564. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106565. static readonly INCR: number;
  106566. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106567. static readonly DECR: number;
  106568. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106569. static readonly INVERT: number;
  106570. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106571. static readonly INCR_WRAP: number;
  106572. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106573. static readonly DECR_WRAP: number;
  106574. /** Texture is not repeating outside of 0..1 UVs */
  106575. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106576. /** Texture is repeating outside of 0..1 UVs */
  106577. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106578. /** Texture is repeating and mirrored */
  106579. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106580. /** ALPHA */
  106581. static readonly TEXTUREFORMAT_ALPHA: number;
  106582. /** LUMINANCE */
  106583. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106584. /** LUMINANCE_ALPHA */
  106585. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106586. /** RGB */
  106587. static readonly TEXTUREFORMAT_RGB: number;
  106588. /** RGBA */
  106589. static readonly TEXTUREFORMAT_RGBA: number;
  106590. /** RED */
  106591. static readonly TEXTUREFORMAT_RED: number;
  106592. /** RED (2nd reference) */
  106593. static readonly TEXTUREFORMAT_R: number;
  106594. /** RG */
  106595. static readonly TEXTUREFORMAT_RG: number;
  106596. /** RED_INTEGER */
  106597. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106598. /** RED_INTEGER (2nd reference) */
  106599. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106600. /** RG_INTEGER */
  106601. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106602. /** RGB_INTEGER */
  106603. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106604. /** RGBA_INTEGER */
  106605. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106606. /** UNSIGNED_BYTE */
  106607. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106608. /** UNSIGNED_BYTE (2nd reference) */
  106609. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106610. /** FLOAT */
  106611. static readonly TEXTURETYPE_FLOAT: number;
  106612. /** HALF_FLOAT */
  106613. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106614. /** BYTE */
  106615. static readonly TEXTURETYPE_BYTE: number;
  106616. /** SHORT */
  106617. static readonly TEXTURETYPE_SHORT: number;
  106618. /** UNSIGNED_SHORT */
  106619. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106620. /** INT */
  106621. static readonly TEXTURETYPE_INT: number;
  106622. /** UNSIGNED_INT */
  106623. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106624. /** UNSIGNED_SHORT_4_4_4_4 */
  106625. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106626. /** UNSIGNED_SHORT_5_5_5_1 */
  106627. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106628. /** UNSIGNED_SHORT_5_6_5 */
  106629. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106630. /** UNSIGNED_INT_2_10_10_10_REV */
  106631. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106632. /** UNSIGNED_INT_24_8 */
  106633. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106634. /** UNSIGNED_INT_10F_11F_11F_REV */
  106635. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106636. /** UNSIGNED_INT_5_9_9_9_REV */
  106637. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106638. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106639. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106640. /** nearest is mag = nearest and min = nearest and mip = linear */
  106641. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106642. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106643. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106644. /** Trilinear is mag = linear and min = linear and mip = linear */
  106645. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106646. /** nearest is mag = nearest and min = nearest and mip = linear */
  106647. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106648. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106649. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106650. /** Trilinear is mag = linear and min = linear and mip = linear */
  106651. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106652. /** mag = nearest and min = nearest and mip = nearest */
  106653. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106654. /** mag = nearest and min = linear and mip = nearest */
  106655. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106656. /** mag = nearest and min = linear and mip = linear */
  106657. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106658. /** mag = nearest and min = linear and mip = none */
  106659. static readonly TEXTURE_NEAREST_LINEAR: number;
  106660. /** mag = nearest and min = nearest and mip = none */
  106661. static readonly TEXTURE_NEAREST_NEAREST: number;
  106662. /** mag = linear and min = nearest and mip = nearest */
  106663. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106664. /** mag = linear and min = nearest and mip = linear */
  106665. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106666. /** mag = linear and min = linear and mip = none */
  106667. static readonly TEXTURE_LINEAR_LINEAR: number;
  106668. /** mag = linear and min = nearest and mip = none */
  106669. static readonly TEXTURE_LINEAR_NEAREST: number;
  106670. /** Explicit coordinates mode */
  106671. static readonly TEXTURE_EXPLICIT_MODE: number;
  106672. /** Spherical coordinates mode */
  106673. static readonly TEXTURE_SPHERICAL_MODE: number;
  106674. /** Planar coordinates mode */
  106675. static readonly TEXTURE_PLANAR_MODE: number;
  106676. /** Cubic coordinates mode */
  106677. static readonly TEXTURE_CUBIC_MODE: number;
  106678. /** Projection coordinates mode */
  106679. static readonly TEXTURE_PROJECTION_MODE: number;
  106680. /** Skybox coordinates mode */
  106681. static readonly TEXTURE_SKYBOX_MODE: number;
  106682. /** Inverse Cubic coordinates mode */
  106683. static readonly TEXTURE_INVCUBIC_MODE: number;
  106684. /** Equirectangular coordinates mode */
  106685. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106686. /** Equirectangular Fixed coordinates mode */
  106687. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106688. /** Equirectangular Fixed Mirrored coordinates mode */
  106689. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106690. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106691. static readonly SCALEMODE_FLOOR: number;
  106692. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106693. static readonly SCALEMODE_NEAREST: number;
  106694. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106695. static readonly SCALEMODE_CEILING: number;
  106696. /**
  106697. * Returns the current npm package of the sdk
  106698. */
  106699. static get NpmPackage(): string;
  106700. /**
  106701. * Returns the current version of the framework
  106702. */
  106703. static get Version(): string;
  106704. /** Gets the list of created engines */
  106705. static get Instances(): Engine[];
  106706. /**
  106707. * Gets the latest created engine
  106708. */
  106709. static get LastCreatedEngine(): Nullable<Engine>;
  106710. /**
  106711. * Gets the latest created scene
  106712. */
  106713. static get LastCreatedScene(): Nullable<Scene>;
  106714. /**
  106715. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106716. * @param flag defines which part of the materials must be marked as dirty
  106717. * @param predicate defines a predicate used to filter which materials should be affected
  106718. */
  106719. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106720. /**
  106721. * Method called to create the default loading screen.
  106722. * This can be overriden in your own app.
  106723. * @param canvas The rendering canvas element
  106724. * @returns The loading screen
  106725. */
  106726. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106727. /**
  106728. * Method called to create the default rescale post process on each engine.
  106729. */
  106730. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106731. /**
  106732. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106733. **/
  106734. enableOfflineSupport: boolean;
  106735. /**
  106736. * 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)
  106737. **/
  106738. disableManifestCheck: boolean;
  106739. /**
  106740. * Gets the list of created scenes
  106741. */
  106742. scenes: Scene[];
  106743. /**
  106744. * Event raised when a new scene is created
  106745. */
  106746. onNewSceneAddedObservable: Observable<Scene>;
  106747. /**
  106748. * Gets the list of created postprocesses
  106749. */
  106750. postProcesses: PostProcess[];
  106751. /**
  106752. * Gets a boolean indicating if the pointer is currently locked
  106753. */
  106754. isPointerLock: boolean;
  106755. /**
  106756. * Observable event triggered each time the rendering canvas is resized
  106757. */
  106758. onResizeObservable: Observable<Engine>;
  106759. /**
  106760. * Observable event triggered each time the canvas loses focus
  106761. */
  106762. onCanvasBlurObservable: Observable<Engine>;
  106763. /**
  106764. * Observable event triggered each time the canvas gains focus
  106765. */
  106766. onCanvasFocusObservable: Observable<Engine>;
  106767. /**
  106768. * Observable event triggered each time the canvas receives pointerout event
  106769. */
  106770. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106771. /**
  106772. * Observable raised when the engine begins a new frame
  106773. */
  106774. onBeginFrameObservable: Observable<Engine>;
  106775. /**
  106776. * If set, will be used to request the next animation frame for the render loop
  106777. */
  106778. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106779. /**
  106780. * Observable raised when the engine ends the current frame
  106781. */
  106782. onEndFrameObservable: Observable<Engine>;
  106783. /**
  106784. * Observable raised when the engine is about to compile a shader
  106785. */
  106786. onBeforeShaderCompilationObservable: Observable<Engine>;
  106787. /**
  106788. * Observable raised when the engine has jsut compiled a shader
  106789. */
  106790. onAfterShaderCompilationObservable: Observable<Engine>;
  106791. /**
  106792. * Gets the audio engine
  106793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106794. * @ignorenaming
  106795. */
  106796. static audioEngine: IAudioEngine;
  106797. /**
  106798. * Default AudioEngine factory responsible of creating the Audio Engine.
  106799. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106800. */
  106801. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106802. /**
  106803. * Default offline support factory responsible of creating a tool used to store data locally.
  106804. * By default, this will create a Database object if the workload has been embedded.
  106805. */
  106806. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106807. private _loadingScreen;
  106808. private _pointerLockRequested;
  106809. private _dummyFramebuffer;
  106810. private _rescalePostProcess;
  106811. private _deterministicLockstep;
  106812. private _lockstepMaxSteps;
  106813. private _timeStep;
  106814. protected get _supportsHardwareTextureRescaling(): boolean;
  106815. private _fps;
  106816. private _deltaTime;
  106817. /** @hidden */
  106818. _drawCalls: PerfCounter;
  106819. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  106820. canvasTabIndex: number;
  106821. /**
  106822. * Turn this value on if you want to pause FPS computation when in background
  106823. */
  106824. disablePerformanceMonitorInBackground: boolean;
  106825. private _performanceMonitor;
  106826. /**
  106827. * Gets the performance monitor attached to this engine
  106828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106829. */
  106830. get performanceMonitor(): PerformanceMonitor;
  106831. private _onFocus;
  106832. private _onBlur;
  106833. private _onCanvasPointerOut;
  106834. private _onCanvasBlur;
  106835. private _onCanvasFocus;
  106836. private _onFullscreenChange;
  106837. private _onPointerLockChange;
  106838. /**
  106839. * Gets the HTML element used to attach event listeners
  106840. * @returns a HTML element
  106841. */
  106842. getInputElement(): Nullable<HTMLElement>;
  106843. /**
  106844. * Creates a new engine
  106845. * @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
  106846. * @param antialias defines enable antialiasing (default: false)
  106847. * @param options defines further options to be sent to the getContext() function
  106848. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106849. */
  106850. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106851. /**
  106852. * Gets current aspect ratio
  106853. * @param viewportOwner defines the camera to use to get the aspect ratio
  106854. * @param useScreen defines if screen size must be used (or the current render target if any)
  106855. * @returns a number defining the aspect ratio
  106856. */
  106857. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106858. /**
  106859. * Gets current screen aspect ratio
  106860. * @returns a number defining the aspect ratio
  106861. */
  106862. getScreenAspectRatio(): number;
  106863. /**
  106864. * Gets the client rect of the HTML canvas attached with the current webGL context
  106865. * @returns a client rectanglee
  106866. */
  106867. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106868. /**
  106869. * Gets the client rect of the HTML element used for events
  106870. * @returns a client rectanglee
  106871. */
  106872. getInputElementClientRect(): Nullable<ClientRect>;
  106873. /**
  106874. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106876. * @returns true if engine is in deterministic lock step mode
  106877. */
  106878. isDeterministicLockStep(): boolean;
  106879. /**
  106880. * Gets the max steps when engine is running in deterministic lock step
  106881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106882. * @returns the max steps
  106883. */
  106884. getLockstepMaxSteps(): number;
  106885. /**
  106886. * Returns the time in ms between steps when using deterministic lock step.
  106887. * @returns time step in (ms)
  106888. */
  106889. getTimeStep(): number;
  106890. /**
  106891. * Force the mipmap generation for the given render target texture
  106892. * @param texture defines the render target texture to use
  106893. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106894. */
  106895. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106896. /** States */
  106897. /**
  106898. * Set various states to the webGL context
  106899. * @param culling defines backface culling state
  106900. * @param zOffset defines the value to apply to zOffset (0 by default)
  106901. * @param force defines if states must be applied even if cache is up to date
  106902. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106903. */
  106904. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106905. /**
  106906. * Set the z offset to apply to current rendering
  106907. * @param value defines the offset to apply
  106908. */
  106909. setZOffset(value: number): void;
  106910. /**
  106911. * Gets the current value of the zOffset
  106912. * @returns the current zOffset state
  106913. */
  106914. getZOffset(): number;
  106915. /**
  106916. * Enable or disable depth buffering
  106917. * @param enable defines the state to set
  106918. */
  106919. setDepthBuffer(enable: boolean): void;
  106920. /**
  106921. * Gets a boolean indicating if depth writing is enabled
  106922. * @returns the current depth writing state
  106923. */
  106924. getDepthWrite(): boolean;
  106925. /**
  106926. * Enable or disable depth writing
  106927. * @param enable defines the state to set
  106928. */
  106929. setDepthWrite(enable: boolean): void;
  106930. /**
  106931. * Gets a boolean indicating if stencil buffer is enabled
  106932. * @returns the current stencil buffer state
  106933. */
  106934. getStencilBuffer(): boolean;
  106935. /**
  106936. * Enable or disable the stencil buffer
  106937. * @param enable defines if the stencil buffer must be enabled or disabled
  106938. */
  106939. setStencilBuffer(enable: boolean): void;
  106940. /**
  106941. * Gets the current stencil mask
  106942. * @returns a number defining the new stencil mask to use
  106943. */
  106944. getStencilMask(): number;
  106945. /**
  106946. * Sets the current stencil mask
  106947. * @param mask defines the new stencil mask to use
  106948. */
  106949. setStencilMask(mask: number): void;
  106950. /**
  106951. * Gets the current stencil function
  106952. * @returns a number defining the stencil function to use
  106953. */
  106954. getStencilFunction(): number;
  106955. /**
  106956. * Gets the current stencil reference value
  106957. * @returns a number defining the stencil reference value to use
  106958. */
  106959. getStencilFunctionReference(): number;
  106960. /**
  106961. * Gets the current stencil mask
  106962. * @returns a number defining the stencil mask to use
  106963. */
  106964. getStencilFunctionMask(): number;
  106965. /**
  106966. * Sets the current stencil function
  106967. * @param stencilFunc defines the new stencil function to use
  106968. */
  106969. setStencilFunction(stencilFunc: number): void;
  106970. /**
  106971. * Sets the current stencil reference
  106972. * @param reference defines the new stencil reference to use
  106973. */
  106974. setStencilFunctionReference(reference: number): void;
  106975. /**
  106976. * Sets the current stencil mask
  106977. * @param mask defines the new stencil mask to use
  106978. */
  106979. setStencilFunctionMask(mask: number): void;
  106980. /**
  106981. * Gets the current stencil operation when stencil fails
  106982. * @returns a number defining stencil operation to use when stencil fails
  106983. */
  106984. getStencilOperationFail(): number;
  106985. /**
  106986. * Gets the current stencil operation when depth fails
  106987. * @returns a number defining stencil operation to use when depth fails
  106988. */
  106989. getStencilOperationDepthFail(): number;
  106990. /**
  106991. * Gets the current stencil operation when stencil passes
  106992. * @returns a number defining stencil operation to use when stencil passes
  106993. */
  106994. getStencilOperationPass(): number;
  106995. /**
  106996. * Sets the stencil operation to use when stencil fails
  106997. * @param operation defines the stencil operation to use when stencil fails
  106998. */
  106999. setStencilOperationFail(operation: number): void;
  107000. /**
  107001. * Sets the stencil operation to use when depth fails
  107002. * @param operation defines the stencil operation to use when depth fails
  107003. */
  107004. setStencilOperationDepthFail(operation: number): void;
  107005. /**
  107006. * Sets the stencil operation to use when stencil passes
  107007. * @param operation defines the stencil operation to use when stencil passes
  107008. */
  107009. setStencilOperationPass(operation: number): void;
  107010. /**
  107011. * Sets a boolean indicating if the dithering state is enabled or disabled
  107012. * @param value defines the dithering state
  107013. */
  107014. setDitheringState(value: boolean): void;
  107015. /**
  107016. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  107017. * @param value defines the rasterizer state
  107018. */
  107019. setRasterizerState(value: boolean): void;
  107020. /**
  107021. * Gets the current depth function
  107022. * @returns a number defining the depth function
  107023. */
  107024. getDepthFunction(): Nullable<number>;
  107025. /**
  107026. * Sets the current depth function
  107027. * @param depthFunc defines the function to use
  107028. */
  107029. setDepthFunction(depthFunc: number): void;
  107030. /**
  107031. * Sets the current depth function to GREATER
  107032. */
  107033. setDepthFunctionToGreater(): void;
  107034. /**
  107035. * Sets the current depth function to GEQUAL
  107036. */
  107037. setDepthFunctionToGreaterOrEqual(): void;
  107038. /**
  107039. * Sets the current depth function to LESS
  107040. */
  107041. setDepthFunctionToLess(): void;
  107042. /**
  107043. * Sets the current depth function to LEQUAL
  107044. */
  107045. setDepthFunctionToLessOrEqual(): void;
  107046. private _cachedStencilBuffer;
  107047. private _cachedStencilFunction;
  107048. private _cachedStencilMask;
  107049. private _cachedStencilOperationPass;
  107050. private _cachedStencilOperationFail;
  107051. private _cachedStencilOperationDepthFail;
  107052. private _cachedStencilReference;
  107053. /**
  107054. * Caches the the state of the stencil buffer
  107055. */
  107056. cacheStencilState(): void;
  107057. /**
  107058. * Restores the state of the stencil buffer
  107059. */
  107060. restoreStencilState(): void;
  107061. /**
  107062. * Directly set the WebGL Viewport
  107063. * @param x defines the x coordinate of the viewport (in screen space)
  107064. * @param y defines the y coordinate of the viewport (in screen space)
  107065. * @param width defines the width of the viewport (in screen space)
  107066. * @param height defines the height of the viewport (in screen space)
  107067. * @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
  107068. */
  107069. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  107070. /**
  107071. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  107072. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107073. * @param y defines the y-coordinate of the corner of the clear rectangle
  107074. * @param width defines the width of the clear rectangle
  107075. * @param height defines the height of the clear rectangle
  107076. * @param clearColor defines the clear color
  107077. */
  107078. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  107079. /**
  107080. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  107081. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  107082. * @param y defines the y-coordinate of the corner of the clear rectangle
  107083. * @param width defines the width of the clear rectangle
  107084. * @param height defines the height of the clear rectangle
  107085. */
  107086. enableScissor(x: number, y: number, width: number, height: number): void;
  107087. /**
  107088. * Disable previously set scissor test rectangle
  107089. */
  107090. disableScissor(): void;
  107091. protected _reportDrawCall(): void;
  107092. /**
  107093. * Initializes a webVR display and starts listening to display change events
  107094. * The onVRDisplayChangedObservable will be notified upon these changes
  107095. * @returns The onVRDisplayChangedObservable
  107096. */
  107097. initWebVR(): Observable<IDisplayChangedEventArgs>;
  107098. /** @hidden */
  107099. _prepareVRComponent(): void;
  107100. /** @hidden */
  107101. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  107102. /** @hidden */
  107103. _submitVRFrame(): void;
  107104. /**
  107105. * Call this function to leave webVR mode
  107106. * Will do nothing if webVR is not supported or if there is no webVR device
  107107. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107108. */
  107109. disableVR(): void;
  107110. /**
  107111. * Gets a boolean indicating that the system is in VR mode and is presenting
  107112. * @returns true if VR mode is engaged
  107113. */
  107114. isVRPresenting(): boolean;
  107115. /** @hidden */
  107116. _requestVRFrame(): void;
  107117. /** @hidden */
  107118. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107119. /**
  107120. * Gets the source code of the vertex shader associated with a specific webGL program
  107121. * @param program defines the program to use
  107122. * @returns a string containing the source code of the vertex shader associated with the program
  107123. */
  107124. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  107125. /**
  107126. * Gets the source code of the fragment shader associated with a specific webGL program
  107127. * @param program defines the program to use
  107128. * @returns a string containing the source code of the fragment shader associated with the program
  107129. */
  107130. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  107131. /**
  107132. * Sets a depth stencil texture from a render target to the according uniform.
  107133. * @param channel The texture channel
  107134. * @param uniform The uniform to set
  107135. * @param texture The render target texture containing the depth stencil texture to apply
  107136. */
  107137. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107138. /**
  107139. * Sets a texture to the webGL context from a postprocess
  107140. * @param channel defines the channel to use
  107141. * @param postProcess defines the source postprocess
  107142. */
  107143. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107144. /**
  107145. * Binds the output of the passed in post process to the texture channel specified
  107146. * @param channel The channel the texture should be bound to
  107147. * @param postProcess The post process which's output should be bound
  107148. */
  107149. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107150. /** @hidden */
  107151. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107152. protected _rebuildBuffers(): void;
  107153. /** @hidden */
  107154. _renderFrame(): void;
  107155. _renderLoop(): void;
  107156. /** @hidden */
  107157. _renderViews(): boolean;
  107158. /**
  107159. * Toggle full screen mode
  107160. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107161. */
  107162. switchFullscreen(requestPointerLock: boolean): void;
  107163. /**
  107164. * Enters full screen mode
  107165. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107166. */
  107167. enterFullscreen(requestPointerLock: boolean): void;
  107168. /**
  107169. * Exits full screen mode
  107170. */
  107171. exitFullscreen(): void;
  107172. /**
  107173. * Enters Pointerlock mode
  107174. */
  107175. enterPointerlock(): void;
  107176. /**
  107177. * Exits Pointerlock mode
  107178. */
  107179. exitPointerlock(): void;
  107180. /**
  107181. * Begin a new frame
  107182. */
  107183. beginFrame(): void;
  107184. /**
  107185. * Enf the current frame
  107186. */
  107187. endFrame(): void;
  107188. resize(): void;
  107189. /**
  107190. * Force a specific size of the canvas
  107191. * @param width defines the new canvas' width
  107192. * @param height defines the new canvas' height
  107193. */
  107194. setSize(width: number, height: number): void;
  107195. /**
  107196. * Updates a dynamic vertex buffer.
  107197. * @param vertexBuffer the vertex buffer to update
  107198. * @param data the data used to update the vertex buffer
  107199. * @param byteOffset the byte offset of the data
  107200. * @param byteLength the byte length of the data
  107201. */
  107202. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107203. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107204. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107205. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107206. _releaseTexture(texture: InternalTexture): void;
  107207. /**
  107208. * @hidden
  107209. * Rescales a texture
  107210. * @param source input texutre
  107211. * @param destination destination texture
  107212. * @param scene scene to use to render the resize
  107213. * @param internalFormat format to use when resizing
  107214. * @param onComplete callback to be called when resize has completed
  107215. */
  107216. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107217. /**
  107218. * Gets the current framerate
  107219. * @returns a number representing the framerate
  107220. */
  107221. getFps(): number;
  107222. /**
  107223. * Gets the time spent between current and previous frame
  107224. * @returns a number representing the delta time in ms
  107225. */
  107226. getDeltaTime(): number;
  107227. private _measureFps;
  107228. /** @hidden */
  107229. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107230. /**
  107231. * Update a dynamic index buffer
  107232. * @param indexBuffer defines the target index buffer
  107233. * @param indices defines the data to update
  107234. * @param offset defines the offset in the target index buffer where update should start
  107235. */
  107236. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107237. /**
  107238. * Updates the sample count of a render target texture
  107239. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107240. * @param texture defines the texture to update
  107241. * @param samples defines the sample count to set
  107242. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107243. */
  107244. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107245. /**
  107246. * Updates a depth texture Comparison Mode and Function.
  107247. * If the comparison Function is equal to 0, the mode will be set to none.
  107248. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107249. * @param texture The texture to set the comparison function for
  107250. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107251. */
  107252. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107253. /**
  107254. * Creates a webGL buffer to use with instanciation
  107255. * @param capacity defines the size of the buffer
  107256. * @returns the webGL buffer
  107257. */
  107258. createInstancesBuffer(capacity: number): DataBuffer;
  107259. /**
  107260. * Delete a webGL buffer used with instanciation
  107261. * @param buffer defines the webGL buffer to delete
  107262. */
  107263. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107264. private _clientWaitAsync;
  107265. /** @hidden */
  107266. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107267. /** @hidden */
  107268. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107269. dispose(): void;
  107270. private _disableTouchAction;
  107271. /**
  107272. * Display the loading screen
  107273. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107274. */
  107275. displayLoadingUI(): void;
  107276. /**
  107277. * Hide the loading screen
  107278. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107279. */
  107280. hideLoadingUI(): void;
  107281. /**
  107282. * Gets the current loading screen object
  107283. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107284. */
  107285. get loadingScreen(): ILoadingScreen;
  107286. /**
  107287. * Sets the current loading screen object
  107288. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107289. */
  107290. set loadingScreen(loadingScreen: ILoadingScreen);
  107291. /**
  107292. * Sets the current loading screen text
  107293. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107294. */
  107295. set loadingUIText(text: string);
  107296. /**
  107297. * Sets the current loading screen background color
  107298. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107299. */
  107300. set loadingUIBackgroundColor(color: string);
  107301. /** Pointerlock and fullscreen */
  107302. /**
  107303. * Ask the browser to promote the current element to pointerlock mode
  107304. * @param element defines the DOM element to promote
  107305. */
  107306. static _RequestPointerlock(element: HTMLElement): void;
  107307. /**
  107308. * Asks the browser to exit pointerlock mode
  107309. */
  107310. static _ExitPointerlock(): void;
  107311. /**
  107312. * Ask the browser to promote the current element to fullscreen rendering mode
  107313. * @param element defines the DOM element to promote
  107314. */
  107315. static _RequestFullscreen(element: HTMLElement): void;
  107316. /**
  107317. * Asks the browser to exit fullscreen mode
  107318. */
  107319. static _ExitFullscreen(): void;
  107320. }
  107321. }
  107322. declare module BABYLON {
  107323. /**
  107324. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107325. * during the life time of the application.
  107326. */
  107327. export class EngineStore {
  107328. /** Gets the list of created engines */
  107329. static Instances: Engine[];
  107330. /** @hidden */
  107331. static _LastCreatedScene: Nullable<Scene>;
  107332. /**
  107333. * Gets the latest created engine
  107334. */
  107335. static get LastCreatedEngine(): Nullable<Engine>;
  107336. /**
  107337. * Gets the latest created scene
  107338. */
  107339. static get LastCreatedScene(): Nullable<Scene>;
  107340. /**
  107341. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107342. * @ignorenaming
  107343. */
  107344. static UseFallbackTexture: boolean;
  107345. /**
  107346. * Texture content used if a texture cannot loaded
  107347. * @ignorenaming
  107348. */
  107349. static FallbackTexture: string;
  107350. }
  107351. }
  107352. declare module BABYLON {
  107353. /**
  107354. * Helper class that provides a small promise polyfill
  107355. */
  107356. export class PromisePolyfill {
  107357. /**
  107358. * Static function used to check if the polyfill is required
  107359. * If this is the case then the function will inject the polyfill to window.Promise
  107360. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107361. */
  107362. static Apply(force?: boolean): void;
  107363. }
  107364. }
  107365. declare module BABYLON {
  107366. /**
  107367. * Interface for screenshot methods with describe argument called `size` as object with options
  107368. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107369. */
  107370. export interface IScreenshotSize {
  107371. /**
  107372. * number in pixels for canvas height
  107373. */
  107374. height?: number;
  107375. /**
  107376. * multiplier allowing render at a higher or lower resolution
  107377. * If value is defined then height and width will be ignored and taken from camera
  107378. */
  107379. precision?: number;
  107380. /**
  107381. * number in pixels for canvas width
  107382. */
  107383. width?: number;
  107384. }
  107385. }
  107386. declare module BABYLON {
  107387. interface IColor4Like {
  107388. r: float;
  107389. g: float;
  107390. b: float;
  107391. a: float;
  107392. }
  107393. /**
  107394. * Class containing a set of static utilities functions
  107395. */
  107396. export class Tools {
  107397. /**
  107398. * Gets or sets the base URL to use to load assets
  107399. */
  107400. static get BaseUrl(): string;
  107401. static set BaseUrl(value: string);
  107402. /**
  107403. * Enable/Disable Custom HTTP Request Headers globally.
  107404. * default = false
  107405. * @see CustomRequestHeaders
  107406. */
  107407. static UseCustomRequestHeaders: boolean;
  107408. /**
  107409. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107410. * i.e. when loading files, where the server/service expects an Authorization header
  107411. */
  107412. static CustomRequestHeaders: {
  107413. [key: string]: string;
  107414. };
  107415. /**
  107416. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107417. */
  107418. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107419. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107420. /**
  107421. * Default behaviour for cors in the application.
  107422. * It can be a string if the expected behavior is identical in the entire app.
  107423. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107424. */
  107425. static get CorsBehavior(): string | ((url: string | string[]) => string);
  107426. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  107427. /**
  107428. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107429. * @ignorenaming
  107430. */
  107431. static get UseFallbackTexture(): boolean;
  107432. static set UseFallbackTexture(value: boolean);
  107433. /**
  107434. * Use this object to register external classes like custom textures or material
  107435. * to allow the laoders to instantiate them
  107436. */
  107437. static get RegisteredExternalClasses(): {
  107438. [key: string]: Object;
  107439. };
  107440. static set RegisteredExternalClasses(classes: {
  107441. [key: string]: Object;
  107442. });
  107443. /**
  107444. * Texture content used if a texture cannot loaded
  107445. * @ignorenaming
  107446. */
  107447. static get fallbackTexture(): string;
  107448. static set fallbackTexture(value: string);
  107449. /**
  107450. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107451. * @param u defines the coordinate on X axis
  107452. * @param v defines the coordinate on Y axis
  107453. * @param width defines the width of the source data
  107454. * @param height defines the height of the source data
  107455. * @param pixels defines the source byte array
  107456. * @param color defines the output color
  107457. */
  107458. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107459. /**
  107460. * Interpolates between a and b via alpha
  107461. * @param a The lower value (returned when alpha = 0)
  107462. * @param b The upper value (returned when alpha = 1)
  107463. * @param alpha The interpolation-factor
  107464. * @return The mixed value
  107465. */
  107466. static Mix(a: number, b: number, alpha: number): number;
  107467. /**
  107468. * Tries to instantiate a new object from a given class name
  107469. * @param className defines the class name to instantiate
  107470. * @returns the new object or null if the system was not able to do the instantiation
  107471. */
  107472. static Instantiate(className: string): any;
  107473. /**
  107474. * Provides a slice function that will work even on IE
  107475. * @param data defines the array to slice
  107476. * @param start defines the start of the data (optional)
  107477. * @param end defines the end of the data (optional)
  107478. * @returns the new sliced array
  107479. */
  107480. static Slice<T>(data: T, start?: number, end?: number): T;
  107481. /**
  107482. * Polyfill for setImmediate
  107483. * @param action defines the action to execute after the current execution block
  107484. */
  107485. static SetImmediate(action: () => void): void;
  107486. /**
  107487. * Function indicating if a number is an exponent of 2
  107488. * @param value defines the value to test
  107489. * @returns true if the value is an exponent of 2
  107490. */
  107491. static IsExponentOfTwo(value: number): boolean;
  107492. private static _tmpFloatArray;
  107493. /**
  107494. * Returns the nearest 32-bit single precision float representation of a Number
  107495. * @param value A Number. If the parameter is of a different type, it will get converted
  107496. * to a number or to NaN if it cannot be converted
  107497. * @returns number
  107498. */
  107499. static FloatRound(value: number): number;
  107500. /**
  107501. * Extracts the filename from a path
  107502. * @param path defines the path to use
  107503. * @returns the filename
  107504. */
  107505. static GetFilename(path: string): string;
  107506. /**
  107507. * Extracts the "folder" part of a path (everything before the filename).
  107508. * @param uri The URI to extract the info from
  107509. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107510. * @returns The "folder" part of the path
  107511. */
  107512. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107513. /**
  107514. * Extracts text content from a DOM element hierarchy
  107515. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107516. */
  107517. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107518. /**
  107519. * Convert an angle in radians to degrees
  107520. * @param angle defines the angle to convert
  107521. * @returns the angle in degrees
  107522. */
  107523. static ToDegrees(angle: number): number;
  107524. /**
  107525. * Convert an angle in degrees to radians
  107526. * @param angle defines the angle to convert
  107527. * @returns the angle in radians
  107528. */
  107529. static ToRadians(angle: number): number;
  107530. /**
  107531. * Returns an array if obj is not an array
  107532. * @param obj defines the object to evaluate as an array
  107533. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107534. * @returns either obj directly if obj is an array or a new array containing obj
  107535. */
  107536. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107537. /**
  107538. * Gets the pointer prefix to use
  107539. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107540. */
  107541. static GetPointerPrefix(): string;
  107542. /**
  107543. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107544. * @param url define the url we are trying
  107545. * @param element define the dom element where to configure the cors policy
  107546. */
  107547. static SetCorsBehavior(url: string | string[], element: {
  107548. crossOrigin: string | null;
  107549. }): void;
  107550. /**
  107551. * Removes unwanted characters from an url
  107552. * @param url defines the url to clean
  107553. * @returns the cleaned url
  107554. */
  107555. static CleanUrl(url: string): string;
  107556. /**
  107557. * Gets or sets a function used to pre-process url before using them to load assets
  107558. */
  107559. static get PreprocessUrl(): (url: string) => string;
  107560. static set PreprocessUrl(processor: (url: string) => string);
  107561. /**
  107562. * Loads an image as an HTMLImageElement.
  107563. * @param input url string, ArrayBuffer, or Blob to load
  107564. * @param onLoad callback called when the image successfully loads
  107565. * @param onError callback called when the image fails to load
  107566. * @param offlineProvider offline provider for caching
  107567. * @param mimeType optional mime type
  107568. * @returns the HTMLImageElement of the loaded image
  107569. */
  107570. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107571. /**
  107572. * Loads a file from a url
  107573. * @param url url string, ArrayBuffer, or Blob to load
  107574. * @param onSuccess callback called when the file successfully loads
  107575. * @param onProgress callback called while file is loading (if the server supports this mode)
  107576. * @param offlineProvider defines the offline provider for caching
  107577. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107578. * @param onError callback called when the file fails to load
  107579. * @returns a file request object
  107580. */
  107581. 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;
  107582. /**
  107583. * Loads a file from a url
  107584. * @param url the file url to load
  107585. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107586. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107587. */
  107588. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107589. /**
  107590. * Load a script (identified by an url). When the url returns, the
  107591. * content of this file is added into a new script element, attached to the DOM (body element)
  107592. * @param scriptUrl defines the url of the script to laod
  107593. * @param onSuccess defines the callback called when the script is loaded
  107594. * @param onError defines the callback to call if an error occurs
  107595. * @param scriptId defines the id of the script element
  107596. */
  107597. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107598. /**
  107599. * Load an asynchronous script (identified by an url). When the url returns, the
  107600. * content of this file is added into a new script element, attached to the DOM (body element)
  107601. * @param scriptUrl defines the url of the script to laod
  107602. * @param scriptId defines the id of the script element
  107603. * @returns a promise request object
  107604. */
  107605. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107606. /**
  107607. * Loads a file from a blob
  107608. * @param fileToLoad defines the blob to use
  107609. * @param callback defines the callback to call when data is loaded
  107610. * @param progressCallback defines the callback to call during loading process
  107611. * @returns a file request object
  107612. */
  107613. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107614. /**
  107615. * Reads a file from a File object
  107616. * @param file defines the file to load
  107617. * @param onSuccess defines the callback to call when data is loaded
  107618. * @param onProgress defines the callback to call during loading process
  107619. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107620. * @param onError defines the callback to call when an error occurs
  107621. * @returns a file request object
  107622. */
  107623. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107624. /**
  107625. * Creates a data url from a given string content
  107626. * @param content defines the content to convert
  107627. * @returns the new data url link
  107628. */
  107629. static FileAsURL(content: string): string;
  107630. /**
  107631. * Format the given number to a specific decimal format
  107632. * @param value defines the number to format
  107633. * @param decimals defines the number of decimals to use
  107634. * @returns the formatted string
  107635. */
  107636. static Format(value: number, decimals?: number): string;
  107637. /**
  107638. * Tries to copy an object by duplicating every property
  107639. * @param source defines the source object
  107640. * @param destination defines the target object
  107641. * @param doNotCopyList defines a list of properties to avoid
  107642. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107643. */
  107644. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107645. /**
  107646. * Gets a boolean indicating if the given object has no own property
  107647. * @param obj defines the object to test
  107648. * @returns true if object has no own property
  107649. */
  107650. static IsEmpty(obj: any): boolean;
  107651. /**
  107652. * Function used to register events at window level
  107653. * @param windowElement defines the Window object to use
  107654. * @param events defines the events to register
  107655. */
  107656. static RegisterTopRootEvents(windowElement: Window, events: {
  107657. name: string;
  107658. handler: Nullable<(e: FocusEvent) => any>;
  107659. }[]): void;
  107660. /**
  107661. * Function used to unregister events from window level
  107662. * @param windowElement defines the Window object to use
  107663. * @param events defines the events to unregister
  107664. */
  107665. static UnregisterTopRootEvents(windowElement: Window, events: {
  107666. name: string;
  107667. handler: Nullable<(e: FocusEvent) => any>;
  107668. }[]): void;
  107669. /**
  107670. * @ignore
  107671. */
  107672. static _ScreenshotCanvas: HTMLCanvasElement;
  107673. /**
  107674. * Dumps the current bound framebuffer
  107675. * @param width defines the rendering width
  107676. * @param height defines the rendering height
  107677. * @param engine defines the hosting engine
  107678. * @param successCallback defines the callback triggered once the data are available
  107679. * @param mimeType defines the mime type of the result
  107680. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107681. */
  107682. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107683. /**
  107684. * Converts the canvas data to blob.
  107685. * This acts as a polyfill for browsers not supporting the to blob function.
  107686. * @param canvas Defines the canvas to extract the data from
  107687. * @param successCallback Defines the callback triggered once the data are available
  107688. * @param mimeType Defines the mime type of the result
  107689. */
  107690. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107691. /**
  107692. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107693. * @param successCallback defines the callback triggered once the data are available
  107694. * @param mimeType defines the mime type of the result
  107695. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107696. */
  107697. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107698. /**
  107699. * Downloads a blob in the browser
  107700. * @param blob defines the blob to download
  107701. * @param fileName defines the name of the downloaded file
  107702. */
  107703. static Download(blob: Blob, fileName: string): void;
  107704. /**
  107705. * Captures a screenshot of the current rendering
  107706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107707. * @param engine defines the rendering engine
  107708. * @param camera defines the source camera
  107709. * @param size This parameter can be set to a single number or to an object with the
  107710. * following (optional) properties: precision, width, height. If a single number is passed,
  107711. * it will be used for both width and height. If an object is passed, the screenshot size
  107712. * will be derived from the parameters. The precision property is a multiplier allowing
  107713. * rendering at a higher or lower resolution
  107714. * @param successCallback defines the callback receives a single parameter which contains the
  107715. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107716. * src parameter of an <img> to display it
  107717. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107718. * Check your browser for supported MIME types
  107719. */
  107720. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107721. /**
  107722. * Captures a screenshot of the current rendering
  107723. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107724. * @param engine defines the rendering engine
  107725. * @param camera defines the source camera
  107726. * @param size This parameter can be set to a single number or to an object with the
  107727. * following (optional) properties: precision, width, height. If a single number is passed,
  107728. * it will be used for both width and height. If an object is passed, the screenshot size
  107729. * will be derived from the parameters. The precision property is a multiplier allowing
  107730. * rendering at a higher or lower resolution
  107731. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107732. * Check your browser for supported MIME types
  107733. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107734. * to the src parameter of an <img> to display it
  107735. */
  107736. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107737. /**
  107738. * Generates an image screenshot from the specified camera.
  107739. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107740. * @param engine The engine to use for rendering
  107741. * @param camera The camera to use for rendering
  107742. * @param size This parameter can be set to a single number or to an object with the
  107743. * following (optional) properties: precision, width, height. If a single number is passed,
  107744. * it will be used for both width and height. If an object is passed, the screenshot size
  107745. * will be derived from the parameters. The precision property is a multiplier allowing
  107746. * rendering at a higher or lower resolution
  107747. * @param successCallback The callback receives a single parameter which contains the
  107748. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107749. * src parameter of an <img> to display it
  107750. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107751. * Check your browser for supported MIME types
  107752. * @param samples Texture samples (default: 1)
  107753. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107754. * @param fileName A name for for the downloaded file.
  107755. */
  107756. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107757. /**
  107758. * Generates an image screenshot from the specified camera.
  107759. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107760. * @param engine The engine to use for rendering
  107761. * @param camera The camera to use for rendering
  107762. * @param size This parameter can be set to a single number or to an object with the
  107763. * following (optional) properties: precision, width, height. If a single number is passed,
  107764. * it will be used for both width and height. If an object is passed, the screenshot size
  107765. * will be derived from the parameters. The precision property is a multiplier allowing
  107766. * rendering at a higher or lower resolution
  107767. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107768. * Check your browser for supported MIME types
  107769. * @param samples Texture samples (default: 1)
  107770. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107771. * @param fileName A name for for the downloaded file.
  107772. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107773. * to the src parameter of an <img> to display it
  107774. */
  107775. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107776. /**
  107777. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107778. * Be aware Math.random() could cause collisions, but:
  107779. * "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"
  107780. * @returns a pseudo random id
  107781. */
  107782. static RandomId(): string;
  107783. /**
  107784. * Test if the given uri is a base64 string
  107785. * @param uri The uri to test
  107786. * @return True if the uri is a base64 string or false otherwise
  107787. */
  107788. static IsBase64(uri: string): boolean;
  107789. /**
  107790. * Decode the given base64 uri.
  107791. * @param uri The uri to decode
  107792. * @return The decoded base64 data.
  107793. */
  107794. static DecodeBase64(uri: string): ArrayBuffer;
  107795. /**
  107796. * Gets the absolute url.
  107797. * @param url the input url
  107798. * @return the absolute url
  107799. */
  107800. static GetAbsoluteUrl(url: string): string;
  107801. /**
  107802. * No log
  107803. */
  107804. static readonly NoneLogLevel: number;
  107805. /**
  107806. * Only message logs
  107807. */
  107808. static readonly MessageLogLevel: number;
  107809. /**
  107810. * Only warning logs
  107811. */
  107812. static readonly WarningLogLevel: number;
  107813. /**
  107814. * Only error logs
  107815. */
  107816. static readonly ErrorLogLevel: number;
  107817. /**
  107818. * All logs
  107819. */
  107820. static readonly AllLogLevel: number;
  107821. /**
  107822. * Gets a value indicating the number of loading errors
  107823. * @ignorenaming
  107824. */
  107825. static get errorsCount(): number;
  107826. /**
  107827. * Callback called when a new log is added
  107828. */
  107829. static OnNewCacheEntry: (entry: string) => void;
  107830. /**
  107831. * Log a message to the console
  107832. * @param message defines the message to log
  107833. */
  107834. static Log(message: string): void;
  107835. /**
  107836. * Write a warning message to the console
  107837. * @param message defines the message to log
  107838. */
  107839. static Warn(message: string): void;
  107840. /**
  107841. * Write an error message to the console
  107842. * @param message defines the message to log
  107843. */
  107844. static Error(message: string): void;
  107845. /**
  107846. * Gets current log cache (list of logs)
  107847. */
  107848. static get LogCache(): string;
  107849. /**
  107850. * Clears the log cache
  107851. */
  107852. static ClearLogCache(): void;
  107853. /**
  107854. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107855. */
  107856. static set LogLevels(level: number);
  107857. /**
  107858. * Checks if the window object exists
  107859. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107860. */
  107861. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107862. /**
  107863. * No performance log
  107864. */
  107865. static readonly PerformanceNoneLogLevel: number;
  107866. /**
  107867. * Use user marks to log performance
  107868. */
  107869. static readonly PerformanceUserMarkLogLevel: number;
  107870. /**
  107871. * Log performance to the console
  107872. */
  107873. static readonly PerformanceConsoleLogLevel: number;
  107874. private static _performance;
  107875. /**
  107876. * Sets the current performance log level
  107877. */
  107878. static set PerformanceLogLevel(level: number);
  107879. private static _StartPerformanceCounterDisabled;
  107880. private static _EndPerformanceCounterDisabled;
  107881. private static _StartUserMark;
  107882. private static _EndUserMark;
  107883. private static _StartPerformanceConsole;
  107884. private static _EndPerformanceConsole;
  107885. /**
  107886. * Starts a performance counter
  107887. */
  107888. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107889. /**
  107890. * Ends a specific performance coutner
  107891. */
  107892. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107893. /**
  107894. * Gets either window.performance.now() if supported or Date.now() else
  107895. */
  107896. static get Now(): number;
  107897. /**
  107898. * This method will return the name of the class used to create the instance of the given object.
  107899. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107900. * @param object the object to get the class name from
  107901. * @param isType defines if the object is actually a type
  107902. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107903. */
  107904. static GetClassName(object: any, isType?: boolean): string;
  107905. /**
  107906. * Gets the first element of an array satisfying a given predicate
  107907. * @param array defines the array to browse
  107908. * @param predicate defines the predicate to use
  107909. * @returns null if not found or the element
  107910. */
  107911. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107912. /**
  107913. * This method will return the name of the full name of the class, including its owning module (if any).
  107914. * 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).
  107915. * @param object the object to get the class name from
  107916. * @param isType defines if the object is actually a type
  107917. * @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.
  107918. * @ignorenaming
  107919. */
  107920. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107921. /**
  107922. * Returns a promise that resolves after the given amount of time.
  107923. * @param delay Number of milliseconds to delay
  107924. * @returns Promise that resolves after the given amount of time
  107925. */
  107926. static DelayAsync(delay: number): Promise<void>;
  107927. /**
  107928. * Utility function to detect if the current user agent is Safari
  107929. * @returns whether or not the current user agent is safari
  107930. */
  107931. static IsSafari(): boolean;
  107932. }
  107933. /**
  107934. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107935. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107936. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107937. * @param name The name of the class, case should be preserved
  107938. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107939. */
  107940. export function className(name: string, module?: string): (target: Object) => void;
  107941. /**
  107942. * An implementation of a loop for asynchronous functions.
  107943. */
  107944. export class AsyncLoop {
  107945. /**
  107946. * Defines the number of iterations for the loop
  107947. */
  107948. iterations: number;
  107949. /**
  107950. * Defines the current index of the loop.
  107951. */
  107952. index: number;
  107953. private _done;
  107954. private _fn;
  107955. private _successCallback;
  107956. /**
  107957. * Constructor.
  107958. * @param iterations the number of iterations.
  107959. * @param func the function to run each iteration
  107960. * @param successCallback the callback that will be called upon succesful execution
  107961. * @param offset starting offset.
  107962. */
  107963. constructor(
  107964. /**
  107965. * Defines the number of iterations for the loop
  107966. */
  107967. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107968. /**
  107969. * Execute the next iteration. Must be called after the last iteration was finished.
  107970. */
  107971. executeNext(): void;
  107972. /**
  107973. * Break the loop and run the success callback.
  107974. */
  107975. breakLoop(): void;
  107976. /**
  107977. * Create and run an async loop.
  107978. * @param iterations the number of iterations.
  107979. * @param fn the function to run each iteration
  107980. * @param successCallback the callback that will be called upon succesful execution
  107981. * @param offset starting offset.
  107982. * @returns the created async loop object
  107983. */
  107984. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107985. /**
  107986. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107987. * @param iterations total number of iterations
  107988. * @param syncedIterations number of synchronous iterations in each async iteration.
  107989. * @param fn the function to call each iteration.
  107990. * @param callback a success call back that will be called when iterating stops.
  107991. * @param breakFunction a break condition (optional)
  107992. * @param timeout timeout settings for the setTimeout function. default - 0.
  107993. * @returns the created async loop object
  107994. */
  107995. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107996. }
  107997. }
  107998. declare module BABYLON {
  107999. /**
  108000. * This class implement a typical dictionary using a string as key and the generic type T as value.
  108001. * The underlying implementation relies on an associative array to ensure the best performances.
  108002. * The value can be anything including 'null' but except 'undefined'
  108003. */
  108004. export class StringDictionary<T> {
  108005. /**
  108006. * This will clear this dictionary and copy the content from the 'source' one.
  108007. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  108008. * @param source the dictionary to take the content from and copy to this dictionary
  108009. */
  108010. copyFrom(source: StringDictionary<T>): void;
  108011. /**
  108012. * Get a value based from its key
  108013. * @param key the given key to get the matching value from
  108014. * @return the value if found, otherwise undefined is returned
  108015. */
  108016. get(key: string): T | undefined;
  108017. /**
  108018. * Get a value from its key or add it if it doesn't exist.
  108019. * This method will ensure you that a given key/data will be present in the dictionary.
  108020. * @param key the given key to get the matching value from
  108021. * @param factory the factory that will create the value if the key is not present in the dictionary.
  108022. * The factory will only be invoked if there's no data for the given key.
  108023. * @return the value corresponding to the key.
  108024. */
  108025. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  108026. /**
  108027. * Get a value from its key if present in the dictionary otherwise add it
  108028. * @param key the key to get the value from
  108029. * @param val if there's no such key/value pair in the dictionary add it with this value
  108030. * @return the value corresponding to the key
  108031. */
  108032. getOrAdd(key: string, val: T): T;
  108033. /**
  108034. * Check if there's a given key in the dictionary
  108035. * @param key the key to check for
  108036. * @return true if the key is present, false otherwise
  108037. */
  108038. contains(key: string): boolean;
  108039. /**
  108040. * Add a new key and its corresponding value
  108041. * @param key the key to add
  108042. * @param value the value corresponding to the key
  108043. * @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
  108044. */
  108045. add(key: string, value: T): boolean;
  108046. /**
  108047. * Update a specific value associated to a key
  108048. * @param key defines the key to use
  108049. * @param value defines the value to store
  108050. * @returns true if the value was updated (or false if the key was not found)
  108051. */
  108052. set(key: string, value: T): boolean;
  108053. /**
  108054. * Get the element of the given key and remove it from the dictionary
  108055. * @param key defines the key to search
  108056. * @returns the value associated with the key or null if not found
  108057. */
  108058. getAndRemove(key: string): Nullable<T>;
  108059. /**
  108060. * Remove a key/value from the dictionary.
  108061. * @param key the key to remove
  108062. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  108063. */
  108064. remove(key: string): boolean;
  108065. /**
  108066. * Clear the whole content of the dictionary
  108067. */
  108068. clear(): void;
  108069. /**
  108070. * Gets the current count
  108071. */
  108072. get count(): number;
  108073. /**
  108074. * Execute a callback on each key/val of the dictionary.
  108075. * Note that you can remove any element in this dictionary in the callback implementation
  108076. * @param callback the callback to execute on a given key/value pair
  108077. */
  108078. forEach(callback: (key: string, val: T) => void): void;
  108079. /**
  108080. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  108081. * If the callback returns null or undefined the method will iterate to the next key/value pair
  108082. * Note that you can remove any element in this dictionary in the callback implementation
  108083. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  108084. * @returns the first item
  108085. */
  108086. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  108087. private _count;
  108088. private _data;
  108089. }
  108090. }
  108091. declare module BABYLON {
  108092. /** @hidden */
  108093. export interface ICollisionCoordinator {
  108094. createCollider(): Collider;
  108095. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108096. init(scene: Scene): void;
  108097. }
  108098. /** @hidden */
  108099. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  108100. private _scene;
  108101. private _scaledPosition;
  108102. private _scaledVelocity;
  108103. private _finalPosition;
  108104. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108105. createCollider(): Collider;
  108106. init(scene: Scene): void;
  108107. private _collideWithWorld;
  108108. }
  108109. }
  108110. declare module BABYLON {
  108111. /**
  108112. * Class used to manage all inputs for the scene.
  108113. */
  108114. export class InputManager {
  108115. /** The distance in pixel that you have to move to prevent some events */
  108116. static DragMovementThreshold: number;
  108117. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108118. static LongPressDelay: number;
  108119. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108120. static DoubleClickDelay: number;
  108121. /** If you need to check double click without raising a single click at first click, enable this flag */
  108122. static ExclusiveDoubleClickMode: boolean;
  108123. private _wheelEventName;
  108124. private _onPointerMove;
  108125. private _onPointerDown;
  108126. private _onPointerUp;
  108127. private _initClickEvent;
  108128. private _initActionManager;
  108129. private _delayedSimpleClick;
  108130. private _delayedSimpleClickTimeout;
  108131. private _previousDelayedSimpleClickTimeout;
  108132. private _meshPickProceed;
  108133. private _previousButtonPressed;
  108134. private _currentPickResult;
  108135. private _previousPickResult;
  108136. private _totalPointersPressed;
  108137. private _doubleClickOccured;
  108138. private _pointerOverMesh;
  108139. private _pickedDownMesh;
  108140. private _pickedUpMesh;
  108141. private _pointerX;
  108142. private _pointerY;
  108143. private _unTranslatedPointerX;
  108144. private _unTranslatedPointerY;
  108145. private _startingPointerPosition;
  108146. private _previousStartingPointerPosition;
  108147. private _startingPointerTime;
  108148. private _previousStartingPointerTime;
  108149. private _pointerCaptures;
  108150. private _onKeyDown;
  108151. private _onKeyUp;
  108152. private _onCanvasFocusObserver;
  108153. private _onCanvasBlurObserver;
  108154. private _scene;
  108155. /**
  108156. * Creates a new InputManager
  108157. * @param scene defines the hosting scene
  108158. */
  108159. constructor(scene: Scene);
  108160. /**
  108161. * Gets the mesh that is currently under the pointer
  108162. */
  108163. get meshUnderPointer(): Nullable<AbstractMesh>;
  108164. /**
  108165. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108166. */
  108167. get unTranslatedPointer(): Vector2;
  108168. /**
  108169. * Gets or sets the current on-screen X position of the pointer
  108170. */
  108171. get pointerX(): number;
  108172. set pointerX(value: number);
  108173. /**
  108174. * Gets or sets the current on-screen Y position of the pointer
  108175. */
  108176. get pointerY(): number;
  108177. set pointerY(value: number);
  108178. private _updatePointerPosition;
  108179. private _processPointerMove;
  108180. private _setRayOnPointerInfo;
  108181. private _checkPrePointerObservable;
  108182. /**
  108183. * Use this method to simulate a pointer move on a mesh
  108184. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108185. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108186. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108187. */
  108188. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108189. /**
  108190. * Use this method to simulate a pointer down on a mesh
  108191. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108192. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108193. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108194. */
  108195. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108196. private _processPointerDown;
  108197. /** @hidden */
  108198. _isPointerSwiping(): boolean;
  108199. /**
  108200. * Use this method to simulate a pointer up on a mesh
  108201. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108202. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108203. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108204. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108205. */
  108206. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108207. private _processPointerUp;
  108208. /**
  108209. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108210. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108211. * @returns true if the pointer was captured
  108212. */
  108213. isPointerCaptured(pointerId?: number): boolean;
  108214. /**
  108215. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108216. * @param attachUp defines if you want to attach events to pointerup
  108217. * @param attachDown defines if you want to attach events to pointerdown
  108218. * @param attachMove defines if you want to attach events to pointermove
  108219. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108220. */
  108221. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108222. /**
  108223. * Detaches all event handlers
  108224. */
  108225. detachControl(): void;
  108226. /**
  108227. * Force the value of meshUnderPointer
  108228. * @param mesh defines the mesh to use
  108229. */
  108230. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108231. /**
  108232. * Gets the mesh under the pointer
  108233. * @returns a Mesh or null if no mesh is under the pointer
  108234. */
  108235. getPointerOverMesh(): Nullable<AbstractMesh>;
  108236. }
  108237. }
  108238. declare module BABYLON {
  108239. /**
  108240. * Helper class used to generate session unique ID
  108241. */
  108242. export class UniqueIdGenerator {
  108243. private static _UniqueIdCounter;
  108244. /**
  108245. * Gets an unique (relatively to the current scene) Id
  108246. */
  108247. static get UniqueId(): number;
  108248. }
  108249. }
  108250. declare module BABYLON {
  108251. /**
  108252. * This class defines the direct association between an animation and a target
  108253. */
  108254. export class TargetedAnimation {
  108255. /**
  108256. * Animation to perform
  108257. */
  108258. animation: Animation;
  108259. /**
  108260. * Target to animate
  108261. */
  108262. target: any;
  108263. /**
  108264. * Serialize the object
  108265. * @returns the JSON object representing the current entity
  108266. */
  108267. serialize(): any;
  108268. }
  108269. /**
  108270. * Use this class to create coordinated animations on multiple targets
  108271. */
  108272. export class AnimationGroup implements IDisposable {
  108273. /** The name of the animation group */
  108274. name: string;
  108275. private _scene;
  108276. private _targetedAnimations;
  108277. private _animatables;
  108278. private _from;
  108279. private _to;
  108280. private _isStarted;
  108281. private _isPaused;
  108282. private _speedRatio;
  108283. private _loopAnimation;
  108284. /**
  108285. * Gets or sets the unique id of the node
  108286. */
  108287. uniqueId: number;
  108288. /**
  108289. * This observable will notify when one animation have ended
  108290. */
  108291. onAnimationEndObservable: Observable<TargetedAnimation>;
  108292. /**
  108293. * Observer raised when one animation loops
  108294. */
  108295. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108296. /**
  108297. * Observer raised when all animations have looped
  108298. */
  108299. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108300. /**
  108301. * This observable will notify when all animations have ended.
  108302. */
  108303. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108304. /**
  108305. * This observable will notify when all animations have paused.
  108306. */
  108307. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108308. /**
  108309. * This observable will notify when all animations are playing.
  108310. */
  108311. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108312. /**
  108313. * Gets the first frame
  108314. */
  108315. get from(): number;
  108316. /**
  108317. * Gets the last frame
  108318. */
  108319. get to(): number;
  108320. /**
  108321. * Define if the animations are started
  108322. */
  108323. get isStarted(): boolean;
  108324. /**
  108325. * Gets a value indicating that the current group is playing
  108326. */
  108327. get isPlaying(): boolean;
  108328. /**
  108329. * Gets or sets the speed ratio to use for all animations
  108330. */
  108331. get speedRatio(): number;
  108332. /**
  108333. * Gets or sets the speed ratio to use for all animations
  108334. */
  108335. set speedRatio(value: number);
  108336. /**
  108337. * Gets or sets if all animations should loop or not
  108338. */
  108339. get loopAnimation(): boolean;
  108340. set loopAnimation(value: boolean);
  108341. /**
  108342. * Gets the targeted animations for this animation group
  108343. */
  108344. get targetedAnimations(): Array<TargetedAnimation>;
  108345. /**
  108346. * returning the list of animatables controlled by this animation group.
  108347. */
  108348. get animatables(): Array<Animatable>;
  108349. /**
  108350. * Instantiates a new Animation Group.
  108351. * This helps managing several animations at once.
  108352. * @see http://doc.babylonjs.com/how_to/group
  108353. * @param name Defines the name of the group
  108354. * @param scene Defines the scene the group belongs to
  108355. */
  108356. constructor(
  108357. /** The name of the animation group */
  108358. name: string, scene?: Nullable<Scene>);
  108359. /**
  108360. * Add an animation (with its target) in the group
  108361. * @param animation defines the animation we want to add
  108362. * @param target defines the target of the animation
  108363. * @returns the TargetedAnimation object
  108364. */
  108365. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108366. /**
  108367. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108368. * It can add constant keys at begin or end
  108369. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108370. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108371. * @returns the animation group
  108372. */
  108373. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108374. private _animationLoopCount;
  108375. private _animationLoopFlags;
  108376. private _processLoop;
  108377. /**
  108378. * Start all animations on given targets
  108379. * @param loop defines if animations must loop
  108380. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108381. * @param from defines the from key (optional)
  108382. * @param to defines the to key (optional)
  108383. * @returns the current animation group
  108384. */
  108385. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108386. /**
  108387. * Pause all animations
  108388. * @returns the animation group
  108389. */
  108390. pause(): AnimationGroup;
  108391. /**
  108392. * Play all animations to initial state
  108393. * This function will start() the animations if they were not started or will restart() them if they were paused
  108394. * @param loop defines if animations must loop
  108395. * @returns the animation group
  108396. */
  108397. play(loop?: boolean): AnimationGroup;
  108398. /**
  108399. * Reset all animations to initial state
  108400. * @returns the animation group
  108401. */
  108402. reset(): AnimationGroup;
  108403. /**
  108404. * Restart animations from key 0
  108405. * @returns the animation group
  108406. */
  108407. restart(): AnimationGroup;
  108408. /**
  108409. * Stop all animations
  108410. * @returns the animation group
  108411. */
  108412. stop(): AnimationGroup;
  108413. /**
  108414. * Set animation weight for all animatables
  108415. * @param weight defines the weight to use
  108416. * @return the animationGroup
  108417. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108418. */
  108419. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108420. /**
  108421. * Synchronize and normalize all animatables with a source animatable
  108422. * @param root defines the root animatable to synchronize with
  108423. * @return the animationGroup
  108424. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108425. */
  108426. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108427. /**
  108428. * Goes to a specific frame in this animation group
  108429. * @param frame the frame number to go to
  108430. * @return the animationGroup
  108431. */
  108432. goToFrame(frame: number): AnimationGroup;
  108433. /**
  108434. * Dispose all associated resources
  108435. */
  108436. dispose(): void;
  108437. private _checkAnimationGroupEnded;
  108438. /**
  108439. * Clone the current animation group and returns a copy
  108440. * @param newName defines the name of the new group
  108441. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108442. * @returns the new aniamtion group
  108443. */
  108444. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108445. /**
  108446. * Serializes the animationGroup to an object
  108447. * @returns Serialized object
  108448. */
  108449. serialize(): any;
  108450. /**
  108451. * Returns a new AnimationGroup object parsed from the source provided.
  108452. * @param parsedAnimationGroup defines the source
  108453. * @param scene defines the scene that will receive the animationGroup
  108454. * @returns a new AnimationGroup
  108455. */
  108456. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108457. /**
  108458. * Returns the string "AnimationGroup"
  108459. * @returns "AnimationGroup"
  108460. */
  108461. getClassName(): string;
  108462. /**
  108463. * Creates a detailled string about the object
  108464. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108465. * @returns a string representing the object
  108466. */
  108467. toString(fullDetails?: boolean): string;
  108468. }
  108469. }
  108470. declare module BABYLON {
  108471. /**
  108472. * Define an interface for all classes that will hold resources
  108473. */
  108474. export interface IDisposable {
  108475. /**
  108476. * Releases all held resources
  108477. */
  108478. dispose(): void;
  108479. }
  108480. /** Interface defining initialization parameters for Scene class */
  108481. export interface SceneOptions {
  108482. /**
  108483. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108484. * It will improve performance when the number of geometries becomes important.
  108485. */
  108486. useGeometryUniqueIdsMap?: boolean;
  108487. /**
  108488. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108489. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108490. */
  108491. useMaterialMeshMap?: boolean;
  108492. /**
  108493. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108494. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108495. */
  108496. useClonedMeshMap?: boolean;
  108497. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108498. virtual?: boolean;
  108499. }
  108500. /**
  108501. * Represents a scene to be rendered by the engine.
  108502. * @see http://doc.babylonjs.com/features/scene
  108503. */
  108504. export class Scene extends AbstractScene implements IAnimatable {
  108505. /** The fog is deactivated */
  108506. static readonly FOGMODE_NONE: number;
  108507. /** The fog density is following an exponential function */
  108508. static readonly FOGMODE_EXP: number;
  108509. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108510. static readonly FOGMODE_EXP2: number;
  108511. /** The fog density is following a linear function. */
  108512. static readonly FOGMODE_LINEAR: number;
  108513. /**
  108514. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108515. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108516. */
  108517. static MinDeltaTime: number;
  108518. /**
  108519. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108520. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108521. */
  108522. static MaxDeltaTime: number;
  108523. /**
  108524. * Factory used to create the default material.
  108525. * @param name The name of the material to create
  108526. * @param scene The scene to create the material for
  108527. * @returns The default material
  108528. */
  108529. static DefaultMaterialFactory(scene: Scene): Material;
  108530. /**
  108531. * Factory used to create the a collision coordinator.
  108532. * @returns The collision coordinator
  108533. */
  108534. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108535. /** @hidden */
  108536. _inputManager: InputManager;
  108537. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108538. cameraToUseForPointers: Nullable<Camera>;
  108539. /** @hidden */
  108540. readonly _isScene: boolean;
  108541. /** @hidden */
  108542. _blockEntityCollection: boolean;
  108543. /**
  108544. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108545. */
  108546. autoClear: boolean;
  108547. /**
  108548. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108549. */
  108550. autoClearDepthAndStencil: boolean;
  108551. /**
  108552. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108553. */
  108554. clearColor: Color4;
  108555. /**
  108556. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108557. */
  108558. ambientColor: Color3;
  108559. /**
  108560. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108561. * It should only be one of the following (if not the default embedded one):
  108562. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108563. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108564. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108565. * The material properties need to be setup according to the type of texture in use.
  108566. */
  108567. environmentBRDFTexture: BaseTexture;
  108568. /** @hidden */
  108569. protected _environmentTexture: Nullable<BaseTexture>;
  108570. /**
  108571. * Texture used in all pbr material as the reflection texture.
  108572. * As in the majority of the scene they are the same (exception for multi room and so on),
  108573. * this is easier to reference from here than from all the materials.
  108574. */
  108575. get environmentTexture(): Nullable<BaseTexture>;
  108576. /**
  108577. * Texture used in all pbr material as the reflection texture.
  108578. * As in the majority of the scene they are the same (exception for multi room and so on),
  108579. * this is easier to set here than in all the materials.
  108580. */
  108581. set environmentTexture(value: Nullable<BaseTexture>);
  108582. /** @hidden */
  108583. protected _environmentIntensity: number;
  108584. /**
  108585. * Intensity of the environment in all pbr material.
  108586. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108587. * As in the majority of the scene they are the same (exception for multi room and so on),
  108588. * this is easier to reference from here than from all the materials.
  108589. */
  108590. get environmentIntensity(): number;
  108591. /**
  108592. * Intensity of the environment in all pbr material.
  108593. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108594. * As in the majority of the scene they are the same (exception for multi room and so on),
  108595. * this is easier to set here than in all the materials.
  108596. */
  108597. set environmentIntensity(value: number);
  108598. /** @hidden */
  108599. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108600. /**
  108601. * Default image processing configuration used either in the rendering
  108602. * Forward main pass or through the imageProcessingPostProcess if present.
  108603. * As in the majority of the scene they are the same (exception for multi camera),
  108604. * this is easier to reference from here than from all the materials and post process.
  108605. *
  108606. * No setter as we it is a shared configuration, you can set the values instead.
  108607. */
  108608. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108609. private _forceWireframe;
  108610. /**
  108611. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108612. */
  108613. set forceWireframe(value: boolean);
  108614. get forceWireframe(): boolean;
  108615. private _skipFrustumClipping;
  108616. /**
  108617. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108618. */
  108619. set skipFrustumClipping(value: boolean);
  108620. get skipFrustumClipping(): boolean;
  108621. private _forcePointsCloud;
  108622. /**
  108623. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108624. */
  108625. set forcePointsCloud(value: boolean);
  108626. get forcePointsCloud(): boolean;
  108627. /**
  108628. * Gets or sets the active clipplane 1
  108629. */
  108630. clipPlane: Nullable<Plane>;
  108631. /**
  108632. * Gets or sets the active clipplane 2
  108633. */
  108634. clipPlane2: Nullable<Plane>;
  108635. /**
  108636. * Gets or sets the active clipplane 3
  108637. */
  108638. clipPlane3: Nullable<Plane>;
  108639. /**
  108640. * Gets or sets the active clipplane 4
  108641. */
  108642. clipPlane4: Nullable<Plane>;
  108643. /**
  108644. * Gets or sets the active clipplane 5
  108645. */
  108646. clipPlane5: Nullable<Plane>;
  108647. /**
  108648. * Gets or sets the active clipplane 6
  108649. */
  108650. clipPlane6: Nullable<Plane>;
  108651. /**
  108652. * Gets or sets a boolean indicating if animations are enabled
  108653. */
  108654. animationsEnabled: boolean;
  108655. private _animationPropertiesOverride;
  108656. /**
  108657. * Gets or sets the animation properties override
  108658. */
  108659. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108660. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108661. /**
  108662. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108663. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108664. */
  108665. useConstantAnimationDeltaTime: boolean;
  108666. /**
  108667. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108668. * Please note that it requires to run a ray cast through the scene on every frame
  108669. */
  108670. constantlyUpdateMeshUnderPointer: boolean;
  108671. /**
  108672. * Defines the HTML cursor to use when hovering over interactive elements
  108673. */
  108674. hoverCursor: string;
  108675. /**
  108676. * Defines the HTML default cursor to use (empty by default)
  108677. */
  108678. defaultCursor: string;
  108679. /**
  108680. * Defines whether cursors are handled by the scene.
  108681. */
  108682. doNotHandleCursors: boolean;
  108683. /**
  108684. * This is used to call preventDefault() on pointer down
  108685. * in order to block unwanted artifacts like system double clicks
  108686. */
  108687. preventDefaultOnPointerDown: boolean;
  108688. /**
  108689. * This is used to call preventDefault() on pointer up
  108690. * in order to block unwanted artifacts like system double clicks
  108691. */
  108692. preventDefaultOnPointerUp: boolean;
  108693. /**
  108694. * Gets or sets user defined metadata
  108695. */
  108696. metadata: any;
  108697. /**
  108698. * For internal use only. Please do not use.
  108699. */
  108700. reservedDataStore: any;
  108701. /**
  108702. * Gets the name of the plugin used to load this scene (null by default)
  108703. */
  108704. loadingPluginName: string;
  108705. /**
  108706. * Use this array to add regular expressions used to disable offline support for specific urls
  108707. */
  108708. disableOfflineSupportExceptionRules: RegExp[];
  108709. /**
  108710. * An event triggered when the scene is disposed.
  108711. */
  108712. onDisposeObservable: Observable<Scene>;
  108713. private _onDisposeObserver;
  108714. /** Sets a function to be executed when this scene is disposed. */
  108715. set onDispose(callback: () => void);
  108716. /**
  108717. * An event triggered before rendering the scene (right after animations and physics)
  108718. */
  108719. onBeforeRenderObservable: Observable<Scene>;
  108720. private _onBeforeRenderObserver;
  108721. /** Sets a function to be executed before rendering this scene */
  108722. set beforeRender(callback: Nullable<() => void>);
  108723. /**
  108724. * An event triggered after rendering the scene
  108725. */
  108726. onAfterRenderObservable: Observable<Scene>;
  108727. /**
  108728. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108729. */
  108730. onAfterRenderCameraObservable: Observable<Camera>;
  108731. private _onAfterRenderObserver;
  108732. /** Sets a function to be executed after rendering this scene */
  108733. set afterRender(callback: Nullable<() => void>);
  108734. /**
  108735. * An event triggered before animating the scene
  108736. */
  108737. onBeforeAnimationsObservable: Observable<Scene>;
  108738. /**
  108739. * An event triggered after animations processing
  108740. */
  108741. onAfterAnimationsObservable: Observable<Scene>;
  108742. /**
  108743. * An event triggered before draw calls are ready to be sent
  108744. */
  108745. onBeforeDrawPhaseObservable: Observable<Scene>;
  108746. /**
  108747. * An event triggered after draw calls have been sent
  108748. */
  108749. onAfterDrawPhaseObservable: Observable<Scene>;
  108750. /**
  108751. * An event triggered when the scene is ready
  108752. */
  108753. onReadyObservable: Observable<Scene>;
  108754. /**
  108755. * An event triggered before rendering a camera
  108756. */
  108757. onBeforeCameraRenderObservable: Observable<Camera>;
  108758. private _onBeforeCameraRenderObserver;
  108759. /** Sets a function to be executed before rendering a camera*/
  108760. set beforeCameraRender(callback: () => void);
  108761. /**
  108762. * An event triggered after rendering a camera
  108763. */
  108764. onAfterCameraRenderObservable: Observable<Camera>;
  108765. private _onAfterCameraRenderObserver;
  108766. /** Sets a function to be executed after rendering a camera*/
  108767. set afterCameraRender(callback: () => void);
  108768. /**
  108769. * An event triggered when active meshes evaluation is about to start
  108770. */
  108771. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108772. /**
  108773. * An event triggered when active meshes evaluation is done
  108774. */
  108775. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108776. /**
  108777. * An event triggered when particles rendering is about to start
  108778. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108779. */
  108780. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108781. /**
  108782. * An event triggered when particles rendering is done
  108783. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108784. */
  108785. onAfterParticlesRenderingObservable: Observable<Scene>;
  108786. /**
  108787. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108788. */
  108789. onDataLoadedObservable: Observable<Scene>;
  108790. /**
  108791. * An event triggered when a camera is created
  108792. */
  108793. onNewCameraAddedObservable: Observable<Camera>;
  108794. /**
  108795. * An event triggered when a camera is removed
  108796. */
  108797. onCameraRemovedObservable: Observable<Camera>;
  108798. /**
  108799. * An event triggered when a light is created
  108800. */
  108801. onNewLightAddedObservable: Observable<Light>;
  108802. /**
  108803. * An event triggered when a light is removed
  108804. */
  108805. onLightRemovedObservable: Observable<Light>;
  108806. /**
  108807. * An event triggered when a geometry is created
  108808. */
  108809. onNewGeometryAddedObservable: Observable<Geometry>;
  108810. /**
  108811. * An event triggered when a geometry is removed
  108812. */
  108813. onGeometryRemovedObservable: Observable<Geometry>;
  108814. /**
  108815. * An event triggered when a transform node is created
  108816. */
  108817. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108818. /**
  108819. * An event triggered when a transform node is removed
  108820. */
  108821. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108822. /**
  108823. * An event triggered when a mesh is created
  108824. */
  108825. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108826. /**
  108827. * An event triggered when a mesh is removed
  108828. */
  108829. onMeshRemovedObservable: Observable<AbstractMesh>;
  108830. /**
  108831. * An event triggered when a skeleton is created
  108832. */
  108833. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108834. /**
  108835. * An event triggered when a skeleton is removed
  108836. */
  108837. onSkeletonRemovedObservable: Observable<Skeleton>;
  108838. /**
  108839. * An event triggered when a material is created
  108840. */
  108841. onNewMaterialAddedObservable: Observable<Material>;
  108842. /**
  108843. * An event triggered when a material is removed
  108844. */
  108845. onMaterialRemovedObservable: Observable<Material>;
  108846. /**
  108847. * An event triggered when a texture is created
  108848. */
  108849. onNewTextureAddedObservable: Observable<BaseTexture>;
  108850. /**
  108851. * An event triggered when a texture is removed
  108852. */
  108853. onTextureRemovedObservable: Observable<BaseTexture>;
  108854. /**
  108855. * An event triggered when render targets are about to be rendered
  108856. * Can happen multiple times per frame.
  108857. */
  108858. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108859. /**
  108860. * An event triggered when render targets were rendered.
  108861. * Can happen multiple times per frame.
  108862. */
  108863. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108864. /**
  108865. * An event triggered before calculating deterministic simulation step
  108866. */
  108867. onBeforeStepObservable: Observable<Scene>;
  108868. /**
  108869. * An event triggered after calculating deterministic simulation step
  108870. */
  108871. onAfterStepObservable: Observable<Scene>;
  108872. /**
  108873. * An event triggered when the activeCamera property is updated
  108874. */
  108875. onActiveCameraChanged: Observable<Scene>;
  108876. /**
  108877. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108878. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108879. * 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)
  108880. */
  108881. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108882. /**
  108883. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108884. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108885. * 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)
  108886. */
  108887. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108888. /**
  108889. * This Observable will when a mesh has been imported into the scene.
  108890. */
  108891. onMeshImportedObservable: Observable<AbstractMesh>;
  108892. /**
  108893. * This Observable will when an animation file has been imported into the scene.
  108894. */
  108895. onAnimationFileImportedObservable: Observable<Scene>;
  108896. /**
  108897. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108898. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108899. */
  108900. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108901. /** @hidden */
  108902. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108903. /**
  108904. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108905. */
  108906. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108907. /**
  108908. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108909. */
  108910. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108911. /**
  108912. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108913. */
  108914. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108915. /** Callback called when a pointer move is detected */
  108916. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108917. /** Callback called when a pointer down is detected */
  108918. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108919. /** Callback called when a pointer up is detected */
  108920. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108921. /** Callback called when a pointer pick is detected */
  108922. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108923. /**
  108924. * 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).
  108925. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108926. */
  108927. onPrePointerObservable: Observable<PointerInfoPre>;
  108928. /**
  108929. * Observable event triggered each time an input event is received from the rendering canvas
  108930. */
  108931. onPointerObservable: Observable<PointerInfo>;
  108932. /**
  108933. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108934. */
  108935. get unTranslatedPointer(): Vector2;
  108936. /**
  108937. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108938. */
  108939. static get DragMovementThreshold(): number;
  108940. static set DragMovementThreshold(value: number);
  108941. /**
  108942. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108943. */
  108944. static get LongPressDelay(): number;
  108945. static set LongPressDelay(value: number);
  108946. /**
  108947. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108948. */
  108949. static get DoubleClickDelay(): number;
  108950. static set DoubleClickDelay(value: number);
  108951. /** If you need to check double click without raising a single click at first click, enable this flag */
  108952. static get ExclusiveDoubleClickMode(): boolean;
  108953. static set ExclusiveDoubleClickMode(value: boolean);
  108954. /** @hidden */
  108955. _mirroredCameraPosition: Nullable<Vector3>;
  108956. /**
  108957. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108958. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108959. */
  108960. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108961. /**
  108962. * Observable event triggered each time an keyboard event is received from the hosting window
  108963. */
  108964. onKeyboardObservable: Observable<KeyboardInfo>;
  108965. private _useRightHandedSystem;
  108966. /**
  108967. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108968. */
  108969. set useRightHandedSystem(value: boolean);
  108970. get useRightHandedSystem(): boolean;
  108971. private _timeAccumulator;
  108972. private _currentStepId;
  108973. private _currentInternalStep;
  108974. /**
  108975. * Sets the step Id used by deterministic lock step
  108976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108977. * @param newStepId defines the step Id
  108978. */
  108979. setStepId(newStepId: number): void;
  108980. /**
  108981. * Gets the step Id used by deterministic lock step
  108982. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108983. * @returns the step Id
  108984. */
  108985. getStepId(): number;
  108986. /**
  108987. * Gets the internal step used by deterministic lock step
  108988. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108989. * @returns the internal step
  108990. */
  108991. getInternalStep(): number;
  108992. private _fogEnabled;
  108993. /**
  108994. * Gets or sets a boolean indicating if fog is enabled on this scene
  108995. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108996. * (Default is true)
  108997. */
  108998. set fogEnabled(value: boolean);
  108999. get fogEnabled(): boolean;
  109000. private _fogMode;
  109001. /**
  109002. * Gets or sets the fog mode to use
  109003. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109004. * | mode | value |
  109005. * | --- | --- |
  109006. * | FOGMODE_NONE | 0 |
  109007. * | FOGMODE_EXP | 1 |
  109008. * | FOGMODE_EXP2 | 2 |
  109009. * | FOGMODE_LINEAR | 3 |
  109010. */
  109011. set fogMode(value: number);
  109012. get fogMode(): number;
  109013. /**
  109014. * Gets or sets the fog color to use
  109015. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109016. * (Default is Color3(0.2, 0.2, 0.3))
  109017. */
  109018. fogColor: Color3;
  109019. /**
  109020. * Gets or sets the fog density to use
  109021. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109022. * (Default is 0.1)
  109023. */
  109024. fogDensity: number;
  109025. /**
  109026. * Gets or sets the fog start distance to use
  109027. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109028. * (Default is 0)
  109029. */
  109030. fogStart: number;
  109031. /**
  109032. * Gets or sets the fog end distance to use
  109033. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109034. * (Default is 1000)
  109035. */
  109036. fogEnd: number;
  109037. private _shadowsEnabled;
  109038. /**
  109039. * Gets or sets a boolean indicating if shadows are enabled on this scene
  109040. */
  109041. set shadowsEnabled(value: boolean);
  109042. get shadowsEnabled(): boolean;
  109043. private _lightsEnabled;
  109044. /**
  109045. * Gets or sets a boolean indicating if lights are enabled on this scene
  109046. */
  109047. set lightsEnabled(value: boolean);
  109048. get lightsEnabled(): boolean;
  109049. /** All of the active cameras added to this scene. */
  109050. activeCameras: Camera[];
  109051. /** @hidden */
  109052. _activeCamera: Nullable<Camera>;
  109053. /** Gets or sets the current active camera */
  109054. get activeCamera(): Nullable<Camera>;
  109055. set activeCamera(value: Nullable<Camera>);
  109056. private _defaultMaterial;
  109057. /** The default material used on meshes when no material is affected */
  109058. get defaultMaterial(): Material;
  109059. /** The default material used on meshes when no material is affected */
  109060. set defaultMaterial(value: Material);
  109061. private _texturesEnabled;
  109062. /**
  109063. * Gets or sets a boolean indicating if textures are enabled on this scene
  109064. */
  109065. set texturesEnabled(value: boolean);
  109066. get texturesEnabled(): boolean;
  109067. /**
  109068. * Gets or sets a boolean indicating if particles are enabled on this scene
  109069. */
  109070. particlesEnabled: boolean;
  109071. /**
  109072. * Gets or sets a boolean indicating if sprites are enabled on this scene
  109073. */
  109074. spritesEnabled: boolean;
  109075. private _skeletonsEnabled;
  109076. /**
  109077. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  109078. */
  109079. set skeletonsEnabled(value: boolean);
  109080. get skeletonsEnabled(): boolean;
  109081. /**
  109082. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  109083. */
  109084. lensFlaresEnabled: boolean;
  109085. /**
  109086. * Gets or sets a boolean indicating if collisions are enabled on this scene
  109087. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109088. */
  109089. collisionsEnabled: boolean;
  109090. private _collisionCoordinator;
  109091. /** @hidden */
  109092. get collisionCoordinator(): ICollisionCoordinator;
  109093. /**
  109094. * Defines the gravity applied to this scene (used only for collisions)
  109095. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109096. */
  109097. gravity: Vector3;
  109098. /**
  109099. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  109100. */
  109101. postProcessesEnabled: boolean;
  109102. /**
  109103. * The list of postprocesses added to the scene
  109104. */
  109105. postProcesses: PostProcess[];
  109106. /**
  109107. * Gets the current postprocess manager
  109108. */
  109109. postProcessManager: PostProcessManager;
  109110. /**
  109111. * Gets or sets a boolean indicating if render targets are enabled on this scene
  109112. */
  109113. renderTargetsEnabled: boolean;
  109114. /**
  109115. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109116. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109117. */
  109118. dumpNextRenderTargets: boolean;
  109119. /**
  109120. * The list of user defined render targets added to the scene
  109121. */
  109122. customRenderTargets: RenderTargetTexture[];
  109123. /**
  109124. * Defines if texture loading must be delayed
  109125. * If true, textures will only be loaded when they need to be rendered
  109126. */
  109127. useDelayedTextureLoading: boolean;
  109128. /**
  109129. * Gets the list of meshes imported to the scene through SceneLoader
  109130. */
  109131. importedMeshesFiles: String[];
  109132. /**
  109133. * Gets or sets a boolean indicating if probes are enabled on this scene
  109134. */
  109135. probesEnabled: boolean;
  109136. /**
  109137. * Gets or sets the current offline provider to use to store scene data
  109138. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109139. */
  109140. offlineProvider: IOfflineProvider;
  109141. /**
  109142. * Gets or sets the action manager associated with the scene
  109143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109144. */
  109145. actionManager: AbstractActionManager;
  109146. private _meshesForIntersections;
  109147. /**
  109148. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109149. */
  109150. proceduralTexturesEnabled: boolean;
  109151. private _engine;
  109152. private _totalVertices;
  109153. /** @hidden */
  109154. _activeIndices: PerfCounter;
  109155. /** @hidden */
  109156. _activeParticles: PerfCounter;
  109157. /** @hidden */
  109158. _activeBones: PerfCounter;
  109159. private _animationRatio;
  109160. /** @hidden */
  109161. _animationTimeLast: number;
  109162. /** @hidden */
  109163. _animationTime: number;
  109164. /**
  109165. * Gets or sets a general scale for animation speed
  109166. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109167. */
  109168. animationTimeScale: number;
  109169. /** @hidden */
  109170. _cachedMaterial: Nullable<Material>;
  109171. /** @hidden */
  109172. _cachedEffect: Nullable<Effect>;
  109173. /** @hidden */
  109174. _cachedVisibility: Nullable<number>;
  109175. private _renderId;
  109176. private _frameId;
  109177. private _executeWhenReadyTimeoutId;
  109178. private _intermediateRendering;
  109179. private _viewUpdateFlag;
  109180. private _projectionUpdateFlag;
  109181. /** @hidden */
  109182. _toBeDisposed: Nullable<IDisposable>[];
  109183. private _activeRequests;
  109184. /** @hidden */
  109185. _pendingData: any[];
  109186. private _isDisposed;
  109187. /**
  109188. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109189. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109190. */
  109191. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109192. private _activeMeshes;
  109193. private _processedMaterials;
  109194. private _renderTargets;
  109195. /** @hidden */
  109196. _activeParticleSystems: SmartArray<IParticleSystem>;
  109197. private _activeSkeletons;
  109198. private _softwareSkinnedMeshes;
  109199. private _renderingManager;
  109200. /** @hidden */
  109201. _activeAnimatables: Animatable[];
  109202. private _transformMatrix;
  109203. private _sceneUbo;
  109204. /** @hidden */
  109205. _viewMatrix: Matrix;
  109206. private _projectionMatrix;
  109207. /** @hidden */
  109208. _forcedViewPosition: Nullable<Vector3>;
  109209. /** @hidden */
  109210. _frustumPlanes: Plane[];
  109211. /**
  109212. * Gets the list of frustum planes (built from the active camera)
  109213. */
  109214. get frustumPlanes(): Plane[];
  109215. /**
  109216. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109217. * This is useful if there are more lights that the maximum simulteanous authorized
  109218. */
  109219. requireLightSorting: boolean;
  109220. /** @hidden */
  109221. readonly useMaterialMeshMap: boolean;
  109222. /** @hidden */
  109223. readonly useClonedMeshMap: boolean;
  109224. private _externalData;
  109225. private _uid;
  109226. /**
  109227. * @hidden
  109228. * Backing store of defined scene components.
  109229. */
  109230. _components: ISceneComponent[];
  109231. /**
  109232. * @hidden
  109233. * Backing store of defined scene components.
  109234. */
  109235. _serializableComponents: ISceneSerializableComponent[];
  109236. /**
  109237. * List of components to register on the next registration step.
  109238. */
  109239. private _transientComponents;
  109240. /**
  109241. * Registers the transient components if needed.
  109242. */
  109243. private _registerTransientComponents;
  109244. /**
  109245. * @hidden
  109246. * Add a component to the scene.
  109247. * Note that the ccomponent could be registered on th next frame if this is called after
  109248. * the register component stage.
  109249. * @param component Defines the component to add to the scene
  109250. */
  109251. _addComponent(component: ISceneComponent): void;
  109252. /**
  109253. * @hidden
  109254. * Gets a component from the scene.
  109255. * @param name defines the name of the component to retrieve
  109256. * @returns the component or null if not present
  109257. */
  109258. _getComponent(name: string): Nullable<ISceneComponent>;
  109259. /**
  109260. * @hidden
  109261. * Defines the actions happening before camera updates.
  109262. */
  109263. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109264. /**
  109265. * @hidden
  109266. * Defines the actions happening before clear the canvas.
  109267. */
  109268. _beforeClearStage: Stage<SimpleStageAction>;
  109269. /**
  109270. * @hidden
  109271. * Defines the actions when collecting render targets for the frame.
  109272. */
  109273. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109274. /**
  109275. * @hidden
  109276. * Defines the actions happening for one camera in the frame.
  109277. */
  109278. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109279. /**
  109280. * @hidden
  109281. * Defines the actions happening during the per mesh ready checks.
  109282. */
  109283. _isReadyForMeshStage: Stage<MeshStageAction>;
  109284. /**
  109285. * @hidden
  109286. * Defines the actions happening before evaluate active mesh checks.
  109287. */
  109288. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109289. /**
  109290. * @hidden
  109291. * Defines the actions happening during the evaluate sub mesh checks.
  109292. */
  109293. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109294. /**
  109295. * @hidden
  109296. * Defines the actions happening during the active mesh stage.
  109297. */
  109298. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109299. /**
  109300. * @hidden
  109301. * Defines the actions happening during the per camera render target step.
  109302. */
  109303. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109304. /**
  109305. * @hidden
  109306. * Defines the actions happening just before the active camera is drawing.
  109307. */
  109308. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109309. /**
  109310. * @hidden
  109311. * Defines the actions happening just before a render target is drawing.
  109312. */
  109313. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109314. /**
  109315. * @hidden
  109316. * Defines the actions happening just before a rendering group is drawing.
  109317. */
  109318. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109319. /**
  109320. * @hidden
  109321. * Defines the actions happening just before a mesh is drawing.
  109322. */
  109323. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109324. /**
  109325. * @hidden
  109326. * Defines the actions happening just after a mesh has been drawn.
  109327. */
  109328. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109329. /**
  109330. * @hidden
  109331. * Defines the actions happening just after a rendering group has been drawn.
  109332. */
  109333. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109334. /**
  109335. * @hidden
  109336. * Defines the actions happening just after the active camera has been drawn.
  109337. */
  109338. _afterCameraDrawStage: Stage<CameraStageAction>;
  109339. /**
  109340. * @hidden
  109341. * Defines the actions happening just after a render target has been drawn.
  109342. */
  109343. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109344. /**
  109345. * @hidden
  109346. * Defines the actions happening just after rendering all cameras and computing intersections.
  109347. */
  109348. _afterRenderStage: Stage<SimpleStageAction>;
  109349. /**
  109350. * @hidden
  109351. * Defines the actions happening when a pointer move event happens.
  109352. */
  109353. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109354. /**
  109355. * @hidden
  109356. * Defines the actions happening when a pointer down event happens.
  109357. */
  109358. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109359. /**
  109360. * @hidden
  109361. * Defines the actions happening when a pointer up event happens.
  109362. */
  109363. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109364. /**
  109365. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109366. */
  109367. private geometriesByUniqueId;
  109368. /**
  109369. * Creates a new Scene
  109370. * @param engine defines the engine to use to render this scene
  109371. * @param options defines the scene options
  109372. */
  109373. constructor(engine: Engine, options?: SceneOptions);
  109374. /**
  109375. * Gets a string idenfifying the name of the class
  109376. * @returns "Scene" string
  109377. */
  109378. getClassName(): string;
  109379. private _defaultMeshCandidates;
  109380. /**
  109381. * @hidden
  109382. */
  109383. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109384. private _defaultSubMeshCandidates;
  109385. /**
  109386. * @hidden
  109387. */
  109388. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109389. /**
  109390. * Sets the default candidate providers for the scene.
  109391. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109392. * and getCollidingSubMeshCandidates to their default function
  109393. */
  109394. setDefaultCandidateProviders(): void;
  109395. /**
  109396. * Gets the mesh that is currently under the pointer
  109397. */
  109398. get meshUnderPointer(): Nullable<AbstractMesh>;
  109399. /**
  109400. * Gets or sets the current on-screen X position of the pointer
  109401. */
  109402. get pointerX(): number;
  109403. set pointerX(value: number);
  109404. /**
  109405. * Gets or sets the current on-screen Y position of the pointer
  109406. */
  109407. get pointerY(): number;
  109408. set pointerY(value: number);
  109409. /**
  109410. * Gets the cached material (ie. the latest rendered one)
  109411. * @returns the cached material
  109412. */
  109413. getCachedMaterial(): Nullable<Material>;
  109414. /**
  109415. * Gets the cached effect (ie. the latest rendered one)
  109416. * @returns the cached effect
  109417. */
  109418. getCachedEffect(): Nullable<Effect>;
  109419. /**
  109420. * Gets the cached visibility state (ie. the latest rendered one)
  109421. * @returns the cached visibility state
  109422. */
  109423. getCachedVisibility(): Nullable<number>;
  109424. /**
  109425. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109426. * @param material defines the current material
  109427. * @param effect defines the current effect
  109428. * @param visibility defines the current visibility state
  109429. * @returns true if one parameter is not cached
  109430. */
  109431. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109432. /**
  109433. * Gets the engine associated with the scene
  109434. * @returns an Engine
  109435. */
  109436. getEngine(): Engine;
  109437. /**
  109438. * Gets the total number of vertices rendered per frame
  109439. * @returns the total number of vertices rendered per frame
  109440. */
  109441. getTotalVertices(): number;
  109442. /**
  109443. * Gets the performance counter for total vertices
  109444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109445. */
  109446. get totalVerticesPerfCounter(): PerfCounter;
  109447. /**
  109448. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109449. * @returns the total number of active indices rendered per frame
  109450. */
  109451. getActiveIndices(): number;
  109452. /**
  109453. * Gets the performance counter for active indices
  109454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109455. */
  109456. get totalActiveIndicesPerfCounter(): PerfCounter;
  109457. /**
  109458. * Gets the total number of active particles rendered per frame
  109459. * @returns the total number of active particles rendered per frame
  109460. */
  109461. getActiveParticles(): number;
  109462. /**
  109463. * Gets the performance counter for active particles
  109464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109465. */
  109466. get activeParticlesPerfCounter(): PerfCounter;
  109467. /**
  109468. * Gets the total number of active bones rendered per frame
  109469. * @returns the total number of active bones rendered per frame
  109470. */
  109471. getActiveBones(): number;
  109472. /**
  109473. * Gets the performance counter for active bones
  109474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109475. */
  109476. get activeBonesPerfCounter(): PerfCounter;
  109477. /**
  109478. * Gets the array of active meshes
  109479. * @returns an array of AbstractMesh
  109480. */
  109481. getActiveMeshes(): SmartArray<AbstractMesh>;
  109482. /**
  109483. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109484. * @returns a number
  109485. */
  109486. getAnimationRatio(): number;
  109487. /**
  109488. * Gets an unique Id for the current render phase
  109489. * @returns a number
  109490. */
  109491. getRenderId(): number;
  109492. /**
  109493. * Gets an unique Id for the current frame
  109494. * @returns a number
  109495. */
  109496. getFrameId(): number;
  109497. /** Call this function if you want to manually increment the render Id*/
  109498. incrementRenderId(): void;
  109499. private _createUbo;
  109500. /**
  109501. * Use this method to simulate a pointer move on a mesh
  109502. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109503. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109504. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109505. * @returns the current scene
  109506. */
  109507. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109508. /**
  109509. * Use this method to simulate a pointer down on a mesh
  109510. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109511. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109512. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109513. * @returns the current scene
  109514. */
  109515. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109516. /**
  109517. * Use this method to simulate a pointer up on a mesh
  109518. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109519. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109520. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109521. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109522. * @returns the current scene
  109523. */
  109524. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109525. /**
  109526. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109527. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109528. * @returns true if the pointer was captured
  109529. */
  109530. isPointerCaptured(pointerId?: number): boolean;
  109531. /**
  109532. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109533. * @param attachUp defines if you want to attach events to pointerup
  109534. * @param attachDown defines if you want to attach events to pointerdown
  109535. * @param attachMove defines if you want to attach events to pointermove
  109536. */
  109537. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109538. /** Detaches all event handlers*/
  109539. detachControl(): void;
  109540. /**
  109541. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109542. * Delay loaded resources are not taking in account
  109543. * @return true if all required resources are ready
  109544. */
  109545. isReady(): boolean;
  109546. /** Resets all cached information relative to material (including effect and visibility) */
  109547. resetCachedMaterial(): void;
  109548. /**
  109549. * Registers a function to be called before every frame render
  109550. * @param func defines the function to register
  109551. */
  109552. registerBeforeRender(func: () => void): void;
  109553. /**
  109554. * Unregisters a function called before every frame render
  109555. * @param func defines the function to unregister
  109556. */
  109557. unregisterBeforeRender(func: () => void): void;
  109558. /**
  109559. * Registers a function to be called after every frame render
  109560. * @param func defines the function to register
  109561. */
  109562. registerAfterRender(func: () => void): void;
  109563. /**
  109564. * Unregisters a function called after every frame render
  109565. * @param func defines the function to unregister
  109566. */
  109567. unregisterAfterRender(func: () => void): void;
  109568. private _executeOnceBeforeRender;
  109569. /**
  109570. * The provided function will run before render once and will be disposed afterwards.
  109571. * A timeout delay can be provided so that the function will be executed in N ms.
  109572. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109573. * @param func The function to be executed.
  109574. * @param timeout optional delay in ms
  109575. */
  109576. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109577. /** @hidden */
  109578. _addPendingData(data: any): void;
  109579. /** @hidden */
  109580. _removePendingData(data: any): void;
  109581. /**
  109582. * Returns the number of items waiting to be loaded
  109583. * @returns the number of items waiting to be loaded
  109584. */
  109585. getWaitingItemsCount(): number;
  109586. /**
  109587. * Returns a boolean indicating if the scene is still loading data
  109588. */
  109589. get isLoading(): boolean;
  109590. /**
  109591. * Registers a function to be executed when the scene is ready
  109592. * @param {Function} func - the function to be executed
  109593. */
  109594. executeWhenReady(func: () => void): void;
  109595. /**
  109596. * Returns a promise that resolves when the scene is ready
  109597. * @returns A promise that resolves when the scene is ready
  109598. */
  109599. whenReadyAsync(): Promise<void>;
  109600. /** @hidden */
  109601. _checkIsReady(): void;
  109602. /**
  109603. * Gets all animatable attached to the scene
  109604. */
  109605. get animatables(): Animatable[];
  109606. /**
  109607. * Resets the last animation time frame.
  109608. * Useful to override when animations start running when loading a scene for the first time.
  109609. */
  109610. resetLastAnimationTimeFrame(): void;
  109611. /**
  109612. * Gets the current view matrix
  109613. * @returns a Matrix
  109614. */
  109615. getViewMatrix(): Matrix;
  109616. /**
  109617. * Gets the current projection matrix
  109618. * @returns a Matrix
  109619. */
  109620. getProjectionMatrix(): Matrix;
  109621. /**
  109622. * Gets the current transform matrix
  109623. * @returns a Matrix made of View * Projection
  109624. */
  109625. getTransformMatrix(): Matrix;
  109626. /**
  109627. * Sets the current transform matrix
  109628. * @param viewL defines the View matrix to use
  109629. * @param projectionL defines the Projection matrix to use
  109630. * @param viewR defines the right View matrix to use (if provided)
  109631. * @param projectionR defines the right Projection matrix to use (if provided)
  109632. */
  109633. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109634. /**
  109635. * Gets the uniform buffer used to store scene data
  109636. * @returns a UniformBuffer
  109637. */
  109638. getSceneUniformBuffer(): UniformBuffer;
  109639. /**
  109640. * Gets an unique (relatively to the current scene) Id
  109641. * @returns an unique number for the scene
  109642. */
  109643. getUniqueId(): number;
  109644. /**
  109645. * Add a mesh to the list of scene's meshes
  109646. * @param newMesh defines the mesh to add
  109647. * @param recursive if all child meshes should also be added to the scene
  109648. */
  109649. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109650. /**
  109651. * Remove a mesh for the list of scene's meshes
  109652. * @param toRemove defines the mesh to remove
  109653. * @param recursive if all child meshes should also be removed from the scene
  109654. * @returns the index where the mesh was in the mesh list
  109655. */
  109656. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109657. /**
  109658. * Add a transform node to the list of scene's transform nodes
  109659. * @param newTransformNode defines the transform node to add
  109660. */
  109661. addTransformNode(newTransformNode: TransformNode): void;
  109662. /**
  109663. * Remove a transform node for the list of scene's transform nodes
  109664. * @param toRemove defines the transform node to remove
  109665. * @returns the index where the transform node was in the transform node list
  109666. */
  109667. removeTransformNode(toRemove: TransformNode): number;
  109668. /**
  109669. * Remove a skeleton for the list of scene's skeletons
  109670. * @param toRemove defines the skeleton to remove
  109671. * @returns the index where the skeleton was in the skeleton list
  109672. */
  109673. removeSkeleton(toRemove: Skeleton): number;
  109674. /**
  109675. * Remove a morph target for the list of scene's morph targets
  109676. * @param toRemove defines the morph target to remove
  109677. * @returns the index where the morph target was in the morph target list
  109678. */
  109679. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109680. /**
  109681. * Remove a light for the list of scene's lights
  109682. * @param toRemove defines the light to remove
  109683. * @returns the index where the light was in the light list
  109684. */
  109685. removeLight(toRemove: Light): number;
  109686. /**
  109687. * Remove a camera for the list of scene's cameras
  109688. * @param toRemove defines the camera to remove
  109689. * @returns the index where the camera was in the camera list
  109690. */
  109691. removeCamera(toRemove: Camera): number;
  109692. /**
  109693. * Remove a particle system for the list of scene's particle systems
  109694. * @param toRemove defines the particle system to remove
  109695. * @returns the index where the particle system was in the particle system list
  109696. */
  109697. removeParticleSystem(toRemove: IParticleSystem): number;
  109698. /**
  109699. * Remove a animation for the list of scene's animations
  109700. * @param toRemove defines the animation to remove
  109701. * @returns the index where the animation was in the animation list
  109702. */
  109703. removeAnimation(toRemove: Animation): number;
  109704. /**
  109705. * Will stop the animation of the given target
  109706. * @param target - the target
  109707. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109708. * @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)
  109709. */
  109710. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109711. /**
  109712. * Removes the given animation group from this scene.
  109713. * @param toRemove The animation group to remove
  109714. * @returns The index of the removed animation group
  109715. */
  109716. removeAnimationGroup(toRemove: AnimationGroup): number;
  109717. /**
  109718. * Removes the given multi-material from this scene.
  109719. * @param toRemove The multi-material to remove
  109720. * @returns The index of the removed multi-material
  109721. */
  109722. removeMultiMaterial(toRemove: MultiMaterial): number;
  109723. /**
  109724. * Removes the given material from this scene.
  109725. * @param toRemove The material to remove
  109726. * @returns The index of the removed material
  109727. */
  109728. removeMaterial(toRemove: Material): number;
  109729. /**
  109730. * Removes the given action manager from this scene.
  109731. * @param toRemove The action manager to remove
  109732. * @returns The index of the removed action manager
  109733. */
  109734. removeActionManager(toRemove: AbstractActionManager): number;
  109735. /**
  109736. * Removes the given texture from this scene.
  109737. * @param toRemove The texture to remove
  109738. * @returns The index of the removed texture
  109739. */
  109740. removeTexture(toRemove: BaseTexture): number;
  109741. /**
  109742. * Adds the given light to this scene
  109743. * @param newLight The light to add
  109744. */
  109745. addLight(newLight: Light): void;
  109746. /**
  109747. * Sorts the list list based on light priorities
  109748. */
  109749. sortLightsByPriority(): void;
  109750. /**
  109751. * Adds the given camera to this scene
  109752. * @param newCamera The camera to add
  109753. */
  109754. addCamera(newCamera: Camera): void;
  109755. /**
  109756. * Adds the given skeleton to this scene
  109757. * @param newSkeleton The skeleton to add
  109758. */
  109759. addSkeleton(newSkeleton: Skeleton): void;
  109760. /**
  109761. * Adds the given particle system to this scene
  109762. * @param newParticleSystem The particle system to add
  109763. */
  109764. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109765. /**
  109766. * Adds the given animation to this scene
  109767. * @param newAnimation The animation to add
  109768. */
  109769. addAnimation(newAnimation: Animation): void;
  109770. /**
  109771. * Adds the given animation group to this scene.
  109772. * @param newAnimationGroup The animation group to add
  109773. */
  109774. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109775. /**
  109776. * Adds the given multi-material to this scene
  109777. * @param newMultiMaterial The multi-material to add
  109778. */
  109779. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109780. /**
  109781. * Adds the given material to this scene
  109782. * @param newMaterial The material to add
  109783. */
  109784. addMaterial(newMaterial: Material): void;
  109785. /**
  109786. * Adds the given morph target to this scene
  109787. * @param newMorphTargetManager The morph target to add
  109788. */
  109789. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109790. /**
  109791. * Adds the given geometry to this scene
  109792. * @param newGeometry The geometry to add
  109793. */
  109794. addGeometry(newGeometry: Geometry): void;
  109795. /**
  109796. * Adds the given action manager to this scene
  109797. * @param newActionManager The action manager to add
  109798. */
  109799. addActionManager(newActionManager: AbstractActionManager): void;
  109800. /**
  109801. * Adds the given texture to this scene.
  109802. * @param newTexture The texture to add
  109803. */
  109804. addTexture(newTexture: BaseTexture): void;
  109805. /**
  109806. * Switch active camera
  109807. * @param newCamera defines the new active camera
  109808. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109809. */
  109810. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109811. /**
  109812. * sets the active camera of the scene using its ID
  109813. * @param id defines the camera's ID
  109814. * @return the new active camera or null if none found.
  109815. */
  109816. setActiveCameraByID(id: string): Nullable<Camera>;
  109817. /**
  109818. * sets the active camera of the scene using its name
  109819. * @param name defines the camera's name
  109820. * @returns the new active camera or null if none found.
  109821. */
  109822. setActiveCameraByName(name: string): Nullable<Camera>;
  109823. /**
  109824. * get an animation group using its name
  109825. * @param name defines the material's name
  109826. * @return the animation group or null if none found.
  109827. */
  109828. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109829. /**
  109830. * Get a material using its unique id
  109831. * @param uniqueId defines the material's unique id
  109832. * @return the material or null if none found.
  109833. */
  109834. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109835. /**
  109836. * get a material using its id
  109837. * @param id defines the material's ID
  109838. * @return the material or null if none found.
  109839. */
  109840. getMaterialByID(id: string): Nullable<Material>;
  109841. /**
  109842. * Gets a the last added material using a given id
  109843. * @param id defines the material's ID
  109844. * @return the last material with the given id or null if none found.
  109845. */
  109846. getLastMaterialByID(id: string): Nullable<Material>;
  109847. /**
  109848. * Gets a material using its name
  109849. * @param name defines the material's name
  109850. * @return the material or null if none found.
  109851. */
  109852. getMaterialByName(name: string): Nullable<Material>;
  109853. /**
  109854. * Get a texture using its unique id
  109855. * @param uniqueId defines the texture's unique id
  109856. * @return the texture or null if none found.
  109857. */
  109858. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109859. /**
  109860. * Gets a camera using its id
  109861. * @param id defines the id to look for
  109862. * @returns the camera or null if not found
  109863. */
  109864. getCameraByID(id: string): Nullable<Camera>;
  109865. /**
  109866. * Gets a camera using its unique id
  109867. * @param uniqueId defines the unique id to look for
  109868. * @returns the camera or null if not found
  109869. */
  109870. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109871. /**
  109872. * Gets a camera using its name
  109873. * @param name defines the camera's name
  109874. * @return the camera or null if none found.
  109875. */
  109876. getCameraByName(name: string): Nullable<Camera>;
  109877. /**
  109878. * Gets a bone using its id
  109879. * @param id defines the bone's id
  109880. * @return the bone or null if not found
  109881. */
  109882. getBoneByID(id: string): Nullable<Bone>;
  109883. /**
  109884. * Gets a bone using its id
  109885. * @param name defines the bone's name
  109886. * @return the bone or null if not found
  109887. */
  109888. getBoneByName(name: string): Nullable<Bone>;
  109889. /**
  109890. * Gets a light node using its name
  109891. * @param name defines the the light's name
  109892. * @return the light or null if none found.
  109893. */
  109894. getLightByName(name: string): Nullable<Light>;
  109895. /**
  109896. * Gets a light node using its id
  109897. * @param id defines the light's id
  109898. * @return the light or null if none found.
  109899. */
  109900. getLightByID(id: string): Nullable<Light>;
  109901. /**
  109902. * Gets a light node using its scene-generated unique ID
  109903. * @param uniqueId defines the light's unique id
  109904. * @return the light or null if none found.
  109905. */
  109906. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109907. /**
  109908. * Gets a particle system by id
  109909. * @param id defines the particle system id
  109910. * @return the corresponding system or null if none found
  109911. */
  109912. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109913. /**
  109914. * Gets a geometry using its ID
  109915. * @param id defines the geometry's id
  109916. * @return the geometry or null if none found.
  109917. */
  109918. getGeometryByID(id: string): Nullable<Geometry>;
  109919. private _getGeometryByUniqueID;
  109920. /**
  109921. * Add a new geometry to this scene
  109922. * @param geometry defines the geometry to be added to the scene.
  109923. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109924. * @return a boolean defining if the geometry was added or not
  109925. */
  109926. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109927. /**
  109928. * Removes an existing geometry
  109929. * @param geometry defines the geometry to be removed from the scene
  109930. * @return a boolean defining if the geometry was removed or not
  109931. */
  109932. removeGeometry(geometry: Geometry): boolean;
  109933. /**
  109934. * Gets the list of geometries attached to the scene
  109935. * @returns an array of Geometry
  109936. */
  109937. getGeometries(): Geometry[];
  109938. /**
  109939. * Gets the first added mesh found of a given ID
  109940. * @param id defines the id to search for
  109941. * @return the mesh found or null if not found at all
  109942. */
  109943. getMeshByID(id: string): Nullable<AbstractMesh>;
  109944. /**
  109945. * Gets a list of meshes using their id
  109946. * @param id defines the id to search for
  109947. * @returns a list of meshes
  109948. */
  109949. getMeshesByID(id: string): Array<AbstractMesh>;
  109950. /**
  109951. * Gets the first added transform node found of a given ID
  109952. * @param id defines the id to search for
  109953. * @return the found transform node or null if not found at all.
  109954. */
  109955. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109956. /**
  109957. * Gets a transform node with its auto-generated unique id
  109958. * @param uniqueId efines the unique id to search for
  109959. * @return the found transform node or null if not found at all.
  109960. */
  109961. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109962. /**
  109963. * Gets a list of transform nodes using their id
  109964. * @param id defines the id to search for
  109965. * @returns a list of transform nodes
  109966. */
  109967. getTransformNodesByID(id: string): Array<TransformNode>;
  109968. /**
  109969. * Gets a mesh with its auto-generated unique id
  109970. * @param uniqueId defines the unique id to search for
  109971. * @return the found mesh or null if not found at all.
  109972. */
  109973. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109974. /**
  109975. * Gets a the last added mesh using a given id
  109976. * @param id defines the id to search for
  109977. * @return the found mesh or null if not found at all.
  109978. */
  109979. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109980. /**
  109981. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109982. * @param id defines the id to search for
  109983. * @return the found node or null if not found at all
  109984. */
  109985. getLastEntryByID(id: string): Nullable<Node>;
  109986. /**
  109987. * Gets a node (Mesh, Camera, Light) using a given id
  109988. * @param id defines the id to search for
  109989. * @return the found node or null if not found at all
  109990. */
  109991. getNodeByID(id: string): Nullable<Node>;
  109992. /**
  109993. * Gets a node (Mesh, Camera, Light) using a given name
  109994. * @param name defines the name to search for
  109995. * @return the found node or null if not found at all.
  109996. */
  109997. getNodeByName(name: string): Nullable<Node>;
  109998. /**
  109999. * Gets a mesh using a given name
  110000. * @param name defines the name to search for
  110001. * @return the found mesh or null if not found at all.
  110002. */
  110003. getMeshByName(name: string): Nullable<AbstractMesh>;
  110004. /**
  110005. * Gets a transform node using a given name
  110006. * @param name defines the name to search for
  110007. * @return the found transform node or null if not found at all.
  110008. */
  110009. getTransformNodeByName(name: string): Nullable<TransformNode>;
  110010. /**
  110011. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  110012. * @param id defines the id to search for
  110013. * @return the found skeleton or null if not found at all.
  110014. */
  110015. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  110016. /**
  110017. * Gets a skeleton using a given auto generated unique id
  110018. * @param uniqueId defines the unique id to search for
  110019. * @return the found skeleton or null if not found at all.
  110020. */
  110021. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  110022. /**
  110023. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  110024. * @param id defines the id to search for
  110025. * @return the found skeleton or null if not found at all.
  110026. */
  110027. getSkeletonById(id: string): Nullable<Skeleton>;
  110028. /**
  110029. * Gets a skeleton using a given name
  110030. * @param name defines the name to search for
  110031. * @return the found skeleton or null if not found at all.
  110032. */
  110033. getSkeletonByName(name: string): Nullable<Skeleton>;
  110034. /**
  110035. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  110036. * @param id defines the id to search for
  110037. * @return the found morph target manager or null if not found at all.
  110038. */
  110039. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  110040. /**
  110041. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  110042. * @param id defines the id to search for
  110043. * @return the found morph target or null if not found at all.
  110044. */
  110045. getMorphTargetById(id: string): Nullable<MorphTarget>;
  110046. /**
  110047. * Gets a boolean indicating if the given mesh is active
  110048. * @param mesh defines the mesh to look for
  110049. * @returns true if the mesh is in the active list
  110050. */
  110051. isActiveMesh(mesh: AbstractMesh): boolean;
  110052. /**
  110053. * Return a unique id as a string which can serve as an identifier for the scene
  110054. */
  110055. get uid(): string;
  110056. /**
  110057. * Add an externaly attached data from its key.
  110058. * This method call will fail and return false, if such key already exists.
  110059. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  110060. * @param key the unique key that identifies the data
  110061. * @param data the data object to associate to the key for this Engine instance
  110062. * @return true if no such key were already present and the data was added successfully, false otherwise
  110063. */
  110064. addExternalData<T>(key: string, data: T): boolean;
  110065. /**
  110066. * Get an externaly attached data from its key
  110067. * @param key the unique key that identifies the data
  110068. * @return the associated data, if present (can be null), or undefined if not present
  110069. */
  110070. getExternalData<T>(key: string): Nullable<T>;
  110071. /**
  110072. * Get an externaly attached data from its key, create it using a factory if it's not already present
  110073. * @param key the unique key that identifies the data
  110074. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  110075. * @return the associated data, can be null if the factory returned null.
  110076. */
  110077. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  110078. /**
  110079. * Remove an externaly attached data from the Engine instance
  110080. * @param key the unique key that identifies the data
  110081. * @return true if the data was successfully removed, false if it doesn't exist
  110082. */
  110083. removeExternalData(key: string): boolean;
  110084. private _evaluateSubMesh;
  110085. /**
  110086. * Clear the processed materials smart array preventing retention point in material dispose.
  110087. */
  110088. freeProcessedMaterials(): void;
  110089. private _preventFreeActiveMeshesAndRenderingGroups;
  110090. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  110091. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  110092. * when disposing several meshes in a row or a hierarchy of meshes.
  110093. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  110094. */
  110095. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  110096. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  110097. /**
  110098. * Clear the active meshes smart array preventing retention point in mesh dispose.
  110099. */
  110100. freeActiveMeshes(): void;
  110101. /**
  110102. * Clear the info related to rendering groups preventing retention points during dispose.
  110103. */
  110104. freeRenderingGroups(): void;
  110105. /** @hidden */
  110106. _isInIntermediateRendering(): boolean;
  110107. /**
  110108. * Lambda returning the list of potentially active meshes.
  110109. */
  110110. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  110111. /**
  110112. * Lambda returning the list of potentially active sub meshes.
  110113. */
  110114. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110115. /**
  110116. * Lambda returning the list of potentially intersecting sub meshes.
  110117. */
  110118. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110119. /**
  110120. * Lambda returning the list of potentially colliding sub meshes.
  110121. */
  110122. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110123. private _activeMeshesFrozen;
  110124. private _skipEvaluateActiveMeshesCompletely;
  110125. /**
  110126. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110127. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110128. * @returns the current scene
  110129. */
  110130. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110131. /**
  110132. * Use this function to restart evaluating active meshes on every frame
  110133. * @returns the current scene
  110134. */
  110135. unfreezeActiveMeshes(): Scene;
  110136. private _evaluateActiveMeshes;
  110137. private _activeMesh;
  110138. /**
  110139. * Update the transform matrix to update from the current active camera
  110140. * @param force defines a boolean used to force the update even if cache is up to date
  110141. */
  110142. updateTransformMatrix(force?: boolean): void;
  110143. private _bindFrameBuffer;
  110144. /** @hidden */
  110145. _allowPostProcessClearColor: boolean;
  110146. /** @hidden */
  110147. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110148. private _processSubCameras;
  110149. private _checkIntersections;
  110150. /** @hidden */
  110151. _advancePhysicsEngineStep(step: number): void;
  110152. /**
  110153. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110154. */
  110155. getDeterministicFrameTime: () => number;
  110156. /** @hidden */
  110157. _animate(): void;
  110158. /** Execute all animations (for a frame) */
  110159. animate(): void;
  110160. /**
  110161. * Render the scene
  110162. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110163. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110164. */
  110165. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110166. /**
  110167. * Freeze all materials
  110168. * A frozen material will not be updatable but should be faster to render
  110169. */
  110170. freezeMaterials(): void;
  110171. /**
  110172. * Unfreeze all materials
  110173. * A frozen material will not be updatable but should be faster to render
  110174. */
  110175. unfreezeMaterials(): void;
  110176. /**
  110177. * Releases all held ressources
  110178. */
  110179. dispose(): void;
  110180. /**
  110181. * Gets if the scene is already disposed
  110182. */
  110183. get isDisposed(): boolean;
  110184. /**
  110185. * Call this function to reduce memory footprint of the scene.
  110186. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110187. */
  110188. clearCachedVertexData(): void;
  110189. /**
  110190. * This function will remove the local cached buffer data from texture.
  110191. * It will save memory but will prevent the texture from being rebuilt
  110192. */
  110193. cleanCachedTextureBuffer(): void;
  110194. /**
  110195. * Get the world extend vectors with an optional filter
  110196. *
  110197. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110198. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110199. */
  110200. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110201. min: Vector3;
  110202. max: Vector3;
  110203. };
  110204. /**
  110205. * Creates a ray that can be used to pick in the scene
  110206. * @param x defines the x coordinate of the origin (on-screen)
  110207. * @param y defines the y coordinate of the origin (on-screen)
  110208. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110209. * @param camera defines the camera to use for the picking
  110210. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110211. * @returns a Ray
  110212. */
  110213. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110214. /**
  110215. * Creates a ray that can be used to pick in the scene
  110216. * @param x defines the x coordinate of the origin (on-screen)
  110217. * @param y defines the y coordinate of the origin (on-screen)
  110218. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110219. * @param result defines the ray where to store the picking ray
  110220. * @param camera defines the camera to use for the picking
  110221. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110222. * @returns the current scene
  110223. */
  110224. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110225. /**
  110226. * Creates a ray that can be used to pick in the scene
  110227. * @param x defines the x coordinate of the origin (on-screen)
  110228. * @param y defines the y coordinate of the origin (on-screen)
  110229. * @param camera defines the camera to use for the picking
  110230. * @returns a Ray
  110231. */
  110232. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110233. /**
  110234. * Creates a ray that can be used to pick in the scene
  110235. * @param x defines the x coordinate of the origin (on-screen)
  110236. * @param y defines the y coordinate of the origin (on-screen)
  110237. * @param result defines the ray where to store the picking ray
  110238. * @param camera defines the camera to use for the picking
  110239. * @returns the current scene
  110240. */
  110241. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110242. /** Launch a ray to try to pick a mesh in the scene
  110243. * @param x position on screen
  110244. * @param y position on screen
  110245. * @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
  110246. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110247. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110248. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110249. * @returns a PickingInfo
  110250. */
  110251. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110252. /** Use the given ray to pick a mesh in the scene
  110253. * @param ray The ray to use to pick meshes
  110254. * @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
  110255. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110257. * @returns a PickingInfo
  110258. */
  110259. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110260. /**
  110261. * Launch a ray to try to pick a mesh in the scene
  110262. * @param x X position on screen
  110263. * @param y Y position on screen
  110264. * @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
  110265. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110266. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110267. * @returns an array of PickingInfo
  110268. */
  110269. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110270. /**
  110271. * Launch a ray to try to pick a mesh in the scene
  110272. * @param ray Ray to use
  110273. * @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
  110274. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110275. * @returns an array of PickingInfo
  110276. */
  110277. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110278. /**
  110279. * Force the value of meshUnderPointer
  110280. * @param mesh defines the mesh to use
  110281. */
  110282. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110283. /**
  110284. * Gets the mesh under the pointer
  110285. * @returns a Mesh or null if no mesh is under the pointer
  110286. */
  110287. getPointerOverMesh(): Nullable<AbstractMesh>;
  110288. /** @hidden */
  110289. _rebuildGeometries(): void;
  110290. /** @hidden */
  110291. _rebuildTextures(): void;
  110292. private _getByTags;
  110293. /**
  110294. * Get a list of meshes by tags
  110295. * @param tagsQuery defines the tags query to use
  110296. * @param forEach defines a predicate used to filter results
  110297. * @returns an array of Mesh
  110298. */
  110299. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110300. /**
  110301. * Get a list of cameras by tags
  110302. * @param tagsQuery defines the tags query to use
  110303. * @param forEach defines a predicate used to filter results
  110304. * @returns an array of Camera
  110305. */
  110306. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110307. /**
  110308. * Get a list of lights by tags
  110309. * @param tagsQuery defines the tags query to use
  110310. * @param forEach defines a predicate used to filter results
  110311. * @returns an array of Light
  110312. */
  110313. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110314. /**
  110315. * Get a list of materials by tags
  110316. * @param tagsQuery defines the tags query to use
  110317. * @param forEach defines a predicate used to filter results
  110318. * @returns an array of Material
  110319. */
  110320. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110321. /**
  110322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110323. * This allowed control for front to back rendering or reversly depending of the special needs.
  110324. *
  110325. * @param renderingGroupId The rendering group id corresponding to its index
  110326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110329. */
  110330. 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;
  110331. /**
  110332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110333. *
  110334. * @param renderingGroupId The rendering group id corresponding to its index
  110335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110336. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110337. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110338. */
  110339. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110340. /**
  110341. * Gets the current auto clear configuration for one rendering group of the rendering
  110342. * manager.
  110343. * @param index the rendering group index to get the information for
  110344. * @returns The auto clear setup for the requested rendering group
  110345. */
  110346. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110347. private _blockMaterialDirtyMechanism;
  110348. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110349. get blockMaterialDirtyMechanism(): boolean;
  110350. set blockMaterialDirtyMechanism(value: boolean);
  110351. /**
  110352. * Will flag all materials as dirty to trigger new shader compilation
  110353. * @param flag defines the flag used to specify which material part must be marked as dirty
  110354. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110355. */
  110356. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110357. /** @hidden */
  110358. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  110359. /** @hidden */
  110360. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110361. /** @hidden */
  110362. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  110363. /** @hidden */
  110364. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110365. /** @hidden */
  110366. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110367. /** @hidden */
  110368. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110369. }
  110370. }
  110371. declare module BABYLON {
  110372. /**
  110373. * Set of assets to keep when moving a scene into an asset container.
  110374. */
  110375. export class KeepAssets extends AbstractScene {
  110376. }
  110377. /**
  110378. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110379. */
  110380. export class InstantiatedEntries {
  110381. /**
  110382. * List of new root nodes (eg. nodes with no parent)
  110383. */
  110384. rootNodes: TransformNode[];
  110385. /**
  110386. * List of new skeletons
  110387. */
  110388. skeletons: Skeleton[];
  110389. /**
  110390. * List of new animation groups
  110391. */
  110392. animationGroups: AnimationGroup[];
  110393. }
  110394. /**
  110395. * Container with a set of assets that can be added or removed from a scene.
  110396. */
  110397. export class AssetContainer extends AbstractScene {
  110398. private _wasAddedToScene;
  110399. /**
  110400. * The scene the AssetContainer belongs to.
  110401. */
  110402. scene: Scene;
  110403. /**
  110404. * Instantiates an AssetContainer.
  110405. * @param scene The scene the AssetContainer belongs to.
  110406. */
  110407. constructor(scene: Scene);
  110408. /**
  110409. * Instantiate or clone all meshes and add the new ones to the scene.
  110410. * Skeletons and animation groups will all be cloned
  110411. * @param nameFunction defines an optional function used to get new names for clones
  110412. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110413. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110414. */
  110415. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110416. /**
  110417. * Adds all the assets from the container to the scene.
  110418. */
  110419. addAllToScene(): void;
  110420. /**
  110421. * Removes all the assets in the container from the scene
  110422. */
  110423. removeAllFromScene(): void;
  110424. /**
  110425. * Disposes all the assets in the container
  110426. */
  110427. dispose(): void;
  110428. private _moveAssets;
  110429. /**
  110430. * Removes all the assets contained in the scene and adds them to the container.
  110431. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110432. */
  110433. moveAllFromScene(keepAssets?: KeepAssets): void;
  110434. /**
  110435. * 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.
  110436. * @returns the root mesh
  110437. */
  110438. createRootMesh(): Mesh;
  110439. /**
  110440. * Merge animations from this asset container into a scene
  110441. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110442. * @param animatables set of animatables to retarget to a node from the scene
  110443. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110444. */
  110445. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110446. }
  110447. }
  110448. declare module BABYLON {
  110449. /**
  110450. * Defines how the parser contract is defined.
  110451. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110452. */
  110453. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110454. /**
  110455. * Defines how the individual parser contract is defined.
  110456. * These parser can parse an individual asset
  110457. */
  110458. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110459. /**
  110460. * Base class of the scene acting as a container for the different elements composing a scene.
  110461. * This class is dynamically extended by the different components of the scene increasing
  110462. * flexibility and reducing coupling
  110463. */
  110464. export abstract class AbstractScene {
  110465. /**
  110466. * Stores the list of available parsers in the application.
  110467. */
  110468. private static _BabylonFileParsers;
  110469. /**
  110470. * Stores the list of available individual parsers in the application.
  110471. */
  110472. private static _IndividualBabylonFileParsers;
  110473. /**
  110474. * Adds a parser in the list of available ones
  110475. * @param name Defines the name of the parser
  110476. * @param parser Defines the parser to add
  110477. */
  110478. static AddParser(name: string, parser: BabylonFileParser): void;
  110479. /**
  110480. * Gets a general parser from the list of avaialble ones
  110481. * @param name Defines the name of the parser
  110482. * @returns the requested parser or null
  110483. */
  110484. static GetParser(name: string): Nullable<BabylonFileParser>;
  110485. /**
  110486. * Adds n individual parser in the list of available ones
  110487. * @param name Defines the name of the parser
  110488. * @param parser Defines the parser to add
  110489. */
  110490. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110491. /**
  110492. * Gets an individual parser from the list of avaialble ones
  110493. * @param name Defines the name of the parser
  110494. * @returns the requested parser or null
  110495. */
  110496. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110497. /**
  110498. * Parser json data and populate both a scene and its associated container object
  110499. * @param jsonData Defines the data to parse
  110500. * @param scene Defines the scene to parse the data for
  110501. * @param container Defines the container attached to the parsing sequence
  110502. * @param rootUrl Defines the root url of the data
  110503. */
  110504. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110505. /**
  110506. * Gets the list of root nodes (ie. nodes with no parent)
  110507. */
  110508. rootNodes: Node[];
  110509. /** All of the cameras added to this scene
  110510. * @see http://doc.babylonjs.com/babylon101/cameras
  110511. */
  110512. cameras: Camera[];
  110513. /**
  110514. * All of the lights added to this scene
  110515. * @see http://doc.babylonjs.com/babylon101/lights
  110516. */
  110517. lights: Light[];
  110518. /**
  110519. * All of the (abstract) meshes added to this scene
  110520. */
  110521. meshes: AbstractMesh[];
  110522. /**
  110523. * The list of skeletons added to the scene
  110524. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110525. */
  110526. skeletons: Skeleton[];
  110527. /**
  110528. * All of the particle systems added to this scene
  110529. * @see http://doc.babylonjs.com/babylon101/particles
  110530. */
  110531. particleSystems: IParticleSystem[];
  110532. /**
  110533. * Gets a list of Animations associated with the scene
  110534. */
  110535. animations: Animation[];
  110536. /**
  110537. * All of the animation groups added to this scene
  110538. * @see http://doc.babylonjs.com/how_to/group
  110539. */
  110540. animationGroups: AnimationGroup[];
  110541. /**
  110542. * All of the multi-materials added to this scene
  110543. * @see http://doc.babylonjs.com/how_to/multi_materials
  110544. */
  110545. multiMaterials: MultiMaterial[];
  110546. /**
  110547. * All of the materials added to this scene
  110548. * In the context of a Scene, it is not supposed to be modified manually.
  110549. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110550. * Note also that the order of the Material within the array is not significant and might change.
  110551. * @see http://doc.babylonjs.com/babylon101/materials
  110552. */
  110553. materials: Material[];
  110554. /**
  110555. * The list of morph target managers added to the scene
  110556. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110557. */
  110558. morphTargetManagers: MorphTargetManager[];
  110559. /**
  110560. * The list of geometries used in the scene.
  110561. */
  110562. geometries: Geometry[];
  110563. /**
  110564. * All of the tranform nodes added to this scene
  110565. * In the context of a Scene, it is not supposed to be modified manually.
  110566. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110567. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110568. * @see http://doc.babylonjs.com/how_to/transformnode
  110569. */
  110570. transformNodes: TransformNode[];
  110571. /**
  110572. * ActionManagers available on the scene.
  110573. */
  110574. actionManagers: AbstractActionManager[];
  110575. /**
  110576. * Textures to keep.
  110577. */
  110578. textures: BaseTexture[];
  110579. /**
  110580. * Environment texture for the scene
  110581. */
  110582. environmentTexture: Nullable<BaseTexture>;
  110583. /**
  110584. * @returns all meshes, lights, cameras, transformNodes and bones
  110585. */
  110586. getNodes(): Array<Node>;
  110587. }
  110588. }
  110589. declare module BABYLON {
  110590. /**
  110591. * Interface used to define options for Sound class
  110592. */
  110593. export interface ISoundOptions {
  110594. /**
  110595. * Does the sound autoplay once loaded.
  110596. */
  110597. autoplay?: boolean;
  110598. /**
  110599. * Does the sound loop after it finishes playing once.
  110600. */
  110601. loop?: boolean;
  110602. /**
  110603. * Sound's volume
  110604. */
  110605. volume?: number;
  110606. /**
  110607. * Is it a spatial sound?
  110608. */
  110609. spatialSound?: boolean;
  110610. /**
  110611. * Maximum distance to hear that sound
  110612. */
  110613. maxDistance?: number;
  110614. /**
  110615. * Uses user defined attenuation function
  110616. */
  110617. useCustomAttenuation?: boolean;
  110618. /**
  110619. * Define the roll off factor of spatial sounds.
  110620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110621. */
  110622. rolloffFactor?: number;
  110623. /**
  110624. * Define the reference distance the sound should be heard perfectly.
  110625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110626. */
  110627. refDistance?: number;
  110628. /**
  110629. * Define the distance attenuation model the sound will follow.
  110630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110631. */
  110632. distanceModel?: string;
  110633. /**
  110634. * Defines the playback speed (1 by default)
  110635. */
  110636. playbackRate?: number;
  110637. /**
  110638. * Defines if the sound is from a streaming source
  110639. */
  110640. streaming?: boolean;
  110641. /**
  110642. * Defines an optional length (in seconds) inside the sound file
  110643. */
  110644. length?: number;
  110645. /**
  110646. * Defines an optional offset (in seconds) inside the sound file
  110647. */
  110648. offset?: number;
  110649. /**
  110650. * If true, URLs will not be required to state the audio file codec to use.
  110651. */
  110652. skipCodecCheck?: boolean;
  110653. }
  110654. /**
  110655. * Defines a sound that can be played in the application.
  110656. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110658. */
  110659. export class Sound {
  110660. /**
  110661. * The name of the sound in the scene.
  110662. */
  110663. name: string;
  110664. /**
  110665. * Does the sound autoplay once loaded.
  110666. */
  110667. autoplay: boolean;
  110668. /**
  110669. * Does the sound loop after it finishes playing once.
  110670. */
  110671. loop: boolean;
  110672. /**
  110673. * Does the sound use a custom attenuation curve to simulate the falloff
  110674. * happening when the source gets further away from the camera.
  110675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110676. */
  110677. useCustomAttenuation: boolean;
  110678. /**
  110679. * The sound track id this sound belongs to.
  110680. */
  110681. soundTrackId: number;
  110682. /**
  110683. * Is this sound currently played.
  110684. */
  110685. isPlaying: boolean;
  110686. /**
  110687. * Is this sound currently paused.
  110688. */
  110689. isPaused: boolean;
  110690. /**
  110691. * Does this sound enables spatial sound.
  110692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110693. */
  110694. spatialSound: boolean;
  110695. /**
  110696. * Define the reference distance the sound should be heard perfectly.
  110697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110698. */
  110699. refDistance: number;
  110700. /**
  110701. * Define the roll off factor of spatial sounds.
  110702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110703. */
  110704. rolloffFactor: number;
  110705. /**
  110706. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110708. */
  110709. maxDistance: number;
  110710. /**
  110711. * Define the distance attenuation model the sound will follow.
  110712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110713. */
  110714. distanceModel: string;
  110715. /**
  110716. * @hidden
  110717. * Back Compat
  110718. **/
  110719. onended: () => any;
  110720. /**
  110721. * Observable event when the current playing sound finishes.
  110722. */
  110723. onEndedObservable: Observable<Sound>;
  110724. private _panningModel;
  110725. private _playbackRate;
  110726. private _streaming;
  110727. private _startTime;
  110728. private _startOffset;
  110729. private _position;
  110730. /** @hidden */
  110731. _positionInEmitterSpace: boolean;
  110732. private _localDirection;
  110733. private _volume;
  110734. private _isReadyToPlay;
  110735. private _isDirectional;
  110736. private _readyToPlayCallback;
  110737. private _audioBuffer;
  110738. private _soundSource;
  110739. private _streamingSource;
  110740. private _soundPanner;
  110741. private _soundGain;
  110742. private _inputAudioNode;
  110743. private _outputAudioNode;
  110744. private _coneInnerAngle;
  110745. private _coneOuterAngle;
  110746. private _coneOuterGain;
  110747. private _scene;
  110748. private _connectedTransformNode;
  110749. private _customAttenuationFunction;
  110750. private _registerFunc;
  110751. private _isOutputConnected;
  110752. private _htmlAudioElement;
  110753. private _urlType;
  110754. private _length?;
  110755. private _offset?;
  110756. /** @hidden */
  110757. static _SceneComponentInitialization: (scene: Scene) => void;
  110758. /**
  110759. * Create a sound and attach it to a scene
  110760. * @param name Name of your sound
  110761. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110762. * @param scene defines the scene the sound belongs to
  110763. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110764. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110765. */
  110766. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110767. /**
  110768. * Release the sound and its associated resources
  110769. */
  110770. dispose(): void;
  110771. /**
  110772. * Gets if the sounds is ready to be played or not.
  110773. * @returns true if ready, otherwise false
  110774. */
  110775. isReady(): boolean;
  110776. private _soundLoaded;
  110777. /**
  110778. * Sets the data of the sound from an audiobuffer
  110779. * @param audioBuffer The audioBuffer containing the data
  110780. */
  110781. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110782. /**
  110783. * Updates the current sounds options such as maxdistance, loop...
  110784. * @param options A JSON object containing values named as the object properties
  110785. */
  110786. updateOptions(options: ISoundOptions): void;
  110787. private _createSpatialParameters;
  110788. private _updateSpatialParameters;
  110789. /**
  110790. * Switch the panning model to HRTF:
  110791. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110793. */
  110794. switchPanningModelToHRTF(): void;
  110795. /**
  110796. * Switch the panning model to Equal Power:
  110797. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110799. */
  110800. switchPanningModelToEqualPower(): void;
  110801. private _switchPanningModel;
  110802. /**
  110803. * Connect this sound to a sound track audio node like gain...
  110804. * @param soundTrackAudioNode the sound track audio node to connect to
  110805. */
  110806. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110807. /**
  110808. * Transform this sound into a directional source
  110809. * @param coneInnerAngle Size of the inner cone in degree
  110810. * @param coneOuterAngle Size of the outer cone in degree
  110811. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110812. */
  110813. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110814. /**
  110815. * Gets or sets the inner angle for the directional cone.
  110816. */
  110817. get directionalConeInnerAngle(): number;
  110818. /**
  110819. * Gets or sets the inner angle for the directional cone.
  110820. */
  110821. set directionalConeInnerAngle(value: number);
  110822. /**
  110823. * Gets or sets the outer angle for the directional cone.
  110824. */
  110825. get directionalConeOuterAngle(): number;
  110826. /**
  110827. * Gets or sets the outer angle for the directional cone.
  110828. */
  110829. set directionalConeOuterAngle(value: number);
  110830. /**
  110831. * Sets the position of the emitter if spatial sound is enabled
  110832. * @param newPosition Defines the new posisiton
  110833. */
  110834. setPosition(newPosition: Vector3): void;
  110835. /**
  110836. * Sets the local direction of the emitter if spatial sound is enabled
  110837. * @param newLocalDirection Defines the new local direction
  110838. */
  110839. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110840. private _updateDirection;
  110841. /** @hidden */
  110842. updateDistanceFromListener(): void;
  110843. /**
  110844. * Sets a new custom attenuation function for the sound.
  110845. * @param callback Defines the function used for the attenuation
  110846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110847. */
  110848. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110849. /**
  110850. * Play the sound
  110851. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110852. * @param offset (optional) Start the sound at a specific time in seconds
  110853. * @param length (optional) Sound duration (in seconds)
  110854. */
  110855. play(time?: number, offset?: number, length?: number): void;
  110856. private _onended;
  110857. /**
  110858. * Stop the sound
  110859. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110860. */
  110861. stop(time?: number): void;
  110862. /**
  110863. * Put the sound in pause
  110864. */
  110865. pause(): void;
  110866. /**
  110867. * Sets a dedicated volume for this sounds
  110868. * @param newVolume Define the new volume of the sound
  110869. * @param time Define time for gradual change to new volume
  110870. */
  110871. setVolume(newVolume: number, time?: number): void;
  110872. /**
  110873. * Set the sound play back rate
  110874. * @param newPlaybackRate Define the playback rate the sound should be played at
  110875. */
  110876. setPlaybackRate(newPlaybackRate: number): void;
  110877. /**
  110878. * Gets the volume of the sound.
  110879. * @returns the volume of the sound
  110880. */
  110881. getVolume(): number;
  110882. /**
  110883. * Attach the sound to a dedicated mesh
  110884. * @param transformNode The transform node to connect the sound with
  110885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110886. */
  110887. attachToMesh(transformNode: TransformNode): void;
  110888. /**
  110889. * Detach the sound from the previously attached mesh
  110890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110891. */
  110892. detachFromMesh(): void;
  110893. private _onRegisterAfterWorldMatrixUpdate;
  110894. /**
  110895. * Clone the current sound in the scene.
  110896. * @returns the new sound clone
  110897. */
  110898. clone(): Nullable<Sound>;
  110899. /**
  110900. * Gets the current underlying audio buffer containing the data
  110901. * @returns the audio buffer
  110902. */
  110903. getAudioBuffer(): Nullable<AudioBuffer>;
  110904. /**
  110905. * Serializes the Sound in a JSON representation
  110906. * @returns the JSON representation of the sound
  110907. */
  110908. serialize(): any;
  110909. /**
  110910. * Parse a JSON representation of a sound to innstantiate in a given scene
  110911. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110912. * @param scene Define the scene the new parsed sound should be created in
  110913. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110914. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110915. * @returns the newly parsed sound
  110916. */
  110917. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110918. }
  110919. }
  110920. declare module BABYLON {
  110921. /**
  110922. * This defines an action helpful to play a defined sound on a triggered action.
  110923. */
  110924. export class PlaySoundAction extends Action {
  110925. private _sound;
  110926. /**
  110927. * Instantiate the action
  110928. * @param triggerOptions defines the trigger options
  110929. * @param sound defines the sound to play
  110930. * @param condition defines the trigger related conditions
  110931. */
  110932. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110933. /** @hidden */
  110934. _prepare(): void;
  110935. /**
  110936. * Execute the action and play the sound.
  110937. */
  110938. execute(): void;
  110939. /**
  110940. * Serializes the actions and its related information.
  110941. * @param parent defines the object to serialize in
  110942. * @returns the serialized object
  110943. */
  110944. serialize(parent: any): any;
  110945. }
  110946. /**
  110947. * This defines an action helpful to stop a defined sound on a triggered action.
  110948. */
  110949. export class StopSoundAction extends Action {
  110950. private _sound;
  110951. /**
  110952. * Instantiate the action
  110953. * @param triggerOptions defines the trigger options
  110954. * @param sound defines the sound to stop
  110955. * @param condition defines the trigger related conditions
  110956. */
  110957. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110958. /** @hidden */
  110959. _prepare(): void;
  110960. /**
  110961. * Execute the action and stop the sound.
  110962. */
  110963. execute(): void;
  110964. /**
  110965. * Serializes the actions and its related information.
  110966. * @param parent defines the object to serialize in
  110967. * @returns the serialized object
  110968. */
  110969. serialize(parent: any): any;
  110970. }
  110971. }
  110972. declare module BABYLON {
  110973. /**
  110974. * This defines an action responsible to change the value of a property
  110975. * by interpolating between its current value and the newly set one once triggered.
  110976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110977. */
  110978. export class InterpolateValueAction extends Action {
  110979. /**
  110980. * Defines the path of the property where the value should be interpolated
  110981. */
  110982. propertyPath: string;
  110983. /**
  110984. * Defines the target value at the end of the interpolation.
  110985. */
  110986. value: any;
  110987. /**
  110988. * Defines the time it will take for the property to interpolate to the value.
  110989. */
  110990. duration: number;
  110991. /**
  110992. * Defines if the other scene animations should be stopped when the action has been triggered
  110993. */
  110994. stopOtherAnimations?: boolean;
  110995. /**
  110996. * Defines a callback raised once the interpolation animation has been done.
  110997. */
  110998. onInterpolationDone?: () => void;
  110999. /**
  111000. * Observable triggered once the interpolation animation has been done.
  111001. */
  111002. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  111003. private _target;
  111004. private _effectiveTarget;
  111005. private _property;
  111006. /**
  111007. * Instantiate the action
  111008. * @param triggerOptions defines the trigger options
  111009. * @param target defines the object containing the value to interpolate
  111010. * @param propertyPath defines the path to the property in the target object
  111011. * @param value defines the target value at the end of the interpolation
  111012. * @param duration deines the time it will take for the property to interpolate to the value.
  111013. * @param condition defines the trigger related conditions
  111014. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  111015. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  111016. */
  111017. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  111018. /** @hidden */
  111019. _prepare(): void;
  111020. /**
  111021. * Execute the action starts the value interpolation.
  111022. */
  111023. execute(): void;
  111024. /**
  111025. * Serializes the actions and its related information.
  111026. * @param parent defines the object to serialize in
  111027. * @returns the serialized object
  111028. */
  111029. serialize(parent: any): any;
  111030. }
  111031. }
  111032. declare module BABYLON {
  111033. /**
  111034. * Options allowed during the creation of a sound track.
  111035. */
  111036. export interface ISoundTrackOptions {
  111037. /**
  111038. * The volume the sound track should take during creation
  111039. */
  111040. volume?: number;
  111041. /**
  111042. * Define if the sound track is the main sound track of the scene
  111043. */
  111044. mainTrack?: boolean;
  111045. }
  111046. /**
  111047. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  111048. * It will be also used in a future release to apply effects on a specific track.
  111049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111050. */
  111051. export class SoundTrack {
  111052. /**
  111053. * The unique identifier of the sound track in the scene.
  111054. */
  111055. id: number;
  111056. /**
  111057. * The list of sounds included in the sound track.
  111058. */
  111059. soundCollection: Array<Sound>;
  111060. private _outputAudioNode;
  111061. private _scene;
  111062. private _connectedAnalyser;
  111063. private _options;
  111064. private _isInitialized;
  111065. /**
  111066. * Creates a new sound track.
  111067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  111068. * @param scene Define the scene the sound track belongs to
  111069. * @param options
  111070. */
  111071. constructor(scene: Scene, options?: ISoundTrackOptions);
  111072. private _initializeSoundTrackAudioGraph;
  111073. /**
  111074. * Release the sound track and its associated resources
  111075. */
  111076. dispose(): void;
  111077. /**
  111078. * Adds a sound to this sound track
  111079. * @param sound define the cound to add
  111080. * @ignoreNaming
  111081. */
  111082. AddSound(sound: Sound): void;
  111083. /**
  111084. * Removes a sound to this sound track
  111085. * @param sound define the cound to remove
  111086. * @ignoreNaming
  111087. */
  111088. RemoveSound(sound: Sound): void;
  111089. /**
  111090. * Set a global volume for the full sound track.
  111091. * @param newVolume Define the new volume of the sound track
  111092. */
  111093. setVolume(newVolume: number): void;
  111094. /**
  111095. * Switch the panning model to HRTF:
  111096. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111098. */
  111099. switchPanningModelToHRTF(): void;
  111100. /**
  111101. * Switch the panning model to Equal Power:
  111102. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111104. */
  111105. switchPanningModelToEqualPower(): void;
  111106. /**
  111107. * Connect the sound track to an audio analyser allowing some amazing
  111108. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  111109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  111110. * @param analyser The analyser to connect to the engine
  111111. */
  111112. connectToAnalyser(analyser: Analyser): void;
  111113. }
  111114. }
  111115. declare module BABYLON {
  111116. interface AbstractScene {
  111117. /**
  111118. * The list of sounds used in the scene.
  111119. */
  111120. sounds: Nullable<Array<Sound>>;
  111121. }
  111122. interface Scene {
  111123. /**
  111124. * @hidden
  111125. * Backing field
  111126. */
  111127. _mainSoundTrack: SoundTrack;
  111128. /**
  111129. * The main sound track played by the scene.
  111130. * It cotains your primary collection of sounds.
  111131. */
  111132. mainSoundTrack: SoundTrack;
  111133. /**
  111134. * The list of sound tracks added to the scene
  111135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111136. */
  111137. soundTracks: Nullable<Array<SoundTrack>>;
  111138. /**
  111139. * Gets a sound using a given name
  111140. * @param name defines the name to search for
  111141. * @return the found sound or null if not found at all.
  111142. */
  111143. getSoundByName(name: string): Nullable<Sound>;
  111144. /**
  111145. * Gets or sets if audio support is enabled
  111146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111147. */
  111148. audioEnabled: boolean;
  111149. /**
  111150. * Gets or sets if audio will be output to headphones
  111151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111152. */
  111153. headphone: boolean;
  111154. /**
  111155. * Gets or sets custom audio listener position provider
  111156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111157. */
  111158. audioListenerPositionProvider: Nullable<() => Vector3>;
  111159. /**
  111160. * Gets or sets a refresh rate when using 3D audio positioning
  111161. */
  111162. audioPositioningRefreshRate: number;
  111163. }
  111164. /**
  111165. * Defines the sound scene component responsible to manage any sounds
  111166. * in a given scene.
  111167. */
  111168. export class AudioSceneComponent implements ISceneSerializableComponent {
  111169. /**
  111170. * The component name helpfull to identify the component in the list of scene components.
  111171. */
  111172. readonly name: string;
  111173. /**
  111174. * The scene the component belongs to.
  111175. */
  111176. scene: Scene;
  111177. private _audioEnabled;
  111178. /**
  111179. * Gets whether audio is enabled or not.
  111180. * Please use related enable/disable method to switch state.
  111181. */
  111182. get audioEnabled(): boolean;
  111183. private _headphone;
  111184. /**
  111185. * Gets whether audio is outputing to headphone or not.
  111186. * Please use the according Switch methods to change output.
  111187. */
  111188. get headphone(): boolean;
  111189. /**
  111190. * Gets or sets a refresh rate when using 3D audio positioning
  111191. */
  111192. audioPositioningRefreshRate: number;
  111193. private _audioListenerPositionProvider;
  111194. /**
  111195. * Gets the current audio listener position provider
  111196. */
  111197. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111198. /**
  111199. * Sets a custom listener position for all sounds in the scene
  111200. * By default, this is the position of the first active camera
  111201. */
  111202. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111203. /**
  111204. * Creates a new instance of the component for the given scene
  111205. * @param scene Defines the scene to register the component in
  111206. */
  111207. constructor(scene: Scene);
  111208. /**
  111209. * Registers the component in a given scene
  111210. */
  111211. register(): void;
  111212. /**
  111213. * Rebuilds the elements related to this component in case of
  111214. * context lost for instance.
  111215. */
  111216. rebuild(): void;
  111217. /**
  111218. * Serializes the component data to the specified json object
  111219. * @param serializationObject The object to serialize to
  111220. */
  111221. serialize(serializationObject: any): void;
  111222. /**
  111223. * Adds all the elements from the container to the scene
  111224. * @param container the container holding the elements
  111225. */
  111226. addFromContainer(container: AbstractScene): void;
  111227. /**
  111228. * Removes all the elements in the container from the scene
  111229. * @param container contains the elements to remove
  111230. * @param dispose if the removed element should be disposed (default: false)
  111231. */
  111232. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111233. /**
  111234. * Disposes the component and the associated ressources.
  111235. */
  111236. dispose(): void;
  111237. /**
  111238. * Disables audio in the associated scene.
  111239. */
  111240. disableAudio(): void;
  111241. /**
  111242. * Enables audio in the associated scene.
  111243. */
  111244. enableAudio(): void;
  111245. /**
  111246. * Switch audio to headphone output.
  111247. */
  111248. switchAudioModeForHeadphones(): void;
  111249. /**
  111250. * Switch audio to normal speakers.
  111251. */
  111252. switchAudioModeForNormalSpeakers(): void;
  111253. private _cachedCameraDirection;
  111254. private _cachedCameraPosition;
  111255. private _lastCheck;
  111256. private _afterRender;
  111257. }
  111258. }
  111259. declare module BABYLON {
  111260. /**
  111261. * Wraps one or more Sound objects and selects one with random weight for playback.
  111262. */
  111263. export class WeightedSound {
  111264. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111265. loop: boolean;
  111266. private _coneInnerAngle;
  111267. private _coneOuterAngle;
  111268. private _volume;
  111269. /** A Sound is currently playing. */
  111270. isPlaying: boolean;
  111271. /** A Sound is currently paused. */
  111272. isPaused: boolean;
  111273. private _sounds;
  111274. private _weights;
  111275. private _currentIndex?;
  111276. /**
  111277. * Creates a new WeightedSound from the list of sounds given.
  111278. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111279. * @param sounds Array of Sounds that will be selected from.
  111280. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111281. */
  111282. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111283. /**
  111284. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111285. */
  111286. get directionalConeInnerAngle(): number;
  111287. /**
  111288. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111289. */
  111290. set directionalConeInnerAngle(value: number);
  111291. /**
  111292. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111293. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111294. */
  111295. get directionalConeOuterAngle(): number;
  111296. /**
  111297. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111298. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111299. */
  111300. set directionalConeOuterAngle(value: number);
  111301. /**
  111302. * Playback volume.
  111303. */
  111304. get volume(): number;
  111305. /**
  111306. * Playback volume.
  111307. */
  111308. set volume(value: number);
  111309. private _onended;
  111310. /**
  111311. * Suspend playback
  111312. */
  111313. pause(): void;
  111314. /**
  111315. * Stop playback
  111316. */
  111317. stop(): void;
  111318. /**
  111319. * Start playback.
  111320. * @param startOffset Position the clip head at a specific time in seconds.
  111321. */
  111322. play(startOffset?: number): void;
  111323. }
  111324. }
  111325. declare module BABYLON {
  111326. /**
  111327. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111329. */
  111330. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111331. /**
  111332. * Gets the name of the behavior.
  111333. */
  111334. get name(): string;
  111335. /**
  111336. * The easing function used by animations
  111337. */
  111338. static EasingFunction: BackEase;
  111339. /**
  111340. * The easing mode used by animations
  111341. */
  111342. static EasingMode: number;
  111343. /**
  111344. * The duration of the animation, in milliseconds
  111345. */
  111346. transitionDuration: number;
  111347. /**
  111348. * Length of the distance animated by the transition when lower radius is reached
  111349. */
  111350. lowerRadiusTransitionRange: number;
  111351. /**
  111352. * Length of the distance animated by the transition when upper radius is reached
  111353. */
  111354. upperRadiusTransitionRange: number;
  111355. private _autoTransitionRange;
  111356. /**
  111357. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111358. */
  111359. get autoTransitionRange(): boolean;
  111360. /**
  111361. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111362. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111363. */
  111364. set autoTransitionRange(value: boolean);
  111365. private _attachedCamera;
  111366. private _onAfterCheckInputsObserver;
  111367. private _onMeshTargetChangedObserver;
  111368. /**
  111369. * Initializes the behavior.
  111370. */
  111371. init(): void;
  111372. /**
  111373. * Attaches the behavior to its arc rotate camera.
  111374. * @param camera Defines the camera to attach the behavior to
  111375. */
  111376. attach(camera: ArcRotateCamera): void;
  111377. /**
  111378. * Detaches the behavior from its current arc rotate camera.
  111379. */
  111380. detach(): void;
  111381. private _radiusIsAnimating;
  111382. private _radiusBounceTransition;
  111383. private _animatables;
  111384. private _cachedWheelPrecision;
  111385. /**
  111386. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111387. * @param radiusLimit The limit to check against.
  111388. * @return Bool to indicate if at limit.
  111389. */
  111390. private _isRadiusAtLimit;
  111391. /**
  111392. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111393. * @param radiusDelta The delta by which to animate to. Can be negative.
  111394. */
  111395. private _applyBoundRadiusAnimation;
  111396. /**
  111397. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111398. */
  111399. protected _clearAnimationLocks(): void;
  111400. /**
  111401. * Stops and removes all animations that have been applied to the camera
  111402. */
  111403. stopAllAnimations(): void;
  111404. }
  111405. }
  111406. declare module BABYLON {
  111407. /**
  111408. * 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.
  111409. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111410. */
  111411. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111412. /**
  111413. * Gets the name of the behavior.
  111414. */
  111415. get name(): string;
  111416. private _mode;
  111417. private _radiusScale;
  111418. private _positionScale;
  111419. private _defaultElevation;
  111420. private _elevationReturnTime;
  111421. private _elevationReturnWaitTime;
  111422. private _zoomStopsAnimation;
  111423. private _framingTime;
  111424. /**
  111425. * The easing function used by animations
  111426. */
  111427. static EasingFunction: ExponentialEase;
  111428. /**
  111429. * The easing mode used by animations
  111430. */
  111431. static EasingMode: number;
  111432. /**
  111433. * Sets the current mode used by the behavior
  111434. */
  111435. set mode(mode: number);
  111436. /**
  111437. * Gets current mode used by the behavior.
  111438. */
  111439. get mode(): number;
  111440. /**
  111441. * Sets the scale applied to the radius (1 by default)
  111442. */
  111443. set radiusScale(radius: number);
  111444. /**
  111445. * Gets the scale applied to the radius
  111446. */
  111447. get radiusScale(): number;
  111448. /**
  111449. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111450. */
  111451. set positionScale(scale: number);
  111452. /**
  111453. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111454. */
  111455. get positionScale(): number;
  111456. /**
  111457. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111458. * behaviour is triggered, in radians.
  111459. */
  111460. set defaultElevation(elevation: number);
  111461. /**
  111462. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111463. * behaviour is triggered, in radians.
  111464. */
  111465. get defaultElevation(): number;
  111466. /**
  111467. * Sets the time (in milliseconds) taken to return to the default beta position.
  111468. * Negative value indicates camera should not return to default.
  111469. */
  111470. set elevationReturnTime(speed: number);
  111471. /**
  111472. * Gets the time (in milliseconds) taken to return to the default beta position.
  111473. * Negative value indicates camera should not return to default.
  111474. */
  111475. get elevationReturnTime(): number;
  111476. /**
  111477. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111478. */
  111479. set elevationReturnWaitTime(time: number);
  111480. /**
  111481. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111482. */
  111483. get elevationReturnWaitTime(): number;
  111484. /**
  111485. * Sets the flag that indicates if user zooming should stop animation.
  111486. */
  111487. set zoomStopsAnimation(flag: boolean);
  111488. /**
  111489. * Gets the flag that indicates if user zooming should stop animation.
  111490. */
  111491. get zoomStopsAnimation(): boolean;
  111492. /**
  111493. * Sets the transition time when framing the mesh, in milliseconds
  111494. */
  111495. set framingTime(time: number);
  111496. /**
  111497. * Gets the transition time when framing the mesh, in milliseconds
  111498. */
  111499. get framingTime(): number;
  111500. /**
  111501. * Define if the behavior should automatically change the configured
  111502. * camera limits and sensibilities.
  111503. */
  111504. autoCorrectCameraLimitsAndSensibility: boolean;
  111505. private _onPrePointerObservableObserver;
  111506. private _onAfterCheckInputsObserver;
  111507. private _onMeshTargetChangedObserver;
  111508. private _attachedCamera;
  111509. private _isPointerDown;
  111510. private _lastInteractionTime;
  111511. /**
  111512. * Initializes the behavior.
  111513. */
  111514. init(): void;
  111515. /**
  111516. * Attaches the behavior to its arc rotate camera.
  111517. * @param camera Defines the camera to attach the behavior to
  111518. */
  111519. attach(camera: ArcRotateCamera): void;
  111520. /**
  111521. * Detaches the behavior from its current arc rotate camera.
  111522. */
  111523. detach(): void;
  111524. private _animatables;
  111525. private _betaIsAnimating;
  111526. private _betaTransition;
  111527. private _radiusTransition;
  111528. private _vectorTransition;
  111529. /**
  111530. * Targets the given mesh and updates zoom level accordingly.
  111531. * @param mesh The mesh to target.
  111532. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111533. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111534. */
  111535. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111536. /**
  111537. * Targets the given mesh with its children and updates zoom level accordingly.
  111538. * @param mesh The mesh to target.
  111539. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111540. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111541. */
  111542. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111543. /**
  111544. * Targets the given meshes with their children and updates zoom level accordingly.
  111545. * @param meshes The mesh to target.
  111546. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111547. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111548. */
  111549. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111550. /**
  111551. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111552. * @param minimumWorld Determines the smaller position of the bounding box extend
  111553. * @param maximumWorld Determines the bigger position of the bounding box extend
  111554. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111555. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111556. */
  111557. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111558. /**
  111559. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111560. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111561. * frustum width.
  111562. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111563. * to fully enclose the mesh in the viewing frustum.
  111564. */
  111565. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111566. /**
  111567. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111568. * is automatically returned to its default position (expected to be above ground plane).
  111569. */
  111570. private _maintainCameraAboveGround;
  111571. /**
  111572. * Returns the frustum slope based on the canvas ratio and camera FOV
  111573. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111574. */
  111575. private _getFrustumSlope;
  111576. /**
  111577. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111578. */
  111579. private _clearAnimationLocks;
  111580. /**
  111581. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111582. */
  111583. private _applyUserInteraction;
  111584. /**
  111585. * Stops and removes all animations that have been applied to the camera
  111586. */
  111587. stopAllAnimations(): void;
  111588. /**
  111589. * Gets a value indicating if the user is moving the camera
  111590. */
  111591. get isUserIsMoving(): boolean;
  111592. /**
  111593. * The camera can move all the way towards the mesh.
  111594. */
  111595. static IgnoreBoundsSizeMode: number;
  111596. /**
  111597. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111598. */
  111599. static FitFrustumSidesMode: number;
  111600. }
  111601. }
  111602. declare module BABYLON {
  111603. /**
  111604. * Base class for Camera Pointer Inputs.
  111605. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111606. * for example usage.
  111607. */
  111608. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111609. /**
  111610. * Defines the camera the input is attached to.
  111611. */
  111612. abstract camera: Camera;
  111613. /**
  111614. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111615. */
  111616. protected _altKey: boolean;
  111617. protected _ctrlKey: boolean;
  111618. protected _metaKey: boolean;
  111619. protected _shiftKey: boolean;
  111620. /**
  111621. * Which mouse buttons were pressed at time of last mouse event.
  111622. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111623. */
  111624. protected _buttonsPressed: number;
  111625. /**
  111626. * Defines the buttons associated with the input to handle camera move.
  111627. */
  111628. buttons: number[];
  111629. /**
  111630. * Attach the input controls to a specific dom element to get the input from.
  111631. * @param element Defines the element the controls should be listened from
  111632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111633. */
  111634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111635. /**
  111636. * Detach the current controls from the specified dom element.
  111637. * @param element Defines the element to stop listening the inputs from
  111638. */
  111639. detachControl(element: Nullable<HTMLElement>): void;
  111640. /**
  111641. * Gets the class name of the current input.
  111642. * @returns the class name
  111643. */
  111644. getClassName(): string;
  111645. /**
  111646. * Get the friendly name associated with the input class.
  111647. * @returns the input friendly name
  111648. */
  111649. getSimpleName(): string;
  111650. /**
  111651. * Called on pointer POINTERDOUBLETAP event.
  111652. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111653. */
  111654. protected onDoubleTap(type: string): void;
  111655. /**
  111656. * Called on pointer POINTERMOVE event if only a single touch is active.
  111657. * Override this method to provide functionality.
  111658. */
  111659. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111660. /**
  111661. * Called on pointer POINTERMOVE event if multiple touches are active.
  111662. * Override this method to provide functionality.
  111663. */
  111664. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111665. /**
  111666. * Called on JS contextmenu event.
  111667. * Override this method to provide functionality.
  111668. */
  111669. protected onContextMenu(evt: PointerEvent): void;
  111670. /**
  111671. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111672. * press.
  111673. * Override this method to provide functionality.
  111674. */
  111675. protected onButtonDown(evt: PointerEvent): void;
  111676. /**
  111677. * Called each time a new POINTERUP event occurs. Ie, for each button
  111678. * release.
  111679. * Override this method to provide functionality.
  111680. */
  111681. protected onButtonUp(evt: PointerEvent): void;
  111682. /**
  111683. * Called when window becomes inactive.
  111684. * Override this method to provide functionality.
  111685. */
  111686. protected onLostFocus(): void;
  111687. private _pointerInput;
  111688. private _observer;
  111689. private _onLostFocus;
  111690. private pointA;
  111691. private pointB;
  111692. }
  111693. }
  111694. declare module BABYLON {
  111695. /**
  111696. * Manage the pointers inputs to control an arc rotate camera.
  111697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111698. */
  111699. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111700. /**
  111701. * Defines the camera the input is attached to.
  111702. */
  111703. camera: ArcRotateCamera;
  111704. /**
  111705. * Gets the class name of the current input.
  111706. * @returns the class name
  111707. */
  111708. getClassName(): string;
  111709. /**
  111710. * Defines the buttons associated with the input to handle camera move.
  111711. */
  111712. buttons: number[];
  111713. /**
  111714. * Defines the pointer angular sensibility along the X axis or how fast is
  111715. * the camera rotating.
  111716. */
  111717. angularSensibilityX: number;
  111718. /**
  111719. * Defines the pointer angular sensibility along the Y axis or how fast is
  111720. * the camera rotating.
  111721. */
  111722. angularSensibilityY: number;
  111723. /**
  111724. * Defines the pointer pinch precision or how fast is the camera zooming.
  111725. */
  111726. pinchPrecision: number;
  111727. /**
  111728. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111729. * from 0.
  111730. * It defines the percentage of current camera.radius to use as delta when
  111731. * pinch zoom is used.
  111732. */
  111733. pinchDeltaPercentage: number;
  111734. /**
  111735. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111736. * that any object in the plane at the camera's target point will scale
  111737. * perfectly with finger motion.
  111738. * Overrides pinchDeltaPercentage and pinchPrecision.
  111739. */
  111740. useNaturalPinchZoom: boolean;
  111741. /**
  111742. * Defines the pointer panning sensibility or how fast is the camera moving.
  111743. */
  111744. panningSensibility: number;
  111745. /**
  111746. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111747. */
  111748. multiTouchPanning: boolean;
  111749. /**
  111750. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111751. * zoom (pinch) through multitouch.
  111752. */
  111753. multiTouchPanAndZoom: boolean;
  111754. /**
  111755. * Revers pinch action direction.
  111756. */
  111757. pinchInwards: boolean;
  111758. private _isPanClick;
  111759. private _twoFingerActivityCount;
  111760. private _isPinching;
  111761. /**
  111762. * Called on pointer POINTERMOVE event if only a single touch is active.
  111763. */
  111764. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111765. /**
  111766. * Called on pointer POINTERDOUBLETAP event.
  111767. */
  111768. protected onDoubleTap(type: string): void;
  111769. /**
  111770. * Called on pointer POINTERMOVE event if multiple touches are active.
  111771. */
  111772. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111773. /**
  111774. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111775. * press.
  111776. */
  111777. protected onButtonDown(evt: PointerEvent): void;
  111778. /**
  111779. * Called each time a new POINTERUP event occurs. Ie, for each button
  111780. * release.
  111781. */
  111782. protected onButtonUp(evt: PointerEvent): void;
  111783. /**
  111784. * Called when window becomes inactive.
  111785. */
  111786. protected onLostFocus(): void;
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. /**
  111791. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111793. */
  111794. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111795. /**
  111796. * Defines the camera the input is attached to.
  111797. */
  111798. camera: ArcRotateCamera;
  111799. /**
  111800. * Defines the list of key codes associated with the up action (increase alpha)
  111801. */
  111802. keysUp: number[];
  111803. /**
  111804. * Defines the list of key codes associated with the down action (decrease alpha)
  111805. */
  111806. keysDown: number[];
  111807. /**
  111808. * Defines the list of key codes associated with the left action (increase beta)
  111809. */
  111810. keysLeft: number[];
  111811. /**
  111812. * Defines the list of key codes associated with the right action (decrease beta)
  111813. */
  111814. keysRight: number[];
  111815. /**
  111816. * Defines the list of key codes associated with the reset action.
  111817. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111818. */
  111819. keysReset: number[];
  111820. /**
  111821. * Defines the panning sensibility of the inputs.
  111822. * (How fast is the camera panning)
  111823. */
  111824. panningSensibility: number;
  111825. /**
  111826. * Defines the zooming sensibility of the inputs.
  111827. * (How fast is the camera zooming)
  111828. */
  111829. zoomingSensibility: number;
  111830. /**
  111831. * Defines whether maintaining the alt key down switch the movement mode from
  111832. * orientation to zoom.
  111833. */
  111834. useAltToZoom: boolean;
  111835. /**
  111836. * Rotation speed of the camera
  111837. */
  111838. angularSpeed: number;
  111839. private _keys;
  111840. private _ctrlPressed;
  111841. private _altPressed;
  111842. private _onCanvasBlurObserver;
  111843. private _onKeyboardObserver;
  111844. private _engine;
  111845. private _scene;
  111846. /**
  111847. * Attach the input controls to a specific dom element to get the input from.
  111848. * @param element Defines the element the controls should be listened from
  111849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111850. */
  111851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111852. /**
  111853. * Detach the current controls from the specified dom element.
  111854. * @param element Defines the element to stop listening the inputs from
  111855. */
  111856. detachControl(element: Nullable<HTMLElement>): void;
  111857. /**
  111858. * Update the current camera state depending on the inputs that have been used this frame.
  111859. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111860. */
  111861. checkInputs(): void;
  111862. /**
  111863. * Gets the class name of the current intput.
  111864. * @returns the class name
  111865. */
  111866. getClassName(): string;
  111867. /**
  111868. * Get the friendly name associated with the input class.
  111869. * @returns the input friendly name
  111870. */
  111871. getSimpleName(): string;
  111872. }
  111873. }
  111874. declare module BABYLON {
  111875. /**
  111876. * Manage the mouse wheel inputs to control an arc rotate camera.
  111877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111878. */
  111879. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111880. /**
  111881. * Defines the camera the input is attached to.
  111882. */
  111883. camera: ArcRotateCamera;
  111884. /**
  111885. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111886. */
  111887. wheelPrecision: number;
  111888. /**
  111889. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111890. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111891. */
  111892. wheelDeltaPercentage: number;
  111893. private _wheel;
  111894. private _observer;
  111895. private computeDeltaFromMouseWheelLegacyEvent;
  111896. /**
  111897. * Attach the input controls to a specific dom element to get the input from.
  111898. * @param element Defines the element the controls should be listened from
  111899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111900. */
  111901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111902. /**
  111903. * Detach the current controls from the specified dom element.
  111904. * @param element Defines the element to stop listening the inputs from
  111905. */
  111906. detachControl(element: Nullable<HTMLElement>): void;
  111907. /**
  111908. * Gets the class name of the current intput.
  111909. * @returns the class name
  111910. */
  111911. getClassName(): string;
  111912. /**
  111913. * Get the friendly name associated with the input class.
  111914. * @returns the input friendly name
  111915. */
  111916. getSimpleName(): string;
  111917. }
  111918. }
  111919. declare module BABYLON {
  111920. /**
  111921. * Default Inputs manager for the ArcRotateCamera.
  111922. * It groups all the default supported inputs for ease of use.
  111923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111924. */
  111925. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111926. /**
  111927. * Instantiates a new ArcRotateCameraInputsManager.
  111928. * @param camera Defines the camera the inputs belong to
  111929. */
  111930. constructor(camera: ArcRotateCamera);
  111931. /**
  111932. * Add mouse wheel input support to the input manager.
  111933. * @returns the current input manager
  111934. */
  111935. addMouseWheel(): ArcRotateCameraInputsManager;
  111936. /**
  111937. * Add pointers input support to the input manager.
  111938. * @returns the current input manager
  111939. */
  111940. addPointers(): ArcRotateCameraInputsManager;
  111941. /**
  111942. * Add keyboard input support to the input manager.
  111943. * @returns the current input manager
  111944. */
  111945. addKeyboard(): ArcRotateCameraInputsManager;
  111946. }
  111947. }
  111948. declare module BABYLON {
  111949. /**
  111950. * This represents an orbital type of camera.
  111951. *
  111952. * 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.
  111953. * 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.
  111954. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111955. */
  111956. export class ArcRotateCamera extends TargetCamera {
  111957. /**
  111958. * Defines the rotation angle of the camera along the longitudinal axis.
  111959. */
  111960. alpha: number;
  111961. /**
  111962. * Defines the rotation angle of the camera along the latitudinal axis.
  111963. */
  111964. beta: number;
  111965. /**
  111966. * Defines the radius of the camera from it s target point.
  111967. */
  111968. radius: number;
  111969. protected _target: Vector3;
  111970. protected _targetHost: Nullable<AbstractMesh>;
  111971. /**
  111972. * Defines the target point of the camera.
  111973. * The camera looks towards it form the radius distance.
  111974. */
  111975. get target(): Vector3;
  111976. set target(value: Vector3);
  111977. /**
  111978. * Define the current local position of the camera in the scene
  111979. */
  111980. get position(): Vector3;
  111981. set position(newPosition: Vector3);
  111982. protected _upVector: Vector3;
  111983. protected _upToYMatrix: Matrix;
  111984. protected _YToUpMatrix: Matrix;
  111985. /**
  111986. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111987. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111988. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111989. */
  111990. set upVector(vec: Vector3);
  111991. get upVector(): Vector3;
  111992. /**
  111993. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111994. */
  111995. setMatUp(): void;
  111996. /**
  111997. * Current inertia value on the longitudinal axis.
  111998. * The bigger this number the longer it will take for the camera to stop.
  111999. */
  112000. inertialAlphaOffset: number;
  112001. /**
  112002. * Current inertia value on the latitudinal axis.
  112003. * The bigger this number the longer it will take for the camera to stop.
  112004. */
  112005. inertialBetaOffset: number;
  112006. /**
  112007. * Current inertia value on the radius axis.
  112008. * The bigger this number the longer it will take for the camera to stop.
  112009. */
  112010. inertialRadiusOffset: number;
  112011. /**
  112012. * Minimum allowed angle on the longitudinal axis.
  112013. * This can help limiting how the Camera is able to move in the scene.
  112014. */
  112015. lowerAlphaLimit: Nullable<number>;
  112016. /**
  112017. * Maximum allowed angle on the longitudinal axis.
  112018. * This can help limiting how the Camera is able to move in the scene.
  112019. */
  112020. upperAlphaLimit: Nullable<number>;
  112021. /**
  112022. * Minimum allowed angle on the latitudinal axis.
  112023. * This can help limiting how the Camera is able to move in the scene.
  112024. */
  112025. lowerBetaLimit: number;
  112026. /**
  112027. * Maximum allowed angle on the latitudinal axis.
  112028. * This can help limiting how the Camera is able to move in the scene.
  112029. */
  112030. upperBetaLimit: number;
  112031. /**
  112032. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  112033. * This can help limiting how the Camera is able to move in the scene.
  112034. */
  112035. lowerRadiusLimit: Nullable<number>;
  112036. /**
  112037. * Maximum allowed distance of the camera to the target (The camera can not get further).
  112038. * This can help limiting how the Camera is able to move in the scene.
  112039. */
  112040. upperRadiusLimit: Nullable<number>;
  112041. /**
  112042. * Defines the current inertia value used during panning of the camera along the X axis.
  112043. */
  112044. inertialPanningX: number;
  112045. /**
  112046. * Defines the current inertia value used during panning of the camera along the Y axis.
  112047. */
  112048. inertialPanningY: number;
  112049. /**
  112050. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  112051. * Basically if your fingers moves away from more than this distance you will be considered
  112052. * in pinch mode.
  112053. */
  112054. pinchToPanMaxDistance: number;
  112055. /**
  112056. * Defines the maximum distance the camera can pan.
  112057. * This could help keeping the cammera always in your scene.
  112058. */
  112059. panningDistanceLimit: Nullable<number>;
  112060. /**
  112061. * Defines the target of the camera before paning.
  112062. */
  112063. panningOriginTarget: Vector3;
  112064. /**
  112065. * Defines the value of the inertia used during panning.
  112066. * 0 would mean stop inertia and one would mean no decelleration at all.
  112067. */
  112068. panningInertia: number;
  112069. /**
  112070. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  112071. */
  112072. get angularSensibilityX(): number;
  112073. set angularSensibilityX(value: number);
  112074. /**
  112075. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  112076. */
  112077. get angularSensibilityY(): number;
  112078. set angularSensibilityY(value: number);
  112079. /**
  112080. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  112081. */
  112082. get pinchPrecision(): number;
  112083. set pinchPrecision(value: number);
  112084. /**
  112085. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  112086. * It will be used instead of pinchDeltaPrecision if different from 0.
  112087. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112088. */
  112089. get pinchDeltaPercentage(): number;
  112090. set pinchDeltaPercentage(value: number);
  112091. /**
  112092. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  112093. * and pinch delta percentage.
  112094. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112095. * that any object in the plane at the camera's target point will scale
  112096. * perfectly with finger motion.
  112097. */
  112098. get useNaturalPinchZoom(): boolean;
  112099. set useNaturalPinchZoom(value: boolean);
  112100. /**
  112101. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  112102. */
  112103. get panningSensibility(): number;
  112104. set panningSensibility(value: number);
  112105. /**
  112106. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112107. */
  112108. get keysUp(): number[];
  112109. set keysUp(value: number[]);
  112110. /**
  112111. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112112. */
  112113. get keysDown(): number[];
  112114. set keysDown(value: number[]);
  112115. /**
  112116. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112117. */
  112118. get keysLeft(): number[];
  112119. set keysLeft(value: number[]);
  112120. /**
  112121. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112122. */
  112123. get keysRight(): number[];
  112124. set keysRight(value: number[]);
  112125. /**
  112126. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112127. */
  112128. get wheelPrecision(): number;
  112129. set wheelPrecision(value: number);
  112130. /**
  112131. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112132. * It will be used instead of pinchDeltaPrecision if different from 0.
  112133. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112134. */
  112135. get wheelDeltaPercentage(): number;
  112136. set wheelDeltaPercentage(value: number);
  112137. /**
  112138. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112139. */
  112140. zoomOnFactor: number;
  112141. /**
  112142. * Defines a screen offset for the camera position.
  112143. */
  112144. targetScreenOffset: Vector2;
  112145. /**
  112146. * Allows the camera to be completely reversed.
  112147. * If false the camera can not arrive upside down.
  112148. */
  112149. allowUpsideDown: boolean;
  112150. /**
  112151. * Define if double tap/click is used to restore the previously saved state of the camera.
  112152. */
  112153. useInputToRestoreState: boolean;
  112154. /** @hidden */
  112155. _viewMatrix: Matrix;
  112156. /** @hidden */
  112157. _useCtrlForPanning: boolean;
  112158. /** @hidden */
  112159. _panningMouseButton: number;
  112160. /**
  112161. * Defines the input associated to the camera.
  112162. */
  112163. inputs: ArcRotateCameraInputsManager;
  112164. /** @hidden */
  112165. _reset: () => void;
  112166. /**
  112167. * Defines the allowed panning axis.
  112168. */
  112169. panningAxis: Vector3;
  112170. protected _localDirection: Vector3;
  112171. protected _transformedDirection: Vector3;
  112172. private _bouncingBehavior;
  112173. /**
  112174. * Gets the bouncing behavior of the camera if it has been enabled.
  112175. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112176. */
  112177. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112178. /**
  112179. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112180. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112181. */
  112182. get useBouncingBehavior(): boolean;
  112183. set useBouncingBehavior(value: boolean);
  112184. private _framingBehavior;
  112185. /**
  112186. * Gets the framing behavior of the camera if it has been enabled.
  112187. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112188. */
  112189. get framingBehavior(): Nullable<FramingBehavior>;
  112190. /**
  112191. * Defines if the framing behavior of the camera is enabled on the camera.
  112192. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112193. */
  112194. get useFramingBehavior(): boolean;
  112195. set useFramingBehavior(value: boolean);
  112196. private _autoRotationBehavior;
  112197. /**
  112198. * Gets the auto rotation behavior of the camera if it has been enabled.
  112199. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112200. */
  112201. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112202. /**
  112203. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112204. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112205. */
  112206. get useAutoRotationBehavior(): boolean;
  112207. set useAutoRotationBehavior(value: boolean);
  112208. /**
  112209. * Observable triggered when the mesh target has been changed on the camera.
  112210. */
  112211. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112212. /**
  112213. * Event raised when the camera is colliding with a mesh.
  112214. */
  112215. onCollide: (collidedMesh: AbstractMesh) => void;
  112216. /**
  112217. * Defines whether the camera should check collision with the objects oh the scene.
  112218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112219. */
  112220. checkCollisions: boolean;
  112221. /**
  112222. * Defines the collision radius of the camera.
  112223. * This simulates a sphere around the camera.
  112224. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112225. */
  112226. collisionRadius: Vector3;
  112227. protected _collider: Collider;
  112228. protected _previousPosition: Vector3;
  112229. protected _collisionVelocity: Vector3;
  112230. protected _newPosition: Vector3;
  112231. protected _previousAlpha: number;
  112232. protected _previousBeta: number;
  112233. protected _previousRadius: number;
  112234. protected _collisionTriggered: boolean;
  112235. protected _targetBoundingCenter: Nullable<Vector3>;
  112236. private _computationVector;
  112237. /**
  112238. * Instantiates a new ArcRotateCamera in a given scene
  112239. * @param name Defines the name of the camera
  112240. * @param alpha Defines the camera rotation along the logitudinal axis
  112241. * @param beta Defines the camera rotation along the latitudinal axis
  112242. * @param radius Defines the camera distance from its target
  112243. * @param target Defines the camera target
  112244. * @param scene Defines the scene the camera belongs to
  112245. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112246. */
  112247. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112248. /** @hidden */
  112249. _initCache(): void;
  112250. /** @hidden */
  112251. _updateCache(ignoreParentClass?: boolean): void;
  112252. protected _getTargetPosition(): Vector3;
  112253. private _storedAlpha;
  112254. private _storedBeta;
  112255. private _storedRadius;
  112256. private _storedTarget;
  112257. private _storedTargetScreenOffset;
  112258. /**
  112259. * Stores the current state of the camera (alpha, beta, radius and target)
  112260. * @returns the camera itself
  112261. */
  112262. storeState(): Camera;
  112263. /**
  112264. * @hidden
  112265. * Restored camera state. You must call storeState() first
  112266. */
  112267. _restoreStateValues(): boolean;
  112268. /** @hidden */
  112269. _isSynchronizedViewMatrix(): boolean;
  112270. /**
  112271. * Attached controls to the current camera.
  112272. * @param element Defines the element the controls should be listened from
  112273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112274. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112275. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112276. */
  112277. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112278. /**
  112279. * Detach the current controls from the camera.
  112280. * The camera will stop reacting to inputs.
  112281. * @param element Defines the element to stop listening the inputs from
  112282. */
  112283. detachControl(element: HTMLElement): void;
  112284. /** @hidden */
  112285. _checkInputs(): void;
  112286. protected _checkLimits(): void;
  112287. /**
  112288. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112289. */
  112290. rebuildAnglesAndRadius(): void;
  112291. /**
  112292. * Use a position to define the current camera related information like alpha, beta and radius
  112293. * @param position Defines the position to set the camera at
  112294. */
  112295. setPosition(position: Vector3): void;
  112296. /**
  112297. * Defines the target the camera should look at.
  112298. * This will automatically adapt alpha beta and radius to fit within the new target.
  112299. * @param target Defines the new target as a Vector or a mesh
  112300. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112301. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112302. */
  112303. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112304. /** @hidden */
  112305. _getViewMatrix(): Matrix;
  112306. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112307. /**
  112308. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112309. * @param meshes Defines the mesh to zoom on
  112310. * @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)
  112311. */
  112312. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112313. /**
  112314. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112315. * The target will be changed but the radius
  112316. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112317. * @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)
  112318. */
  112319. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112320. min: Vector3;
  112321. max: Vector3;
  112322. distance: number;
  112323. }, doNotUpdateMaxZ?: boolean): void;
  112324. /**
  112325. * @override
  112326. * Override Camera.createRigCamera
  112327. */
  112328. createRigCamera(name: string, cameraIndex: number): Camera;
  112329. /**
  112330. * @hidden
  112331. * @override
  112332. * Override Camera._updateRigCameras
  112333. */
  112334. _updateRigCameras(): void;
  112335. /**
  112336. * Destroy the camera and release the current resources hold by it.
  112337. */
  112338. dispose(): void;
  112339. /**
  112340. * Gets the current object class name.
  112341. * @return the class name
  112342. */
  112343. getClassName(): string;
  112344. }
  112345. }
  112346. declare module BABYLON {
  112347. /**
  112348. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112350. */
  112351. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112352. /**
  112353. * Gets the name of the behavior.
  112354. */
  112355. get name(): string;
  112356. private _zoomStopsAnimation;
  112357. private _idleRotationSpeed;
  112358. private _idleRotationWaitTime;
  112359. private _idleRotationSpinupTime;
  112360. /**
  112361. * Sets the flag that indicates if user zooming should stop animation.
  112362. */
  112363. set zoomStopsAnimation(flag: boolean);
  112364. /**
  112365. * Gets the flag that indicates if user zooming should stop animation.
  112366. */
  112367. get zoomStopsAnimation(): boolean;
  112368. /**
  112369. * Sets the default speed at which the camera rotates around the model.
  112370. */
  112371. set idleRotationSpeed(speed: number);
  112372. /**
  112373. * Gets the default speed at which the camera rotates around the model.
  112374. */
  112375. get idleRotationSpeed(): number;
  112376. /**
  112377. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112378. */
  112379. set idleRotationWaitTime(time: number);
  112380. /**
  112381. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112382. */
  112383. get idleRotationWaitTime(): number;
  112384. /**
  112385. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112386. */
  112387. set idleRotationSpinupTime(time: number);
  112388. /**
  112389. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112390. */
  112391. get idleRotationSpinupTime(): number;
  112392. /**
  112393. * Gets a value indicating if the camera is currently rotating because of this behavior
  112394. */
  112395. get rotationInProgress(): boolean;
  112396. private _onPrePointerObservableObserver;
  112397. private _onAfterCheckInputsObserver;
  112398. private _attachedCamera;
  112399. private _isPointerDown;
  112400. private _lastFrameTime;
  112401. private _lastInteractionTime;
  112402. private _cameraRotationSpeed;
  112403. /**
  112404. * Initializes the behavior.
  112405. */
  112406. init(): void;
  112407. /**
  112408. * Attaches the behavior to its arc rotate camera.
  112409. * @param camera Defines the camera to attach the behavior to
  112410. */
  112411. attach(camera: ArcRotateCamera): void;
  112412. /**
  112413. * Detaches the behavior from its current arc rotate camera.
  112414. */
  112415. detach(): void;
  112416. /**
  112417. * Returns true if user is scrolling.
  112418. * @return true if user is scrolling.
  112419. */
  112420. private _userIsZooming;
  112421. private _lastFrameRadius;
  112422. private _shouldAnimationStopForInteraction;
  112423. /**
  112424. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112425. */
  112426. private _applyUserInteraction;
  112427. private _userIsMoving;
  112428. }
  112429. }
  112430. declare module BABYLON {
  112431. /**
  112432. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112433. */
  112434. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112435. private ui;
  112436. /**
  112437. * The name of the behavior
  112438. */
  112439. name: string;
  112440. /**
  112441. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112442. */
  112443. distanceAwayFromFace: number;
  112444. /**
  112445. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112446. */
  112447. distanceAwayFromBottomOfFace: number;
  112448. private _faceVectors;
  112449. private _target;
  112450. private _scene;
  112451. private _onRenderObserver;
  112452. private _tmpMatrix;
  112453. private _tmpVector;
  112454. /**
  112455. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112456. * @param ui The transform node that should be attched to the mesh
  112457. */
  112458. constructor(ui: TransformNode);
  112459. /**
  112460. * Initializes the behavior
  112461. */
  112462. init(): void;
  112463. private _closestFace;
  112464. private _zeroVector;
  112465. private _lookAtTmpMatrix;
  112466. private _lookAtToRef;
  112467. /**
  112468. * Attaches the AttachToBoxBehavior to the passed in mesh
  112469. * @param target The mesh that the specified node will be attached to
  112470. */
  112471. attach(target: Mesh): void;
  112472. /**
  112473. * Detaches the behavior from the mesh
  112474. */
  112475. detach(): void;
  112476. }
  112477. }
  112478. declare module BABYLON {
  112479. /**
  112480. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112481. */
  112482. export class FadeInOutBehavior implements Behavior<Mesh> {
  112483. /**
  112484. * Time in milliseconds to delay before fading in (Default: 0)
  112485. */
  112486. delay: number;
  112487. /**
  112488. * Time in milliseconds for the mesh to fade in (Default: 300)
  112489. */
  112490. fadeInTime: number;
  112491. private _millisecondsPerFrame;
  112492. private _hovered;
  112493. private _hoverValue;
  112494. private _ownerNode;
  112495. /**
  112496. * Instatiates the FadeInOutBehavior
  112497. */
  112498. constructor();
  112499. /**
  112500. * The name of the behavior
  112501. */
  112502. get name(): string;
  112503. /**
  112504. * Initializes the behavior
  112505. */
  112506. init(): void;
  112507. /**
  112508. * Attaches the fade behavior on the passed in mesh
  112509. * @param ownerNode The mesh that will be faded in/out once attached
  112510. */
  112511. attach(ownerNode: Mesh): void;
  112512. /**
  112513. * Detaches the behavior from the mesh
  112514. */
  112515. detach(): void;
  112516. /**
  112517. * Triggers the mesh to begin fading in or out
  112518. * @param value if the object should fade in or out (true to fade in)
  112519. */
  112520. fadeIn(value: boolean): void;
  112521. private _update;
  112522. private _setAllVisibility;
  112523. }
  112524. }
  112525. declare module BABYLON {
  112526. /**
  112527. * Class containing a set of static utilities functions for managing Pivots
  112528. * @hidden
  112529. */
  112530. export class PivotTools {
  112531. private static _PivotCached;
  112532. private static _OldPivotPoint;
  112533. private static _PivotTranslation;
  112534. private static _PivotTmpVector;
  112535. /** @hidden */
  112536. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112537. /** @hidden */
  112538. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112539. }
  112540. }
  112541. declare module BABYLON {
  112542. /**
  112543. * Class containing static functions to help procedurally build meshes
  112544. */
  112545. export class PlaneBuilder {
  112546. /**
  112547. * Creates a plane mesh
  112548. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112549. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112550. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112554. * @param name defines the name of the mesh
  112555. * @param options defines the options used to create the mesh
  112556. * @param scene defines the hosting scene
  112557. * @returns the plane mesh
  112558. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112559. */
  112560. static CreatePlane(name: string, options: {
  112561. size?: number;
  112562. width?: number;
  112563. height?: number;
  112564. sideOrientation?: number;
  112565. frontUVs?: Vector4;
  112566. backUVs?: Vector4;
  112567. updatable?: boolean;
  112568. sourcePlane?: Plane;
  112569. }, scene?: Nullable<Scene>): Mesh;
  112570. }
  112571. }
  112572. declare module BABYLON {
  112573. /**
  112574. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112575. */
  112576. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112577. private static _AnyMouseID;
  112578. /**
  112579. * Abstract mesh the behavior is set on
  112580. */
  112581. attachedNode: AbstractMesh;
  112582. private _dragPlane;
  112583. private _scene;
  112584. private _pointerObserver;
  112585. private _beforeRenderObserver;
  112586. private static _planeScene;
  112587. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112588. /**
  112589. * 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)
  112590. */
  112591. maxDragAngle: number;
  112592. /**
  112593. * @hidden
  112594. */
  112595. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112596. /**
  112597. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112598. */
  112599. currentDraggingPointerID: number;
  112600. /**
  112601. * The last position where the pointer hit the drag plane in world space
  112602. */
  112603. lastDragPosition: Vector3;
  112604. /**
  112605. * If the behavior is currently in a dragging state
  112606. */
  112607. dragging: boolean;
  112608. /**
  112609. * 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)
  112610. */
  112611. dragDeltaRatio: number;
  112612. /**
  112613. * If the drag plane orientation should be updated during the dragging (Default: true)
  112614. */
  112615. updateDragPlane: boolean;
  112616. private _debugMode;
  112617. private _moving;
  112618. /**
  112619. * Fires each time the attached mesh is dragged with the pointer
  112620. * * delta between last drag position and current drag position in world space
  112621. * * dragDistance along the drag axis
  112622. * * dragPlaneNormal normal of the current drag plane used during the drag
  112623. * * dragPlanePoint in world space where the drag intersects the drag plane
  112624. */
  112625. onDragObservable: Observable<{
  112626. delta: Vector3;
  112627. dragPlanePoint: Vector3;
  112628. dragPlaneNormal: Vector3;
  112629. dragDistance: number;
  112630. pointerId: number;
  112631. }>;
  112632. /**
  112633. * Fires each time a drag begins (eg. mouse down on mesh)
  112634. */
  112635. onDragStartObservable: Observable<{
  112636. dragPlanePoint: Vector3;
  112637. pointerId: number;
  112638. }>;
  112639. /**
  112640. * Fires each time a drag ends (eg. mouse release after drag)
  112641. */
  112642. onDragEndObservable: Observable<{
  112643. dragPlanePoint: Vector3;
  112644. pointerId: number;
  112645. }>;
  112646. /**
  112647. * If the attached mesh should be moved when dragged
  112648. */
  112649. moveAttached: boolean;
  112650. /**
  112651. * If the drag behavior will react to drag events (Default: true)
  112652. */
  112653. enabled: boolean;
  112654. /**
  112655. * If pointer events should start and release the drag (Default: true)
  112656. */
  112657. startAndReleaseDragOnPointerEvents: boolean;
  112658. /**
  112659. * If camera controls should be detached during the drag
  112660. */
  112661. detachCameraControls: boolean;
  112662. /**
  112663. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112664. */
  112665. useObjectOrientationForDragging: boolean;
  112666. private _options;
  112667. /**
  112668. * Gets the options used by the behavior
  112669. */
  112670. get options(): {
  112671. dragAxis?: Vector3;
  112672. dragPlaneNormal?: Vector3;
  112673. };
  112674. /**
  112675. * Sets the options used by the behavior
  112676. */
  112677. set options(options: {
  112678. dragAxis?: Vector3;
  112679. dragPlaneNormal?: Vector3;
  112680. });
  112681. /**
  112682. * Creates a pointer drag behavior that can be attached to a mesh
  112683. * @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)
  112684. */
  112685. constructor(options?: {
  112686. dragAxis?: Vector3;
  112687. dragPlaneNormal?: Vector3;
  112688. });
  112689. /**
  112690. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112691. */
  112692. validateDrag: (targetPosition: Vector3) => boolean;
  112693. /**
  112694. * The name of the behavior
  112695. */
  112696. get name(): string;
  112697. /**
  112698. * Initializes the behavior
  112699. */
  112700. init(): void;
  112701. private _tmpVector;
  112702. private _alternatePickedPoint;
  112703. private _worldDragAxis;
  112704. private _targetPosition;
  112705. private _attachedElement;
  112706. /**
  112707. * Attaches the drag behavior the passed in mesh
  112708. * @param ownerNode The mesh that will be dragged around once attached
  112709. * @param predicate Predicate to use for pick filtering
  112710. */
  112711. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112712. /**
  112713. * Force relase the drag action by code.
  112714. */
  112715. releaseDrag(): void;
  112716. private _startDragRay;
  112717. private _lastPointerRay;
  112718. /**
  112719. * Simulates the start of a pointer drag event on the behavior
  112720. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112721. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112722. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112723. */
  112724. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112725. private _startDrag;
  112726. private _dragDelta;
  112727. private _moveDrag;
  112728. private _pickWithRayOnDragPlane;
  112729. private _pointA;
  112730. private _pointB;
  112731. private _pointC;
  112732. private _lineA;
  112733. private _lineB;
  112734. private _localAxis;
  112735. private _lookAt;
  112736. private _updateDragPlanePosition;
  112737. /**
  112738. * Detaches the behavior from the mesh
  112739. */
  112740. detach(): void;
  112741. }
  112742. }
  112743. declare module BABYLON {
  112744. /**
  112745. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112746. */
  112747. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112748. private _dragBehaviorA;
  112749. private _dragBehaviorB;
  112750. private _startDistance;
  112751. private _initialScale;
  112752. private _targetScale;
  112753. private _ownerNode;
  112754. private _sceneRenderObserver;
  112755. /**
  112756. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112757. */
  112758. constructor();
  112759. /**
  112760. * The name of the behavior
  112761. */
  112762. get name(): string;
  112763. /**
  112764. * Initializes the behavior
  112765. */
  112766. init(): void;
  112767. private _getCurrentDistance;
  112768. /**
  112769. * Attaches the scale behavior the passed in mesh
  112770. * @param ownerNode The mesh that will be scaled around once attached
  112771. */
  112772. attach(ownerNode: Mesh): void;
  112773. /**
  112774. * Detaches the behavior from the mesh
  112775. */
  112776. detach(): void;
  112777. }
  112778. }
  112779. declare module BABYLON {
  112780. /**
  112781. * 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
  112782. */
  112783. export class SixDofDragBehavior implements Behavior<Mesh> {
  112784. private static _virtualScene;
  112785. private _ownerNode;
  112786. private _sceneRenderObserver;
  112787. private _scene;
  112788. private _targetPosition;
  112789. private _virtualOriginMesh;
  112790. private _virtualDragMesh;
  112791. private _pointerObserver;
  112792. private _moving;
  112793. private _startingOrientation;
  112794. /**
  112795. * 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)
  112796. */
  112797. private zDragFactor;
  112798. /**
  112799. * If the object should rotate to face the drag origin
  112800. */
  112801. rotateDraggedObject: boolean;
  112802. /**
  112803. * If the behavior is currently in a dragging state
  112804. */
  112805. dragging: boolean;
  112806. /**
  112807. * 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)
  112808. */
  112809. dragDeltaRatio: number;
  112810. /**
  112811. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112812. */
  112813. currentDraggingPointerID: number;
  112814. /**
  112815. * If camera controls should be detached during the drag
  112816. */
  112817. detachCameraControls: boolean;
  112818. /**
  112819. * Fires each time a drag starts
  112820. */
  112821. onDragStartObservable: Observable<{}>;
  112822. /**
  112823. * Fires each time a drag ends (eg. mouse release after drag)
  112824. */
  112825. onDragEndObservable: Observable<{}>;
  112826. /**
  112827. * 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
  112828. */
  112829. constructor();
  112830. /**
  112831. * The name of the behavior
  112832. */
  112833. get name(): string;
  112834. /**
  112835. * Initializes the behavior
  112836. */
  112837. init(): void;
  112838. /**
  112839. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112840. */
  112841. private get _pointerCamera();
  112842. /**
  112843. * Attaches the scale behavior the passed in mesh
  112844. * @param ownerNode The mesh that will be scaled around once attached
  112845. */
  112846. attach(ownerNode: Mesh): void;
  112847. /**
  112848. * Detaches the behavior from the mesh
  112849. */
  112850. detach(): void;
  112851. }
  112852. }
  112853. declare module BABYLON {
  112854. /**
  112855. * Class used to apply inverse kinematics to bones
  112856. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112857. */
  112858. export class BoneIKController {
  112859. private static _tmpVecs;
  112860. private static _tmpQuat;
  112861. private static _tmpMats;
  112862. /**
  112863. * Gets or sets the target mesh
  112864. */
  112865. targetMesh: AbstractMesh;
  112866. /** Gets or sets the mesh used as pole */
  112867. poleTargetMesh: AbstractMesh;
  112868. /**
  112869. * Gets or sets the bone used as pole
  112870. */
  112871. poleTargetBone: Nullable<Bone>;
  112872. /**
  112873. * Gets or sets the target position
  112874. */
  112875. targetPosition: Vector3;
  112876. /**
  112877. * Gets or sets the pole target position
  112878. */
  112879. poleTargetPosition: Vector3;
  112880. /**
  112881. * Gets or sets the pole target local offset
  112882. */
  112883. poleTargetLocalOffset: Vector3;
  112884. /**
  112885. * Gets or sets the pole angle
  112886. */
  112887. poleAngle: number;
  112888. /**
  112889. * Gets or sets the mesh associated with the controller
  112890. */
  112891. mesh: AbstractMesh;
  112892. /**
  112893. * 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)
  112894. */
  112895. slerpAmount: number;
  112896. private _bone1Quat;
  112897. private _bone1Mat;
  112898. private _bone2Ang;
  112899. private _bone1;
  112900. private _bone2;
  112901. private _bone1Length;
  112902. private _bone2Length;
  112903. private _maxAngle;
  112904. private _maxReach;
  112905. private _rightHandedSystem;
  112906. private _bendAxis;
  112907. private _slerping;
  112908. private _adjustRoll;
  112909. /**
  112910. * Gets or sets maximum allowed angle
  112911. */
  112912. get maxAngle(): number;
  112913. set maxAngle(value: number);
  112914. /**
  112915. * Creates a new BoneIKController
  112916. * @param mesh defines the mesh to control
  112917. * @param bone defines the bone to control
  112918. * @param options defines options to set up the controller
  112919. */
  112920. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112921. targetMesh?: AbstractMesh;
  112922. poleTargetMesh?: AbstractMesh;
  112923. poleTargetBone?: Bone;
  112924. poleTargetLocalOffset?: Vector3;
  112925. poleAngle?: number;
  112926. bendAxis?: Vector3;
  112927. maxAngle?: number;
  112928. slerpAmount?: number;
  112929. });
  112930. private _setMaxAngle;
  112931. /**
  112932. * Force the controller to update the bones
  112933. */
  112934. update(): void;
  112935. }
  112936. }
  112937. declare module BABYLON {
  112938. /**
  112939. * Class used to make a bone look toward a point in space
  112940. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112941. */
  112942. export class BoneLookController {
  112943. private static _tmpVecs;
  112944. private static _tmpQuat;
  112945. private static _tmpMats;
  112946. /**
  112947. * The target Vector3 that the bone will look at
  112948. */
  112949. target: Vector3;
  112950. /**
  112951. * The mesh that the bone is attached to
  112952. */
  112953. mesh: AbstractMesh;
  112954. /**
  112955. * The bone that will be looking to the target
  112956. */
  112957. bone: Bone;
  112958. /**
  112959. * The up axis of the coordinate system that is used when the bone is rotated
  112960. */
  112961. upAxis: Vector3;
  112962. /**
  112963. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112964. */
  112965. upAxisSpace: Space;
  112966. /**
  112967. * Used to make an adjustment to the yaw of the bone
  112968. */
  112969. adjustYaw: number;
  112970. /**
  112971. * Used to make an adjustment to the pitch of the bone
  112972. */
  112973. adjustPitch: number;
  112974. /**
  112975. * Used to make an adjustment to the roll of the bone
  112976. */
  112977. adjustRoll: number;
  112978. /**
  112979. * 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)
  112980. */
  112981. slerpAmount: number;
  112982. private _minYaw;
  112983. private _maxYaw;
  112984. private _minPitch;
  112985. private _maxPitch;
  112986. private _minYawSin;
  112987. private _minYawCos;
  112988. private _maxYawSin;
  112989. private _maxYawCos;
  112990. private _midYawConstraint;
  112991. private _minPitchTan;
  112992. private _maxPitchTan;
  112993. private _boneQuat;
  112994. private _slerping;
  112995. private _transformYawPitch;
  112996. private _transformYawPitchInv;
  112997. private _firstFrameSkipped;
  112998. private _yawRange;
  112999. private _fowardAxis;
  113000. /**
  113001. * Gets or sets the minimum yaw angle that the bone can look to
  113002. */
  113003. get minYaw(): number;
  113004. set minYaw(value: number);
  113005. /**
  113006. * Gets or sets the maximum yaw angle that the bone can look to
  113007. */
  113008. get maxYaw(): number;
  113009. set maxYaw(value: number);
  113010. /**
  113011. * Gets or sets the minimum pitch angle that the bone can look to
  113012. */
  113013. get minPitch(): number;
  113014. set minPitch(value: number);
  113015. /**
  113016. * Gets or sets the maximum pitch angle that the bone can look to
  113017. */
  113018. get maxPitch(): number;
  113019. set maxPitch(value: number);
  113020. /**
  113021. * Create a BoneLookController
  113022. * @param mesh the mesh that the bone belongs to
  113023. * @param bone the bone that will be looking to the target
  113024. * @param target the target Vector3 to look at
  113025. * @param options optional settings:
  113026. * * maxYaw: the maximum angle the bone will yaw to
  113027. * * minYaw: the minimum angle the bone will yaw to
  113028. * * maxPitch: the maximum angle the bone will pitch to
  113029. * * minPitch: the minimum angle the bone will yaw to
  113030. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  113031. * * upAxis: the up axis of the coordinate system
  113032. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  113033. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  113034. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  113035. * * adjustYaw: used to make an adjustment to the yaw of the bone
  113036. * * adjustPitch: used to make an adjustment to the pitch of the bone
  113037. * * adjustRoll: used to make an adjustment to the roll of the bone
  113038. **/
  113039. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  113040. maxYaw?: number;
  113041. minYaw?: number;
  113042. maxPitch?: number;
  113043. minPitch?: number;
  113044. slerpAmount?: number;
  113045. upAxis?: Vector3;
  113046. upAxisSpace?: Space;
  113047. yawAxis?: Vector3;
  113048. pitchAxis?: Vector3;
  113049. adjustYaw?: number;
  113050. adjustPitch?: number;
  113051. adjustRoll?: number;
  113052. });
  113053. /**
  113054. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  113055. */
  113056. update(): void;
  113057. private _getAngleDiff;
  113058. private _getAngleBetween;
  113059. private _isAngleBetween;
  113060. }
  113061. }
  113062. declare module BABYLON {
  113063. /**
  113064. * Manage the gamepad inputs to control an arc rotate camera.
  113065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113066. */
  113067. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  113068. /**
  113069. * Defines the camera the input is attached to.
  113070. */
  113071. camera: ArcRotateCamera;
  113072. /**
  113073. * Defines the gamepad the input is gathering event from.
  113074. */
  113075. gamepad: Nullable<Gamepad>;
  113076. /**
  113077. * Defines the gamepad rotation sensiblity.
  113078. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113079. */
  113080. gamepadRotationSensibility: number;
  113081. /**
  113082. * Defines the gamepad move sensiblity.
  113083. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113084. */
  113085. gamepadMoveSensibility: number;
  113086. private _yAxisScale;
  113087. /**
  113088. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113089. */
  113090. get invertYAxis(): boolean;
  113091. set invertYAxis(value: boolean);
  113092. private _onGamepadConnectedObserver;
  113093. private _onGamepadDisconnectedObserver;
  113094. /**
  113095. * Attach the input controls to a specific dom element to get the input from.
  113096. * @param element Defines the element the controls should be listened from
  113097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113098. */
  113099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113100. /**
  113101. * Detach the current controls from the specified dom element.
  113102. * @param element Defines the element to stop listening the inputs from
  113103. */
  113104. detachControl(element: Nullable<HTMLElement>): void;
  113105. /**
  113106. * Update the current camera state depending on the inputs that have been used this frame.
  113107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113108. */
  113109. checkInputs(): void;
  113110. /**
  113111. * Gets the class name of the current intput.
  113112. * @returns the class name
  113113. */
  113114. getClassName(): string;
  113115. /**
  113116. * Get the friendly name associated with the input class.
  113117. * @returns the input friendly name
  113118. */
  113119. getSimpleName(): string;
  113120. }
  113121. }
  113122. declare module BABYLON {
  113123. interface ArcRotateCameraInputsManager {
  113124. /**
  113125. * Add orientation input support to the input manager.
  113126. * @returns the current input manager
  113127. */
  113128. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113129. }
  113130. /**
  113131. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113133. */
  113134. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113135. /**
  113136. * Defines the camera the input is attached to.
  113137. */
  113138. camera: ArcRotateCamera;
  113139. /**
  113140. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113141. */
  113142. alphaCorrection: number;
  113143. /**
  113144. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113145. */
  113146. gammaCorrection: number;
  113147. private _alpha;
  113148. private _gamma;
  113149. private _dirty;
  113150. private _deviceOrientationHandler;
  113151. /**
  113152. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113153. */
  113154. constructor();
  113155. /**
  113156. * Attach the input controls to a specific dom element to get the input from.
  113157. * @param element Defines the element the controls should be listened from
  113158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113159. */
  113160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113161. /** @hidden */
  113162. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113163. /**
  113164. * Update the current camera state depending on the inputs that have been used this frame.
  113165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113166. */
  113167. checkInputs(): void;
  113168. /**
  113169. * Detach the current controls from the specified dom element.
  113170. * @param element Defines the element to stop listening the inputs from
  113171. */
  113172. detachControl(element: Nullable<HTMLElement>): void;
  113173. /**
  113174. * Gets the class name of the current intput.
  113175. * @returns the class name
  113176. */
  113177. getClassName(): string;
  113178. /**
  113179. * Get the friendly name associated with the input class.
  113180. * @returns the input friendly name
  113181. */
  113182. getSimpleName(): string;
  113183. }
  113184. }
  113185. declare module BABYLON {
  113186. /**
  113187. * Listen to mouse events to control the camera.
  113188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113189. */
  113190. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113191. /**
  113192. * Defines the camera the input is attached to.
  113193. */
  113194. camera: FlyCamera;
  113195. /**
  113196. * Defines if touch is enabled. (Default is true.)
  113197. */
  113198. touchEnabled: boolean;
  113199. /**
  113200. * Defines the buttons associated with the input to handle camera rotation.
  113201. */
  113202. buttons: number[];
  113203. /**
  113204. * Assign buttons for Yaw control.
  113205. */
  113206. buttonsYaw: number[];
  113207. /**
  113208. * Assign buttons for Pitch control.
  113209. */
  113210. buttonsPitch: number[];
  113211. /**
  113212. * Assign buttons for Roll control.
  113213. */
  113214. buttonsRoll: number[];
  113215. /**
  113216. * Detect if any button is being pressed while mouse is moved.
  113217. * -1 = Mouse locked.
  113218. * 0 = Left button.
  113219. * 1 = Middle Button.
  113220. * 2 = Right Button.
  113221. */
  113222. activeButton: number;
  113223. /**
  113224. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113225. * Higher values reduce its sensitivity.
  113226. */
  113227. angularSensibility: number;
  113228. private _mousemoveCallback;
  113229. private _observer;
  113230. private _rollObserver;
  113231. private previousPosition;
  113232. private noPreventDefault;
  113233. private element;
  113234. /**
  113235. * Listen to mouse events to control the camera.
  113236. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113238. */
  113239. constructor(touchEnabled?: boolean);
  113240. /**
  113241. * Attach the mouse control to the HTML DOM element.
  113242. * @param element Defines the element that listens to the input events.
  113243. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113244. */
  113245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113246. /**
  113247. * Detach the current controls from the specified dom element.
  113248. * @param element Defines the element to stop listening the inputs from
  113249. */
  113250. detachControl(element: Nullable<HTMLElement>): void;
  113251. /**
  113252. * Gets the class name of the current input.
  113253. * @returns the class name.
  113254. */
  113255. getClassName(): string;
  113256. /**
  113257. * Get the friendly name associated with the input class.
  113258. * @returns the input's friendly name.
  113259. */
  113260. getSimpleName(): string;
  113261. private _pointerInput;
  113262. private _onMouseMove;
  113263. /**
  113264. * Rotate camera by mouse offset.
  113265. */
  113266. private rotateCamera;
  113267. }
  113268. }
  113269. declare module BABYLON {
  113270. /**
  113271. * Default Inputs manager for the FlyCamera.
  113272. * It groups all the default supported inputs for ease of use.
  113273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113274. */
  113275. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113276. /**
  113277. * Instantiates a new FlyCameraInputsManager.
  113278. * @param camera Defines the camera the inputs belong to.
  113279. */
  113280. constructor(camera: FlyCamera);
  113281. /**
  113282. * Add keyboard input support to the input manager.
  113283. * @returns the new FlyCameraKeyboardMoveInput().
  113284. */
  113285. addKeyboard(): FlyCameraInputsManager;
  113286. /**
  113287. * Add mouse input support to the input manager.
  113288. * @param touchEnabled Enable touch screen support.
  113289. * @returns the new FlyCameraMouseInput().
  113290. */
  113291. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113292. }
  113293. }
  113294. declare module BABYLON {
  113295. /**
  113296. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113297. * such as in a 3D Space Shooter or a Flight Simulator.
  113298. */
  113299. export class FlyCamera extends TargetCamera {
  113300. /**
  113301. * Define the collision ellipsoid of the camera.
  113302. * This is helpful for simulating a camera body, like a player's body.
  113303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113304. */
  113305. ellipsoid: Vector3;
  113306. /**
  113307. * Define an offset for the position of the ellipsoid around the camera.
  113308. * This can be helpful if the camera is attached away from the player's body center,
  113309. * such as at its head.
  113310. */
  113311. ellipsoidOffset: Vector3;
  113312. /**
  113313. * Enable or disable collisions of the camera with the rest of the scene objects.
  113314. */
  113315. checkCollisions: boolean;
  113316. /**
  113317. * Enable or disable gravity on the camera.
  113318. */
  113319. applyGravity: boolean;
  113320. /**
  113321. * Define the current direction the camera is moving to.
  113322. */
  113323. cameraDirection: Vector3;
  113324. /**
  113325. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113326. * This overrides and empties cameraRotation.
  113327. */
  113328. rotationQuaternion: Quaternion;
  113329. /**
  113330. * Track Roll to maintain the wanted Rolling when looking around.
  113331. */
  113332. _trackRoll: number;
  113333. /**
  113334. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113335. */
  113336. rollCorrect: number;
  113337. /**
  113338. * Mimic a banked turn, Rolling the camera when Yawing.
  113339. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113340. */
  113341. bankedTurn: boolean;
  113342. /**
  113343. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113344. */
  113345. bankedTurnLimit: number;
  113346. /**
  113347. * Value of 0 disables the banked Roll.
  113348. * Value of 1 is equal to the Yaw angle in radians.
  113349. */
  113350. bankedTurnMultiplier: number;
  113351. /**
  113352. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113353. */
  113354. inputs: FlyCameraInputsManager;
  113355. /**
  113356. * Gets the input sensibility for mouse input.
  113357. * Higher values reduce sensitivity.
  113358. */
  113359. get angularSensibility(): number;
  113360. /**
  113361. * Sets the input sensibility for a mouse input.
  113362. * Higher values reduce sensitivity.
  113363. */
  113364. set angularSensibility(value: number);
  113365. /**
  113366. * Get the keys for camera movement forward.
  113367. */
  113368. get keysForward(): number[];
  113369. /**
  113370. * Set the keys for camera movement forward.
  113371. */
  113372. set keysForward(value: number[]);
  113373. /**
  113374. * Get the keys for camera movement backward.
  113375. */
  113376. get keysBackward(): number[];
  113377. set keysBackward(value: number[]);
  113378. /**
  113379. * Get the keys for camera movement up.
  113380. */
  113381. get keysUp(): number[];
  113382. /**
  113383. * Set the keys for camera movement up.
  113384. */
  113385. set keysUp(value: number[]);
  113386. /**
  113387. * Get the keys for camera movement down.
  113388. */
  113389. get keysDown(): number[];
  113390. /**
  113391. * Set the keys for camera movement down.
  113392. */
  113393. set keysDown(value: number[]);
  113394. /**
  113395. * Get the keys for camera movement left.
  113396. */
  113397. get keysLeft(): number[];
  113398. /**
  113399. * Set the keys for camera movement left.
  113400. */
  113401. set keysLeft(value: number[]);
  113402. /**
  113403. * Set the keys for camera movement right.
  113404. */
  113405. get keysRight(): number[];
  113406. /**
  113407. * Set the keys for camera movement right.
  113408. */
  113409. set keysRight(value: number[]);
  113410. /**
  113411. * Event raised when the camera collides with a mesh in the scene.
  113412. */
  113413. onCollide: (collidedMesh: AbstractMesh) => void;
  113414. private _collider;
  113415. private _needMoveForGravity;
  113416. private _oldPosition;
  113417. private _diffPosition;
  113418. private _newPosition;
  113419. /** @hidden */
  113420. _localDirection: Vector3;
  113421. /** @hidden */
  113422. _transformedDirection: Vector3;
  113423. /**
  113424. * Instantiates a FlyCamera.
  113425. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113426. * such as in a 3D Space Shooter or a Flight Simulator.
  113427. * @param name Define the name of the camera in the scene.
  113428. * @param position Define the starting position of the camera in the scene.
  113429. * @param scene Define the scene the camera belongs to.
  113430. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113431. */
  113432. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113433. /**
  113434. * Attach a control to the HTML DOM element.
  113435. * @param element Defines the element that listens to the input events.
  113436. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113437. */
  113438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113439. /**
  113440. * Detach a control from the HTML DOM element.
  113441. * The camera will stop reacting to that input.
  113442. * @param element Defines the element that listens to the input events.
  113443. */
  113444. detachControl(element: HTMLElement): void;
  113445. private _collisionMask;
  113446. /**
  113447. * Get the mask that the camera ignores in collision events.
  113448. */
  113449. get collisionMask(): number;
  113450. /**
  113451. * Set the mask that the camera ignores in collision events.
  113452. */
  113453. set collisionMask(mask: number);
  113454. /** @hidden */
  113455. _collideWithWorld(displacement: Vector3): void;
  113456. /** @hidden */
  113457. private _onCollisionPositionChange;
  113458. /** @hidden */
  113459. _checkInputs(): void;
  113460. /** @hidden */
  113461. _decideIfNeedsToMove(): boolean;
  113462. /** @hidden */
  113463. _updatePosition(): void;
  113464. /**
  113465. * Restore the Roll to its target value at the rate specified.
  113466. * @param rate - Higher means slower restoring.
  113467. * @hidden
  113468. */
  113469. restoreRoll(rate: number): void;
  113470. /**
  113471. * Destroy the camera and release the current resources held by it.
  113472. */
  113473. dispose(): void;
  113474. /**
  113475. * Get the current object class name.
  113476. * @returns the class name.
  113477. */
  113478. getClassName(): string;
  113479. }
  113480. }
  113481. declare module BABYLON {
  113482. /**
  113483. * Listen to keyboard events to control the camera.
  113484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113485. */
  113486. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113487. /**
  113488. * Defines the camera the input is attached to.
  113489. */
  113490. camera: FlyCamera;
  113491. /**
  113492. * The list of keyboard keys used to control the forward move of the camera.
  113493. */
  113494. keysForward: number[];
  113495. /**
  113496. * The list of keyboard keys used to control the backward move of the camera.
  113497. */
  113498. keysBackward: number[];
  113499. /**
  113500. * The list of keyboard keys used to control the forward move of the camera.
  113501. */
  113502. keysUp: number[];
  113503. /**
  113504. * The list of keyboard keys used to control the backward move of the camera.
  113505. */
  113506. keysDown: number[];
  113507. /**
  113508. * The list of keyboard keys used to control the right strafe move of the camera.
  113509. */
  113510. keysRight: number[];
  113511. /**
  113512. * The list of keyboard keys used to control the left strafe move of the camera.
  113513. */
  113514. keysLeft: number[];
  113515. private _keys;
  113516. private _onCanvasBlurObserver;
  113517. private _onKeyboardObserver;
  113518. private _engine;
  113519. private _scene;
  113520. /**
  113521. * Attach the input controls to a specific dom element to get the input from.
  113522. * @param element Defines the element the controls should be listened from
  113523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113524. */
  113525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113526. /**
  113527. * Detach the current controls from the specified dom element.
  113528. * @param element Defines the element to stop listening the inputs from
  113529. */
  113530. detachControl(element: Nullable<HTMLElement>): void;
  113531. /**
  113532. * Gets the class name of the current intput.
  113533. * @returns the class name
  113534. */
  113535. getClassName(): string;
  113536. /** @hidden */
  113537. _onLostFocus(e: FocusEvent): void;
  113538. /**
  113539. * Get the friendly name associated with the input class.
  113540. * @returns the input friendly name
  113541. */
  113542. getSimpleName(): string;
  113543. /**
  113544. * Update the current camera state depending on the inputs that have been used this frame.
  113545. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113546. */
  113547. checkInputs(): void;
  113548. }
  113549. }
  113550. declare module BABYLON {
  113551. /**
  113552. * Manage the mouse wheel inputs to control a follow camera.
  113553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113554. */
  113555. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113556. /**
  113557. * Defines the camera the input is attached to.
  113558. */
  113559. camera: FollowCamera;
  113560. /**
  113561. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113562. */
  113563. axisControlRadius: boolean;
  113564. /**
  113565. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113566. */
  113567. axisControlHeight: boolean;
  113568. /**
  113569. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113570. */
  113571. axisControlRotation: boolean;
  113572. /**
  113573. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113574. * relation to mouseWheel events.
  113575. */
  113576. wheelPrecision: number;
  113577. /**
  113578. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113579. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113580. */
  113581. wheelDeltaPercentage: number;
  113582. private _wheel;
  113583. private _observer;
  113584. /**
  113585. * Attach the input controls to a specific dom element to get the input from.
  113586. * @param element Defines the element the controls should be listened from
  113587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113588. */
  113589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113590. /**
  113591. * Detach the current controls from the specified dom element.
  113592. * @param element Defines the element to stop listening the inputs from
  113593. */
  113594. detachControl(element: Nullable<HTMLElement>): void;
  113595. /**
  113596. * Gets the class name of the current intput.
  113597. * @returns the class name
  113598. */
  113599. getClassName(): string;
  113600. /**
  113601. * Get the friendly name associated with the input class.
  113602. * @returns the input friendly name
  113603. */
  113604. getSimpleName(): string;
  113605. }
  113606. }
  113607. declare module BABYLON {
  113608. /**
  113609. * Manage the pointers inputs to control an follow camera.
  113610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113611. */
  113612. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113613. /**
  113614. * Defines the camera the input is attached to.
  113615. */
  113616. camera: FollowCamera;
  113617. /**
  113618. * Gets the class name of the current input.
  113619. * @returns the class name
  113620. */
  113621. getClassName(): string;
  113622. /**
  113623. * Defines the pointer angular sensibility along the X axis or how fast is
  113624. * the camera rotating.
  113625. * A negative number will reverse the axis direction.
  113626. */
  113627. angularSensibilityX: number;
  113628. /**
  113629. * Defines the pointer angular sensibility along the Y axis or how fast is
  113630. * the camera rotating.
  113631. * A negative number will reverse the axis direction.
  113632. */
  113633. angularSensibilityY: number;
  113634. /**
  113635. * Defines the pointer pinch precision or how fast is the camera zooming.
  113636. * A negative number will reverse the axis direction.
  113637. */
  113638. pinchPrecision: number;
  113639. /**
  113640. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113641. * from 0.
  113642. * It defines the percentage of current camera.radius to use as delta when
  113643. * pinch zoom is used.
  113644. */
  113645. pinchDeltaPercentage: number;
  113646. /**
  113647. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113648. */
  113649. axisXControlRadius: boolean;
  113650. /**
  113651. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113652. */
  113653. axisXControlHeight: boolean;
  113654. /**
  113655. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113656. */
  113657. axisXControlRotation: boolean;
  113658. /**
  113659. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113660. */
  113661. axisYControlRadius: boolean;
  113662. /**
  113663. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113664. */
  113665. axisYControlHeight: boolean;
  113666. /**
  113667. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113668. */
  113669. axisYControlRotation: boolean;
  113670. /**
  113671. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113672. */
  113673. axisPinchControlRadius: boolean;
  113674. /**
  113675. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113676. */
  113677. axisPinchControlHeight: boolean;
  113678. /**
  113679. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113680. */
  113681. axisPinchControlRotation: boolean;
  113682. /**
  113683. * Log error messages if basic misconfiguration has occurred.
  113684. */
  113685. warningEnable: boolean;
  113686. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113687. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113688. private _warningCounter;
  113689. private _warning;
  113690. }
  113691. }
  113692. declare module BABYLON {
  113693. /**
  113694. * Default Inputs manager for the FollowCamera.
  113695. * It groups all the default supported inputs for ease of use.
  113696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113697. */
  113698. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113699. /**
  113700. * Instantiates a new FollowCameraInputsManager.
  113701. * @param camera Defines the camera the inputs belong to
  113702. */
  113703. constructor(camera: FollowCamera);
  113704. /**
  113705. * Add keyboard input support to the input manager.
  113706. * @returns the current input manager
  113707. */
  113708. addKeyboard(): FollowCameraInputsManager;
  113709. /**
  113710. * Add mouse wheel input support to the input manager.
  113711. * @returns the current input manager
  113712. */
  113713. addMouseWheel(): FollowCameraInputsManager;
  113714. /**
  113715. * Add pointers input support to the input manager.
  113716. * @returns the current input manager
  113717. */
  113718. addPointers(): FollowCameraInputsManager;
  113719. /**
  113720. * Add orientation input support to the input manager.
  113721. * @returns the current input manager
  113722. */
  113723. addVRDeviceOrientation(): FollowCameraInputsManager;
  113724. }
  113725. }
  113726. declare module BABYLON {
  113727. /**
  113728. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113729. * an arc rotate version arcFollowCamera are available.
  113730. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113731. */
  113732. export class FollowCamera extends TargetCamera {
  113733. /**
  113734. * Distance the follow camera should follow an object at
  113735. */
  113736. radius: number;
  113737. /**
  113738. * Minimum allowed distance of the camera to the axis of rotation
  113739. * (The camera can not get closer).
  113740. * This can help limiting how the Camera is able to move in the scene.
  113741. */
  113742. lowerRadiusLimit: Nullable<number>;
  113743. /**
  113744. * Maximum allowed distance of the camera to the axis of rotation
  113745. * (The camera can not get further).
  113746. * This can help limiting how the Camera is able to move in the scene.
  113747. */
  113748. upperRadiusLimit: Nullable<number>;
  113749. /**
  113750. * Define a rotation offset between the camera and the object it follows
  113751. */
  113752. rotationOffset: number;
  113753. /**
  113754. * Minimum allowed angle to camera position relative to target object.
  113755. * This can help limiting how the Camera is able to move in the scene.
  113756. */
  113757. lowerRotationOffsetLimit: Nullable<number>;
  113758. /**
  113759. * Maximum allowed angle to camera position relative to target object.
  113760. * This can help limiting how the Camera is able to move in the scene.
  113761. */
  113762. upperRotationOffsetLimit: Nullable<number>;
  113763. /**
  113764. * Define a height offset between the camera and the object it follows.
  113765. * It can help following an object from the top (like a car chaing a plane)
  113766. */
  113767. heightOffset: number;
  113768. /**
  113769. * Minimum allowed height of camera position relative to target object.
  113770. * This can help limiting how the Camera is able to move in the scene.
  113771. */
  113772. lowerHeightOffsetLimit: Nullable<number>;
  113773. /**
  113774. * Maximum allowed height of camera position relative to target object.
  113775. * This can help limiting how the Camera is able to move in the scene.
  113776. */
  113777. upperHeightOffsetLimit: Nullable<number>;
  113778. /**
  113779. * Define how fast the camera can accelerate to follow it s target.
  113780. */
  113781. cameraAcceleration: number;
  113782. /**
  113783. * Define the speed limit of the camera following an object.
  113784. */
  113785. maxCameraSpeed: number;
  113786. /**
  113787. * Define the target of the camera.
  113788. */
  113789. lockedTarget: Nullable<AbstractMesh>;
  113790. /**
  113791. * Defines the input associated with the camera.
  113792. */
  113793. inputs: FollowCameraInputsManager;
  113794. /**
  113795. * Instantiates the follow camera.
  113796. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113797. * @param name Define the name of the camera in the scene
  113798. * @param position Define the position of the camera
  113799. * @param scene Define the scene the camera belong to
  113800. * @param lockedTarget Define the target of the camera
  113801. */
  113802. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113803. private _follow;
  113804. /**
  113805. * Attached controls to the current camera.
  113806. * @param element Defines the element the controls should be listened from
  113807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113808. */
  113809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113810. /**
  113811. * Detach the current controls from the camera.
  113812. * The camera will stop reacting to inputs.
  113813. * @param element Defines the element to stop listening the inputs from
  113814. */
  113815. detachControl(element: HTMLElement): void;
  113816. /** @hidden */
  113817. _checkInputs(): void;
  113818. private _checkLimits;
  113819. /**
  113820. * Gets the camera class name.
  113821. * @returns the class name
  113822. */
  113823. getClassName(): string;
  113824. }
  113825. /**
  113826. * Arc Rotate version of the follow camera.
  113827. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113828. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113829. */
  113830. export class ArcFollowCamera extends TargetCamera {
  113831. /** The longitudinal angle of the camera */
  113832. alpha: number;
  113833. /** The latitudinal angle of the camera */
  113834. beta: number;
  113835. /** The radius of the camera from its target */
  113836. radius: number;
  113837. /** Define the camera target (the messh it should follow) */
  113838. target: Nullable<AbstractMesh>;
  113839. private _cartesianCoordinates;
  113840. /**
  113841. * Instantiates a new ArcFollowCamera
  113842. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113843. * @param name Define the name of the camera
  113844. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113845. * @param beta Define the rotation angle of the camera around the elevation axis
  113846. * @param radius Define the radius of the camera from its target point
  113847. * @param target Define the target of the camera
  113848. * @param scene Define the scene the camera belongs to
  113849. */
  113850. constructor(name: string,
  113851. /** The longitudinal angle of the camera */
  113852. alpha: number,
  113853. /** The latitudinal angle of the camera */
  113854. beta: number,
  113855. /** The radius of the camera from its target */
  113856. radius: number,
  113857. /** Define the camera target (the messh it should follow) */
  113858. target: Nullable<AbstractMesh>, scene: Scene);
  113859. private _follow;
  113860. /** @hidden */
  113861. _checkInputs(): void;
  113862. /**
  113863. * Returns the class name of the object.
  113864. * It is mostly used internally for serialization purposes.
  113865. */
  113866. getClassName(): string;
  113867. }
  113868. }
  113869. declare module BABYLON {
  113870. /**
  113871. * Manage the keyboard inputs to control the movement of a follow camera.
  113872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113873. */
  113874. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113875. /**
  113876. * Defines the camera the input is attached to.
  113877. */
  113878. camera: FollowCamera;
  113879. /**
  113880. * Defines the list of key codes associated with the up action (increase heightOffset)
  113881. */
  113882. keysHeightOffsetIncr: number[];
  113883. /**
  113884. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113885. */
  113886. keysHeightOffsetDecr: number[];
  113887. /**
  113888. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113889. */
  113890. keysHeightOffsetModifierAlt: boolean;
  113891. /**
  113892. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113893. */
  113894. keysHeightOffsetModifierCtrl: boolean;
  113895. /**
  113896. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113897. */
  113898. keysHeightOffsetModifierShift: boolean;
  113899. /**
  113900. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113901. */
  113902. keysRotationOffsetIncr: number[];
  113903. /**
  113904. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113905. */
  113906. keysRotationOffsetDecr: number[];
  113907. /**
  113908. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113909. */
  113910. keysRotationOffsetModifierAlt: boolean;
  113911. /**
  113912. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113913. */
  113914. keysRotationOffsetModifierCtrl: boolean;
  113915. /**
  113916. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113917. */
  113918. keysRotationOffsetModifierShift: boolean;
  113919. /**
  113920. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113921. */
  113922. keysRadiusIncr: number[];
  113923. /**
  113924. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113925. */
  113926. keysRadiusDecr: number[];
  113927. /**
  113928. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113929. */
  113930. keysRadiusModifierAlt: boolean;
  113931. /**
  113932. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113933. */
  113934. keysRadiusModifierCtrl: boolean;
  113935. /**
  113936. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113937. */
  113938. keysRadiusModifierShift: boolean;
  113939. /**
  113940. * Defines the rate of change of heightOffset.
  113941. */
  113942. heightSensibility: number;
  113943. /**
  113944. * Defines the rate of change of rotationOffset.
  113945. */
  113946. rotationSensibility: number;
  113947. /**
  113948. * Defines the rate of change of radius.
  113949. */
  113950. radiusSensibility: number;
  113951. private _keys;
  113952. private _ctrlPressed;
  113953. private _altPressed;
  113954. private _shiftPressed;
  113955. private _onCanvasBlurObserver;
  113956. private _onKeyboardObserver;
  113957. private _engine;
  113958. private _scene;
  113959. /**
  113960. * Attach the input controls to a specific dom element to get the input from.
  113961. * @param element Defines the element the controls should be listened from
  113962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113963. */
  113964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113965. /**
  113966. * Detach the current controls from the specified dom element.
  113967. * @param element Defines the element to stop listening the inputs from
  113968. */
  113969. detachControl(element: Nullable<HTMLElement>): void;
  113970. /**
  113971. * Update the current camera state depending on the inputs that have been used this frame.
  113972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113973. */
  113974. checkInputs(): void;
  113975. /**
  113976. * Gets the class name of the current input.
  113977. * @returns the class name
  113978. */
  113979. getClassName(): string;
  113980. /**
  113981. * Get the friendly name associated with the input class.
  113982. * @returns the input friendly name
  113983. */
  113984. getSimpleName(): string;
  113985. /**
  113986. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113987. * allow modification of the heightOffset value.
  113988. */
  113989. private _modifierHeightOffset;
  113990. /**
  113991. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113992. * allow modification of the rotationOffset value.
  113993. */
  113994. private _modifierRotationOffset;
  113995. /**
  113996. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113997. * allow modification of the radius value.
  113998. */
  113999. private _modifierRadius;
  114000. }
  114001. }
  114002. declare module BABYLON {
  114003. interface FreeCameraInputsManager {
  114004. /**
  114005. * @hidden
  114006. */
  114007. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  114008. /**
  114009. * Add orientation input support to the input manager.
  114010. * @returns the current input manager
  114011. */
  114012. addDeviceOrientation(): FreeCameraInputsManager;
  114013. }
  114014. /**
  114015. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  114016. * Screen rotation is taken into account.
  114017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114018. */
  114019. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  114020. private _camera;
  114021. private _screenOrientationAngle;
  114022. private _constantTranform;
  114023. private _screenQuaternion;
  114024. private _alpha;
  114025. private _beta;
  114026. private _gamma;
  114027. /**
  114028. * Can be used to detect if a device orientation sensor is available on a device
  114029. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  114030. * @returns a promise that will resolve on orientation change
  114031. */
  114032. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  114033. /**
  114034. * @hidden
  114035. */
  114036. _onDeviceOrientationChangedObservable: Observable<void>;
  114037. /**
  114038. * Instantiates a new input
  114039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114040. */
  114041. constructor();
  114042. /**
  114043. * Define the camera controlled by the input.
  114044. */
  114045. get camera(): FreeCamera;
  114046. set camera(camera: FreeCamera);
  114047. /**
  114048. * Attach the input controls to a specific dom element to get the input from.
  114049. * @param element Defines the element the controls should be listened from
  114050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114051. */
  114052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114053. private _orientationChanged;
  114054. private _deviceOrientation;
  114055. /**
  114056. * Detach the current controls from the specified dom element.
  114057. * @param element Defines the element to stop listening the inputs from
  114058. */
  114059. detachControl(element: Nullable<HTMLElement>): void;
  114060. /**
  114061. * Update the current camera state depending on the inputs that have been used this frame.
  114062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114063. */
  114064. checkInputs(): void;
  114065. /**
  114066. * Gets the class name of the current intput.
  114067. * @returns the class name
  114068. */
  114069. getClassName(): string;
  114070. /**
  114071. * Get the friendly name associated with the input class.
  114072. * @returns the input friendly name
  114073. */
  114074. getSimpleName(): string;
  114075. }
  114076. }
  114077. declare module BABYLON {
  114078. /**
  114079. * Manage the gamepad inputs to control a free camera.
  114080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114081. */
  114082. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  114083. /**
  114084. * Define the camera the input is attached to.
  114085. */
  114086. camera: FreeCamera;
  114087. /**
  114088. * Define the Gamepad controlling the input
  114089. */
  114090. gamepad: Nullable<Gamepad>;
  114091. /**
  114092. * Defines the gamepad rotation sensiblity.
  114093. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114094. */
  114095. gamepadAngularSensibility: number;
  114096. /**
  114097. * Defines the gamepad move sensiblity.
  114098. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114099. */
  114100. gamepadMoveSensibility: number;
  114101. private _yAxisScale;
  114102. /**
  114103. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114104. */
  114105. get invertYAxis(): boolean;
  114106. set invertYAxis(value: boolean);
  114107. private _onGamepadConnectedObserver;
  114108. private _onGamepadDisconnectedObserver;
  114109. private _cameraTransform;
  114110. private _deltaTransform;
  114111. private _vector3;
  114112. private _vector2;
  114113. /**
  114114. * Attach the input controls to a specific dom element to get the input from.
  114115. * @param element Defines the element the controls should be listened from
  114116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114117. */
  114118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114119. /**
  114120. * Detach the current controls from the specified dom element.
  114121. * @param element Defines the element to stop listening the inputs from
  114122. */
  114123. detachControl(element: Nullable<HTMLElement>): void;
  114124. /**
  114125. * Update the current camera state depending on the inputs that have been used this frame.
  114126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114127. */
  114128. checkInputs(): void;
  114129. /**
  114130. * Gets the class name of the current intput.
  114131. * @returns the class name
  114132. */
  114133. getClassName(): string;
  114134. /**
  114135. * Get the friendly name associated with the input class.
  114136. * @returns the input friendly name
  114137. */
  114138. getSimpleName(): string;
  114139. }
  114140. }
  114141. declare module BABYLON {
  114142. /**
  114143. * Defines the potential axis of a Joystick
  114144. */
  114145. export enum JoystickAxis {
  114146. /** X axis */
  114147. X = 0,
  114148. /** Y axis */
  114149. Y = 1,
  114150. /** Z axis */
  114151. Z = 2
  114152. }
  114153. /**
  114154. * Class used to define virtual joystick (used in touch mode)
  114155. */
  114156. export class VirtualJoystick {
  114157. /**
  114158. * Gets or sets a boolean indicating that left and right values must be inverted
  114159. */
  114160. reverseLeftRight: boolean;
  114161. /**
  114162. * Gets or sets a boolean indicating that up and down values must be inverted
  114163. */
  114164. reverseUpDown: boolean;
  114165. /**
  114166. * Gets the offset value for the position (ie. the change of the position value)
  114167. */
  114168. deltaPosition: Vector3;
  114169. /**
  114170. * Gets a boolean indicating if the virtual joystick was pressed
  114171. */
  114172. pressed: boolean;
  114173. /**
  114174. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114175. */
  114176. static Canvas: Nullable<HTMLCanvasElement>;
  114177. private static _globalJoystickIndex;
  114178. private static vjCanvasContext;
  114179. private static vjCanvasWidth;
  114180. private static vjCanvasHeight;
  114181. private static halfWidth;
  114182. private _action;
  114183. private _axisTargetedByLeftAndRight;
  114184. private _axisTargetedByUpAndDown;
  114185. private _joystickSensibility;
  114186. private _inversedSensibility;
  114187. private _joystickPointerID;
  114188. private _joystickColor;
  114189. private _joystickPointerPos;
  114190. private _joystickPreviousPointerPos;
  114191. private _joystickPointerStartPos;
  114192. private _deltaJoystickVector;
  114193. private _leftJoystick;
  114194. private _touches;
  114195. private _onPointerDownHandlerRef;
  114196. private _onPointerMoveHandlerRef;
  114197. private _onPointerUpHandlerRef;
  114198. private _onResize;
  114199. /**
  114200. * Creates a new virtual joystick
  114201. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114202. */
  114203. constructor(leftJoystick?: boolean);
  114204. /**
  114205. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114206. * @param newJoystickSensibility defines the new sensibility
  114207. */
  114208. setJoystickSensibility(newJoystickSensibility: number): void;
  114209. private _onPointerDown;
  114210. private _onPointerMove;
  114211. private _onPointerUp;
  114212. /**
  114213. * Change the color of the virtual joystick
  114214. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114215. */
  114216. setJoystickColor(newColor: string): void;
  114217. /**
  114218. * Defines a callback to call when the joystick is touched
  114219. * @param action defines the callback
  114220. */
  114221. setActionOnTouch(action: () => any): void;
  114222. /**
  114223. * Defines which axis you'd like to control for left & right
  114224. * @param axis defines the axis to use
  114225. */
  114226. setAxisForLeftRight(axis: JoystickAxis): void;
  114227. /**
  114228. * Defines which axis you'd like to control for up & down
  114229. * @param axis defines the axis to use
  114230. */
  114231. setAxisForUpDown(axis: JoystickAxis): void;
  114232. private _drawVirtualJoystick;
  114233. /**
  114234. * Release internal HTML canvas
  114235. */
  114236. releaseCanvas(): void;
  114237. }
  114238. }
  114239. declare module BABYLON {
  114240. interface FreeCameraInputsManager {
  114241. /**
  114242. * Add virtual joystick input support to the input manager.
  114243. * @returns the current input manager
  114244. */
  114245. addVirtualJoystick(): FreeCameraInputsManager;
  114246. }
  114247. /**
  114248. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114250. */
  114251. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114252. /**
  114253. * Defines the camera the input is attached to.
  114254. */
  114255. camera: FreeCamera;
  114256. private _leftjoystick;
  114257. private _rightjoystick;
  114258. /**
  114259. * Gets the left stick of the virtual joystick.
  114260. * @returns The virtual Joystick
  114261. */
  114262. getLeftJoystick(): VirtualJoystick;
  114263. /**
  114264. * Gets the right stick of the virtual joystick.
  114265. * @returns The virtual Joystick
  114266. */
  114267. getRightJoystick(): VirtualJoystick;
  114268. /**
  114269. * Update the current camera state depending on the inputs that have been used this frame.
  114270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114271. */
  114272. checkInputs(): void;
  114273. /**
  114274. * Attach the input controls to a specific dom element to get the input from.
  114275. * @param element Defines the element the controls should be listened from
  114276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114277. */
  114278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114279. /**
  114280. * Detach the current controls from the specified dom element.
  114281. * @param element Defines the element to stop listening the inputs from
  114282. */
  114283. detachControl(element: Nullable<HTMLElement>): void;
  114284. /**
  114285. * Gets the class name of the current intput.
  114286. * @returns the class name
  114287. */
  114288. getClassName(): string;
  114289. /**
  114290. * Get the friendly name associated with the input class.
  114291. * @returns the input friendly name
  114292. */
  114293. getSimpleName(): string;
  114294. }
  114295. }
  114296. declare module BABYLON {
  114297. /**
  114298. * This represents a FPS type of camera controlled by touch.
  114299. * This is like a universal camera minus the Gamepad controls.
  114300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114301. */
  114302. export class TouchCamera extends FreeCamera {
  114303. /**
  114304. * Defines the touch sensibility for rotation.
  114305. * The higher the faster.
  114306. */
  114307. get touchAngularSensibility(): number;
  114308. set touchAngularSensibility(value: number);
  114309. /**
  114310. * Defines the touch sensibility for move.
  114311. * The higher the faster.
  114312. */
  114313. get touchMoveSensibility(): number;
  114314. set touchMoveSensibility(value: number);
  114315. /**
  114316. * Instantiates a new touch camera.
  114317. * This represents a FPS type of camera controlled by touch.
  114318. * This is like a universal camera minus the Gamepad controls.
  114319. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114320. * @param name Define the name of the camera in the scene
  114321. * @param position Define the start position of the camera in the scene
  114322. * @param scene Define the scene the camera belongs to
  114323. */
  114324. constructor(name: string, position: Vector3, scene: Scene);
  114325. /**
  114326. * Gets the current object class name.
  114327. * @return the class name
  114328. */
  114329. getClassName(): string;
  114330. /** @hidden */
  114331. _setupInputs(): void;
  114332. }
  114333. }
  114334. declare module BABYLON {
  114335. /**
  114336. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114337. * being tilted forward or back and left or right.
  114338. */
  114339. export class DeviceOrientationCamera extends FreeCamera {
  114340. private _initialQuaternion;
  114341. private _quaternionCache;
  114342. private _tmpDragQuaternion;
  114343. private _disablePointerInputWhenUsingDeviceOrientation;
  114344. /**
  114345. * Creates a new device orientation camera
  114346. * @param name The name of the camera
  114347. * @param position The start position camera
  114348. * @param scene The scene the camera belongs to
  114349. */
  114350. constructor(name: string, position: Vector3, scene: Scene);
  114351. /**
  114352. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114353. */
  114354. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114355. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114356. private _dragFactor;
  114357. /**
  114358. * Enabled turning on the y axis when the orientation sensor is active
  114359. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114360. */
  114361. enableHorizontalDragging(dragFactor?: number): void;
  114362. /**
  114363. * Gets the current instance class name ("DeviceOrientationCamera").
  114364. * This helps avoiding instanceof at run time.
  114365. * @returns the class name
  114366. */
  114367. getClassName(): string;
  114368. /**
  114369. * @hidden
  114370. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114371. */
  114372. _checkInputs(): void;
  114373. /**
  114374. * Reset the camera to its default orientation on the specified axis only.
  114375. * @param axis The axis to reset
  114376. */
  114377. resetToCurrentRotation(axis?: Axis): void;
  114378. }
  114379. }
  114380. declare module BABYLON {
  114381. /**
  114382. * Defines supported buttons for XBox360 compatible gamepads
  114383. */
  114384. export enum Xbox360Button {
  114385. /** A */
  114386. A = 0,
  114387. /** B */
  114388. B = 1,
  114389. /** X */
  114390. X = 2,
  114391. /** Y */
  114392. Y = 3,
  114393. /** Left button */
  114394. LB = 4,
  114395. /** Right button */
  114396. RB = 5,
  114397. /** Back */
  114398. Back = 8,
  114399. /** Start */
  114400. Start = 9,
  114401. /** Left stick */
  114402. LeftStick = 10,
  114403. /** Right stick */
  114404. RightStick = 11
  114405. }
  114406. /** Defines values for XBox360 DPad */
  114407. export enum Xbox360Dpad {
  114408. /** Up */
  114409. Up = 12,
  114410. /** Down */
  114411. Down = 13,
  114412. /** Left */
  114413. Left = 14,
  114414. /** Right */
  114415. Right = 15
  114416. }
  114417. /**
  114418. * Defines a XBox360 gamepad
  114419. */
  114420. export class Xbox360Pad extends Gamepad {
  114421. private _leftTrigger;
  114422. private _rightTrigger;
  114423. private _onlefttriggerchanged;
  114424. private _onrighttriggerchanged;
  114425. private _onbuttondown;
  114426. private _onbuttonup;
  114427. private _ondpaddown;
  114428. private _ondpadup;
  114429. /** Observable raised when a button is pressed */
  114430. onButtonDownObservable: Observable<Xbox360Button>;
  114431. /** Observable raised when a button is released */
  114432. onButtonUpObservable: Observable<Xbox360Button>;
  114433. /** Observable raised when a pad is pressed */
  114434. onPadDownObservable: Observable<Xbox360Dpad>;
  114435. /** Observable raised when a pad is released */
  114436. onPadUpObservable: Observable<Xbox360Dpad>;
  114437. private _buttonA;
  114438. private _buttonB;
  114439. private _buttonX;
  114440. private _buttonY;
  114441. private _buttonBack;
  114442. private _buttonStart;
  114443. private _buttonLB;
  114444. private _buttonRB;
  114445. private _buttonLeftStick;
  114446. private _buttonRightStick;
  114447. private _dPadUp;
  114448. private _dPadDown;
  114449. private _dPadLeft;
  114450. private _dPadRight;
  114451. private _isXboxOnePad;
  114452. /**
  114453. * Creates a new XBox360 gamepad object
  114454. * @param id defines the id of this gamepad
  114455. * @param index defines its index
  114456. * @param gamepad defines the internal HTML gamepad object
  114457. * @param xboxOne defines if it is a XBox One gamepad
  114458. */
  114459. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114460. /**
  114461. * Defines the callback to call when left trigger is pressed
  114462. * @param callback defines the callback to use
  114463. */
  114464. onlefttriggerchanged(callback: (value: number) => void): void;
  114465. /**
  114466. * Defines the callback to call when right trigger is pressed
  114467. * @param callback defines the callback to use
  114468. */
  114469. onrighttriggerchanged(callback: (value: number) => void): void;
  114470. /**
  114471. * Gets the left trigger value
  114472. */
  114473. get leftTrigger(): number;
  114474. /**
  114475. * Sets the left trigger value
  114476. */
  114477. set leftTrigger(newValue: number);
  114478. /**
  114479. * Gets the right trigger value
  114480. */
  114481. get rightTrigger(): number;
  114482. /**
  114483. * Sets the right trigger value
  114484. */
  114485. set rightTrigger(newValue: number);
  114486. /**
  114487. * Defines the callback to call when a button is pressed
  114488. * @param callback defines the callback to use
  114489. */
  114490. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114491. /**
  114492. * Defines the callback to call when a button is released
  114493. * @param callback defines the callback to use
  114494. */
  114495. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114496. /**
  114497. * Defines the callback to call when a pad is pressed
  114498. * @param callback defines the callback to use
  114499. */
  114500. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114501. /**
  114502. * Defines the callback to call when a pad is released
  114503. * @param callback defines the callback to use
  114504. */
  114505. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114506. private _setButtonValue;
  114507. private _setDPadValue;
  114508. /**
  114509. * Gets the value of the `A` button
  114510. */
  114511. get buttonA(): number;
  114512. /**
  114513. * Sets the value of the `A` button
  114514. */
  114515. set buttonA(value: number);
  114516. /**
  114517. * Gets the value of the `B` button
  114518. */
  114519. get buttonB(): number;
  114520. /**
  114521. * Sets the value of the `B` button
  114522. */
  114523. set buttonB(value: number);
  114524. /**
  114525. * Gets the value of the `X` button
  114526. */
  114527. get buttonX(): number;
  114528. /**
  114529. * Sets the value of the `X` button
  114530. */
  114531. set buttonX(value: number);
  114532. /**
  114533. * Gets the value of the `Y` button
  114534. */
  114535. get buttonY(): number;
  114536. /**
  114537. * Sets the value of the `Y` button
  114538. */
  114539. set buttonY(value: number);
  114540. /**
  114541. * Gets the value of the `Start` button
  114542. */
  114543. get buttonStart(): number;
  114544. /**
  114545. * Sets the value of the `Start` button
  114546. */
  114547. set buttonStart(value: number);
  114548. /**
  114549. * Gets the value of the `Back` button
  114550. */
  114551. get buttonBack(): number;
  114552. /**
  114553. * Sets the value of the `Back` button
  114554. */
  114555. set buttonBack(value: number);
  114556. /**
  114557. * Gets the value of the `Left` button
  114558. */
  114559. get buttonLB(): number;
  114560. /**
  114561. * Sets the value of the `Left` button
  114562. */
  114563. set buttonLB(value: number);
  114564. /**
  114565. * Gets the value of the `Right` button
  114566. */
  114567. get buttonRB(): number;
  114568. /**
  114569. * Sets the value of the `Right` button
  114570. */
  114571. set buttonRB(value: number);
  114572. /**
  114573. * Gets the value of the Left joystick
  114574. */
  114575. get buttonLeftStick(): number;
  114576. /**
  114577. * Sets the value of the Left joystick
  114578. */
  114579. set buttonLeftStick(value: number);
  114580. /**
  114581. * Gets the value of the Right joystick
  114582. */
  114583. get buttonRightStick(): number;
  114584. /**
  114585. * Sets the value of the Right joystick
  114586. */
  114587. set buttonRightStick(value: number);
  114588. /**
  114589. * Gets the value of D-pad up
  114590. */
  114591. get dPadUp(): number;
  114592. /**
  114593. * Sets the value of D-pad up
  114594. */
  114595. set dPadUp(value: number);
  114596. /**
  114597. * Gets the value of D-pad down
  114598. */
  114599. get dPadDown(): number;
  114600. /**
  114601. * Sets the value of D-pad down
  114602. */
  114603. set dPadDown(value: number);
  114604. /**
  114605. * Gets the value of D-pad left
  114606. */
  114607. get dPadLeft(): number;
  114608. /**
  114609. * Sets the value of D-pad left
  114610. */
  114611. set dPadLeft(value: number);
  114612. /**
  114613. * Gets the value of D-pad right
  114614. */
  114615. get dPadRight(): number;
  114616. /**
  114617. * Sets the value of D-pad right
  114618. */
  114619. set dPadRight(value: number);
  114620. /**
  114621. * Force the gamepad to synchronize with device values
  114622. */
  114623. update(): void;
  114624. /**
  114625. * Disposes the gamepad
  114626. */
  114627. dispose(): void;
  114628. }
  114629. }
  114630. declare module BABYLON {
  114631. /**
  114632. * Defines supported buttons for DualShock compatible gamepads
  114633. */
  114634. export enum DualShockButton {
  114635. /** Cross */
  114636. Cross = 0,
  114637. /** Circle */
  114638. Circle = 1,
  114639. /** Square */
  114640. Square = 2,
  114641. /** Triangle */
  114642. Triangle = 3,
  114643. /** L1 */
  114644. L1 = 4,
  114645. /** R1 */
  114646. R1 = 5,
  114647. /** Share */
  114648. Share = 8,
  114649. /** Options */
  114650. Options = 9,
  114651. /** Left stick */
  114652. LeftStick = 10,
  114653. /** Right stick */
  114654. RightStick = 11
  114655. }
  114656. /** Defines values for DualShock DPad */
  114657. export enum DualShockDpad {
  114658. /** Up */
  114659. Up = 12,
  114660. /** Down */
  114661. Down = 13,
  114662. /** Left */
  114663. Left = 14,
  114664. /** Right */
  114665. Right = 15
  114666. }
  114667. /**
  114668. * Defines a DualShock gamepad
  114669. */
  114670. export class DualShockPad extends Gamepad {
  114671. private _leftTrigger;
  114672. private _rightTrigger;
  114673. private _onlefttriggerchanged;
  114674. private _onrighttriggerchanged;
  114675. private _onbuttondown;
  114676. private _onbuttonup;
  114677. private _ondpaddown;
  114678. private _ondpadup;
  114679. /** Observable raised when a button is pressed */
  114680. onButtonDownObservable: Observable<DualShockButton>;
  114681. /** Observable raised when a button is released */
  114682. onButtonUpObservable: Observable<DualShockButton>;
  114683. /** Observable raised when a pad is pressed */
  114684. onPadDownObservable: Observable<DualShockDpad>;
  114685. /** Observable raised when a pad is released */
  114686. onPadUpObservable: Observable<DualShockDpad>;
  114687. private _buttonCross;
  114688. private _buttonCircle;
  114689. private _buttonSquare;
  114690. private _buttonTriangle;
  114691. private _buttonShare;
  114692. private _buttonOptions;
  114693. private _buttonL1;
  114694. private _buttonR1;
  114695. private _buttonLeftStick;
  114696. private _buttonRightStick;
  114697. private _dPadUp;
  114698. private _dPadDown;
  114699. private _dPadLeft;
  114700. private _dPadRight;
  114701. /**
  114702. * Creates a new DualShock gamepad object
  114703. * @param id defines the id of this gamepad
  114704. * @param index defines its index
  114705. * @param gamepad defines the internal HTML gamepad object
  114706. */
  114707. constructor(id: string, index: number, gamepad: any);
  114708. /**
  114709. * Defines the callback to call when left trigger is pressed
  114710. * @param callback defines the callback to use
  114711. */
  114712. onlefttriggerchanged(callback: (value: number) => void): void;
  114713. /**
  114714. * Defines the callback to call when right trigger is pressed
  114715. * @param callback defines the callback to use
  114716. */
  114717. onrighttriggerchanged(callback: (value: number) => void): void;
  114718. /**
  114719. * Gets the left trigger value
  114720. */
  114721. get leftTrigger(): number;
  114722. /**
  114723. * Sets the left trigger value
  114724. */
  114725. set leftTrigger(newValue: number);
  114726. /**
  114727. * Gets the right trigger value
  114728. */
  114729. get rightTrigger(): number;
  114730. /**
  114731. * Sets the right trigger value
  114732. */
  114733. set rightTrigger(newValue: number);
  114734. /**
  114735. * Defines the callback to call when a button is pressed
  114736. * @param callback defines the callback to use
  114737. */
  114738. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114739. /**
  114740. * Defines the callback to call when a button is released
  114741. * @param callback defines the callback to use
  114742. */
  114743. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114744. /**
  114745. * Defines the callback to call when a pad is pressed
  114746. * @param callback defines the callback to use
  114747. */
  114748. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114749. /**
  114750. * Defines the callback to call when a pad is released
  114751. * @param callback defines the callback to use
  114752. */
  114753. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114754. private _setButtonValue;
  114755. private _setDPadValue;
  114756. /**
  114757. * Gets the value of the `Cross` button
  114758. */
  114759. get buttonCross(): number;
  114760. /**
  114761. * Sets the value of the `Cross` button
  114762. */
  114763. set buttonCross(value: number);
  114764. /**
  114765. * Gets the value of the `Circle` button
  114766. */
  114767. get buttonCircle(): number;
  114768. /**
  114769. * Sets the value of the `Circle` button
  114770. */
  114771. set buttonCircle(value: number);
  114772. /**
  114773. * Gets the value of the `Square` button
  114774. */
  114775. get buttonSquare(): number;
  114776. /**
  114777. * Sets the value of the `Square` button
  114778. */
  114779. set buttonSquare(value: number);
  114780. /**
  114781. * Gets the value of the `Triangle` button
  114782. */
  114783. get buttonTriangle(): number;
  114784. /**
  114785. * Sets the value of the `Triangle` button
  114786. */
  114787. set buttonTriangle(value: number);
  114788. /**
  114789. * Gets the value of the `Options` button
  114790. */
  114791. get buttonOptions(): number;
  114792. /**
  114793. * Sets the value of the `Options` button
  114794. */
  114795. set buttonOptions(value: number);
  114796. /**
  114797. * Gets the value of the `Share` button
  114798. */
  114799. get buttonShare(): number;
  114800. /**
  114801. * Sets the value of the `Share` button
  114802. */
  114803. set buttonShare(value: number);
  114804. /**
  114805. * Gets the value of the `L1` button
  114806. */
  114807. get buttonL1(): number;
  114808. /**
  114809. * Sets the value of the `L1` button
  114810. */
  114811. set buttonL1(value: number);
  114812. /**
  114813. * Gets the value of the `R1` button
  114814. */
  114815. get buttonR1(): number;
  114816. /**
  114817. * Sets the value of the `R1` button
  114818. */
  114819. set buttonR1(value: number);
  114820. /**
  114821. * Gets the value of the Left joystick
  114822. */
  114823. get buttonLeftStick(): number;
  114824. /**
  114825. * Sets the value of the Left joystick
  114826. */
  114827. set buttonLeftStick(value: number);
  114828. /**
  114829. * Gets the value of the Right joystick
  114830. */
  114831. get buttonRightStick(): number;
  114832. /**
  114833. * Sets the value of the Right joystick
  114834. */
  114835. set buttonRightStick(value: number);
  114836. /**
  114837. * Gets the value of D-pad up
  114838. */
  114839. get dPadUp(): number;
  114840. /**
  114841. * Sets the value of D-pad up
  114842. */
  114843. set dPadUp(value: number);
  114844. /**
  114845. * Gets the value of D-pad down
  114846. */
  114847. get dPadDown(): number;
  114848. /**
  114849. * Sets the value of D-pad down
  114850. */
  114851. set dPadDown(value: number);
  114852. /**
  114853. * Gets the value of D-pad left
  114854. */
  114855. get dPadLeft(): number;
  114856. /**
  114857. * Sets the value of D-pad left
  114858. */
  114859. set dPadLeft(value: number);
  114860. /**
  114861. * Gets the value of D-pad right
  114862. */
  114863. get dPadRight(): number;
  114864. /**
  114865. * Sets the value of D-pad right
  114866. */
  114867. set dPadRight(value: number);
  114868. /**
  114869. * Force the gamepad to synchronize with device values
  114870. */
  114871. update(): void;
  114872. /**
  114873. * Disposes the gamepad
  114874. */
  114875. dispose(): void;
  114876. }
  114877. }
  114878. declare module BABYLON {
  114879. /**
  114880. * Manager for handling gamepads
  114881. */
  114882. export class GamepadManager {
  114883. private _scene?;
  114884. private _babylonGamepads;
  114885. private _oneGamepadConnected;
  114886. /** @hidden */
  114887. _isMonitoring: boolean;
  114888. private _gamepadEventSupported;
  114889. private _gamepadSupport?;
  114890. /**
  114891. * observable to be triggered when the gamepad controller has been connected
  114892. */
  114893. onGamepadConnectedObservable: Observable<Gamepad>;
  114894. /**
  114895. * observable to be triggered when the gamepad controller has been disconnected
  114896. */
  114897. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114898. private _onGamepadConnectedEvent;
  114899. private _onGamepadDisconnectedEvent;
  114900. /**
  114901. * Initializes the gamepad manager
  114902. * @param _scene BabylonJS scene
  114903. */
  114904. constructor(_scene?: Scene | undefined);
  114905. /**
  114906. * The gamepads in the game pad manager
  114907. */
  114908. get gamepads(): Gamepad[];
  114909. /**
  114910. * Get the gamepad controllers based on type
  114911. * @param type The type of gamepad controller
  114912. * @returns Nullable gamepad
  114913. */
  114914. getGamepadByType(type?: number): Nullable<Gamepad>;
  114915. /**
  114916. * Disposes the gamepad manager
  114917. */
  114918. dispose(): void;
  114919. private _addNewGamepad;
  114920. private _startMonitoringGamepads;
  114921. private _stopMonitoringGamepads;
  114922. /** @hidden */
  114923. _checkGamepadsStatus(): void;
  114924. private _updateGamepadObjects;
  114925. }
  114926. }
  114927. declare module BABYLON {
  114928. interface Scene {
  114929. /** @hidden */
  114930. _gamepadManager: Nullable<GamepadManager>;
  114931. /**
  114932. * Gets the gamepad manager associated with the scene
  114933. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114934. */
  114935. gamepadManager: GamepadManager;
  114936. }
  114937. /**
  114938. * Interface representing a free camera inputs manager
  114939. */
  114940. interface FreeCameraInputsManager {
  114941. /**
  114942. * Adds gamepad input support to the FreeCameraInputsManager.
  114943. * @returns the FreeCameraInputsManager
  114944. */
  114945. addGamepad(): FreeCameraInputsManager;
  114946. }
  114947. /**
  114948. * Interface representing an arc rotate camera inputs manager
  114949. */
  114950. interface ArcRotateCameraInputsManager {
  114951. /**
  114952. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114953. * @returns the camera inputs manager
  114954. */
  114955. addGamepad(): ArcRotateCameraInputsManager;
  114956. }
  114957. /**
  114958. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114959. */
  114960. export class GamepadSystemSceneComponent implements ISceneComponent {
  114961. /**
  114962. * The component name helpfull to identify the component in the list of scene components.
  114963. */
  114964. readonly name: string;
  114965. /**
  114966. * The scene the component belongs to.
  114967. */
  114968. scene: Scene;
  114969. /**
  114970. * Creates a new instance of the component for the given scene
  114971. * @param scene Defines the scene to register the component in
  114972. */
  114973. constructor(scene: Scene);
  114974. /**
  114975. * Registers the component in a given scene
  114976. */
  114977. register(): void;
  114978. /**
  114979. * Rebuilds the elements related to this component in case of
  114980. * context lost for instance.
  114981. */
  114982. rebuild(): void;
  114983. /**
  114984. * Disposes the component and the associated ressources
  114985. */
  114986. dispose(): void;
  114987. private _beforeCameraUpdate;
  114988. }
  114989. }
  114990. declare module BABYLON {
  114991. /**
  114992. * 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,
  114993. * which still works and will still be found in many Playgrounds.
  114994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114995. */
  114996. export class UniversalCamera extends TouchCamera {
  114997. /**
  114998. * Defines the gamepad rotation sensiblity.
  114999. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115000. */
  115001. get gamepadAngularSensibility(): number;
  115002. set gamepadAngularSensibility(value: number);
  115003. /**
  115004. * Defines the gamepad move sensiblity.
  115005. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115006. */
  115007. get gamepadMoveSensibility(): number;
  115008. set gamepadMoveSensibility(value: number);
  115009. /**
  115010. * 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,
  115011. * which still works and will still be found in many Playgrounds.
  115012. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115013. * @param name Define the name of the camera in the scene
  115014. * @param position Define the start position of the camera in the scene
  115015. * @param scene Define the scene the camera belongs to
  115016. */
  115017. constructor(name: string, position: Vector3, scene: Scene);
  115018. /**
  115019. * Gets the current object class name.
  115020. * @return the class name
  115021. */
  115022. getClassName(): string;
  115023. }
  115024. }
  115025. declare module BABYLON {
  115026. /**
  115027. * This represents a FPS type of camera. This is only here for back compat purpose.
  115028. * Please use the UniversalCamera instead as both are identical.
  115029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115030. */
  115031. export class GamepadCamera extends UniversalCamera {
  115032. /**
  115033. * Instantiates a new Gamepad Camera
  115034. * This represents a FPS type of camera. This is only here for back compat purpose.
  115035. * Please use the UniversalCamera instead as both are identical.
  115036. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115037. * @param name Define the name of the camera in the scene
  115038. * @param position Define the start position of the camera in the scene
  115039. * @param scene Define the scene the camera belongs to
  115040. */
  115041. constructor(name: string, position: Vector3, scene: Scene);
  115042. /**
  115043. * Gets the current object class name.
  115044. * @return the class name
  115045. */
  115046. getClassName(): string;
  115047. }
  115048. }
  115049. declare module BABYLON {
  115050. /** @hidden */
  115051. export var passPixelShader: {
  115052. name: string;
  115053. shader: string;
  115054. };
  115055. }
  115056. declare module BABYLON {
  115057. /** @hidden */
  115058. export var passCubePixelShader: {
  115059. name: string;
  115060. shader: string;
  115061. };
  115062. }
  115063. declare module BABYLON {
  115064. /**
  115065. * PassPostProcess which produces an output the same as it's input
  115066. */
  115067. export class PassPostProcess extends PostProcess {
  115068. /**
  115069. * Creates the PassPostProcess
  115070. * @param name The name of the effect.
  115071. * @param options The required width/height ratio to downsize to before computing the render pass.
  115072. * @param camera The camera to apply the render pass to.
  115073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115074. * @param engine The engine which the post process will be applied. (default: current engine)
  115075. * @param reusable If the post process can be reused on the same frame. (default: false)
  115076. * @param textureType The type of texture to be used when performing the post processing.
  115077. * @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)
  115078. */
  115079. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115080. }
  115081. /**
  115082. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  115083. */
  115084. export class PassCubePostProcess extends PostProcess {
  115085. private _face;
  115086. /**
  115087. * Gets or sets the cube face to display.
  115088. * * 0 is +X
  115089. * * 1 is -X
  115090. * * 2 is +Y
  115091. * * 3 is -Y
  115092. * * 4 is +Z
  115093. * * 5 is -Z
  115094. */
  115095. get face(): number;
  115096. set face(value: number);
  115097. /**
  115098. * Creates the PassCubePostProcess
  115099. * @param name The name of the effect.
  115100. * @param options The required width/height ratio to downsize to before computing the render pass.
  115101. * @param camera The camera to apply the render pass to.
  115102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115103. * @param engine The engine which the post process will be applied. (default: current engine)
  115104. * @param reusable If the post process can be reused on the same frame. (default: false)
  115105. * @param textureType The type of texture to be used when performing the post processing.
  115106. * @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)
  115107. */
  115108. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115109. }
  115110. }
  115111. declare module BABYLON {
  115112. /** @hidden */
  115113. export var anaglyphPixelShader: {
  115114. name: string;
  115115. shader: string;
  115116. };
  115117. }
  115118. declare module BABYLON {
  115119. /**
  115120. * Postprocess used to generate anaglyphic rendering
  115121. */
  115122. export class AnaglyphPostProcess extends PostProcess {
  115123. private _passedProcess;
  115124. /**
  115125. * Creates a new AnaglyphPostProcess
  115126. * @param name defines postprocess name
  115127. * @param options defines creation options or target ratio scale
  115128. * @param rigCameras defines cameras using this postprocess
  115129. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115130. * @param engine defines hosting engine
  115131. * @param reusable defines if the postprocess will be reused multiple times per frame
  115132. */
  115133. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115134. }
  115135. }
  115136. declare module BABYLON {
  115137. /**
  115138. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115139. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115140. */
  115141. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115142. /**
  115143. * Creates a new AnaglyphArcRotateCamera
  115144. * @param name defines camera name
  115145. * @param alpha defines alpha angle (in radians)
  115146. * @param beta defines beta angle (in radians)
  115147. * @param radius defines radius
  115148. * @param target defines camera target
  115149. * @param interaxialDistance defines distance between each color axis
  115150. * @param scene defines the hosting scene
  115151. */
  115152. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115153. /**
  115154. * Gets camera class name
  115155. * @returns AnaglyphArcRotateCamera
  115156. */
  115157. getClassName(): string;
  115158. }
  115159. }
  115160. declare module BABYLON {
  115161. /**
  115162. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115163. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115164. */
  115165. export class AnaglyphFreeCamera extends FreeCamera {
  115166. /**
  115167. * Creates a new AnaglyphFreeCamera
  115168. * @param name defines camera name
  115169. * @param position defines initial position
  115170. * @param interaxialDistance defines distance between each color axis
  115171. * @param scene defines the hosting scene
  115172. */
  115173. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115174. /**
  115175. * Gets camera class name
  115176. * @returns AnaglyphFreeCamera
  115177. */
  115178. getClassName(): string;
  115179. }
  115180. }
  115181. declare module BABYLON {
  115182. /**
  115183. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115184. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115185. */
  115186. export class AnaglyphGamepadCamera extends GamepadCamera {
  115187. /**
  115188. * Creates a new AnaglyphGamepadCamera
  115189. * @param name defines camera name
  115190. * @param position defines initial position
  115191. * @param interaxialDistance defines distance between each color axis
  115192. * @param scene defines the hosting scene
  115193. */
  115194. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115195. /**
  115196. * Gets camera class name
  115197. * @returns AnaglyphGamepadCamera
  115198. */
  115199. getClassName(): string;
  115200. }
  115201. }
  115202. declare module BABYLON {
  115203. /**
  115204. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115205. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115206. */
  115207. export class AnaglyphUniversalCamera extends UniversalCamera {
  115208. /**
  115209. * Creates a new AnaglyphUniversalCamera
  115210. * @param name defines camera name
  115211. * @param position defines initial position
  115212. * @param interaxialDistance defines distance between each color axis
  115213. * @param scene defines the hosting scene
  115214. */
  115215. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115216. /**
  115217. * Gets camera class name
  115218. * @returns AnaglyphUniversalCamera
  115219. */
  115220. getClassName(): string;
  115221. }
  115222. }
  115223. declare module BABYLON {
  115224. /** @hidden */
  115225. export var stereoscopicInterlacePixelShader: {
  115226. name: string;
  115227. shader: string;
  115228. };
  115229. }
  115230. declare module BABYLON {
  115231. /**
  115232. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115233. */
  115234. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115235. private _stepSize;
  115236. private _passedProcess;
  115237. /**
  115238. * Initializes a StereoscopicInterlacePostProcessI
  115239. * @param name The name of the effect.
  115240. * @param rigCameras The rig cameras to be appled to the post process
  115241. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115242. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115244. * @param engine The engine which the post process will be applied. (default: current engine)
  115245. * @param reusable If the post process can be reused on the same frame. (default: false)
  115246. */
  115247. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115248. }
  115249. /**
  115250. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115251. */
  115252. export class StereoscopicInterlacePostProcess extends PostProcess {
  115253. private _stepSize;
  115254. private _passedProcess;
  115255. /**
  115256. * Initializes a StereoscopicInterlacePostProcess
  115257. * @param name The name of the effect.
  115258. * @param rigCameras The rig cameras to be appled to the post process
  115259. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115261. * @param engine The engine which the post process will be applied. (default: current engine)
  115262. * @param reusable If the post process can be reused on the same frame. (default: false)
  115263. */
  115264. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115265. }
  115266. }
  115267. declare module BABYLON {
  115268. /**
  115269. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115270. * @see http://doc.babylonjs.com/features/cameras
  115271. */
  115272. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115273. /**
  115274. * Creates a new StereoscopicArcRotateCamera
  115275. * @param name defines camera name
  115276. * @param alpha defines alpha angle (in radians)
  115277. * @param beta defines beta angle (in radians)
  115278. * @param radius defines radius
  115279. * @param target defines camera target
  115280. * @param interaxialDistance defines distance between each color axis
  115281. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115282. * @param scene defines the hosting scene
  115283. */
  115284. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115285. /**
  115286. * Gets camera class name
  115287. * @returns StereoscopicArcRotateCamera
  115288. */
  115289. getClassName(): string;
  115290. }
  115291. }
  115292. declare module BABYLON {
  115293. /**
  115294. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115295. * @see http://doc.babylonjs.com/features/cameras
  115296. */
  115297. export class StereoscopicFreeCamera extends FreeCamera {
  115298. /**
  115299. * Creates a new StereoscopicFreeCamera
  115300. * @param name defines camera name
  115301. * @param position defines initial position
  115302. * @param interaxialDistance defines distance between each color axis
  115303. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115304. * @param scene defines the hosting scene
  115305. */
  115306. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115307. /**
  115308. * Gets camera class name
  115309. * @returns StereoscopicFreeCamera
  115310. */
  115311. getClassName(): string;
  115312. }
  115313. }
  115314. declare module BABYLON {
  115315. /**
  115316. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115317. * @see http://doc.babylonjs.com/features/cameras
  115318. */
  115319. export class StereoscopicGamepadCamera extends GamepadCamera {
  115320. /**
  115321. * Creates a new StereoscopicGamepadCamera
  115322. * @param name defines camera name
  115323. * @param position defines initial position
  115324. * @param interaxialDistance defines distance between each color axis
  115325. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115326. * @param scene defines the hosting scene
  115327. */
  115328. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115329. /**
  115330. * Gets camera class name
  115331. * @returns StereoscopicGamepadCamera
  115332. */
  115333. getClassName(): string;
  115334. }
  115335. }
  115336. declare module BABYLON {
  115337. /**
  115338. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115339. * @see http://doc.babylonjs.com/features/cameras
  115340. */
  115341. export class StereoscopicUniversalCamera extends UniversalCamera {
  115342. /**
  115343. * Creates a new StereoscopicUniversalCamera
  115344. * @param name defines camera name
  115345. * @param position defines initial position
  115346. * @param interaxialDistance defines distance between each color axis
  115347. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115348. * @param scene defines the hosting scene
  115349. */
  115350. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115351. /**
  115352. * Gets camera class name
  115353. * @returns StereoscopicUniversalCamera
  115354. */
  115355. getClassName(): string;
  115356. }
  115357. }
  115358. declare module BABYLON {
  115359. /**
  115360. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115361. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115362. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115363. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115364. */
  115365. export class VirtualJoysticksCamera extends FreeCamera {
  115366. /**
  115367. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115368. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115369. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115370. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115371. * @param name Define the name of the camera in the scene
  115372. * @param position Define the start position of the camera in the scene
  115373. * @param scene Define the scene the camera belongs to
  115374. */
  115375. constructor(name: string, position: Vector3, scene: Scene);
  115376. /**
  115377. * Gets the current object class name.
  115378. * @return the class name
  115379. */
  115380. getClassName(): string;
  115381. }
  115382. }
  115383. declare module BABYLON {
  115384. /**
  115385. * This represents all the required metrics to create a VR camera.
  115386. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115387. */
  115388. export class VRCameraMetrics {
  115389. /**
  115390. * Define the horizontal resolution off the screen.
  115391. */
  115392. hResolution: number;
  115393. /**
  115394. * Define the vertical resolution off the screen.
  115395. */
  115396. vResolution: number;
  115397. /**
  115398. * Define the horizontal screen size.
  115399. */
  115400. hScreenSize: number;
  115401. /**
  115402. * Define the vertical screen size.
  115403. */
  115404. vScreenSize: number;
  115405. /**
  115406. * Define the vertical screen center position.
  115407. */
  115408. vScreenCenter: number;
  115409. /**
  115410. * Define the distance of the eyes to the screen.
  115411. */
  115412. eyeToScreenDistance: number;
  115413. /**
  115414. * Define the distance between both lenses
  115415. */
  115416. lensSeparationDistance: number;
  115417. /**
  115418. * Define the distance between both viewer's eyes.
  115419. */
  115420. interpupillaryDistance: number;
  115421. /**
  115422. * Define the distortion factor of the VR postprocess.
  115423. * Please, touch with care.
  115424. */
  115425. distortionK: number[];
  115426. /**
  115427. * Define the chromatic aberration correction factors for the VR post process.
  115428. */
  115429. chromaAbCorrection: number[];
  115430. /**
  115431. * Define the scale factor of the post process.
  115432. * The smaller the better but the slower.
  115433. */
  115434. postProcessScaleFactor: number;
  115435. /**
  115436. * Define an offset for the lens center.
  115437. */
  115438. lensCenterOffset: number;
  115439. /**
  115440. * Define if the current vr camera should compensate the distortion of the lense or not.
  115441. */
  115442. compensateDistortion: boolean;
  115443. /**
  115444. * Defines if multiview should be enabled when rendering (Default: false)
  115445. */
  115446. multiviewEnabled: boolean;
  115447. /**
  115448. * Gets the rendering aspect ratio based on the provided resolutions.
  115449. */
  115450. get aspectRatio(): number;
  115451. /**
  115452. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115453. */
  115454. get aspectRatioFov(): number;
  115455. /**
  115456. * @hidden
  115457. */
  115458. get leftHMatrix(): Matrix;
  115459. /**
  115460. * @hidden
  115461. */
  115462. get rightHMatrix(): Matrix;
  115463. /**
  115464. * @hidden
  115465. */
  115466. get leftPreViewMatrix(): Matrix;
  115467. /**
  115468. * @hidden
  115469. */
  115470. get rightPreViewMatrix(): Matrix;
  115471. /**
  115472. * Get the default VRMetrics based on the most generic setup.
  115473. * @returns the default vr metrics
  115474. */
  115475. static GetDefault(): VRCameraMetrics;
  115476. }
  115477. }
  115478. declare module BABYLON {
  115479. /** @hidden */
  115480. export var vrDistortionCorrectionPixelShader: {
  115481. name: string;
  115482. shader: string;
  115483. };
  115484. }
  115485. declare module BABYLON {
  115486. /**
  115487. * VRDistortionCorrectionPostProcess used for mobile VR
  115488. */
  115489. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115490. private _isRightEye;
  115491. private _distortionFactors;
  115492. private _postProcessScaleFactor;
  115493. private _lensCenterOffset;
  115494. private _scaleIn;
  115495. private _scaleFactor;
  115496. private _lensCenter;
  115497. /**
  115498. * Initializes the VRDistortionCorrectionPostProcess
  115499. * @param name The name of the effect.
  115500. * @param camera The camera to apply the render pass to.
  115501. * @param isRightEye If this is for the right eye distortion
  115502. * @param vrMetrics All the required metrics for the VR camera
  115503. */
  115504. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115505. }
  115506. }
  115507. declare module BABYLON {
  115508. /**
  115509. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115510. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115511. */
  115512. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115513. /**
  115514. * Creates a new VRDeviceOrientationArcRotateCamera
  115515. * @param name defines camera name
  115516. * @param alpha defines the camera rotation along the logitudinal axis
  115517. * @param beta defines the camera rotation along the latitudinal axis
  115518. * @param radius defines the camera distance from its target
  115519. * @param target defines the camera target
  115520. * @param scene defines the scene the camera belongs to
  115521. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115522. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115523. */
  115524. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115525. /**
  115526. * Gets camera class name
  115527. * @returns VRDeviceOrientationArcRotateCamera
  115528. */
  115529. getClassName(): string;
  115530. }
  115531. }
  115532. declare module BABYLON {
  115533. /**
  115534. * Camera used to simulate VR rendering (based on FreeCamera)
  115535. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115536. */
  115537. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115538. /**
  115539. * Creates a new VRDeviceOrientationFreeCamera
  115540. * @param name defines camera name
  115541. * @param position defines the start position of the camera
  115542. * @param scene defines the scene the camera belongs to
  115543. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115544. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115545. */
  115546. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115547. /**
  115548. * Gets camera class name
  115549. * @returns VRDeviceOrientationFreeCamera
  115550. */
  115551. getClassName(): string;
  115552. }
  115553. }
  115554. declare module BABYLON {
  115555. /**
  115556. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115557. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115558. */
  115559. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115560. /**
  115561. * Creates a new VRDeviceOrientationGamepadCamera
  115562. * @param name defines camera name
  115563. * @param position defines the start position of the camera
  115564. * @param scene defines the scene the camera belongs to
  115565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115567. */
  115568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115569. /**
  115570. * Gets camera class name
  115571. * @returns VRDeviceOrientationGamepadCamera
  115572. */
  115573. getClassName(): string;
  115574. }
  115575. }
  115576. declare module BABYLON {
  115577. /** @hidden */
  115578. export var imageProcessingPixelShader: {
  115579. name: string;
  115580. shader: string;
  115581. };
  115582. }
  115583. declare module BABYLON {
  115584. /**
  115585. * ImageProcessingPostProcess
  115586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115587. */
  115588. export class ImageProcessingPostProcess extends PostProcess {
  115589. /**
  115590. * Default configuration related to image processing available in the PBR Material.
  115591. */
  115592. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115593. /**
  115594. * Gets the image processing configuration used either in this material.
  115595. */
  115596. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115597. /**
  115598. * Sets the Default image processing configuration used either in the this material.
  115599. *
  115600. * If sets to null, the scene one is in use.
  115601. */
  115602. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115603. /**
  115604. * Keep track of the image processing observer to allow dispose and replace.
  115605. */
  115606. private _imageProcessingObserver;
  115607. /**
  115608. * Attaches a new image processing configuration to the PBR Material.
  115609. * @param configuration
  115610. */
  115611. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115612. /**
  115613. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115614. */
  115615. get colorCurves(): Nullable<ColorCurves>;
  115616. /**
  115617. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115618. */
  115619. set colorCurves(value: Nullable<ColorCurves>);
  115620. /**
  115621. * Gets wether the color curves effect is enabled.
  115622. */
  115623. get colorCurvesEnabled(): boolean;
  115624. /**
  115625. * Sets wether the color curves effect is enabled.
  115626. */
  115627. set colorCurvesEnabled(value: boolean);
  115628. /**
  115629. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115630. */
  115631. get colorGradingTexture(): Nullable<BaseTexture>;
  115632. /**
  115633. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115634. */
  115635. set colorGradingTexture(value: Nullable<BaseTexture>);
  115636. /**
  115637. * Gets wether the color grading effect is enabled.
  115638. */
  115639. get colorGradingEnabled(): boolean;
  115640. /**
  115641. * Gets wether the color grading effect is enabled.
  115642. */
  115643. set colorGradingEnabled(value: boolean);
  115644. /**
  115645. * Gets exposure used in the effect.
  115646. */
  115647. get exposure(): number;
  115648. /**
  115649. * Sets exposure used in the effect.
  115650. */
  115651. set exposure(value: number);
  115652. /**
  115653. * Gets wether tonemapping is enabled or not.
  115654. */
  115655. get toneMappingEnabled(): boolean;
  115656. /**
  115657. * Sets wether tonemapping is enabled or not
  115658. */
  115659. set toneMappingEnabled(value: boolean);
  115660. /**
  115661. * Gets the type of tone mapping effect.
  115662. */
  115663. get toneMappingType(): number;
  115664. /**
  115665. * Sets the type of tone mapping effect.
  115666. */
  115667. set toneMappingType(value: number);
  115668. /**
  115669. * Gets contrast used in the effect.
  115670. */
  115671. get contrast(): number;
  115672. /**
  115673. * Sets contrast used in the effect.
  115674. */
  115675. set contrast(value: number);
  115676. /**
  115677. * Gets Vignette stretch size.
  115678. */
  115679. get vignetteStretch(): number;
  115680. /**
  115681. * Sets Vignette stretch size.
  115682. */
  115683. set vignetteStretch(value: number);
  115684. /**
  115685. * Gets Vignette centre X Offset.
  115686. */
  115687. get vignetteCentreX(): number;
  115688. /**
  115689. * Sets Vignette centre X Offset.
  115690. */
  115691. set vignetteCentreX(value: number);
  115692. /**
  115693. * Gets Vignette centre Y Offset.
  115694. */
  115695. get vignetteCentreY(): number;
  115696. /**
  115697. * Sets Vignette centre Y Offset.
  115698. */
  115699. set vignetteCentreY(value: number);
  115700. /**
  115701. * Gets Vignette weight or intensity of the vignette effect.
  115702. */
  115703. get vignetteWeight(): number;
  115704. /**
  115705. * Sets Vignette weight or intensity of the vignette effect.
  115706. */
  115707. set vignetteWeight(value: number);
  115708. /**
  115709. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115710. * if vignetteEnabled is set to true.
  115711. */
  115712. get vignetteColor(): Color4;
  115713. /**
  115714. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115715. * if vignetteEnabled is set to true.
  115716. */
  115717. set vignetteColor(value: Color4);
  115718. /**
  115719. * Gets Camera field of view used by the Vignette effect.
  115720. */
  115721. get vignetteCameraFov(): number;
  115722. /**
  115723. * Sets Camera field of view used by the Vignette effect.
  115724. */
  115725. set vignetteCameraFov(value: number);
  115726. /**
  115727. * Gets the vignette blend mode allowing different kind of effect.
  115728. */
  115729. get vignetteBlendMode(): number;
  115730. /**
  115731. * Sets the vignette blend mode allowing different kind of effect.
  115732. */
  115733. set vignetteBlendMode(value: number);
  115734. /**
  115735. * Gets wether the vignette effect is enabled.
  115736. */
  115737. get vignetteEnabled(): boolean;
  115738. /**
  115739. * Sets wether the vignette effect is enabled.
  115740. */
  115741. set vignetteEnabled(value: boolean);
  115742. private _fromLinearSpace;
  115743. /**
  115744. * Gets wether the input of the processing is in Gamma or Linear Space.
  115745. */
  115746. get fromLinearSpace(): boolean;
  115747. /**
  115748. * Sets wether the input of the processing is in Gamma or Linear Space.
  115749. */
  115750. set fromLinearSpace(value: boolean);
  115751. /**
  115752. * Defines cache preventing GC.
  115753. */
  115754. private _defines;
  115755. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115756. /**
  115757. * "ImageProcessingPostProcess"
  115758. * @returns "ImageProcessingPostProcess"
  115759. */
  115760. getClassName(): string;
  115761. protected _updateParameters(): void;
  115762. dispose(camera?: Camera): void;
  115763. }
  115764. }
  115765. declare module BABYLON {
  115766. /**
  115767. * Class containing static functions to help procedurally build meshes
  115768. */
  115769. export class GroundBuilder {
  115770. /**
  115771. * Creates a ground mesh
  115772. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115773. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115775. * @param name defines the name of the mesh
  115776. * @param options defines the options used to create the mesh
  115777. * @param scene defines the hosting scene
  115778. * @returns the ground mesh
  115779. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115780. */
  115781. static CreateGround(name: string, options: {
  115782. width?: number;
  115783. height?: number;
  115784. subdivisions?: number;
  115785. subdivisionsX?: number;
  115786. subdivisionsY?: number;
  115787. updatable?: boolean;
  115788. }, scene: any): Mesh;
  115789. /**
  115790. * Creates a tiled ground mesh
  115791. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115792. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115793. * * 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
  115794. * * 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
  115795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115796. * @param name defines the name of the mesh
  115797. * @param options defines the options used to create the mesh
  115798. * @param scene defines the hosting scene
  115799. * @returns the tiled ground mesh
  115800. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115801. */
  115802. static CreateTiledGround(name: string, options: {
  115803. xmin: number;
  115804. zmin: number;
  115805. xmax: number;
  115806. zmax: number;
  115807. subdivisions?: {
  115808. w: number;
  115809. h: number;
  115810. };
  115811. precision?: {
  115812. w: number;
  115813. h: number;
  115814. };
  115815. updatable?: boolean;
  115816. }, scene?: Nullable<Scene>): Mesh;
  115817. /**
  115818. * Creates a ground mesh from a height map
  115819. * * The parameter `url` sets the URL of the height map image resource.
  115820. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115821. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115822. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115823. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115824. * * 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.
  115825. * * 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).
  115826. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115828. * @param name defines the name of the mesh
  115829. * @param url defines the url to the height map
  115830. * @param options defines the options used to create the mesh
  115831. * @param scene defines the hosting scene
  115832. * @returns the ground mesh
  115833. * @see https://doc.babylonjs.com/babylon101/height_map
  115834. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115835. */
  115836. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115837. width?: number;
  115838. height?: number;
  115839. subdivisions?: number;
  115840. minHeight?: number;
  115841. maxHeight?: number;
  115842. colorFilter?: Color3;
  115843. alphaFilter?: number;
  115844. updatable?: boolean;
  115845. onReady?: (mesh: GroundMesh) => void;
  115846. }, scene?: Nullable<Scene>): GroundMesh;
  115847. }
  115848. }
  115849. declare module BABYLON {
  115850. /**
  115851. * Class containing static functions to help procedurally build meshes
  115852. */
  115853. export class TorusBuilder {
  115854. /**
  115855. * Creates a torus mesh
  115856. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115857. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115858. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115862. * @param name defines the name of the mesh
  115863. * @param options defines the options used to create the mesh
  115864. * @param scene defines the hosting scene
  115865. * @returns the torus mesh
  115866. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115867. */
  115868. static CreateTorus(name: string, options: {
  115869. diameter?: number;
  115870. thickness?: number;
  115871. tessellation?: number;
  115872. updatable?: boolean;
  115873. sideOrientation?: number;
  115874. frontUVs?: Vector4;
  115875. backUVs?: Vector4;
  115876. }, scene: any): Mesh;
  115877. }
  115878. }
  115879. declare module BABYLON {
  115880. /**
  115881. * Class containing static functions to help procedurally build meshes
  115882. */
  115883. export class CylinderBuilder {
  115884. /**
  115885. * Creates a cylinder or a cone mesh
  115886. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115887. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115888. * * 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.
  115889. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115890. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115891. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115892. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115893. * * 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).
  115894. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115895. * * 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).
  115896. * * 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
  115897. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115898. * * 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
  115899. * * 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.
  115900. * * If `enclose` is false, a ring surface is one element.
  115901. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115902. * * 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
  115903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115906. * @param name defines the name of the mesh
  115907. * @param options defines the options used to create the mesh
  115908. * @param scene defines the hosting scene
  115909. * @returns the cylinder mesh
  115910. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115911. */
  115912. static CreateCylinder(name: string, options: {
  115913. height?: number;
  115914. diameterTop?: number;
  115915. diameterBottom?: number;
  115916. diameter?: number;
  115917. tessellation?: number;
  115918. subdivisions?: number;
  115919. arc?: number;
  115920. faceColors?: Color4[];
  115921. faceUV?: Vector4[];
  115922. updatable?: boolean;
  115923. hasRings?: boolean;
  115924. enclose?: boolean;
  115925. cap?: number;
  115926. sideOrientation?: number;
  115927. frontUVs?: Vector4;
  115928. backUVs?: Vector4;
  115929. }, scene: any): Mesh;
  115930. }
  115931. }
  115932. declare module BABYLON {
  115933. /**
  115934. * States of the webXR experience
  115935. */
  115936. export enum WebXRState {
  115937. /**
  115938. * Transitioning to being in XR mode
  115939. */
  115940. ENTERING_XR = 0,
  115941. /**
  115942. * Transitioning to non XR mode
  115943. */
  115944. EXITING_XR = 1,
  115945. /**
  115946. * In XR mode and presenting
  115947. */
  115948. IN_XR = 2,
  115949. /**
  115950. * Not entered XR mode
  115951. */
  115952. NOT_IN_XR = 3
  115953. }
  115954. /**
  115955. * Abstraction of the XR render target
  115956. */
  115957. export interface WebXRRenderTarget extends IDisposable {
  115958. /**
  115959. * xrpresent context of the canvas which can be used to display/mirror xr content
  115960. */
  115961. canvasContext: WebGLRenderingContext;
  115962. /**
  115963. * xr layer for the canvas
  115964. */
  115965. xrLayer: Nullable<XRWebGLLayer>;
  115966. /**
  115967. * Initializes the xr layer for the session
  115968. * @param xrSession xr session
  115969. * @returns a promise that will resolve once the XR Layer has been created
  115970. */
  115971. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115972. }
  115973. }
  115974. declare module BABYLON {
  115975. /**
  115976. * COnfiguration object for WebXR output canvas
  115977. */
  115978. export class WebXRManagedOutputCanvasOptions {
  115979. /**
  115980. * An optional canvas in case you wish to create it yourself and provide it here.
  115981. * If not provided, a new canvas will be created
  115982. */
  115983. canvasElement?: HTMLCanvasElement;
  115984. /**
  115985. * Options for this XR Layer output
  115986. */
  115987. canvasOptions?: XRWebGLLayerOptions;
  115988. /**
  115989. * CSS styling for a newly created canvas (if not provided)
  115990. */
  115991. newCanvasCssStyle?: string;
  115992. /**
  115993. * Get the default values of the configuration object
  115994. * @returns default values of this configuration object
  115995. */
  115996. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115997. }
  115998. /**
  115999. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  116000. */
  116001. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  116002. private _options;
  116003. private _canvas;
  116004. private _engine;
  116005. /**
  116006. * Rendering context of the canvas which can be used to display/mirror xr content
  116007. */
  116008. canvasContext: WebGLRenderingContext;
  116009. /**
  116010. * xr layer for the canvas
  116011. */
  116012. xrLayer: Nullable<XRWebGLLayer>;
  116013. /**
  116014. * Initializes the canvas to be added/removed upon entering/exiting xr
  116015. * @param _xrSessionManager The XR Session manager
  116016. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  116017. */
  116018. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  116019. /**
  116020. * Disposes of the object
  116021. */
  116022. dispose(): void;
  116023. /**
  116024. * Initializes the xr layer for the session
  116025. * @param xrSession xr session
  116026. * @returns a promise that will resolve once the XR Layer has been created
  116027. */
  116028. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116029. private _addCanvas;
  116030. private _removeCanvas;
  116031. private _setManagedOutputCanvas;
  116032. }
  116033. }
  116034. declare module BABYLON {
  116035. /**
  116036. * Manages an XRSession to work with Babylon's engine
  116037. * @see https://doc.babylonjs.com/how_to/webxr
  116038. */
  116039. export class WebXRSessionManager implements IDisposable {
  116040. /** The scene which the session should be created for */
  116041. scene: Scene;
  116042. private _referenceSpace;
  116043. private _rttProvider;
  116044. private _sessionEnded;
  116045. private _xrNavigator;
  116046. private baseLayer;
  116047. /**
  116048. * The base reference space from which the session started. good if you want to reset your
  116049. * reference space
  116050. */
  116051. baseReferenceSpace: XRReferenceSpace;
  116052. /**
  116053. * Current XR frame
  116054. */
  116055. currentFrame: Nullable<XRFrame>;
  116056. /** WebXR timestamp updated every frame */
  116057. currentTimestamp: number;
  116058. /**
  116059. * Used just in case of a failure to initialize an immersive session.
  116060. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  116061. */
  116062. defaultHeightCompensation: number;
  116063. /**
  116064. * Fires every time a new xrFrame arrives which can be used to update the camera
  116065. */
  116066. onXRFrameObservable: Observable<XRFrame>;
  116067. /**
  116068. * Fires when the reference space changed
  116069. */
  116070. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  116071. /**
  116072. * Fires when the xr session is ended either by the device or manually done
  116073. */
  116074. onXRSessionEnded: Observable<any>;
  116075. /**
  116076. * Fires when the xr session is ended either by the device or manually done
  116077. */
  116078. onXRSessionInit: Observable<XRSession>;
  116079. /**
  116080. * Underlying xr session
  116081. */
  116082. session: XRSession;
  116083. /**
  116084. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  116085. * or get the offset the player is currently at.
  116086. */
  116087. viewerReferenceSpace: XRReferenceSpace;
  116088. /**
  116089. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  116090. * @param scene The scene which the session should be created for
  116091. */
  116092. constructor(
  116093. /** The scene which the session should be created for */
  116094. scene: Scene);
  116095. /**
  116096. * The current reference space used in this session. This reference space can constantly change!
  116097. * It is mainly used to offset the camera's position.
  116098. */
  116099. get referenceSpace(): XRReferenceSpace;
  116100. /**
  116101. * Set a new reference space and triggers the observable
  116102. */
  116103. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  116104. /**
  116105. * Disposes of the session manager
  116106. */
  116107. dispose(): void;
  116108. /**
  116109. * Stops the xrSession and restores the render loop
  116110. * @returns Promise which resolves after it exits XR
  116111. */
  116112. exitXRAsync(): Promise<void>;
  116113. /**
  116114. * Gets the correct render target texture to be rendered this frame for this eye
  116115. * @param eye the eye for which to get the render target
  116116. * @returns the render target for the specified eye
  116117. */
  116118. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116119. /**
  116120. * Creates a WebXRRenderTarget object for the XR session
  116121. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116122. * @param options optional options to provide when creating a new render target
  116123. * @returns a WebXR render target to which the session can render
  116124. */
  116125. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116126. /**
  116127. * Initializes the manager
  116128. * After initialization enterXR can be called to start an XR session
  116129. * @returns Promise which resolves after it is initialized
  116130. */
  116131. initializeAsync(): Promise<void>;
  116132. /**
  116133. * Initializes an xr session
  116134. * @param xrSessionMode mode to initialize
  116135. * @param xrSessionInit defines optional and required values to pass to the session builder
  116136. * @returns a promise which will resolve once the session has been initialized
  116137. */
  116138. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116139. /**
  116140. * Checks if a session would be supported for the creation options specified
  116141. * @param sessionMode session mode to check if supported eg. immersive-vr
  116142. * @returns A Promise that resolves to true if supported and false if not
  116143. */
  116144. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116145. /**
  116146. * Resets the reference space to the one started the session
  116147. */
  116148. resetReferenceSpace(): void;
  116149. /**
  116150. * Starts rendering to the xr layer
  116151. */
  116152. runXRRenderLoop(): void;
  116153. /**
  116154. * Sets the reference space on the xr session
  116155. * @param referenceSpaceType space to set
  116156. * @returns a promise that will resolve once the reference space has been set
  116157. */
  116158. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116159. /**
  116160. * Updates the render state of the session
  116161. * @param state state to set
  116162. * @returns a promise that resolves once the render state has been updated
  116163. */
  116164. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116165. /**
  116166. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116167. * @param sessionMode defines the session to test
  116168. * @returns a promise with boolean as final value
  116169. */
  116170. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116171. private _createRenderTargetTexture;
  116172. }
  116173. }
  116174. declare module BABYLON {
  116175. /**
  116176. * WebXR Camera which holds the views for the xrSession
  116177. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116178. */
  116179. export class WebXRCamera extends FreeCamera {
  116180. private _xrSessionManager;
  116181. private _firstFrame;
  116182. private _referenceQuaternion;
  116183. private _referencedPosition;
  116184. private _xrInvPositionCache;
  116185. private _xrInvQuaternionCache;
  116186. /**
  116187. * Should position compensation execute on first frame.
  116188. * This is used when copying the position from a native (non XR) camera
  116189. */
  116190. compensateOnFirstFrame: boolean;
  116191. /**
  116192. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116193. * @param name the name of the camera
  116194. * @param scene the scene to add the camera to
  116195. * @param _xrSessionManager a constructed xr session manager
  116196. */
  116197. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116198. /**
  116199. * Return the user's height, unrelated to the current ground.
  116200. * This will be the y position of this camera, when ground level is 0.
  116201. */
  116202. get realWorldHeight(): number;
  116203. /** @hidden */
  116204. _updateForDualEyeDebugging(): void;
  116205. /**
  116206. * Sets this camera's transformation based on a non-vr camera
  116207. * @param otherCamera the non-vr camera to copy the transformation from
  116208. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116209. */
  116210. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116211. /**
  116212. * Gets the current instance class name ("WebXRCamera").
  116213. * @returns the class name
  116214. */
  116215. getClassName(): string;
  116216. private _updateFromXRSession;
  116217. private _updateNumberOfRigCameras;
  116218. private _updateReferenceSpace;
  116219. private _updateReferenceSpaceOffset;
  116220. }
  116221. }
  116222. declare module BABYLON {
  116223. /**
  116224. * Defining the interface required for a (webxr) feature
  116225. */
  116226. export interface IWebXRFeature extends IDisposable {
  116227. /**
  116228. * Is this feature attached
  116229. */
  116230. attached: boolean;
  116231. /**
  116232. * Should auto-attach be disabled?
  116233. */
  116234. disableAutoAttach: boolean;
  116235. /**
  116236. * Attach the feature to the session
  116237. * Will usually be called by the features manager
  116238. *
  116239. * @param force should attachment be forced (even when already attached)
  116240. * @returns true if successful.
  116241. */
  116242. attach(force?: boolean): boolean;
  116243. /**
  116244. * Detach the feature from the session
  116245. * Will usually be called by the features manager
  116246. *
  116247. * @returns true if successful.
  116248. */
  116249. detach(): boolean;
  116250. }
  116251. /**
  116252. * A list of the currently available features without referencing them
  116253. */
  116254. export class WebXRFeatureName {
  116255. /**
  116256. * The name of the anchor system feature
  116257. */
  116258. static ANCHOR_SYSTEM: string;
  116259. /**
  116260. * The name of the background remover feature
  116261. */
  116262. static BACKGROUND_REMOVER: string;
  116263. /**
  116264. * The name of the hit test feature
  116265. */
  116266. static HIT_TEST: string;
  116267. /**
  116268. * physics impostors for xr controllers feature
  116269. */
  116270. static PHYSICS_CONTROLLERS: string;
  116271. /**
  116272. * The name of the plane detection feature
  116273. */
  116274. static PLANE_DETECTION: string;
  116275. /**
  116276. * The name of the pointer selection feature
  116277. */
  116278. static POINTER_SELECTION: string;
  116279. /**
  116280. * The name of the teleportation feature
  116281. */
  116282. static TELEPORTATION: string;
  116283. }
  116284. /**
  116285. * Defining the constructor of a feature. Used to register the modules.
  116286. */
  116287. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116288. /**
  116289. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116290. * It is mainly used in AR sessions.
  116291. *
  116292. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116293. */
  116294. export class WebXRFeaturesManager implements IDisposable {
  116295. private _xrSessionManager;
  116296. private static readonly _AvailableFeatures;
  116297. private _features;
  116298. /**
  116299. * constructs a new features manages.
  116300. *
  116301. * @param _xrSessionManager an instance of WebXRSessionManager
  116302. */
  116303. constructor(_xrSessionManager: WebXRSessionManager);
  116304. /**
  116305. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116306. * Mainly used internally.
  116307. *
  116308. * @param featureName the name of the feature to register
  116309. * @param constructorFunction the function used to construct the module
  116310. * @param version the (babylon) version of the module
  116311. * @param stable is that a stable version of this module
  116312. */
  116313. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116314. /**
  116315. * Returns a constructor of a specific feature.
  116316. *
  116317. * @param featureName the name of the feature to construct
  116318. * @param version the version of the feature to load
  116319. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116320. * @param options optional options provided to the module.
  116321. * @returns a function that, when called, will return a new instance of this feature
  116322. */
  116323. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116324. /**
  116325. * Can be used to return the list of features currently registered
  116326. *
  116327. * @returns an Array of available features
  116328. */
  116329. static GetAvailableFeatures(): string[];
  116330. /**
  116331. * Gets the versions available for a specific feature
  116332. * @param featureName the name of the feature
  116333. * @returns an array with the available versions
  116334. */
  116335. static GetAvailableVersions(featureName: string): string[];
  116336. /**
  116337. * Return the latest unstable version of this feature
  116338. * @param featureName the name of the feature to search
  116339. * @returns the version number. if not found will return -1
  116340. */
  116341. static GetLatestVersionOfFeature(featureName: string): number;
  116342. /**
  116343. * Return the latest stable version of this feature
  116344. * @param featureName the name of the feature to search
  116345. * @returns the version number. if not found will return -1
  116346. */
  116347. static GetStableVersionOfFeature(featureName: string): number;
  116348. /**
  116349. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116350. * Can be used during a session to start a feature
  116351. * @param featureName the name of feature to attach
  116352. */
  116353. attachFeature(featureName: string): void;
  116354. /**
  116355. * Can be used inside a session or when the session ends to detach a specific feature
  116356. * @param featureName the name of the feature to detach
  116357. */
  116358. detachFeature(featureName: string): void;
  116359. /**
  116360. * Used to disable an already-enabled feature
  116361. * The feature will be disposed and will be recreated once enabled.
  116362. * @param featureName the feature to disable
  116363. * @returns true if disable was successful
  116364. */
  116365. disableFeature(featureName: string | {
  116366. Name: string;
  116367. }): boolean;
  116368. /**
  116369. * dispose this features manager
  116370. */
  116371. dispose(): void;
  116372. /**
  116373. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  116374. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  116375. *
  116376. * @param featureName the name of the feature to load or the class of the feature
  116377. * @param version optional version to load. if not provided the latest version will be enabled
  116378. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116379. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116380. * @returns a new constructed feature or throws an error if feature not found.
  116381. */
  116382. enableFeature(featureName: string | {
  116383. Name: string;
  116384. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116385. /**
  116386. * get the implementation of an enabled feature.
  116387. * @param featureName the name of the feature to load
  116388. * @returns the feature class, if found
  116389. */
  116390. getEnabledFeature(featureName: string): IWebXRFeature;
  116391. /**
  116392. * Get the list of enabled features
  116393. * @returns an array of enabled features
  116394. */
  116395. getEnabledFeatures(): string[];
  116396. }
  116397. }
  116398. declare module BABYLON {
  116399. /**
  116400. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116401. * @see https://doc.babylonjs.com/how_to/webxr
  116402. */
  116403. export class WebXRExperienceHelper implements IDisposable {
  116404. private scene;
  116405. private _nonVRCamera;
  116406. private _originalSceneAutoClear;
  116407. private _supported;
  116408. /**
  116409. * Camera used to render xr content
  116410. */
  116411. camera: WebXRCamera;
  116412. /** A features manager for this xr session */
  116413. featuresManager: WebXRFeaturesManager;
  116414. /**
  116415. * Observers registered here will be triggered after the camera's initial transformation is set
  116416. * This can be used to set a different ground level or an extra rotation.
  116417. *
  116418. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116419. * to the position set after this observable is done executing.
  116420. */
  116421. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116422. /**
  116423. * Fires when the state of the experience helper has changed
  116424. */
  116425. onStateChangedObservable: Observable<WebXRState>;
  116426. /** Session manager used to keep track of xr session */
  116427. sessionManager: WebXRSessionManager;
  116428. /**
  116429. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116430. */
  116431. state: WebXRState;
  116432. /**
  116433. * Creates a WebXRExperienceHelper
  116434. * @param scene The scene the helper should be created in
  116435. */
  116436. private constructor();
  116437. /**
  116438. * Creates the experience helper
  116439. * @param scene the scene to attach the experience helper to
  116440. * @returns a promise for the experience helper
  116441. */
  116442. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116443. /**
  116444. * Disposes of the experience helper
  116445. */
  116446. dispose(): void;
  116447. /**
  116448. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116449. * @param sessionMode options for the XR session
  116450. * @param referenceSpaceType frame of reference of the XR session
  116451. * @param renderTarget the output canvas that will be used to enter XR mode
  116452. * @returns promise that resolves after xr mode has entered
  116453. */
  116454. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116455. /**
  116456. * Exits XR mode and returns the scene to its original state
  116457. * @returns promise that resolves after xr mode has exited
  116458. */
  116459. exitXRAsync(): Promise<void>;
  116460. private _nonXRToXRCamera;
  116461. private _setState;
  116462. }
  116463. }
  116464. declare module BABYLON {
  116465. /**
  116466. * X-Y values for axes in WebXR
  116467. */
  116468. export interface IWebXRMotionControllerAxesValue {
  116469. /**
  116470. * The value of the x axis
  116471. */
  116472. x: number;
  116473. /**
  116474. * The value of the y-axis
  116475. */
  116476. y: number;
  116477. }
  116478. /**
  116479. * changed / previous values for the values of this component
  116480. */
  116481. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116482. /**
  116483. * current (this frame) value
  116484. */
  116485. current: T;
  116486. /**
  116487. * previous (last change) value
  116488. */
  116489. previous: T;
  116490. }
  116491. /**
  116492. * Represents changes in the component between current frame and last values recorded
  116493. */
  116494. export interface IWebXRMotionControllerComponentChanges {
  116495. /**
  116496. * will be populated with previous and current values if axes changed
  116497. */
  116498. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116499. /**
  116500. * will be populated with previous and current values if pressed changed
  116501. */
  116502. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116503. /**
  116504. * will be populated with previous and current values if touched changed
  116505. */
  116506. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116507. /**
  116508. * will be populated with previous and current values if value changed
  116509. */
  116510. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116511. }
  116512. /**
  116513. * This class represents a single component (for example button or thumbstick) of a motion controller
  116514. */
  116515. export class WebXRControllerComponent implements IDisposable {
  116516. /**
  116517. * the id of this component
  116518. */
  116519. id: string;
  116520. /**
  116521. * the type of the component
  116522. */
  116523. type: MotionControllerComponentType;
  116524. private _buttonIndex;
  116525. private _axesIndices;
  116526. private _axes;
  116527. private _changes;
  116528. private _currentValue;
  116529. private _hasChanges;
  116530. private _pressed;
  116531. private _touched;
  116532. /**
  116533. * button component type
  116534. */
  116535. static BUTTON_TYPE: MotionControllerComponentType;
  116536. /**
  116537. * squeeze component type
  116538. */
  116539. static SQUEEZE_TYPE: MotionControllerComponentType;
  116540. /**
  116541. * Thumbstick component type
  116542. */
  116543. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116544. /**
  116545. * Touchpad component type
  116546. */
  116547. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116548. /**
  116549. * trigger component type
  116550. */
  116551. static TRIGGER_TYPE: MotionControllerComponentType;
  116552. /**
  116553. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116554. * the axes data changes
  116555. */
  116556. onAxisValueChangedObservable: Observable<{
  116557. x: number;
  116558. y: number;
  116559. }>;
  116560. /**
  116561. * Observers registered here will be triggered when the state of a button changes
  116562. * State change is either pressed / touched / value
  116563. */
  116564. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116565. /**
  116566. * Creates a new component for a motion controller.
  116567. * It is created by the motion controller itself
  116568. *
  116569. * @param id the id of this component
  116570. * @param type the type of the component
  116571. * @param _buttonIndex index in the buttons array of the gamepad
  116572. * @param _axesIndices indices of the values in the axes array of the gamepad
  116573. */
  116574. constructor(
  116575. /**
  116576. * the id of this component
  116577. */
  116578. id: string,
  116579. /**
  116580. * the type of the component
  116581. */
  116582. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116583. /**
  116584. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116585. */
  116586. get axes(): IWebXRMotionControllerAxesValue;
  116587. /**
  116588. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116589. */
  116590. get changes(): IWebXRMotionControllerComponentChanges;
  116591. /**
  116592. * Return whether or not the component changed the last frame
  116593. */
  116594. get hasChanges(): boolean;
  116595. /**
  116596. * is the button currently pressed
  116597. */
  116598. get pressed(): boolean;
  116599. /**
  116600. * is the button currently touched
  116601. */
  116602. get touched(): boolean;
  116603. /**
  116604. * Get the current value of this component
  116605. */
  116606. get value(): number;
  116607. /**
  116608. * Dispose this component
  116609. */
  116610. dispose(): void;
  116611. /**
  116612. * Are there axes correlating to this component
  116613. * @return true is axes data is available
  116614. */
  116615. isAxes(): boolean;
  116616. /**
  116617. * Is this component a button (hence - pressable)
  116618. * @returns true if can be pressed
  116619. */
  116620. isButton(): boolean;
  116621. /**
  116622. * update this component using the gamepad object it is in. Called on every frame
  116623. * @param nativeController the native gamepad controller object
  116624. */
  116625. update(nativeController: IMinimalMotionControllerObject): void;
  116626. }
  116627. }
  116628. declare module BABYLON {
  116629. /**
  116630. * Class used to represent data loading progression
  116631. */
  116632. export class SceneLoaderProgressEvent {
  116633. /** defines if data length to load can be evaluated */
  116634. readonly lengthComputable: boolean;
  116635. /** defines the loaded data length */
  116636. readonly loaded: number;
  116637. /** defines the data length to load */
  116638. readonly total: number;
  116639. /**
  116640. * Create a new progress event
  116641. * @param lengthComputable defines if data length to load can be evaluated
  116642. * @param loaded defines the loaded data length
  116643. * @param total defines the data length to load
  116644. */
  116645. constructor(
  116646. /** defines if data length to load can be evaluated */
  116647. lengthComputable: boolean,
  116648. /** defines the loaded data length */
  116649. loaded: number,
  116650. /** defines the data length to load */
  116651. total: number);
  116652. /**
  116653. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116654. * @param event defines the source event
  116655. * @returns a new SceneLoaderProgressEvent
  116656. */
  116657. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116658. }
  116659. /**
  116660. * Interface used by SceneLoader plugins to define supported file extensions
  116661. */
  116662. export interface ISceneLoaderPluginExtensions {
  116663. /**
  116664. * Defines the list of supported extensions
  116665. */
  116666. [extension: string]: {
  116667. isBinary: boolean;
  116668. };
  116669. }
  116670. /**
  116671. * Interface used by SceneLoader plugin factory
  116672. */
  116673. export interface ISceneLoaderPluginFactory {
  116674. /**
  116675. * Defines the name of the factory
  116676. */
  116677. name: string;
  116678. /**
  116679. * Function called to create a new plugin
  116680. * @return the new plugin
  116681. */
  116682. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116683. /**
  116684. * The callback that returns true if the data can be directly loaded.
  116685. * @param data string containing the file data
  116686. * @returns if the data can be loaded directly
  116687. */
  116688. canDirectLoad?(data: string): boolean;
  116689. }
  116690. /**
  116691. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116692. */
  116693. export interface ISceneLoaderPluginBase {
  116694. /**
  116695. * The friendly name of this plugin.
  116696. */
  116697. name: string;
  116698. /**
  116699. * The file extensions supported by this plugin.
  116700. */
  116701. extensions: string | ISceneLoaderPluginExtensions;
  116702. /**
  116703. * The callback called when loading from a url.
  116704. * @param scene scene loading this url
  116705. * @param url url to load
  116706. * @param onSuccess callback called when the file successfully loads
  116707. * @param onProgress callback called while file is loading (if the server supports this mode)
  116708. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116709. * @param onError callback called when the file fails to load
  116710. * @returns a file request object
  116711. */
  116712. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116713. /**
  116714. * The callback called when loading from a file object.
  116715. * @param scene scene loading this file
  116716. * @param file defines the file to load
  116717. * @param onSuccess defines the callback to call when data is loaded
  116718. * @param onProgress defines the callback to call during loading process
  116719. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116720. * @param onError defines the callback to call when an error occurs
  116721. * @returns a file request object
  116722. */
  116723. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116724. /**
  116725. * The callback that returns true if the data can be directly loaded.
  116726. * @param data string containing the file data
  116727. * @returns if the data can be loaded directly
  116728. */
  116729. canDirectLoad?(data: string): boolean;
  116730. /**
  116731. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116732. * @param scene scene loading this data
  116733. * @param data string containing the data
  116734. * @returns data to pass to the plugin
  116735. */
  116736. directLoad?(scene: Scene, data: string): any;
  116737. /**
  116738. * The callback that allows custom handling of the root url based on the response url.
  116739. * @param rootUrl the original root url
  116740. * @param responseURL the response url if available
  116741. * @returns the new root url
  116742. */
  116743. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116744. }
  116745. /**
  116746. * Interface used to define a SceneLoader plugin
  116747. */
  116748. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116749. /**
  116750. * Import meshes into a scene.
  116751. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116752. * @param scene The scene to import into
  116753. * @param data The data to import
  116754. * @param rootUrl The root url for scene and resources
  116755. * @param meshes The meshes array to import into
  116756. * @param particleSystems The particle systems array to import into
  116757. * @param skeletons The skeletons array to import into
  116758. * @param onError The callback when import fails
  116759. * @returns True if successful or false otherwise
  116760. */
  116761. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116762. /**
  116763. * Load into a scene.
  116764. * @param scene The scene to load into
  116765. * @param data The data to import
  116766. * @param rootUrl The root url for scene and resources
  116767. * @param onError The callback when import fails
  116768. * @returns True if successful or false otherwise
  116769. */
  116770. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116771. /**
  116772. * Load into an asset container.
  116773. * @param scene The scene to load into
  116774. * @param data The data to import
  116775. * @param rootUrl The root url for scene and resources
  116776. * @param onError The callback when import fails
  116777. * @returns The loaded asset container
  116778. */
  116779. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116780. }
  116781. /**
  116782. * Interface used to define an async SceneLoader plugin
  116783. */
  116784. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116785. /**
  116786. * Import meshes into a scene.
  116787. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116788. * @param scene The scene to import into
  116789. * @param data The data to import
  116790. * @param rootUrl The root url for scene and resources
  116791. * @param onProgress The callback when the load progresses
  116792. * @param fileName Defines the name of the file to load
  116793. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116794. */
  116795. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116796. meshes: AbstractMesh[];
  116797. particleSystems: IParticleSystem[];
  116798. skeletons: Skeleton[];
  116799. animationGroups: AnimationGroup[];
  116800. }>;
  116801. /**
  116802. * Load into a scene.
  116803. * @param scene The scene to load into
  116804. * @param data The data to import
  116805. * @param rootUrl The root url for scene and resources
  116806. * @param onProgress The callback when the load progresses
  116807. * @param fileName Defines the name of the file to load
  116808. * @returns Nothing
  116809. */
  116810. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116811. /**
  116812. * Load into an asset container.
  116813. * @param scene The scene to load into
  116814. * @param data The data to import
  116815. * @param rootUrl The root url for scene and resources
  116816. * @param onProgress The callback when the load progresses
  116817. * @param fileName Defines the name of the file to load
  116818. * @returns The loaded asset container
  116819. */
  116820. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116821. }
  116822. /**
  116823. * Mode that determines how to handle old animation groups before loading new ones.
  116824. */
  116825. export enum SceneLoaderAnimationGroupLoadingMode {
  116826. /**
  116827. * Reset all old animations to initial state then dispose them.
  116828. */
  116829. Clean = 0,
  116830. /**
  116831. * Stop all old animations.
  116832. */
  116833. Stop = 1,
  116834. /**
  116835. * Restart old animations from first frame.
  116836. */
  116837. Sync = 2,
  116838. /**
  116839. * Old animations remains untouched.
  116840. */
  116841. NoSync = 3
  116842. }
  116843. /**
  116844. * Class used to load scene from various file formats using registered plugins
  116845. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116846. */
  116847. export class SceneLoader {
  116848. /**
  116849. * No logging while loading
  116850. */
  116851. static readonly NO_LOGGING: number;
  116852. /**
  116853. * Minimal logging while loading
  116854. */
  116855. static readonly MINIMAL_LOGGING: number;
  116856. /**
  116857. * Summary logging while loading
  116858. */
  116859. static readonly SUMMARY_LOGGING: number;
  116860. /**
  116861. * Detailled logging while loading
  116862. */
  116863. static readonly DETAILED_LOGGING: number;
  116864. /**
  116865. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116866. */
  116867. static get ForceFullSceneLoadingForIncremental(): boolean;
  116868. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116869. /**
  116870. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116871. */
  116872. static get ShowLoadingScreen(): boolean;
  116873. static set ShowLoadingScreen(value: boolean);
  116874. /**
  116875. * Defines the current logging level (while loading the scene)
  116876. * @ignorenaming
  116877. */
  116878. static get loggingLevel(): number;
  116879. static set loggingLevel(value: number);
  116880. /**
  116881. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116882. */
  116883. static get CleanBoneMatrixWeights(): boolean;
  116884. static set CleanBoneMatrixWeights(value: boolean);
  116885. /**
  116886. * Event raised when a plugin is used to load a scene
  116887. */
  116888. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116889. private static _registeredPlugins;
  116890. private static _getDefaultPlugin;
  116891. private static _getPluginForExtension;
  116892. private static _getPluginForDirectLoad;
  116893. private static _getPluginForFilename;
  116894. private static _getDirectLoad;
  116895. private static _loadData;
  116896. private static _getFileInfo;
  116897. /**
  116898. * Gets a plugin that can load the given extension
  116899. * @param extension defines the extension to load
  116900. * @returns a plugin or null if none works
  116901. */
  116902. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116903. /**
  116904. * Gets a boolean indicating that the given extension can be loaded
  116905. * @param extension defines the extension to load
  116906. * @returns true if the extension is supported
  116907. */
  116908. static IsPluginForExtensionAvailable(extension: string): boolean;
  116909. /**
  116910. * Adds a new plugin to the list of registered plugins
  116911. * @param plugin defines the plugin to add
  116912. */
  116913. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116914. /**
  116915. * Import meshes into a scene
  116916. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116917. * @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)
  116918. * @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)
  116919. * @param scene the instance of BABYLON.Scene to append to
  116920. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116921. * @param onProgress a callback with a progress event for each file being loaded
  116922. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116923. * @param pluginExtension the extension used to determine the plugin
  116924. * @returns The loaded plugin
  116925. */
  116926. 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>;
  116927. /**
  116928. * Import meshes into a scene
  116929. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116930. * @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)
  116931. * @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)
  116932. * @param scene the instance of BABYLON.Scene to append to
  116933. * @param onProgress a callback with a progress event for each file being loaded
  116934. * @param pluginExtension the extension used to determine the plugin
  116935. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116936. */
  116937. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116938. meshes: AbstractMesh[];
  116939. particleSystems: IParticleSystem[];
  116940. skeletons: Skeleton[];
  116941. animationGroups: AnimationGroup[];
  116942. }>;
  116943. /**
  116944. * Load a scene
  116945. * @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)
  116946. * @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)
  116947. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116948. * @param onSuccess a callback with the scene when import succeeds
  116949. * @param onProgress a callback with a progress event for each file being loaded
  116950. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116951. * @param pluginExtension the extension used to determine the plugin
  116952. * @returns The loaded plugin
  116953. */
  116954. 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>;
  116955. /**
  116956. * Load a scene
  116957. * @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)
  116958. * @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)
  116959. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116960. * @param onProgress a callback with a progress event for each file being loaded
  116961. * @param pluginExtension the extension used to determine the plugin
  116962. * @returns The loaded scene
  116963. */
  116964. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116965. /**
  116966. * Append a scene
  116967. * @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)
  116968. * @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)
  116969. * @param scene is the instance of BABYLON.Scene to append to
  116970. * @param onSuccess a callback with the scene when import succeeds
  116971. * @param onProgress a callback with a progress event for each file being loaded
  116972. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116973. * @param pluginExtension the extension used to determine the plugin
  116974. * @returns The loaded plugin
  116975. */
  116976. 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>;
  116977. /**
  116978. * Append a scene
  116979. * @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)
  116980. * @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)
  116981. * @param scene is the instance of BABYLON.Scene to append to
  116982. * @param onProgress a callback with a progress event for each file being loaded
  116983. * @param pluginExtension the extension used to determine the plugin
  116984. * @returns The given scene
  116985. */
  116986. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116987. /**
  116988. * Load a scene into an asset container
  116989. * @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)
  116990. * @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)
  116991. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116992. * @param onSuccess a callback with the scene when import succeeds
  116993. * @param onProgress a callback with a progress event for each file being loaded
  116994. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116995. * @param pluginExtension the extension used to determine the plugin
  116996. * @returns The loaded plugin
  116997. */
  116998. 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>;
  116999. /**
  117000. * Load a scene into an asset container
  117001. * @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)
  117002. * @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)
  117003. * @param scene is the instance of Scene to append to
  117004. * @param onProgress a callback with a progress event for each file being loaded
  117005. * @param pluginExtension the extension used to determine the plugin
  117006. * @returns The loaded asset container
  117007. */
  117008. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  117009. /**
  117010. * Import animations from a file into a scene
  117011. * @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)
  117012. * @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)
  117013. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117014. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117015. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117016. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117017. * @param onSuccess a callback with the scene when import succeeds
  117018. * @param onProgress a callback with a progress event for each file being loaded
  117019. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117020. */
  117021. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  117022. /**
  117023. * Import animations from a file into a scene
  117024. * @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)
  117025. * @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)
  117026. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117027. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  117028. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  117029. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  117030. * @param onSuccess a callback with the scene when import succeeds
  117031. * @param onProgress a callback with a progress event for each file being loaded
  117032. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117033. * @returns the updated scene with imported animations
  117034. */
  117035. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  117036. }
  117037. }
  117038. declare module BABYLON {
  117039. /**
  117040. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  117041. */
  117042. export type MotionControllerHandness = "none" | "left" | "right";
  117043. /**
  117044. * The type of components available in motion controllers.
  117045. * This is not the name of the component.
  117046. */
  117047. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  117048. /**
  117049. * The state of a controller component
  117050. */
  117051. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  117052. /**
  117053. * The schema of motion controller layout.
  117054. * No object will be initialized using this interface
  117055. * This is used just to define the profile.
  117056. */
  117057. export interface IMotionControllerLayout {
  117058. /**
  117059. * Path to load the assets. Usually relative to the base path
  117060. */
  117061. assetPath: string;
  117062. /**
  117063. * Available components (unsorted)
  117064. */
  117065. components: {
  117066. /**
  117067. * A map of component Ids
  117068. */
  117069. [componentId: string]: {
  117070. /**
  117071. * The type of input the component outputs
  117072. */
  117073. type: MotionControllerComponentType;
  117074. /**
  117075. * The indices of this component in the gamepad object
  117076. */
  117077. gamepadIndices: {
  117078. /**
  117079. * Index of button
  117080. */
  117081. button?: number;
  117082. /**
  117083. * If available, index of x-axis
  117084. */
  117085. xAxis?: number;
  117086. /**
  117087. * If available, index of y-axis
  117088. */
  117089. yAxis?: number;
  117090. };
  117091. /**
  117092. * The mesh's root node name
  117093. */
  117094. rootNodeName: string;
  117095. /**
  117096. * Animation definitions for this model
  117097. */
  117098. visualResponses: {
  117099. [stateKey: string]: {
  117100. /**
  117101. * What property will be animated
  117102. */
  117103. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  117104. /**
  117105. * What states influence this visual response
  117106. */
  117107. states: MotionControllerComponentStateType[];
  117108. /**
  117109. * Type of animation - movement or visibility
  117110. */
  117111. valueNodeProperty: "transform" | "visibility";
  117112. /**
  117113. * Base node name to move. Its position will be calculated according to the min and max nodes
  117114. */
  117115. valueNodeName?: string;
  117116. /**
  117117. * Minimum movement node
  117118. */
  117119. minNodeName?: string;
  117120. /**
  117121. * Max movement node
  117122. */
  117123. maxNodeName?: string;
  117124. };
  117125. };
  117126. /**
  117127. * If touch enabled, what is the name of node to display user feedback
  117128. */
  117129. touchPointNodeName?: string;
  117130. };
  117131. };
  117132. /**
  117133. * Is it xr standard mapping or not
  117134. */
  117135. gamepadMapping: "" | "xr-standard";
  117136. /**
  117137. * Base root node of this entire model
  117138. */
  117139. rootNodeName: string;
  117140. /**
  117141. * Defines the main button component id
  117142. */
  117143. selectComponentId: string;
  117144. }
  117145. /**
  117146. * A definition for the layout map in the input profile
  117147. */
  117148. export interface IMotionControllerLayoutMap {
  117149. /**
  117150. * Layouts with handness type as a key
  117151. */
  117152. [handness: string]: IMotionControllerLayout;
  117153. }
  117154. /**
  117155. * The XR Input profile schema
  117156. * Profiles can be found here:
  117157. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117158. */
  117159. export interface IMotionControllerProfile {
  117160. /**
  117161. * fallback profiles for this profileId
  117162. */
  117163. fallbackProfileIds: string[];
  117164. /**
  117165. * The layout map, with handness as key
  117166. */
  117167. layouts: IMotionControllerLayoutMap;
  117168. /**
  117169. * The id of this profile
  117170. * correlates to the profile(s) in the xrInput.profiles array
  117171. */
  117172. profileId: string;
  117173. }
  117174. /**
  117175. * A helper-interface for the 3 meshes needed for controller button animation
  117176. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117177. */
  117178. export interface IMotionControllerButtonMeshMap {
  117179. /**
  117180. * the mesh that defines the pressed value mesh position.
  117181. * This is used to find the max-position of this button
  117182. */
  117183. pressedMesh: AbstractMesh;
  117184. /**
  117185. * the mesh that defines the unpressed value mesh position.
  117186. * This is used to find the min (or initial) position of this button
  117187. */
  117188. unpressedMesh: AbstractMesh;
  117189. /**
  117190. * The mesh that will be changed when value changes
  117191. */
  117192. valueMesh: AbstractMesh;
  117193. }
  117194. /**
  117195. * A helper-interface for the 3 meshes needed for controller axis animation.
  117196. * This will be expanded when touchpad animations are fully supported
  117197. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117198. */
  117199. export interface IMotionControllerMeshMap {
  117200. /**
  117201. * the mesh that defines the maximum value mesh position.
  117202. */
  117203. maxMesh?: AbstractMesh;
  117204. /**
  117205. * the mesh that defines the minimum value mesh position.
  117206. */
  117207. minMesh?: AbstractMesh;
  117208. /**
  117209. * The mesh that will be changed when axis value changes
  117210. */
  117211. valueMesh: AbstractMesh;
  117212. }
  117213. /**
  117214. * The elements needed for change-detection of the gamepad objects in motion controllers
  117215. */
  117216. export interface IMinimalMotionControllerObject {
  117217. /**
  117218. * Available axes of this controller
  117219. */
  117220. axes: number[];
  117221. /**
  117222. * An array of available buttons
  117223. */
  117224. buttons: Array<{
  117225. /**
  117226. * Value of the button/trigger
  117227. */
  117228. value: number;
  117229. /**
  117230. * If the button/trigger is currently touched
  117231. */
  117232. touched: boolean;
  117233. /**
  117234. * If the button/trigger is currently pressed
  117235. */
  117236. pressed: boolean;
  117237. }>;
  117238. }
  117239. /**
  117240. * An Abstract Motion controller
  117241. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117242. * Each component has an observable to check for changes in value and state
  117243. */
  117244. export abstract class WebXRAbstractMotionController implements IDisposable {
  117245. protected scene: Scene;
  117246. protected layout: IMotionControllerLayout;
  117247. /**
  117248. * The gamepad object correlating to this controller
  117249. */
  117250. gamepadObject: IMinimalMotionControllerObject;
  117251. /**
  117252. * handness (left/right/none) of this controller
  117253. */
  117254. handness: MotionControllerHandness;
  117255. private _initComponent;
  117256. private _modelReady;
  117257. /**
  117258. * A map of components (WebXRControllerComponent) in this motion controller
  117259. * Components have a ComponentType and can also have both button and axis definitions
  117260. */
  117261. readonly components: {
  117262. [id: string]: WebXRControllerComponent;
  117263. };
  117264. /**
  117265. * Disable the model's animation. Can be set at any time.
  117266. */
  117267. disableAnimation: boolean;
  117268. /**
  117269. * Observers registered here will be triggered when the model of this controller is done loading
  117270. */
  117271. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117272. /**
  117273. * The profile id of this motion controller
  117274. */
  117275. abstract profileId: string;
  117276. /**
  117277. * The root mesh of the model. It is null if the model was not yet initialized
  117278. */
  117279. rootMesh: Nullable<AbstractMesh>;
  117280. /**
  117281. * constructs a new abstract motion controller
  117282. * @param scene the scene to which the model of the controller will be added
  117283. * @param layout The profile layout to load
  117284. * @param gamepadObject The gamepad object correlating to this controller
  117285. * @param handness handness (left/right/none) of this controller
  117286. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117287. */
  117288. constructor(scene: Scene, layout: IMotionControllerLayout,
  117289. /**
  117290. * The gamepad object correlating to this controller
  117291. */
  117292. gamepadObject: IMinimalMotionControllerObject,
  117293. /**
  117294. * handness (left/right/none) of this controller
  117295. */
  117296. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117297. /**
  117298. * Dispose this controller, the model mesh and all its components
  117299. */
  117300. dispose(): void;
  117301. /**
  117302. * Returns all components of specific type
  117303. * @param type the type to search for
  117304. * @return an array of components with this type
  117305. */
  117306. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117307. /**
  117308. * get a component based an its component id as defined in layout.components
  117309. * @param id the id of the component
  117310. * @returns the component correlates to the id or undefined if not found
  117311. */
  117312. getComponent(id: string): WebXRControllerComponent;
  117313. /**
  117314. * Get the list of components available in this motion controller
  117315. * @returns an array of strings correlating to available components
  117316. */
  117317. getComponentIds(): string[];
  117318. /**
  117319. * Get the first component of specific type
  117320. * @param type type of component to find
  117321. * @return a controller component or null if not found
  117322. */
  117323. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117324. /**
  117325. * Get the main (Select) component of this controller as defined in the layout
  117326. * @returns the main component of this controller
  117327. */
  117328. getMainComponent(): WebXRControllerComponent;
  117329. /**
  117330. * Loads the model correlating to this controller
  117331. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117332. * @returns A promise fulfilled with the result of the model loading
  117333. */
  117334. loadModel(): Promise<boolean>;
  117335. /**
  117336. * Update this model using the current XRFrame
  117337. * @param xrFrame the current xr frame to use and update the model
  117338. */
  117339. updateFromXRFrame(xrFrame: XRFrame): void;
  117340. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117341. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117342. /**
  117343. * Moves the axis on the controller mesh based on its current state
  117344. * @param axis the index of the axis
  117345. * @param axisValue the value of the axis which determines the meshes new position
  117346. * @hidden
  117347. */
  117348. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117349. /**
  117350. * Update the model itself with the current frame data
  117351. * @param xrFrame the frame to use for updating the model mesh
  117352. */
  117353. protected updateModel(xrFrame: XRFrame): void;
  117354. /**
  117355. * Get the filename and path for this controller's model
  117356. * @returns a map of filename and path
  117357. */
  117358. protected abstract _getFilenameAndPath(): {
  117359. filename: string;
  117360. path: string;
  117361. };
  117362. /**
  117363. * This function is called before the mesh is loaded. It checks for loading constraints.
  117364. * For example, this function can check if the GLB loader is available
  117365. * If this function returns false, the generic controller will be loaded instead
  117366. * @returns Is the client ready to load the mesh
  117367. */
  117368. protected abstract _getModelLoadingConstraints(): boolean;
  117369. /**
  117370. * This function will be called after the model was successfully loaded and can be used
  117371. * for mesh transformations before it is available for the user
  117372. * @param meshes the loaded meshes
  117373. */
  117374. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117375. /**
  117376. * Set the root mesh for this controller. Important for the WebXR controller class
  117377. * @param meshes the loaded meshes
  117378. */
  117379. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117380. /**
  117381. * A function executed each frame that updates the mesh (if needed)
  117382. * @param xrFrame the current xrFrame
  117383. */
  117384. protected abstract _updateModel(xrFrame: XRFrame): void;
  117385. private _getGenericFilenameAndPath;
  117386. private _getGenericParentMesh;
  117387. }
  117388. }
  117389. declare module BABYLON {
  117390. /**
  117391. * A generic trigger-only motion controller for WebXR
  117392. */
  117393. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117394. /**
  117395. * Static version of the profile id of this controller
  117396. */
  117397. static ProfileId: string;
  117398. profileId: string;
  117399. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117400. protected _getFilenameAndPath(): {
  117401. filename: string;
  117402. path: string;
  117403. };
  117404. protected _getModelLoadingConstraints(): boolean;
  117405. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117406. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117407. protected _updateModel(): void;
  117408. }
  117409. }
  117410. declare module BABYLON {
  117411. /**
  117412. * Class containing static functions to help procedurally build meshes
  117413. */
  117414. export class SphereBuilder {
  117415. /**
  117416. * Creates a sphere mesh
  117417. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117418. * * 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`)
  117419. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117420. * * 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
  117421. * * 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)
  117422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117425. * @param name defines the name of the mesh
  117426. * @param options defines the options used to create the mesh
  117427. * @param scene defines the hosting scene
  117428. * @returns the sphere mesh
  117429. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117430. */
  117431. static CreateSphere(name: string, options: {
  117432. segments?: number;
  117433. diameter?: number;
  117434. diameterX?: number;
  117435. diameterY?: number;
  117436. diameterZ?: number;
  117437. arc?: number;
  117438. slice?: number;
  117439. sideOrientation?: number;
  117440. frontUVs?: Vector4;
  117441. backUVs?: Vector4;
  117442. updatable?: boolean;
  117443. }, scene?: Nullable<Scene>): Mesh;
  117444. }
  117445. }
  117446. declare module BABYLON {
  117447. /**
  117448. * A profiled motion controller has its profile loaded from an online repository.
  117449. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117450. */
  117451. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117452. private _repositoryUrl;
  117453. private _buttonMeshMapping;
  117454. private _touchDots;
  117455. /**
  117456. * The profile ID of this controller. Will be populated when the controller initializes.
  117457. */
  117458. profileId: string;
  117459. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117460. dispose(): void;
  117461. protected _getFilenameAndPath(): {
  117462. filename: string;
  117463. path: string;
  117464. };
  117465. protected _getModelLoadingConstraints(): boolean;
  117466. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117467. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117468. protected _updateModel(_xrFrame: XRFrame): void;
  117469. }
  117470. }
  117471. declare module BABYLON {
  117472. /**
  117473. * A construction function type to create a new controller based on an xrInput object
  117474. */
  117475. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117476. /**
  117477. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117478. *
  117479. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117480. * it should be replaced with auto-loaded controllers.
  117481. *
  117482. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117483. */
  117484. export class WebXRMotionControllerManager {
  117485. private static _AvailableControllers;
  117486. private static _Fallbacks;
  117487. private static _ProfileLoadingPromises;
  117488. private static _ProfilesList;
  117489. /**
  117490. * The base URL of the online controller repository. Can be changed at any time.
  117491. */
  117492. static BaseRepositoryUrl: string;
  117493. /**
  117494. * Which repository gets priority - local or online
  117495. */
  117496. static PrioritizeOnlineRepository: boolean;
  117497. /**
  117498. * Use the online repository, or use only locally-defined controllers
  117499. */
  117500. static UseOnlineRepository: boolean;
  117501. /**
  117502. * Clear the cache used for profile loading and reload when requested again
  117503. */
  117504. static ClearProfilesCache(): void;
  117505. /**
  117506. * Register the default fallbacks.
  117507. * This function is called automatically when this file is imported.
  117508. */
  117509. static DefaultFallbacks(): void;
  117510. /**
  117511. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117512. * @param profileId the profile to which a fallback needs to be found
  117513. * @return an array with corresponding fallback profiles
  117514. */
  117515. static FindFallbackWithProfileId(profileId: string): string[];
  117516. /**
  117517. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117518. * The order of search:
  117519. *
  117520. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117521. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117522. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117523. * 4) return the generic trigger controller if none were found
  117524. *
  117525. * @param xrInput the xrInput to which a new controller is initialized
  117526. * @param scene the scene to which the model will be added
  117527. * @param forceProfile force a certain profile for this controller
  117528. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117529. */
  117530. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117531. /**
  117532. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117533. *
  117534. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117535. *
  117536. * @param type the profile type to register
  117537. * @param constructFunction the function to be called when loading this profile
  117538. */
  117539. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117540. /**
  117541. * Register a fallback to a specific profile.
  117542. * @param profileId the profileId that will receive the fallbacks
  117543. * @param fallbacks A list of fallback profiles
  117544. */
  117545. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117546. /**
  117547. * Will update the list of profiles available in the repository
  117548. * @return a promise that resolves to a map of profiles available online
  117549. */
  117550. static UpdateProfilesList(): Promise<{
  117551. [profile: string]: string;
  117552. }>;
  117553. private static _LoadProfileFromRepository;
  117554. private static _LoadProfilesFromAvailableControllers;
  117555. }
  117556. }
  117557. declare module BABYLON {
  117558. /**
  117559. * Configuration options for the WebXR controller creation
  117560. */
  117561. export interface IWebXRControllerOptions {
  117562. /**
  117563. * Should the controller mesh be animated when a user interacts with it
  117564. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117565. */
  117566. disableMotionControllerAnimation?: boolean;
  117567. /**
  117568. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117569. */
  117570. doNotLoadControllerMesh?: boolean;
  117571. /**
  117572. * Force a specific controller type for this controller.
  117573. * This can be used when creating your own profile or when testing different controllers
  117574. */
  117575. forceControllerProfile?: string;
  117576. }
  117577. /**
  117578. * Represents an XR controller
  117579. */
  117580. export class WebXRInputSource {
  117581. private _scene;
  117582. /** The underlying input source for the controller */
  117583. inputSource: XRInputSource;
  117584. private _options;
  117585. private _tmpQuaternion;
  117586. private _tmpVector;
  117587. private _uniqueId;
  117588. /**
  117589. * 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
  117590. */
  117591. grip?: AbstractMesh;
  117592. /**
  117593. * If available, this is the gamepad object related to this controller.
  117594. * Using this object it is possible to get click events and trackpad changes of the
  117595. * webxr controller that is currently being used.
  117596. */
  117597. motionController?: WebXRAbstractMotionController;
  117598. /**
  117599. * Event that fires when the controller is removed/disposed.
  117600. * The object provided as event data is this controller, after associated assets were disposed.
  117601. * uniqueId is still available.
  117602. */
  117603. onDisposeObservable: Observable<WebXRInputSource>;
  117604. /**
  117605. * Will be triggered when the mesh associated with the motion controller is done loading.
  117606. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117607. * A shortened version of controller -> motion controller -> on mesh loaded.
  117608. */
  117609. onMeshLoadedObservable: Observable<AbstractMesh>;
  117610. /**
  117611. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117612. */
  117613. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117614. /**
  117615. * Pointer which can be used to select objects or attach a visible laser to
  117616. */
  117617. pointer: AbstractMesh;
  117618. /**
  117619. * Creates the controller
  117620. * @see https://doc.babylonjs.com/how_to/webxr
  117621. * @param _scene the scene which the controller should be associated to
  117622. * @param inputSource the underlying input source for the controller
  117623. * @param _options options for this controller creation
  117624. */
  117625. constructor(_scene: Scene,
  117626. /** The underlying input source for the controller */
  117627. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117628. /**
  117629. * Get this controllers unique id
  117630. */
  117631. get uniqueId(): string;
  117632. /**
  117633. * Disposes of the object
  117634. */
  117635. dispose(): void;
  117636. /**
  117637. * Gets a world space ray coming from the pointer or grip
  117638. * @param result the resulting ray
  117639. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117640. */
  117641. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117642. /**
  117643. * Updates the controller pose based on the given XRFrame
  117644. * @param xrFrame xr frame to update the pose with
  117645. * @param referenceSpace reference space to use
  117646. */
  117647. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117648. }
  117649. }
  117650. declare module BABYLON {
  117651. /**
  117652. * The schema for initialization options of the XR Input class
  117653. */
  117654. export interface IWebXRInputOptions {
  117655. /**
  117656. * If set to true no model will be automatically loaded
  117657. */
  117658. doNotLoadControllerMeshes?: boolean;
  117659. /**
  117660. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117661. * If not found, the xr input profile data will be used.
  117662. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117663. */
  117664. forceInputProfile?: string;
  117665. /**
  117666. * Do not send a request to the controller repository to load the profile.
  117667. *
  117668. * Instead, use the controllers available in babylon itself.
  117669. */
  117670. disableOnlineControllerRepository?: boolean;
  117671. /**
  117672. * A custom URL for the controllers repository
  117673. */
  117674. customControllersRepositoryURL?: string;
  117675. /**
  117676. * Should the controller model's components not move according to the user input
  117677. */
  117678. disableControllerAnimation?: boolean;
  117679. }
  117680. /**
  117681. * XR input used to track XR inputs such as controllers/rays
  117682. */
  117683. export class WebXRInput implements IDisposable {
  117684. /**
  117685. * the xr session manager for this session
  117686. */
  117687. xrSessionManager: WebXRSessionManager;
  117688. /**
  117689. * the WebXR camera for this session. Mainly used for teleportation
  117690. */
  117691. xrCamera: WebXRCamera;
  117692. private readonly options;
  117693. /**
  117694. * XR controllers being tracked
  117695. */
  117696. controllers: Array<WebXRInputSource>;
  117697. private _frameObserver;
  117698. private _sessionEndedObserver;
  117699. private _sessionInitObserver;
  117700. /**
  117701. * Event when a controller has been connected/added
  117702. */
  117703. onControllerAddedObservable: Observable<WebXRInputSource>;
  117704. /**
  117705. * Event when a controller has been removed/disconnected
  117706. */
  117707. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117708. /**
  117709. * Initializes the WebXRInput
  117710. * @param xrSessionManager the xr session manager for this session
  117711. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117712. * @param options = initialization options for this xr input
  117713. */
  117714. constructor(
  117715. /**
  117716. * the xr session manager for this session
  117717. */
  117718. xrSessionManager: WebXRSessionManager,
  117719. /**
  117720. * the WebXR camera for this session. Mainly used for teleportation
  117721. */
  117722. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117723. private _onInputSourcesChange;
  117724. private _addAndRemoveControllers;
  117725. /**
  117726. * Disposes of the object
  117727. */
  117728. dispose(): void;
  117729. }
  117730. }
  117731. declare module BABYLON {
  117732. /**
  117733. * This is the base class for all WebXR features.
  117734. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117735. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117736. */
  117737. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117738. protected _xrSessionManager: WebXRSessionManager;
  117739. private _attached;
  117740. private _removeOnDetach;
  117741. /**
  117742. * Should auto-attach be disabled?
  117743. */
  117744. disableAutoAttach: boolean;
  117745. /**
  117746. * Construct a new (abstract) WebXR feature
  117747. * @param _xrSessionManager the xr session manager for this feature
  117748. */
  117749. constructor(_xrSessionManager: WebXRSessionManager);
  117750. /**
  117751. * Is this feature attached
  117752. */
  117753. get attached(): boolean;
  117754. /**
  117755. * attach this feature
  117756. *
  117757. * @param force should attachment be forced (even when already attached)
  117758. * @returns true if successful, false is failed or already attached
  117759. */
  117760. attach(force?: boolean): boolean;
  117761. /**
  117762. * detach this feature.
  117763. *
  117764. * @returns true if successful, false if failed or already detached
  117765. */
  117766. detach(): boolean;
  117767. /**
  117768. * Dispose this feature and all of the resources attached
  117769. */
  117770. dispose(): void;
  117771. /**
  117772. * This is used to register callbacks that will automatically be removed when detach is called.
  117773. * @param observable the observable to which the observer will be attached
  117774. * @param callback the callback to register
  117775. */
  117776. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117777. /**
  117778. * Code in this function will be executed on each xrFrame received from the browser.
  117779. * This function will not execute after the feature is detached.
  117780. * @param _xrFrame the current frame
  117781. */
  117782. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117783. }
  117784. }
  117785. declare module BABYLON {
  117786. /**
  117787. * Renders a layer on top of an existing scene
  117788. */
  117789. export class UtilityLayerRenderer implements IDisposable {
  117790. /** the original scene that will be rendered on top of */
  117791. originalScene: Scene;
  117792. private _pointerCaptures;
  117793. private _lastPointerEvents;
  117794. private static _DefaultUtilityLayer;
  117795. private static _DefaultKeepDepthUtilityLayer;
  117796. private _sharedGizmoLight;
  117797. private _renderCamera;
  117798. /**
  117799. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117800. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  117801. * @returns the camera that is used when rendering the utility layer
  117802. */
  117803. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  117804. /**
  117805. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117806. * @param cam the camera that should be used when rendering the utility layer
  117807. */
  117808. setRenderCamera(cam: Nullable<Camera>): void;
  117809. /**
  117810. * @hidden
  117811. * Light which used by gizmos to get light shading
  117812. */
  117813. _getSharedGizmoLight(): HemisphericLight;
  117814. /**
  117815. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117816. */
  117817. pickUtilitySceneFirst: boolean;
  117818. /**
  117819. * 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)
  117820. */
  117821. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117822. /**
  117823. * 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)
  117824. */
  117825. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117826. /**
  117827. * The scene that is rendered on top of the original scene
  117828. */
  117829. utilityLayerScene: Scene;
  117830. /**
  117831. * If the utility layer should automatically be rendered on top of existing scene
  117832. */
  117833. shouldRender: boolean;
  117834. /**
  117835. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117836. */
  117837. onlyCheckPointerDownEvents: boolean;
  117838. /**
  117839. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117840. */
  117841. processAllEvents: boolean;
  117842. /**
  117843. * Observable raised when the pointer move from the utility layer scene to the main scene
  117844. */
  117845. onPointerOutObservable: Observable<number>;
  117846. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117847. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117848. private _afterRenderObserver;
  117849. private _sceneDisposeObserver;
  117850. private _originalPointerObserver;
  117851. /**
  117852. * Instantiates a UtilityLayerRenderer
  117853. * @param originalScene the original scene that will be rendered on top of
  117854. * @param handleEvents boolean indicating if the utility layer should handle events
  117855. */
  117856. constructor(
  117857. /** the original scene that will be rendered on top of */
  117858. originalScene: Scene, handleEvents?: boolean);
  117859. private _notifyObservers;
  117860. /**
  117861. * Renders the utility layers scene on top of the original scene
  117862. */
  117863. render(): void;
  117864. /**
  117865. * Disposes of the renderer
  117866. */
  117867. dispose(): void;
  117868. private _updateCamera;
  117869. }
  117870. }
  117871. declare module BABYLON {
  117872. /**
  117873. * Options interface for the pointer selection module
  117874. */
  117875. export interface IWebXRControllerPointerSelectionOptions {
  117876. /**
  117877. * if provided, this scene will be used to render meshes.
  117878. */
  117879. customUtilityLayerScene?: Scene;
  117880. /**
  117881. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  117882. * If not disabled, the last picked point will be used to execute a pointer up event
  117883. * If disabled, pointer up event will be triggered right after the pointer down event.
  117884. * Used in screen and gaze target ray mode only
  117885. */
  117886. disablePointerUpOnTouchOut: boolean;
  117887. /**
  117888. * For gaze mode (time to select instead of press)
  117889. */
  117890. forceGazeMode: boolean;
  117891. /**
  117892. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  117893. * to start a new countdown to the pointer down event.
  117894. * Defaults to 1.
  117895. */
  117896. gazeModePointerMovedFactor?: number;
  117897. /**
  117898. * Different button type to use instead of the main component
  117899. */
  117900. overrideButtonId?: string;
  117901. /**
  117902. * use this rendering group id for the meshes (optional)
  117903. */
  117904. renderingGroupId?: number;
  117905. /**
  117906. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117907. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117908. * 3000 means 3 seconds between pointing at something and selecting it
  117909. */
  117910. timeToSelect?: number;
  117911. /**
  117912. * Should meshes created here be added to a utility layer or the main scene
  117913. */
  117914. useUtilityLayer?: boolean;
  117915. /**
  117916. * the xr input to use with this pointer selection
  117917. */
  117918. xrInput: WebXRInput;
  117919. }
  117920. /**
  117921. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117922. */
  117923. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117924. private readonly _options;
  117925. private static _idCounter;
  117926. private _attachController;
  117927. private _controllers;
  117928. private _scene;
  117929. private _tmpVectorForPickCompare;
  117930. /**
  117931. * The module's name
  117932. */
  117933. static readonly Name: string;
  117934. /**
  117935. * The (Babylon) version of this module.
  117936. * This is an integer representing the implementation version.
  117937. * This number does not correspond to the WebXR specs version
  117938. */
  117939. static readonly Version: number;
  117940. /**
  117941. * Disable lighting on the laser pointer (so it will always be visible)
  117942. */
  117943. disablePointerLighting: boolean;
  117944. /**
  117945. * Disable lighting on the selection mesh (so it will always be visible)
  117946. */
  117947. disableSelectionMeshLighting: boolean;
  117948. /**
  117949. * Should the laser pointer be displayed
  117950. */
  117951. displayLaserPointer: boolean;
  117952. /**
  117953. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117954. */
  117955. displaySelectionMesh: boolean;
  117956. /**
  117957. * This color will be set to the laser pointer when selection is triggered
  117958. */
  117959. laserPointerPickedColor: Color3;
  117960. /**
  117961. * Default color of the laser pointer
  117962. */
  117963. lasterPointerDefaultColor: Color3;
  117964. /**
  117965. * default color of the selection ring
  117966. */
  117967. selectionMeshDefaultColor: Color3;
  117968. /**
  117969. * This color will be applied to the selection ring when selection is triggered
  117970. */
  117971. selectionMeshPickedColor: Color3;
  117972. /**
  117973. * constructs a new background remover module
  117974. * @param _xrSessionManager the session manager for this module
  117975. * @param _options read-only options to be used in this module
  117976. */
  117977. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117978. /**
  117979. * attach this feature
  117980. * Will usually be called by the features manager
  117981. *
  117982. * @returns true if successful.
  117983. */
  117984. attach(): boolean;
  117985. /**
  117986. * detach this feature.
  117987. * Will usually be called by the features manager
  117988. *
  117989. * @returns true if successful.
  117990. */
  117991. detach(): boolean;
  117992. /**
  117993. * Will get the mesh under a specific pointer.
  117994. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117995. * @param controllerId the controllerId to check
  117996. * @returns The mesh under pointer or null if no mesh is under the pointer
  117997. */
  117998. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117999. /**
  118000. * Get the xr controller that correlates to the pointer id in the pointer event
  118001. *
  118002. * @param id the pointer id to search for
  118003. * @returns the controller that correlates to this id or null if not found
  118004. */
  118005. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  118006. protected _onXRFrame(_xrFrame: XRFrame): void;
  118007. private _attachGazeMode;
  118008. private _attachScreenRayMode;
  118009. private _attachTrackedPointerRayMode;
  118010. private _convertNormalToDirectionOfRay;
  118011. private _detachController;
  118012. private _generateNewMeshPair;
  118013. private _pickingMoved;
  118014. private _updatePointerDistance;
  118015. }
  118016. }
  118017. declare module BABYLON {
  118018. /**
  118019. * Button which can be used to enter a different mode of XR
  118020. */
  118021. export class WebXREnterExitUIButton {
  118022. /** button element */
  118023. element: HTMLElement;
  118024. /** XR initialization options for the button */
  118025. sessionMode: XRSessionMode;
  118026. /** Reference space type */
  118027. referenceSpaceType: XRReferenceSpaceType;
  118028. /**
  118029. * Creates a WebXREnterExitUIButton
  118030. * @param element button element
  118031. * @param sessionMode XR initialization session mode
  118032. * @param referenceSpaceType the type of reference space to be used
  118033. */
  118034. constructor(
  118035. /** button element */
  118036. element: HTMLElement,
  118037. /** XR initialization options for the button */
  118038. sessionMode: XRSessionMode,
  118039. /** Reference space type */
  118040. referenceSpaceType: XRReferenceSpaceType);
  118041. /**
  118042. * Extendable function which can be used to update the button's visuals when the state changes
  118043. * @param activeButton the current active button in the UI
  118044. */
  118045. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  118046. }
  118047. /**
  118048. * Options to create the webXR UI
  118049. */
  118050. export class WebXREnterExitUIOptions {
  118051. /**
  118052. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  118053. */
  118054. customButtons?: Array<WebXREnterExitUIButton>;
  118055. /**
  118056. * A reference space type to use when creating the default button.
  118057. * Default is local-floor
  118058. */
  118059. referenceSpaceType?: XRReferenceSpaceType;
  118060. /**
  118061. * Context to enter xr with
  118062. */
  118063. renderTarget?: Nullable<WebXRRenderTarget>;
  118064. /**
  118065. * A session mode to use when creating the default button.
  118066. * Default is immersive-vr
  118067. */
  118068. sessionMode?: XRSessionMode;
  118069. }
  118070. /**
  118071. * UI to allow the user to enter/exit XR mode
  118072. */
  118073. export class WebXREnterExitUI implements IDisposable {
  118074. private scene;
  118075. /** version of the options passed to this UI */
  118076. options: WebXREnterExitUIOptions;
  118077. private _activeButton;
  118078. private _buttons;
  118079. private _overlay;
  118080. /**
  118081. * Fired every time the active button is changed.
  118082. *
  118083. * When xr is entered via a button that launches xr that button will be the callback parameter
  118084. *
  118085. * When exiting xr the callback parameter will be null)
  118086. */
  118087. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  118088. /**
  118089. *
  118090. * @param scene babylon scene object to use
  118091. * @param options (read-only) version of the options passed to this UI
  118092. */
  118093. private constructor();
  118094. /**
  118095. * Creates UI to allow the user to enter/exit XR mode
  118096. * @param scene the scene to add the ui to
  118097. * @param helper the xr experience helper to enter/exit xr with
  118098. * @param options options to configure the UI
  118099. * @returns the created ui
  118100. */
  118101. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  118102. /**
  118103. * Disposes of the XR UI component
  118104. */
  118105. dispose(): void;
  118106. private _updateButtons;
  118107. }
  118108. }
  118109. declare module BABYLON {
  118110. /**
  118111. * Class containing static functions to help procedurally build meshes
  118112. */
  118113. export class LinesBuilder {
  118114. /**
  118115. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118116. * * 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
  118117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118118. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118119. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118120. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118121. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118122. * * 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
  118123. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118126. * @param name defines the name of the new line system
  118127. * @param options defines the options used to create the line system
  118128. * @param scene defines the hosting scene
  118129. * @returns a new line system mesh
  118130. */
  118131. static CreateLineSystem(name: string, options: {
  118132. lines: Vector3[][];
  118133. updatable?: boolean;
  118134. instance?: Nullable<LinesMesh>;
  118135. colors?: Nullable<Color4[][]>;
  118136. useVertexAlpha?: boolean;
  118137. }, scene: Nullable<Scene>): LinesMesh;
  118138. /**
  118139. * Creates a line mesh
  118140. * 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
  118141. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118142. * * The parameter `points` is an array successive Vector3
  118143. * * 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
  118144. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118145. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118146. * * When updating an instance, remember that only point positions can change, not the number of points
  118147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118149. * @param name defines the name of the new line system
  118150. * @param options defines the options used to create the line system
  118151. * @param scene defines the hosting scene
  118152. * @returns a new line mesh
  118153. */
  118154. static CreateLines(name: string, options: {
  118155. points: Vector3[];
  118156. updatable?: boolean;
  118157. instance?: Nullable<LinesMesh>;
  118158. colors?: Color4[];
  118159. useVertexAlpha?: boolean;
  118160. }, scene?: Nullable<Scene>): LinesMesh;
  118161. /**
  118162. * Creates a dashed line mesh
  118163. * * 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
  118164. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118165. * * The parameter `points` is an array successive Vector3
  118166. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118167. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118168. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118169. * * 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
  118170. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118171. * * When updating an instance, remember that only point positions can change, not the number of points
  118172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118173. * @param name defines the name of the mesh
  118174. * @param options defines the options used to create the mesh
  118175. * @param scene defines the hosting scene
  118176. * @returns the dashed line mesh
  118177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118178. */
  118179. static CreateDashedLines(name: string, options: {
  118180. points: Vector3[];
  118181. dashSize?: number;
  118182. gapSize?: number;
  118183. dashNb?: number;
  118184. updatable?: boolean;
  118185. instance?: LinesMesh;
  118186. useVertexAlpha?: boolean;
  118187. }, scene?: Nullable<Scene>): LinesMesh;
  118188. }
  118189. }
  118190. declare module BABYLON {
  118191. /**
  118192. * The options container for the teleportation module
  118193. */
  118194. export interface IWebXRTeleportationOptions {
  118195. /**
  118196. * if provided, this scene will be used to render meshes.
  118197. */
  118198. customUtilityLayerScene?: Scene;
  118199. /**
  118200. * Values to configure the default target mesh
  118201. */
  118202. defaultTargetMeshOptions?: {
  118203. /**
  118204. * Fill color of the teleportation area
  118205. */
  118206. teleportationFillColor?: string;
  118207. /**
  118208. * Border color for the teleportation area
  118209. */
  118210. teleportationBorderColor?: string;
  118211. /**
  118212. * Disable the mesh's animation sequence
  118213. */
  118214. disableAnimation?: boolean;
  118215. /**
  118216. * Disable lighting on the material or the ring and arrow
  118217. */
  118218. disableLighting?: boolean;
  118219. /**
  118220. * Override the default material of the torus and arrow
  118221. */
  118222. torusArrowMaterial?: Material;
  118223. };
  118224. /**
  118225. * A list of meshes to use as floor meshes.
  118226. * Meshes can be added and removed after initializing the feature using the
  118227. * addFloorMesh and removeFloorMesh functions
  118228. * If empty, rotation will still work
  118229. */
  118230. floorMeshes?: AbstractMesh[];
  118231. /**
  118232. * use this rendering group id for the meshes (optional)
  118233. */
  118234. renderingGroupId?: number;
  118235. /**
  118236. * Should teleportation move only to snap points
  118237. */
  118238. snapPointsOnly?: boolean;
  118239. /**
  118240. * An array of points to which the teleportation will snap to.
  118241. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118242. */
  118243. snapPositions?: Vector3[];
  118244. /**
  118245. * How close should the teleportation ray be in order to snap to position.
  118246. * Default to 0.8 units (meters)
  118247. */
  118248. snapToPositionRadius?: number;
  118249. /**
  118250. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118251. * If you want to support rotation, make sure your mesh has a direction indicator.
  118252. *
  118253. * When left untouched, the default mesh will be initialized.
  118254. */
  118255. teleportationTargetMesh?: AbstractMesh;
  118256. /**
  118257. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118258. */
  118259. timeToTeleport?: number;
  118260. /**
  118261. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118262. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118263. */
  118264. useMainComponentOnly?: boolean;
  118265. /**
  118266. * Should meshes created here be added to a utility layer or the main scene
  118267. */
  118268. useUtilityLayer?: boolean;
  118269. /**
  118270. * Babylon XR Input class for controller
  118271. */
  118272. xrInput: WebXRInput;
  118273. }
  118274. /**
  118275. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118276. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118277. * the input of the attached controllers.
  118278. */
  118279. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118280. private _options;
  118281. private _controllers;
  118282. private _currentTeleportationControllerId;
  118283. private _floorMeshes;
  118284. private _quadraticBezierCurve;
  118285. private _selectionFeature;
  118286. private _snapToPositions;
  118287. private _snappedToPoint;
  118288. private _teleportationRingMaterial?;
  118289. private _tmpRay;
  118290. private _tmpVector;
  118291. /**
  118292. * The module's name
  118293. */
  118294. static readonly Name: string;
  118295. /**
  118296. * The (Babylon) version of this module.
  118297. * This is an integer representing the implementation version.
  118298. * This number does not correspond to the webxr specs version
  118299. */
  118300. static readonly Version: number;
  118301. /**
  118302. * Is movement backwards enabled
  118303. */
  118304. backwardsMovementEnabled: boolean;
  118305. /**
  118306. * Distance to travel when moving backwards
  118307. */
  118308. backwardsTeleportationDistance: number;
  118309. /**
  118310. * The distance from the user to the inspection point in the direction of the controller
  118311. * A higher number will allow the user to move further
  118312. * defaults to 5 (meters, in xr units)
  118313. */
  118314. parabolicCheckRadius: number;
  118315. /**
  118316. * Should the module support parabolic ray on top of direct ray
  118317. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118318. * Very helpful when moving between floors / different heights
  118319. */
  118320. parabolicRayEnabled: boolean;
  118321. /**
  118322. * How much rotation should be applied when rotating right and left
  118323. */
  118324. rotationAngle: number;
  118325. /**
  118326. * Is rotation enabled when moving forward?
  118327. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118328. */
  118329. rotationEnabled: boolean;
  118330. /**
  118331. * constructs a new anchor system
  118332. * @param _xrSessionManager an instance of WebXRSessionManager
  118333. * @param _options configuration object for this feature
  118334. */
  118335. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118336. /**
  118337. * Get the snapPointsOnly flag
  118338. */
  118339. get snapPointsOnly(): boolean;
  118340. /**
  118341. * Sets the snapPointsOnly flag
  118342. * @param snapToPoints should teleportation be exclusively to snap points
  118343. */
  118344. set snapPointsOnly(snapToPoints: boolean);
  118345. /**
  118346. * Add a new mesh to the floor meshes array
  118347. * @param mesh the mesh to use as floor mesh
  118348. */
  118349. addFloorMesh(mesh: AbstractMesh): void;
  118350. /**
  118351. * Add a new snap-to point to fix teleportation to this position
  118352. * @param newSnapPoint The new Snap-To point
  118353. */
  118354. addSnapPoint(newSnapPoint: Vector3): void;
  118355. attach(): boolean;
  118356. detach(): boolean;
  118357. dispose(): void;
  118358. /**
  118359. * Remove a mesh from the floor meshes array
  118360. * @param mesh the mesh to remove
  118361. */
  118362. removeFloorMesh(mesh: AbstractMesh): void;
  118363. /**
  118364. * Remove a mesh from the floor meshes array using its name
  118365. * @param name the mesh name to remove
  118366. */
  118367. removeFloorMeshByName(name: string): void;
  118368. /**
  118369. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  118370. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118371. * @returns was the point found and removed or not
  118372. */
  118373. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118374. /**
  118375. * This function sets a selection feature that will be disabled when
  118376. * the forward ray is shown and will be reattached when hidden.
  118377. * This is used to remove the selection rays when moving.
  118378. * @param selectionFeature the feature to disable when forward movement is enabled
  118379. */
  118380. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118381. protected _onXRFrame(_xrFrame: XRFrame): void;
  118382. private _attachController;
  118383. private _createDefaultTargetMesh;
  118384. private _detachController;
  118385. private _findClosestSnapPointWithRadius;
  118386. private _setTargetMeshPosition;
  118387. private _setTargetMeshVisibility;
  118388. private _showParabolicPath;
  118389. private _teleportForward;
  118390. }
  118391. }
  118392. declare module BABYLON {
  118393. /**
  118394. * Options for the default xr helper
  118395. */
  118396. export class WebXRDefaultExperienceOptions {
  118397. /**
  118398. * Enable or disable default UI to enter XR
  118399. */
  118400. disableDefaultUI?: boolean;
  118401. /**
  118402. * Should teleportation not initialize. defaults to false.
  118403. */
  118404. disableTeleportation?: boolean;
  118405. /**
  118406. * Floor meshes that will be used for teleport
  118407. */
  118408. floorMeshes?: Array<AbstractMesh>;
  118409. /**
  118410. * If set to true, the first frame will not be used to reset position
  118411. * The first frame is mainly used when copying transformation from the old camera
  118412. * Mainly used in AR
  118413. */
  118414. ignoreNativeCameraTransformation?: boolean;
  118415. /**
  118416. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118417. */
  118418. inputOptions?: IWebXRInputOptions;
  118419. /**
  118420. * optional configuration for the output canvas
  118421. */
  118422. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118423. /**
  118424. * optional UI options. This can be used among other to change session mode and reference space type
  118425. */
  118426. uiOptions?: WebXREnterExitUIOptions;
  118427. /**
  118428. * When loading teleportation and pointer select, use stable versions instead of latest.
  118429. */
  118430. useStablePlugins?: boolean;
  118431. }
  118432. /**
  118433. * Default experience which provides a similar setup to the previous webVRExperience
  118434. */
  118435. export class WebXRDefaultExperience {
  118436. /**
  118437. * Base experience
  118438. */
  118439. baseExperience: WebXRExperienceHelper;
  118440. /**
  118441. * Enables ui for entering/exiting xr
  118442. */
  118443. enterExitUI: WebXREnterExitUI;
  118444. /**
  118445. * Input experience extension
  118446. */
  118447. input: WebXRInput;
  118448. /**
  118449. * Enables laser pointer and selection
  118450. */
  118451. pointerSelection: WebXRControllerPointerSelection;
  118452. /**
  118453. * Default target xr should render to
  118454. */
  118455. renderTarget: WebXRRenderTarget;
  118456. /**
  118457. * Enables teleportation
  118458. */
  118459. teleportation: WebXRMotionControllerTeleportation;
  118460. private constructor();
  118461. /**
  118462. * Creates the default xr experience
  118463. * @param scene scene
  118464. * @param options options for basic configuration
  118465. * @returns resulting WebXRDefaultExperience
  118466. */
  118467. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118468. /**
  118469. * DIsposes of the experience helper
  118470. */
  118471. dispose(): void;
  118472. }
  118473. }
  118474. declare module BABYLON {
  118475. /**
  118476. * Options to modify the vr teleportation behavior.
  118477. */
  118478. export interface VRTeleportationOptions {
  118479. /**
  118480. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118481. */
  118482. floorMeshName?: string;
  118483. /**
  118484. * A list of meshes to be used as the teleportation floor. (default: empty)
  118485. */
  118486. floorMeshes?: Mesh[];
  118487. /**
  118488. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118489. */
  118490. teleportationMode?: number;
  118491. /**
  118492. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118493. */
  118494. teleportationTime?: number;
  118495. /**
  118496. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118497. */
  118498. teleportationSpeed?: number;
  118499. /**
  118500. * The easing function used in the animation or null for Linear. (default CircleEase)
  118501. */
  118502. easingFunction?: EasingFunction;
  118503. }
  118504. /**
  118505. * Options to modify the vr experience helper's behavior.
  118506. */
  118507. export interface VRExperienceHelperOptions extends WebVROptions {
  118508. /**
  118509. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118510. */
  118511. createDeviceOrientationCamera?: boolean;
  118512. /**
  118513. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118514. */
  118515. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118516. /**
  118517. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118518. */
  118519. laserToggle?: boolean;
  118520. /**
  118521. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118522. */
  118523. floorMeshes?: Mesh[];
  118524. /**
  118525. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118526. */
  118527. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118528. /**
  118529. * Defines if WebXR should be used instead of WebVR (if available)
  118530. */
  118531. useXR?: boolean;
  118532. }
  118533. /**
  118534. * Event containing information after VR has been entered
  118535. */
  118536. export class OnAfterEnteringVRObservableEvent {
  118537. /**
  118538. * If entering vr was successful
  118539. */
  118540. success: boolean;
  118541. }
  118542. /**
  118543. * Helps to quickly add VR support to an existing scene.
  118544. * See http://doc.babylonjs.com/how_to/webvr_helper
  118545. */
  118546. export class VRExperienceHelper {
  118547. /** Options to modify the vr experience helper's behavior. */
  118548. webVROptions: VRExperienceHelperOptions;
  118549. private _scene;
  118550. private _position;
  118551. private _btnVR;
  118552. private _btnVRDisplayed;
  118553. private _webVRsupported;
  118554. private _webVRready;
  118555. private _webVRrequesting;
  118556. private _webVRpresenting;
  118557. private _hasEnteredVR;
  118558. private _fullscreenVRpresenting;
  118559. private _inputElement;
  118560. private _webVRCamera;
  118561. private _vrDeviceOrientationCamera;
  118562. private _deviceOrientationCamera;
  118563. private _existingCamera;
  118564. private _onKeyDown;
  118565. private _onVrDisplayPresentChange;
  118566. private _onVRDisplayChanged;
  118567. private _onVRRequestPresentStart;
  118568. private _onVRRequestPresentComplete;
  118569. /**
  118570. * 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)
  118571. */
  118572. enableGazeEvenWhenNoPointerLock: boolean;
  118573. /**
  118574. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118575. */
  118576. exitVROnDoubleTap: boolean;
  118577. /**
  118578. * Observable raised right before entering VR.
  118579. */
  118580. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118581. /**
  118582. * Observable raised when entering VR has completed.
  118583. */
  118584. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118585. /**
  118586. * Observable raised when exiting VR.
  118587. */
  118588. onExitingVRObservable: Observable<VRExperienceHelper>;
  118589. /**
  118590. * Observable raised when controller mesh is loaded.
  118591. */
  118592. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118593. /** Return this.onEnteringVRObservable
  118594. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118595. */
  118596. get onEnteringVR(): Observable<VRExperienceHelper>;
  118597. /** Return this.onExitingVRObservable
  118598. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118599. */
  118600. get onExitingVR(): Observable<VRExperienceHelper>;
  118601. /** Return this.onControllerMeshLoadedObservable
  118602. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118603. */
  118604. get onControllerMeshLoaded(): Observable<WebVRController>;
  118605. private _rayLength;
  118606. private _useCustomVRButton;
  118607. private _teleportationRequested;
  118608. private _teleportActive;
  118609. private _floorMeshName;
  118610. private _floorMeshesCollection;
  118611. private _teleportationMode;
  118612. private _teleportationTime;
  118613. private _teleportationSpeed;
  118614. private _teleportationEasing;
  118615. private _rotationAllowed;
  118616. private _teleportBackwardsVector;
  118617. private _teleportationTarget;
  118618. private _isDefaultTeleportationTarget;
  118619. private _postProcessMove;
  118620. private _teleportationFillColor;
  118621. private _teleportationBorderColor;
  118622. private _rotationAngle;
  118623. private _haloCenter;
  118624. private _cameraGazer;
  118625. private _padSensibilityUp;
  118626. private _padSensibilityDown;
  118627. private _leftController;
  118628. private _rightController;
  118629. private _gazeColor;
  118630. private _laserColor;
  118631. private _pickedLaserColor;
  118632. private _pickedGazeColor;
  118633. /**
  118634. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118635. */
  118636. onNewMeshSelected: Observable<AbstractMesh>;
  118637. /**
  118638. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118639. * This observable will provide the mesh and the controller used to select the mesh
  118640. */
  118641. onMeshSelectedWithController: Observable<{
  118642. mesh: AbstractMesh;
  118643. controller: WebVRController;
  118644. }>;
  118645. /**
  118646. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118647. */
  118648. onNewMeshPicked: Observable<PickingInfo>;
  118649. private _circleEase;
  118650. /**
  118651. * Observable raised before camera teleportation
  118652. */
  118653. onBeforeCameraTeleport: Observable<Vector3>;
  118654. /**
  118655. * Observable raised after camera teleportation
  118656. */
  118657. onAfterCameraTeleport: Observable<Vector3>;
  118658. /**
  118659. * Observable raised when current selected mesh gets unselected
  118660. */
  118661. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118662. private _raySelectionPredicate;
  118663. /**
  118664. * To be optionaly changed by user to define custom ray selection
  118665. */
  118666. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118667. /**
  118668. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118669. */
  118670. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118671. /**
  118672. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118673. */
  118674. teleportationEnabled: boolean;
  118675. private _defaultHeight;
  118676. private _teleportationInitialized;
  118677. private _interactionsEnabled;
  118678. private _interactionsRequested;
  118679. private _displayGaze;
  118680. private _displayLaserPointer;
  118681. /**
  118682. * The mesh used to display where the user is going to teleport.
  118683. */
  118684. get teleportationTarget(): Mesh;
  118685. /**
  118686. * Sets the mesh to be used to display where the user is going to teleport.
  118687. */
  118688. set teleportationTarget(value: Mesh);
  118689. /**
  118690. * 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
  118691. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118692. * See http://doc.babylonjs.com/resources/baking_transformations
  118693. */
  118694. get gazeTrackerMesh(): Mesh;
  118695. set gazeTrackerMesh(value: Mesh);
  118696. /**
  118697. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118698. */
  118699. updateGazeTrackerScale: boolean;
  118700. /**
  118701. * If the gaze trackers color should be updated when selecting meshes
  118702. */
  118703. updateGazeTrackerColor: boolean;
  118704. /**
  118705. * If the controller laser color should be updated when selecting meshes
  118706. */
  118707. updateControllerLaserColor: boolean;
  118708. /**
  118709. * The gaze tracking mesh corresponding to the left controller
  118710. */
  118711. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118712. /**
  118713. * The gaze tracking mesh corresponding to the right controller
  118714. */
  118715. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118716. /**
  118717. * If the ray of the gaze should be displayed.
  118718. */
  118719. get displayGaze(): boolean;
  118720. /**
  118721. * Sets if the ray of the gaze should be displayed.
  118722. */
  118723. set displayGaze(value: boolean);
  118724. /**
  118725. * If the ray of the LaserPointer should be displayed.
  118726. */
  118727. get displayLaserPointer(): boolean;
  118728. /**
  118729. * Sets if the ray of the LaserPointer should be displayed.
  118730. */
  118731. set displayLaserPointer(value: boolean);
  118732. /**
  118733. * The deviceOrientationCamera used as the camera when not in VR.
  118734. */
  118735. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118736. /**
  118737. * Based on the current WebVR support, returns the current VR camera used.
  118738. */
  118739. get currentVRCamera(): Nullable<Camera>;
  118740. /**
  118741. * The webVRCamera which is used when in VR.
  118742. */
  118743. get webVRCamera(): WebVRFreeCamera;
  118744. /**
  118745. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118746. */
  118747. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118748. /**
  118749. * The html button that is used to trigger entering into VR.
  118750. */
  118751. get vrButton(): Nullable<HTMLButtonElement>;
  118752. private get _teleportationRequestInitiated();
  118753. /**
  118754. * Defines whether or not Pointer lock should be requested when switching to
  118755. * full screen.
  118756. */
  118757. requestPointerLockOnFullScreen: boolean;
  118758. /**
  118759. * If asking to force XR, this will be populated with the default xr experience
  118760. */
  118761. xr: WebXRDefaultExperience;
  118762. /**
  118763. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118764. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118765. */
  118766. xrTestDone: boolean;
  118767. /**
  118768. * Instantiates a VRExperienceHelper.
  118769. * Helps to quickly add VR support to an existing scene.
  118770. * @param scene The scene the VRExperienceHelper belongs to.
  118771. * @param webVROptions Options to modify the vr experience helper's behavior.
  118772. */
  118773. constructor(scene: Scene,
  118774. /** Options to modify the vr experience helper's behavior. */
  118775. webVROptions?: VRExperienceHelperOptions);
  118776. private completeVRInit;
  118777. private _onDefaultMeshLoaded;
  118778. private _onResize;
  118779. private _onFullscreenChange;
  118780. /**
  118781. * Gets a value indicating if we are currently in VR mode.
  118782. */
  118783. get isInVRMode(): boolean;
  118784. private onVrDisplayPresentChange;
  118785. private onVRDisplayChanged;
  118786. private moveButtonToBottomRight;
  118787. private displayVRButton;
  118788. private updateButtonVisibility;
  118789. private _cachedAngularSensibility;
  118790. /**
  118791. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118792. * Otherwise, will use the fullscreen API.
  118793. */
  118794. enterVR(): void;
  118795. /**
  118796. * Attempt to exit VR, or fullscreen.
  118797. */
  118798. exitVR(): void;
  118799. /**
  118800. * The position of the vr experience helper.
  118801. */
  118802. get position(): Vector3;
  118803. /**
  118804. * Sets the position of the vr experience helper.
  118805. */
  118806. set position(value: Vector3);
  118807. /**
  118808. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118809. */
  118810. enableInteractions(): void;
  118811. private get _noControllerIsActive();
  118812. private beforeRender;
  118813. private _isTeleportationFloor;
  118814. /**
  118815. * Adds a floor mesh to be used for teleportation.
  118816. * @param floorMesh the mesh to be used for teleportation.
  118817. */
  118818. addFloorMesh(floorMesh: Mesh): void;
  118819. /**
  118820. * Removes a floor mesh from being used for teleportation.
  118821. * @param floorMesh the mesh to be removed.
  118822. */
  118823. removeFloorMesh(floorMesh: Mesh): void;
  118824. /**
  118825. * Enables interactions and teleportation using the VR controllers and gaze.
  118826. * @param vrTeleportationOptions options to modify teleportation behavior.
  118827. */
  118828. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118829. private _onNewGamepadConnected;
  118830. private _tryEnableInteractionOnController;
  118831. private _onNewGamepadDisconnected;
  118832. private _enableInteractionOnController;
  118833. private _checkTeleportWithRay;
  118834. private _checkRotate;
  118835. private _checkTeleportBackwards;
  118836. private _enableTeleportationOnController;
  118837. private _createTeleportationCircles;
  118838. private _displayTeleportationTarget;
  118839. private _hideTeleportationTarget;
  118840. private _rotateCamera;
  118841. private _moveTeleportationSelectorTo;
  118842. private _workingVector;
  118843. private _workingQuaternion;
  118844. private _workingMatrix;
  118845. /**
  118846. * Time Constant Teleportation Mode
  118847. */
  118848. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118849. /**
  118850. * Speed Constant Teleportation Mode
  118851. */
  118852. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118853. /**
  118854. * Teleports the users feet to the desired location
  118855. * @param location The location where the user's feet should be placed
  118856. */
  118857. teleportCamera(location: Vector3): void;
  118858. private _convertNormalToDirectionOfRay;
  118859. private _castRayAndSelectObject;
  118860. private _notifySelectedMeshUnselected;
  118861. /**
  118862. * Permanently set new colors for the laser pointer
  118863. * @param color the new laser color
  118864. * @param pickedColor the new laser color when picked mesh detected
  118865. */
  118866. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118867. /**
  118868. * Set lighting enabled / disabled on the laser pointer of both controllers
  118869. * @param enabled should the lighting be enabled on the laser pointer
  118870. */
  118871. setLaserLightingState(enabled?: boolean): void;
  118872. /**
  118873. * Permanently set new colors for the gaze pointer
  118874. * @param color the new gaze color
  118875. * @param pickedColor the new gaze color when picked mesh detected
  118876. */
  118877. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118878. /**
  118879. * Sets the color of the laser ray from the vr controllers.
  118880. * @param color new color for the ray.
  118881. */
  118882. changeLaserColor(color: Color3): void;
  118883. /**
  118884. * Sets the color of the ray from the vr headsets gaze.
  118885. * @param color new color for the ray.
  118886. */
  118887. changeGazeColor(color: Color3): void;
  118888. /**
  118889. * Exits VR and disposes of the vr experience helper
  118890. */
  118891. dispose(): void;
  118892. /**
  118893. * Gets the name of the VRExperienceHelper class
  118894. * @returns "VRExperienceHelper"
  118895. */
  118896. getClassName(): string;
  118897. }
  118898. }
  118899. declare module BABYLON {
  118900. /**
  118901. * Contains an array of blocks representing the octree
  118902. */
  118903. export interface IOctreeContainer<T> {
  118904. /**
  118905. * Blocks within the octree
  118906. */
  118907. blocks: Array<OctreeBlock<T>>;
  118908. }
  118909. /**
  118910. * Class used to store a cell in an octree
  118911. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118912. */
  118913. export class OctreeBlock<T> {
  118914. /**
  118915. * Gets the content of the current block
  118916. */
  118917. entries: T[];
  118918. /**
  118919. * Gets the list of block children
  118920. */
  118921. blocks: Array<OctreeBlock<T>>;
  118922. private _depth;
  118923. private _maxDepth;
  118924. private _capacity;
  118925. private _minPoint;
  118926. private _maxPoint;
  118927. private _boundingVectors;
  118928. private _creationFunc;
  118929. /**
  118930. * Creates a new block
  118931. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118932. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118933. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118934. * @param depth defines the current depth of this block in the octree
  118935. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118936. * @param creationFunc defines a callback to call when an element is added to the block
  118937. */
  118938. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118939. /**
  118940. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118941. */
  118942. get capacity(): number;
  118943. /**
  118944. * Gets the minimum vector (in world space) of the block's bounding box
  118945. */
  118946. get minPoint(): Vector3;
  118947. /**
  118948. * Gets the maximum vector (in world space) of the block's bounding box
  118949. */
  118950. get maxPoint(): Vector3;
  118951. /**
  118952. * Add a new element to this block
  118953. * @param entry defines the element to add
  118954. */
  118955. addEntry(entry: T): void;
  118956. /**
  118957. * Remove an element from this block
  118958. * @param entry defines the element to remove
  118959. */
  118960. removeEntry(entry: T): void;
  118961. /**
  118962. * Add an array of elements to this block
  118963. * @param entries defines the array of elements to add
  118964. */
  118965. addEntries(entries: T[]): void;
  118966. /**
  118967. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118968. * @param frustumPlanes defines the frustum planes to test
  118969. * @param selection defines the array to store current content if selection is positive
  118970. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118971. */
  118972. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118973. /**
  118974. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118975. * @param sphereCenter defines the bounding sphere center
  118976. * @param sphereRadius defines the bounding sphere radius
  118977. * @param selection defines the array to store current content if selection is positive
  118978. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118979. */
  118980. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118981. /**
  118982. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118983. * @param ray defines the ray to test with
  118984. * @param selection defines the array to store current content if selection is positive
  118985. */
  118986. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118987. /**
  118988. * Subdivide the content into child blocks (this block will then be empty)
  118989. */
  118990. createInnerBlocks(): void;
  118991. /**
  118992. * @hidden
  118993. */
  118994. 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;
  118995. }
  118996. }
  118997. declare module BABYLON {
  118998. /**
  118999. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  119000. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119001. */
  119002. export class Octree<T> {
  119003. /** 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.) */
  119004. maxDepth: number;
  119005. /**
  119006. * Blocks within the octree containing objects
  119007. */
  119008. blocks: Array<OctreeBlock<T>>;
  119009. /**
  119010. * Content stored in the octree
  119011. */
  119012. dynamicContent: T[];
  119013. private _maxBlockCapacity;
  119014. private _selectionContent;
  119015. private _creationFunc;
  119016. /**
  119017. * Creates a octree
  119018. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119019. * @param creationFunc function to be used to instatiate the octree
  119020. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  119021. * @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.)
  119022. */
  119023. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  119024. /** 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.) */
  119025. maxDepth?: number);
  119026. /**
  119027. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  119028. * @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);
  119029. * @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);
  119030. * @param entries meshes to be added to the octree blocks
  119031. */
  119032. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  119033. /**
  119034. * Adds a mesh to the octree
  119035. * @param entry Mesh to add to the octree
  119036. */
  119037. addMesh(entry: T): void;
  119038. /**
  119039. * Remove an element from the octree
  119040. * @param entry defines the element to remove
  119041. */
  119042. removeMesh(entry: T): void;
  119043. /**
  119044. * Selects an array of meshes within the frustum
  119045. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  119046. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  119047. * @returns array of meshes within the frustum
  119048. */
  119049. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  119050. /**
  119051. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  119052. * @param sphereCenter defines the bounding sphere center
  119053. * @param sphereRadius defines the bounding sphere radius
  119054. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119055. * @returns an array of objects that intersect the sphere
  119056. */
  119057. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  119058. /**
  119059. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  119060. * @param ray defines the ray to test with
  119061. * @returns array of intersected objects
  119062. */
  119063. intersectsRay(ray: Ray): SmartArray<T>;
  119064. /**
  119065. * Adds a mesh into the octree block if it intersects the block
  119066. */
  119067. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  119068. /**
  119069. * Adds a submesh into the octree block if it intersects the block
  119070. */
  119071. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  119072. }
  119073. }
  119074. declare module BABYLON {
  119075. interface Scene {
  119076. /**
  119077. * @hidden
  119078. * Backing Filed
  119079. */
  119080. _selectionOctree: Octree<AbstractMesh>;
  119081. /**
  119082. * Gets the octree used to boost mesh selection (picking)
  119083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119084. */
  119085. selectionOctree: Octree<AbstractMesh>;
  119086. /**
  119087. * Creates or updates the octree used to boost selection (picking)
  119088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119089. * @param maxCapacity defines the maximum capacity per leaf
  119090. * @param maxDepth defines the maximum depth of the octree
  119091. * @returns an octree of AbstractMesh
  119092. */
  119093. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  119094. }
  119095. interface AbstractMesh {
  119096. /**
  119097. * @hidden
  119098. * Backing Field
  119099. */
  119100. _submeshesOctree: Octree<SubMesh>;
  119101. /**
  119102. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  119103. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  119104. * @param maxCapacity defines the maximum size of each block (64 by default)
  119105. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119106. * @returns the new octree
  119107. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119109. */
  119110. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119111. }
  119112. /**
  119113. * Defines the octree scene component responsible to manage any octrees
  119114. * in a given scene.
  119115. */
  119116. export class OctreeSceneComponent {
  119117. /**
  119118. * The component name help to identify the component in the list of scene components.
  119119. */
  119120. readonly name: string;
  119121. /**
  119122. * The scene the component belongs to.
  119123. */
  119124. scene: Scene;
  119125. /**
  119126. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119127. */
  119128. readonly checksIsEnabled: boolean;
  119129. /**
  119130. * Creates a new instance of the component for the given scene
  119131. * @param scene Defines the scene to register the component in
  119132. */
  119133. constructor(scene: Scene);
  119134. /**
  119135. * Registers the component in a given scene
  119136. */
  119137. register(): void;
  119138. /**
  119139. * Return the list of active meshes
  119140. * @returns the list of active meshes
  119141. */
  119142. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119143. /**
  119144. * Return the list of active sub meshes
  119145. * @param mesh The mesh to get the candidates sub meshes from
  119146. * @returns the list of active sub meshes
  119147. */
  119148. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119149. private _tempRay;
  119150. /**
  119151. * Return the list of sub meshes intersecting with a given local ray
  119152. * @param mesh defines the mesh to find the submesh for
  119153. * @param localRay defines the ray in local space
  119154. * @returns the list of intersecting sub meshes
  119155. */
  119156. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119157. /**
  119158. * Return the list of sub meshes colliding with a collider
  119159. * @param mesh defines the mesh to find the submesh for
  119160. * @param collider defines the collider to evaluate the collision against
  119161. * @returns the list of colliding sub meshes
  119162. */
  119163. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119164. /**
  119165. * Rebuilds the elements related to this component in case of
  119166. * context lost for instance.
  119167. */
  119168. rebuild(): void;
  119169. /**
  119170. * Disposes the component and the associated ressources.
  119171. */
  119172. dispose(): void;
  119173. }
  119174. }
  119175. declare module BABYLON {
  119176. /**
  119177. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119178. */
  119179. export class Gizmo implements IDisposable {
  119180. /** The utility layer the gizmo will be added to */
  119181. gizmoLayer: UtilityLayerRenderer;
  119182. /**
  119183. * The root mesh of the gizmo
  119184. */
  119185. _rootMesh: Mesh;
  119186. private _attachedMesh;
  119187. /**
  119188. * Ratio for the scale of the gizmo (Default: 1)
  119189. */
  119190. scaleRatio: number;
  119191. /**
  119192. * If a custom mesh has been set (Default: false)
  119193. */
  119194. protected _customMeshSet: boolean;
  119195. /**
  119196. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119197. * * When set, interactions will be enabled
  119198. */
  119199. get attachedMesh(): Nullable<AbstractMesh>;
  119200. set attachedMesh(value: Nullable<AbstractMesh>);
  119201. /**
  119202. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119203. * @param mesh The mesh to replace the default mesh of the gizmo
  119204. */
  119205. setCustomMesh(mesh: Mesh): void;
  119206. /**
  119207. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119208. */
  119209. updateGizmoRotationToMatchAttachedMesh: boolean;
  119210. /**
  119211. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119212. */
  119213. updateGizmoPositionToMatchAttachedMesh: boolean;
  119214. /**
  119215. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119216. */
  119217. updateScale: boolean;
  119218. protected _interactionsEnabled: boolean;
  119219. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119220. private _beforeRenderObserver;
  119221. private _tempVector;
  119222. /**
  119223. * Creates a gizmo
  119224. * @param gizmoLayer The utility layer the gizmo will be added to
  119225. */
  119226. constructor(
  119227. /** The utility layer the gizmo will be added to */
  119228. gizmoLayer?: UtilityLayerRenderer);
  119229. /**
  119230. * Updates the gizmo to match the attached mesh's position/rotation
  119231. */
  119232. protected _update(): void;
  119233. /**
  119234. * Disposes of the gizmo
  119235. */
  119236. dispose(): void;
  119237. }
  119238. }
  119239. declare module BABYLON {
  119240. /**
  119241. * Single plane drag gizmo
  119242. */
  119243. export class PlaneDragGizmo extends Gizmo {
  119244. /**
  119245. * Drag behavior responsible for the gizmos dragging interactions
  119246. */
  119247. dragBehavior: PointerDragBehavior;
  119248. private _pointerObserver;
  119249. /**
  119250. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119251. */
  119252. snapDistance: number;
  119253. /**
  119254. * Event that fires each time the gizmo snaps to a new location.
  119255. * * snapDistance is the the change in distance
  119256. */
  119257. onSnapObservable: Observable<{
  119258. snapDistance: number;
  119259. }>;
  119260. private _plane;
  119261. private _coloredMaterial;
  119262. private _hoverMaterial;
  119263. private _isEnabled;
  119264. private _parent;
  119265. /** @hidden */
  119266. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119267. /** @hidden */
  119268. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119269. /**
  119270. * Creates a PlaneDragGizmo
  119271. * @param gizmoLayer The utility layer the gizmo will be added to
  119272. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119273. * @param color The color of the gizmo
  119274. */
  119275. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119276. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119277. /**
  119278. * If the gizmo is enabled
  119279. */
  119280. set isEnabled(value: boolean);
  119281. get isEnabled(): boolean;
  119282. /**
  119283. * Disposes of the gizmo
  119284. */
  119285. dispose(): void;
  119286. }
  119287. }
  119288. declare module BABYLON {
  119289. /**
  119290. * Gizmo that enables dragging a mesh along 3 axis
  119291. */
  119292. export class PositionGizmo extends Gizmo {
  119293. /**
  119294. * Internal gizmo used for interactions on the x axis
  119295. */
  119296. xGizmo: AxisDragGizmo;
  119297. /**
  119298. * Internal gizmo used for interactions on the y axis
  119299. */
  119300. yGizmo: AxisDragGizmo;
  119301. /**
  119302. * Internal gizmo used for interactions on the z axis
  119303. */
  119304. zGizmo: AxisDragGizmo;
  119305. /**
  119306. * Internal gizmo used for interactions on the yz plane
  119307. */
  119308. xPlaneGizmo: PlaneDragGizmo;
  119309. /**
  119310. * Internal gizmo used for interactions on the xz plane
  119311. */
  119312. yPlaneGizmo: PlaneDragGizmo;
  119313. /**
  119314. * Internal gizmo used for interactions on the xy plane
  119315. */
  119316. zPlaneGizmo: PlaneDragGizmo;
  119317. /**
  119318. * private variables
  119319. */
  119320. private _meshAttached;
  119321. private _updateGizmoRotationToMatchAttachedMesh;
  119322. private _snapDistance;
  119323. private _scaleRatio;
  119324. /** Fires an event when any of it's sub gizmos are dragged */
  119325. onDragStartObservable: Observable<unknown>;
  119326. /** Fires an event when any of it's sub gizmos are released from dragging */
  119327. onDragEndObservable: Observable<unknown>;
  119328. /**
  119329. * If set to true, planar drag is enabled
  119330. */
  119331. private _planarGizmoEnabled;
  119332. get attachedMesh(): Nullable<AbstractMesh>;
  119333. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119334. /**
  119335. * Creates a PositionGizmo
  119336. * @param gizmoLayer The utility layer the gizmo will be added to
  119337. */
  119338. constructor(gizmoLayer?: UtilityLayerRenderer);
  119339. /**
  119340. * If the planar drag gizmo is enabled
  119341. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119342. */
  119343. set planarGizmoEnabled(value: boolean);
  119344. get planarGizmoEnabled(): boolean;
  119345. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119346. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119347. /**
  119348. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119349. */
  119350. set snapDistance(value: number);
  119351. get snapDistance(): number;
  119352. /**
  119353. * Ratio for the scale of the gizmo (Default: 1)
  119354. */
  119355. set scaleRatio(value: number);
  119356. get scaleRatio(): number;
  119357. /**
  119358. * Disposes of the gizmo
  119359. */
  119360. dispose(): void;
  119361. /**
  119362. * CustomMeshes are not supported by this gizmo
  119363. * @param mesh The mesh to replace the default mesh of the gizmo
  119364. */
  119365. setCustomMesh(mesh: Mesh): void;
  119366. }
  119367. }
  119368. declare module BABYLON {
  119369. /**
  119370. * Single axis drag gizmo
  119371. */
  119372. export class AxisDragGizmo extends Gizmo {
  119373. /**
  119374. * Drag behavior responsible for the gizmos dragging interactions
  119375. */
  119376. dragBehavior: PointerDragBehavior;
  119377. private _pointerObserver;
  119378. /**
  119379. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119380. */
  119381. snapDistance: number;
  119382. /**
  119383. * Event that fires each time the gizmo snaps to a new location.
  119384. * * snapDistance is the the change in distance
  119385. */
  119386. onSnapObservable: Observable<{
  119387. snapDistance: number;
  119388. }>;
  119389. private _isEnabled;
  119390. private _parent;
  119391. private _arrow;
  119392. private _coloredMaterial;
  119393. private _hoverMaterial;
  119394. /** @hidden */
  119395. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119396. /** @hidden */
  119397. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119398. /**
  119399. * Creates an AxisDragGizmo
  119400. * @param gizmoLayer The utility layer the gizmo will be added to
  119401. * @param dragAxis The axis which the gizmo will be able to drag on
  119402. * @param color The color of the gizmo
  119403. */
  119404. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119405. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119406. /**
  119407. * If the gizmo is enabled
  119408. */
  119409. set isEnabled(value: boolean);
  119410. get isEnabled(): boolean;
  119411. /**
  119412. * Disposes of the gizmo
  119413. */
  119414. dispose(): void;
  119415. }
  119416. }
  119417. declare module BABYLON.Debug {
  119418. /**
  119419. * The Axes viewer will show 3 axes in a specific point in space
  119420. */
  119421. export class AxesViewer {
  119422. private _xAxis;
  119423. private _yAxis;
  119424. private _zAxis;
  119425. private _scaleLinesFactor;
  119426. private _instanced;
  119427. /**
  119428. * Gets the hosting scene
  119429. */
  119430. scene: Scene;
  119431. /**
  119432. * Gets or sets a number used to scale line length
  119433. */
  119434. scaleLines: number;
  119435. /** Gets the node hierarchy used to render x-axis */
  119436. get xAxis(): TransformNode;
  119437. /** Gets the node hierarchy used to render y-axis */
  119438. get yAxis(): TransformNode;
  119439. /** Gets the node hierarchy used to render z-axis */
  119440. get zAxis(): TransformNode;
  119441. /**
  119442. * Creates a new AxesViewer
  119443. * @param scene defines the hosting scene
  119444. * @param scaleLines defines a number used to scale line length (1 by default)
  119445. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119446. * @param xAxis defines the node hierarchy used to render the x-axis
  119447. * @param yAxis defines the node hierarchy used to render the y-axis
  119448. * @param zAxis defines the node hierarchy used to render the z-axis
  119449. */
  119450. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119451. /**
  119452. * Force the viewer to update
  119453. * @param position defines the position of the viewer
  119454. * @param xaxis defines the x axis of the viewer
  119455. * @param yaxis defines the y axis of the viewer
  119456. * @param zaxis defines the z axis of the viewer
  119457. */
  119458. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119459. /**
  119460. * Creates an instance of this axes viewer.
  119461. * @returns a new axes viewer with instanced meshes
  119462. */
  119463. createInstance(): AxesViewer;
  119464. /** Releases resources */
  119465. dispose(): void;
  119466. private static _SetRenderingGroupId;
  119467. }
  119468. }
  119469. declare module BABYLON.Debug {
  119470. /**
  119471. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119472. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119473. */
  119474. export class BoneAxesViewer extends AxesViewer {
  119475. /**
  119476. * Gets or sets the target mesh where to display the axes viewer
  119477. */
  119478. mesh: Nullable<Mesh>;
  119479. /**
  119480. * Gets or sets the target bone where to display the axes viewer
  119481. */
  119482. bone: Nullable<Bone>;
  119483. /** Gets current position */
  119484. pos: Vector3;
  119485. /** Gets direction of X axis */
  119486. xaxis: Vector3;
  119487. /** Gets direction of Y axis */
  119488. yaxis: Vector3;
  119489. /** Gets direction of Z axis */
  119490. zaxis: Vector3;
  119491. /**
  119492. * Creates a new BoneAxesViewer
  119493. * @param scene defines the hosting scene
  119494. * @param bone defines the target bone
  119495. * @param mesh defines the target mesh
  119496. * @param scaleLines defines a scaling factor for line length (1 by default)
  119497. */
  119498. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119499. /**
  119500. * Force the viewer to update
  119501. */
  119502. update(): void;
  119503. /** Releases resources */
  119504. dispose(): void;
  119505. }
  119506. }
  119507. declare module BABYLON {
  119508. /**
  119509. * Interface used to define scene explorer extensibility option
  119510. */
  119511. export interface IExplorerExtensibilityOption {
  119512. /**
  119513. * Define the option label
  119514. */
  119515. label: string;
  119516. /**
  119517. * Defines the action to execute on click
  119518. */
  119519. action: (entity: any) => void;
  119520. }
  119521. /**
  119522. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119523. */
  119524. export interface IExplorerExtensibilityGroup {
  119525. /**
  119526. * Defines a predicate to test if a given type mut be extended
  119527. */
  119528. predicate: (entity: any) => boolean;
  119529. /**
  119530. * Gets the list of options added to a type
  119531. */
  119532. entries: IExplorerExtensibilityOption[];
  119533. }
  119534. /**
  119535. * Interface used to define the options to use to create the Inspector
  119536. */
  119537. export interface IInspectorOptions {
  119538. /**
  119539. * Display in overlay mode (default: false)
  119540. */
  119541. overlay?: boolean;
  119542. /**
  119543. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119544. */
  119545. globalRoot?: HTMLElement;
  119546. /**
  119547. * Display the Scene explorer
  119548. */
  119549. showExplorer?: boolean;
  119550. /**
  119551. * Display the property inspector
  119552. */
  119553. showInspector?: boolean;
  119554. /**
  119555. * Display in embed mode (both panes on the right)
  119556. */
  119557. embedMode?: boolean;
  119558. /**
  119559. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119560. */
  119561. handleResize?: boolean;
  119562. /**
  119563. * Allow the panes to popup (default: true)
  119564. */
  119565. enablePopup?: boolean;
  119566. /**
  119567. * Allow the panes to be closed by users (default: true)
  119568. */
  119569. enableClose?: boolean;
  119570. /**
  119571. * Optional list of extensibility entries
  119572. */
  119573. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119574. /**
  119575. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119576. */
  119577. inspectorURL?: string;
  119578. /**
  119579. * Optional initial tab (default to DebugLayerTab.Properties)
  119580. */
  119581. initialTab?: DebugLayerTab;
  119582. }
  119583. interface Scene {
  119584. /**
  119585. * @hidden
  119586. * Backing field
  119587. */
  119588. _debugLayer: DebugLayer;
  119589. /**
  119590. * Gets the debug layer (aka Inspector) associated with the scene
  119591. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119592. */
  119593. debugLayer: DebugLayer;
  119594. }
  119595. /**
  119596. * Enum of inspector action tab
  119597. */
  119598. export enum DebugLayerTab {
  119599. /**
  119600. * Properties tag (default)
  119601. */
  119602. Properties = 0,
  119603. /**
  119604. * Debug tab
  119605. */
  119606. Debug = 1,
  119607. /**
  119608. * Statistics tab
  119609. */
  119610. Statistics = 2,
  119611. /**
  119612. * Tools tab
  119613. */
  119614. Tools = 3,
  119615. /**
  119616. * Settings tab
  119617. */
  119618. Settings = 4
  119619. }
  119620. /**
  119621. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119622. * what is happening in your scene
  119623. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119624. */
  119625. export class DebugLayer {
  119626. /**
  119627. * Define the url to get the inspector script from.
  119628. * By default it uses the babylonjs CDN.
  119629. * @ignoreNaming
  119630. */
  119631. static InspectorURL: string;
  119632. private _scene;
  119633. private BJSINSPECTOR;
  119634. private _onPropertyChangedObservable?;
  119635. /**
  119636. * Observable triggered when a property is changed through the inspector.
  119637. */
  119638. get onPropertyChangedObservable(): any;
  119639. /**
  119640. * Instantiates a new debug layer.
  119641. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119642. * what is happening in your scene
  119643. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119644. * @param scene Defines the scene to inspect
  119645. */
  119646. constructor(scene: Scene);
  119647. /** Creates the inspector window. */
  119648. private _createInspector;
  119649. /**
  119650. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119651. * @param entity defines the entity to select
  119652. * @param lineContainerTitle defines the specific block to highlight
  119653. */
  119654. select(entity: any, lineContainerTitle?: string): void;
  119655. /** Get the inspector from bundle or global */
  119656. private _getGlobalInspector;
  119657. /**
  119658. * Get if the inspector is visible or not.
  119659. * @returns true if visible otherwise, false
  119660. */
  119661. isVisible(): boolean;
  119662. /**
  119663. * Hide the inspector and close its window.
  119664. */
  119665. hide(): void;
  119666. /**
  119667. * Launch the debugLayer.
  119668. * @param config Define the configuration of the inspector
  119669. * @return a promise fulfilled when the debug layer is visible
  119670. */
  119671. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119672. }
  119673. }
  119674. declare module BABYLON {
  119675. /**
  119676. * Class containing static functions to help procedurally build meshes
  119677. */
  119678. export class BoxBuilder {
  119679. /**
  119680. * Creates a box mesh
  119681. * * The parameter `size` sets the size (float) of each box side (default 1)
  119682. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119683. * * 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)
  119684. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119688. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119689. * @param name defines the name of the mesh
  119690. * @param options defines the options used to create the mesh
  119691. * @param scene defines the hosting scene
  119692. * @returns the box mesh
  119693. */
  119694. static CreateBox(name: string, options: {
  119695. size?: number;
  119696. width?: number;
  119697. height?: number;
  119698. depth?: number;
  119699. faceUV?: Vector4[];
  119700. faceColors?: Color4[];
  119701. sideOrientation?: number;
  119702. frontUVs?: Vector4;
  119703. backUVs?: Vector4;
  119704. wrap?: boolean;
  119705. topBaseAt?: number;
  119706. bottomBaseAt?: number;
  119707. updatable?: boolean;
  119708. }, scene?: Nullable<Scene>): Mesh;
  119709. }
  119710. }
  119711. declare module BABYLON.Debug {
  119712. /**
  119713. * Used to show the physics impostor around the specific mesh
  119714. */
  119715. export class PhysicsViewer {
  119716. /** @hidden */
  119717. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119718. /** @hidden */
  119719. protected _meshes: Array<Nullable<AbstractMesh>>;
  119720. /** @hidden */
  119721. protected _scene: Nullable<Scene>;
  119722. /** @hidden */
  119723. protected _numMeshes: number;
  119724. /** @hidden */
  119725. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119726. private _renderFunction;
  119727. private _utilityLayer;
  119728. private _debugBoxMesh;
  119729. private _debugSphereMesh;
  119730. private _debugCylinderMesh;
  119731. private _debugMaterial;
  119732. private _debugMeshMeshes;
  119733. /**
  119734. * Creates a new PhysicsViewer
  119735. * @param scene defines the hosting scene
  119736. */
  119737. constructor(scene: Scene);
  119738. /** @hidden */
  119739. protected _updateDebugMeshes(): void;
  119740. /**
  119741. * Renders a specified physic impostor
  119742. * @param impostor defines the impostor to render
  119743. * @param targetMesh defines the mesh represented by the impostor
  119744. * @returns the new debug mesh used to render the impostor
  119745. */
  119746. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119747. /**
  119748. * Hides a specified physic impostor
  119749. * @param impostor defines the impostor to hide
  119750. */
  119751. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119752. private _getDebugMaterial;
  119753. private _getDebugBoxMesh;
  119754. private _getDebugSphereMesh;
  119755. private _getDebugCylinderMesh;
  119756. private _getDebugMeshMesh;
  119757. private _getDebugMesh;
  119758. /** Releases all resources */
  119759. dispose(): void;
  119760. }
  119761. }
  119762. declare module BABYLON {
  119763. /**
  119764. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119765. * in order to better appreciate the issue one might have.
  119766. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119767. */
  119768. export class RayHelper {
  119769. /**
  119770. * Defines the ray we are currently tryin to visualize.
  119771. */
  119772. ray: Nullable<Ray>;
  119773. private _renderPoints;
  119774. private _renderLine;
  119775. private _renderFunction;
  119776. private _scene;
  119777. private _updateToMeshFunction;
  119778. private _attachedToMesh;
  119779. private _meshSpaceDirection;
  119780. private _meshSpaceOrigin;
  119781. /**
  119782. * Helper function to create a colored helper in a scene in one line.
  119783. * @param ray Defines the ray we are currently tryin to visualize
  119784. * @param scene Defines the scene the ray is used in
  119785. * @param color Defines the color we want to see the ray in
  119786. * @returns The newly created ray helper.
  119787. */
  119788. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119789. /**
  119790. * Instantiate a new ray helper.
  119791. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119792. * in order to better appreciate the issue one might have.
  119793. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119794. * @param ray Defines the ray we are currently tryin to visualize
  119795. */
  119796. constructor(ray: Ray);
  119797. /**
  119798. * Shows the ray we are willing to debug.
  119799. * @param scene Defines the scene the ray needs to be rendered in
  119800. * @param color Defines the color the ray needs to be rendered in
  119801. */
  119802. show(scene: Scene, color?: Color3): void;
  119803. /**
  119804. * Hides the ray we are debugging.
  119805. */
  119806. hide(): void;
  119807. private _render;
  119808. /**
  119809. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119810. * @param mesh Defines the mesh we want the helper attached to
  119811. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119812. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119813. * @param length Defines the length of the ray
  119814. */
  119815. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119816. /**
  119817. * Detach the ray helper from the mesh it has previously been attached to.
  119818. */
  119819. detachFromMesh(): void;
  119820. private _updateToMesh;
  119821. /**
  119822. * Dispose the helper and release its associated resources.
  119823. */
  119824. dispose(): void;
  119825. }
  119826. }
  119827. declare module BABYLON.Debug {
  119828. /**
  119829. * Class used to render a debug view of a given skeleton
  119830. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119831. */
  119832. export class SkeletonViewer {
  119833. /** defines the skeleton to render */
  119834. skeleton: Skeleton;
  119835. /** defines the mesh attached to the skeleton */
  119836. mesh: AbstractMesh;
  119837. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119838. autoUpdateBonesMatrices: boolean;
  119839. /** defines the rendering group id to use with the viewer */
  119840. renderingGroupId: number;
  119841. /** Gets or sets the color used to render the skeleton */
  119842. color: Color3;
  119843. private _scene;
  119844. private _debugLines;
  119845. private _debugMesh;
  119846. private _isEnabled;
  119847. private _renderFunction;
  119848. private _utilityLayer;
  119849. /**
  119850. * Returns the mesh used to render the bones
  119851. */
  119852. get debugMesh(): Nullable<LinesMesh>;
  119853. /**
  119854. * Creates a new SkeletonViewer
  119855. * @param skeleton defines the skeleton to render
  119856. * @param mesh defines the mesh attached to the skeleton
  119857. * @param scene defines the hosting scene
  119858. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119859. * @param renderingGroupId defines the rendering group id to use with the viewer
  119860. */
  119861. constructor(
  119862. /** defines the skeleton to render */
  119863. skeleton: Skeleton,
  119864. /** defines the mesh attached to the skeleton */
  119865. mesh: AbstractMesh, scene: Scene,
  119866. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119867. autoUpdateBonesMatrices?: boolean,
  119868. /** defines the rendering group id to use with the viewer */
  119869. renderingGroupId?: number);
  119870. /** Gets or sets a boolean indicating if the viewer is enabled */
  119871. set isEnabled(value: boolean);
  119872. get isEnabled(): boolean;
  119873. private _getBonePosition;
  119874. private _getLinesForBonesWithLength;
  119875. private _getLinesForBonesNoLength;
  119876. /** Update the viewer to sync with current skeleton state */
  119877. update(): void;
  119878. /** Release associated resources */
  119879. dispose(): void;
  119880. }
  119881. }
  119882. declare module BABYLON {
  119883. /**
  119884. * Options to create the null engine
  119885. */
  119886. export class NullEngineOptions {
  119887. /**
  119888. * Render width (Default: 512)
  119889. */
  119890. renderWidth: number;
  119891. /**
  119892. * Render height (Default: 256)
  119893. */
  119894. renderHeight: number;
  119895. /**
  119896. * Texture size (Default: 512)
  119897. */
  119898. textureSize: number;
  119899. /**
  119900. * If delta time between frames should be constant
  119901. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119902. */
  119903. deterministicLockstep: boolean;
  119904. /**
  119905. * Maximum about of steps between frames (Default: 4)
  119906. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119907. */
  119908. lockstepMaxSteps: number;
  119909. }
  119910. /**
  119911. * The null engine class provides support for headless version of babylon.js.
  119912. * This can be used in server side scenario or for testing purposes
  119913. */
  119914. export class NullEngine extends Engine {
  119915. private _options;
  119916. /**
  119917. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119919. * @returns true if engine is in deterministic lock step mode
  119920. */
  119921. isDeterministicLockStep(): boolean;
  119922. /**
  119923. * Gets the max steps when engine is running in deterministic lock step
  119924. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119925. * @returns the max steps
  119926. */
  119927. getLockstepMaxSteps(): number;
  119928. /**
  119929. * Gets the current hardware scaling level.
  119930. * By default the hardware scaling level is computed from the window device ratio.
  119931. * 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.
  119932. * @returns a number indicating the current hardware scaling level
  119933. */
  119934. getHardwareScalingLevel(): number;
  119935. constructor(options?: NullEngineOptions);
  119936. /**
  119937. * Creates a vertex buffer
  119938. * @param vertices the data for the vertex buffer
  119939. * @returns the new WebGL static buffer
  119940. */
  119941. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119942. /**
  119943. * Creates a new index buffer
  119944. * @param indices defines the content of the index buffer
  119945. * @param updatable defines if the index buffer must be updatable
  119946. * @returns a new webGL buffer
  119947. */
  119948. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119949. /**
  119950. * Clear the current render buffer or the current render target (if any is set up)
  119951. * @param color defines the color to use
  119952. * @param backBuffer defines if the back buffer must be cleared
  119953. * @param depth defines if the depth buffer must be cleared
  119954. * @param stencil defines if the stencil buffer must be cleared
  119955. */
  119956. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119957. /**
  119958. * Gets the current render width
  119959. * @param useScreen defines if screen size must be used (or the current render target if any)
  119960. * @returns a number defining the current render width
  119961. */
  119962. getRenderWidth(useScreen?: boolean): number;
  119963. /**
  119964. * Gets the current render height
  119965. * @param useScreen defines if screen size must be used (or the current render target if any)
  119966. * @returns a number defining the current render height
  119967. */
  119968. getRenderHeight(useScreen?: boolean): number;
  119969. /**
  119970. * Set the WebGL's viewport
  119971. * @param viewport defines the viewport element to be used
  119972. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119973. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119974. */
  119975. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119976. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119977. /**
  119978. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119979. * @param pipelineContext defines the pipeline context to use
  119980. * @param uniformsNames defines the list of uniform names
  119981. * @returns an array of webGL uniform locations
  119982. */
  119983. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119984. /**
  119985. * Gets the lsit of active attributes for a given webGL program
  119986. * @param pipelineContext defines the pipeline context to use
  119987. * @param attributesNames defines the list of attribute names to get
  119988. * @returns an array of indices indicating the offset of each attribute
  119989. */
  119990. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119991. /**
  119992. * Binds an effect to the webGL context
  119993. * @param effect defines the effect to bind
  119994. */
  119995. bindSamplers(effect: Effect): void;
  119996. /**
  119997. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119998. * @param effect defines the effect to activate
  119999. */
  120000. enableEffect(effect: Effect): void;
  120001. /**
  120002. * Set various states to the webGL context
  120003. * @param culling defines backface culling state
  120004. * @param zOffset defines the value to apply to zOffset (0 by default)
  120005. * @param force defines if states must be applied even if cache is up to date
  120006. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  120007. */
  120008. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120009. /**
  120010. * Set the value of an uniform to an array of int32
  120011. * @param uniform defines the webGL uniform location where to store the value
  120012. * @param array defines the array of int32 to store
  120013. */
  120014. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120015. /**
  120016. * Set the value of an uniform to an array of int32 (stored as vec2)
  120017. * @param uniform defines the webGL uniform location where to store the value
  120018. * @param array defines the array of int32 to store
  120019. */
  120020. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120021. /**
  120022. * Set the value of an uniform to an array of int32 (stored as vec3)
  120023. * @param uniform defines the webGL uniform location where to store the value
  120024. * @param array defines the array of int32 to store
  120025. */
  120026. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120027. /**
  120028. * Set the value of an uniform to an array of int32 (stored as vec4)
  120029. * @param uniform defines the webGL uniform location where to store the value
  120030. * @param array defines the array of int32 to store
  120031. */
  120032. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120033. /**
  120034. * Set the value of an uniform to an array of float32
  120035. * @param uniform defines the webGL uniform location where to store the value
  120036. * @param array defines the array of float32 to store
  120037. */
  120038. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120039. /**
  120040. * Set the value of an uniform to an array of float32 (stored as vec2)
  120041. * @param uniform defines the webGL uniform location where to store the value
  120042. * @param array defines the array of float32 to store
  120043. */
  120044. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120045. /**
  120046. * Set the value of an uniform to an array of float32 (stored as vec3)
  120047. * @param uniform defines the webGL uniform location where to store the value
  120048. * @param array defines the array of float32 to store
  120049. */
  120050. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120051. /**
  120052. * Set the value of an uniform to an array of float32 (stored as vec4)
  120053. * @param uniform defines the webGL uniform location where to store the value
  120054. * @param array defines the array of float32 to store
  120055. */
  120056. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120057. /**
  120058. * Set the value of an uniform to an array of number
  120059. * @param uniform defines the webGL uniform location where to store the value
  120060. * @param array defines the array of number to store
  120061. */
  120062. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120063. /**
  120064. * Set the value of an uniform to an array of number (stored as vec2)
  120065. * @param uniform defines the webGL uniform location where to store the value
  120066. * @param array defines the array of number to store
  120067. */
  120068. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120069. /**
  120070. * Set the value of an uniform to an array of number (stored as vec3)
  120071. * @param uniform defines the webGL uniform location where to store the value
  120072. * @param array defines the array of number to store
  120073. */
  120074. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120075. /**
  120076. * Set the value of an uniform to an array of number (stored as vec4)
  120077. * @param uniform defines the webGL uniform location where to store the value
  120078. * @param array defines the array of number to store
  120079. */
  120080. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120081. /**
  120082. * Set the value of an uniform to an array of float32 (stored as matrices)
  120083. * @param uniform defines the webGL uniform location where to store the value
  120084. * @param matrices defines the array of float32 to store
  120085. */
  120086. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120087. /**
  120088. * Set the value of an uniform to a matrix (3x3)
  120089. * @param uniform defines the webGL uniform location where to store the value
  120090. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120091. */
  120092. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120093. /**
  120094. * Set the value of an uniform to a matrix (2x2)
  120095. * @param uniform defines the webGL uniform location where to store the value
  120096. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120097. */
  120098. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120099. /**
  120100. * Set the value of an uniform to a number (float)
  120101. * @param uniform defines the webGL uniform location where to store the value
  120102. * @param value defines the float number to store
  120103. */
  120104. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120105. /**
  120106. * Set the value of an uniform to a vec2
  120107. * @param uniform defines the webGL uniform location where to store the value
  120108. * @param x defines the 1st component of the value
  120109. * @param y defines the 2nd component of the value
  120110. */
  120111. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120112. /**
  120113. * Set the value of an uniform to a vec3
  120114. * @param uniform defines the webGL uniform location where to store the value
  120115. * @param x defines the 1st component of the value
  120116. * @param y defines the 2nd component of the value
  120117. * @param z defines the 3rd component of the value
  120118. */
  120119. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120120. /**
  120121. * Set the value of an uniform to a boolean
  120122. * @param uniform defines the webGL uniform location where to store the value
  120123. * @param bool defines the boolean to store
  120124. */
  120125. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120126. /**
  120127. * Set the value of an uniform to a vec4
  120128. * @param uniform defines the webGL uniform location where to store the value
  120129. * @param x defines the 1st component of the value
  120130. * @param y defines the 2nd component of the value
  120131. * @param z defines the 3rd component of the value
  120132. * @param w defines the 4th component of the value
  120133. */
  120134. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120135. /**
  120136. * Sets the current alpha mode
  120137. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120138. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120139. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120140. */
  120141. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120142. /**
  120143. * Bind webGl buffers directly to the webGL context
  120144. * @param vertexBuffers defines the vertex buffer to bind
  120145. * @param indexBuffer defines the index buffer to bind
  120146. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120147. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120148. * @param effect defines the effect associated with the vertex buffer
  120149. */
  120150. bindBuffers(vertexBuffers: {
  120151. [key: string]: VertexBuffer;
  120152. }, indexBuffer: DataBuffer, effect: Effect): void;
  120153. /**
  120154. * Force the entire cache to be cleared
  120155. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120156. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120157. */
  120158. wipeCaches(bruteForce?: boolean): void;
  120159. /**
  120160. * Send a draw order
  120161. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120162. * @param indexStart defines the starting index
  120163. * @param indexCount defines the number of index to draw
  120164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120165. */
  120166. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120167. /**
  120168. * Draw a list of indexed primitives
  120169. * @param fillMode defines the primitive to use
  120170. * @param indexStart defines the starting index
  120171. * @param indexCount defines the number of index to draw
  120172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120173. */
  120174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120175. /**
  120176. * Draw a list of unindexed primitives
  120177. * @param fillMode defines the primitive to use
  120178. * @param verticesStart defines the index of first vertex to draw
  120179. * @param verticesCount defines the count of vertices to draw
  120180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120181. */
  120182. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120183. /** @hidden */
  120184. _createTexture(): WebGLTexture;
  120185. /** @hidden */
  120186. _releaseTexture(texture: InternalTexture): void;
  120187. /**
  120188. * Usually called from Texture.ts.
  120189. * Passed information to create a WebGLTexture
  120190. * @param urlArg defines a value which contains one of the following:
  120191. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120192. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120193. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120194. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120195. * @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)
  120196. * @param scene needed for loading to the correct scene
  120197. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120198. * @param onLoad optional callback to be called upon successful completion
  120199. * @param onError optional callback to be called upon failure
  120200. * @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
  120201. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120202. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120203. * @param forcedExtension defines the extension to use to pick the right loader
  120204. * @param mimeType defines an optional mime type
  120205. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120206. */
  120207. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  120208. /**
  120209. * Creates a new render target texture
  120210. * @param size defines the size of the texture
  120211. * @param options defines the options used to create the texture
  120212. * @returns a new render target texture stored in an InternalTexture
  120213. */
  120214. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120215. /**
  120216. * Update the sampling mode of a given texture
  120217. * @param samplingMode defines the required sampling mode
  120218. * @param texture defines the texture to update
  120219. */
  120220. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120221. /**
  120222. * Binds the frame buffer to the specified texture.
  120223. * @param texture The texture to render to or null for the default canvas
  120224. * @param faceIndex The face of the texture to render to in case of cube texture
  120225. * @param requiredWidth The width of the target to render to
  120226. * @param requiredHeight The height of the target to render to
  120227. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120228. * @param lodLevel defines le lod level to bind to the frame buffer
  120229. */
  120230. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120231. /**
  120232. * Unbind the current render target texture from the webGL context
  120233. * @param texture defines the render target texture to unbind
  120234. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120235. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120236. */
  120237. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120238. /**
  120239. * Creates a dynamic vertex buffer
  120240. * @param vertices the data for the dynamic vertex buffer
  120241. * @returns the new WebGL dynamic buffer
  120242. */
  120243. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120244. /**
  120245. * Update the content of a dynamic texture
  120246. * @param texture defines the texture to update
  120247. * @param canvas defines the canvas containing the source
  120248. * @param invertY defines if data must be stored with Y axis inverted
  120249. * @param premulAlpha defines if alpha is stored as premultiplied
  120250. * @param format defines the format of the data
  120251. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120252. */
  120253. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120254. /**
  120255. * Gets a boolean indicating if all created effects are ready
  120256. * @returns true if all effects are ready
  120257. */
  120258. areAllEffectsReady(): boolean;
  120259. /**
  120260. * @hidden
  120261. * Get the current error code of the webGL context
  120262. * @returns the error code
  120263. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120264. */
  120265. getError(): number;
  120266. /** @hidden */
  120267. _getUnpackAlignement(): number;
  120268. /** @hidden */
  120269. _unpackFlipY(value: boolean): void;
  120270. /**
  120271. * Update a dynamic index buffer
  120272. * @param indexBuffer defines the target index buffer
  120273. * @param indices defines the data to update
  120274. * @param offset defines the offset in the target index buffer where update should start
  120275. */
  120276. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120277. /**
  120278. * Updates a dynamic vertex buffer.
  120279. * @param vertexBuffer the vertex buffer to update
  120280. * @param vertices the data used to update the vertex buffer
  120281. * @param byteOffset the byte offset of the data (optional)
  120282. * @param byteLength the byte length of the data (optional)
  120283. */
  120284. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120285. /** @hidden */
  120286. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120287. /** @hidden */
  120288. _bindTexture(channel: number, texture: InternalTexture): void;
  120289. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120290. /**
  120291. * 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
  120292. */
  120293. releaseEffects(): void;
  120294. displayLoadingUI(): void;
  120295. hideLoadingUI(): void;
  120296. /** @hidden */
  120297. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120298. /** @hidden */
  120299. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120300. /** @hidden */
  120301. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120302. /** @hidden */
  120303. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120304. }
  120305. }
  120306. declare module BABYLON {
  120307. /**
  120308. * @hidden
  120309. **/
  120310. export class _TimeToken {
  120311. _startTimeQuery: Nullable<WebGLQuery>;
  120312. _endTimeQuery: Nullable<WebGLQuery>;
  120313. _timeElapsedQuery: Nullable<WebGLQuery>;
  120314. _timeElapsedQueryEnded: boolean;
  120315. }
  120316. }
  120317. declare module BABYLON {
  120318. /** @hidden */
  120319. export class _OcclusionDataStorage {
  120320. /** @hidden */
  120321. occlusionInternalRetryCounter: number;
  120322. /** @hidden */
  120323. isOcclusionQueryInProgress: boolean;
  120324. /** @hidden */
  120325. isOccluded: boolean;
  120326. /** @hidden */
  120327. occlusionRetryCount: number;
  120328. /** @hidden */
  120329. occlusionType: number;
  120330. /** @hidden */
  120331. occlusionQueryAlgorithmType: number;
  120332. }
  120333. interface Engine {
  120334. /**
  120335. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120336. * @return the new query
  120337. */
  120338. createQuery(): WebGLQuery;
  120339. /**
  120340. * Delete and release a webGL query
  120341. * @param query defines the query to delete
  120342. * @return the current engine
  120343. */
  120344. deleteQuery(query: WebGLQuery): Engine;
  120345. /**
  120346. * Check if a given query has resolved and got its value
  120347. * @param query defines the query to check
  120348. * @returns true if the query got its value
  120349. */
  120350. isQueryResultAvailable(query: WebGLQuery): boolean;
  120351. /**
  120352. * Gets the value of a given query
  120353. * @param query defines the query to check
  120354. * @returns the value of the query
  120355. */
  120356. getQueryResult(query: WebGLQuery): number;
  120357. /**
  120358. * Initiates an occlusion query
  120359. * @param algorithmType defines the algorithm to use
  120360. * @param query defines the query to use
  120361. * @returns the current engine
  120362. * @see http://doc.babylonjs.com/features/occlusionquery
  120363. */
  120364. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120365. /**
  120366. * Ends an occlusion query
  120367. * @see http://doc.babylonjs.com/features/occlusionquery
  120368. * @param algorithmType defines the algorithm to use
  120369. * @returns the current engine
  120370. */
  120371. endOcclusionQuery(algorithmType: number): Engine;
  120372. /**
  120373. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120374. * Please note that only one query can be issued at a time
  120375. * @returns a time token used to track the time span
  120376. */
  120377. startTimeQuery(): Nullable<_TimeToken>;
  120378. /**
  120379. * Ends a time query
  120380. * @param token defines the token used to measure the time span
  120381. * @returns the time spent (in ns)
  120382. */
  120383. endTimeQuery(token: _TimeToken): int;
  120384. /** @hidden */
  120385. _currentNonTimestampToken: Nullable<_TimeToken>;
  120386. /** @hidden */
  120387. _createTimeQuery(): WebGLQuery;
  120388. /** @hidden */
  120389. _deleteTimeQuery(query: WebGLQuery): void;
  120390. /** @hidden */
  120391. _getGlAlgorithmType(algorithmType: number): number;
  120392. /** @hidden */
  120393. _getTimeQueryResult(query: WebGLQuery): any;
  120394. /** @hidden */
  120395. _getTimeQueryAvailability(query: WebGLQuery): any;
  120396. }
  120397. interface AbstractMesh {
  120398. /**
  120399. * Backing filed
  120400. * @hidden
  120401. */
  120402. __occlusionDataStorage: _OcclusionDataStorage;
  120403. /**
  120404. * Access property
  120405. * @hidden
  120406. */
  120407. _occlusionDataStorage: _OcclusionDataStorage;
  120408. /**
  120409. * 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.
  120410. * The default value is -1 which means don't break the query and wait till the result
  120411. * @see http://doc.babylonjs.com/features/occlusionquery
  120412. */
  120413. occlusionRetryCount: number;
  120414. /**
  120415. * 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:
  120416. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120417. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120418. * * 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.
  120419. * @see http://doc.babylonjs.com/features/occlusionquery
  120420. */
  120421. occlusionType: number;
  120422. /**
  120423. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120424. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120425. * * 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.
  120426. * @see http://doc.babylonjs.com/features/occlusionquery
  120427. */
  120428. occlusionQueryAlgorithmType: number;
  120429. /**
  120430. * 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
  120431. * @see http://doc.babylonjs.com/features/occlusionquery
  120432. */
  120433. isOccluded: boolean;
  120434. /**
  120435. * Flag to check the progress status of the query
  120436. * @see http://doc.babylonjs.com/features/occlusionquery
  120437. */
  120438. isOcclusionQueryInProgress: boolean;
  120439. }
  120440. }
  120441. declare module BABYLON {
  120442. /** @hidden */
  120443. export var _forceTransformFeedbackToBundle: boolean;
  120444. interface Engine {
  120445. /**
  120446. * Creates a webGL transform feedback object
  120447. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120448. * @returns the webGL transform feedback object
  120449. */
  120450. createTransformFeedback(): WebGLTransformFeedback;
  120451. /**
  120452. * Delete a webGL transform feedback object
  120453. * @param value defines the webGL transform feedback object to delete
  120454. */
  120455. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120456. /**
  120457. * Bind a webGL transform feedback object to the webgl context
  120458. * @param value defines the webGL transform feedback object to bind
  120459. */
  120460. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120461. /**
  120462. * Begins a transform feedback operation
  120463. * @param usePoints defines if points or triangles must be used
  120464. */
  120465. beginTransformFeedback(usePoints: boolean): void;
  120466. /**
  120467. * Ends a transform feedback operation
  120468. */
  120469. endTransformFeedback(): void;
  120470. /**
  120471. * Specify the varyings to use with transform feedback
  120472. * @param program defines the associated webGL program
  120473. * @param value defines the list of strings representing the varying names
  120474. */
  120475. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120476. /**
  120477. * Bind a webGL buffer for a transform feedback operation
  120478. * @param value defines the webGL buffer to bind
  120479. */
  120480. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120481. }
  120482. }
  120483. declare module BABYLON {
  120484. /**
  120485. * Creation options of the multi render target texture.
  120486. */
  120487. export interface IMultiRenderTargetOptions {
  120488. /**
  120489. * Define if the texture needs to create mip maps after render.
  120490. */
  120491. generateMipMaps?: boolean;
  120492. /**
  120493. * Define the types of all the draw buffers we want to create
  120494. */
  120495. types?: number[];
  120496. /**
  120497. * Define the sampling modes of all the draw buffers we want to create
  120498. */
  120499. samplingModes?: number[];
  120500. /**
  120501. * Define if a depth buffer is required
  120502. */
  120503. generateDepthBuffer?: boolean;
  120504. /**
  120505. * Define if a stencil buffer is required
  120506. */
  120507. generateStencilBuffer?: boolean;
  120508. /**
  120509. * Define if a depth texture is required instead of a depth buffer
  120510. */
  120511. generateDepthTexture?: boolean;
  120512. /**
  120513. * Define the number of desired draw buffers
  120514. */
  120515. textureCount?: number;
  120516. /**
  120517. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120518. */
  120519. doNotChangeAspectRatio?: boolean;
  120520. /**
  120521. * Define the default type of the buffers we are creating
  120522. */
  120523. defaultType?: number;
  120524. }
  120525. /**
  120526. * A multi render target, like a render target provides the ability to render to a texture.
  120527. * Unlike the render target, it can render to several draw buffers in one draw.
  120528. * This is specially interesting in deferred rendering or for any effects requiring more than
  120529. * just one color from a single pass.
  120530. */
  120531. export class MultiRenderTarget extends RenderTargetTexture {
  120532. private _internalTextures;
  120533. private _textures;
  120534. private _multiRenderTargetOptions;
  120535. /**
  120536. * Get if draw buffers are currently supported by the used hardware and browser.
  120537. */
  120538. get isSupported(): boolean;
  120539. /**
  120540. * Get the list of textures generated by the multi render target.
  120541. */
  120542. get textures(): Texture[];
  120543. /**
  120544. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120545. */
  120546. get depthTexture(): Texture;
  120547. /**
  120548. * Set the wrapping mode on U of all the textures we are rendering to.
  120549. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120550. */
  120551. set wrapU(wrap: number);
  120552. /**
  120553. * Set the wrapping mode on V of all the textures we are rendering to.
  120554. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120555. */
  120556. set wrapV(wrap: number);
  120557. /**
  120558. * Instantiate a new multi render target texture.
  120559. * A multi render target, like a render target provides the ability to render to a texture.
  120560. * Unlike the render target, it can render to several draw buffers in one draw.
  120561. * This is specially interesting in deferred rendering or for any effects requiring more than
  120562. * just one color from a single pass.
  120563. * @param name Define the name of the texture
  120564. * @param size Define the size of the buffers to render to
  120565. * @param count Define the number of target we are rendering into
  120566. * @param scene Define the scene the texture belongs to
  120567. * @param options Define the options used to create the multi render target
  120568. */
  120569. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120570. /** @hidden */
  120571. _rebuild(): void;
  120572. private _createInternalTextures;
  120573. private _createTextures;
  120574. /**
  120575. * Define the number of samples used if MSAA is enabled.
  120576. */
  120577. get samples(): number;
  120578. set samples(value: number);
  120579. /**
  120580. * Resize all the textures in the multi render target.
  120581. * Be carrefull as it will recreate all the data in the new texture.
  120582. * @param size Define the new size
  120583. */
  120584. resize(size: any): void;
  120585. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120586. /**
  120587. * Dispose the render targets and their associated resources
  120588. */
  120589. dispose(): void;
  120590. /**
  120591. * Release all the underlying texture used as draw buffers.
  120592. */
  120593. releaseInternalTextures(): void;
  120594. }
  120595. }
  120596. declare module BABYLON {
  120597. interface ThinEngine {
  120598. /**
  120599. * Unbind a list of render target textures from the webGL context
  120600. * This is used only when drawBuffer extension or webGL2 are active
  120601. * @param textures defines the render target textures to unbind
  120602. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120603. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120604. */
  120605. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120606. /**
  120607. * Create a multi render target texture
  120608. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120609. * @param size defines the size of the texture
  120610. * @param options defines the creation options
  120611. * @returns the cube texture as an InternalTexture
  120612. */
  120613. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120614. /**
  120615. * Update the sample count for a given multiple render target texture
  120616. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120617. * @param textures defines the textures to update
  120618. * @param samples defines the sample count to set
  120619. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120620. */
  120621. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120622. }
  120623. }
  120624. declare module BABYLON {
  120625. /**
  120626. * Class used to define an additional view for the engine
  120627. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120628. */
  120629. export class EngineView {
  120630. /** Defines the canvas where to render the view */
  120631. target: HTMLCanvasElement;
  120632. /** Defines an optional camera used to render the view (will use active camera else) */
  120633. camera?: Camera;
  120634. }
  120635. interface Engine {
  120636. /**
  120637. * Gets or sets the HTML element to use for attaching events
  120638. */
  120639. inputElement: Nullable<HTMLElement>;
  120640. /**
  120641. * Gets the current engine view
  120642. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120643. */
  120644. activeView: Nullable<EngineView>;
  120645. /** Gets or sets the list of views */
  120646. views: EngineView[];
  120647. /**
  120648. * Register a new child canvas
  120649. * @param canvas defines the canvas to register
  120650. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120651. * @returns the associated view
  120652. */
  120653. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120654. /**
  120655. * Remove a registered child canvas
  120656. * @param canvas defines the canvas to remove
  120657. * @returns the current engine
  120658. */
  120659. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120660. }
  120661. }
  120662. declare module BABYLON {
  120663. /**
  120664. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120665. */
  120666. export interface CubeMapInfo {
  120667. /**
  120668. * The pixel array for the front face.
  120669. * This is stored in format, left to right, up to down format.
  120670. */
  120671. front: Nullable<ArrayBufferView>;
  120672. /**
  120673. * The pixel array for the back face.
  120674. * This is stored in format, left to right, up to down format.
  120675. */
  120676. back: Nullable<ArrayBufferView>;
  120677. /**
  120678. * The pixel array for the left face.
  120679. * This is stored in format, left to right, up to down format.
  120680. */
  120681. left: Nullable<ArrayBufferView>;
  120682. /**
  120683. * The pixel array for the right face.
  120684. * This is stored in format, left to right, up to down format.
  120685. */
  120686. right: Nullable<ArrayBufferView>;
  120687. /**
  120688. * The pixel array for the up face.
  120689. * This is stored in format, left to right, up to down format.
  120690. */
  120691. up: Nullable<ArrayBufferView>;
  120692. /**
  120693. * The pixel array for the down face.
  120694. * This is stored in format, left to right, up to down format.
  120695. */
  120696. down: Nullable<ArrayBufferView>;
  120697. /**
  120698. * The size of the cubemap stored.
  120699. *
  120700. * Each faces will be size * size pixels.
  120701. */
  120702. size: number;
  120703. /**
  120704. * The format of the texture.
  120705. *
  120706. * RGBA, RGB.
  120707. */
  120708. format: number;
  120709. /**
  120710. * The type of the texture data.
  120711. *
  120712. * UNSIGNED_INT, FLOAT.
  120713. */
  120714. type: number;
  120715. /**
  120716. * Specifies whether the texture is in gamma space.
  120717. */
  120718. gammaSpace: boolean;
  120719. }
  120720. /**
  120721. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120722. */
  120723. export class PanoramaToCubeMapTools {
  120724. private static FACE_FRONT;
  120725. private static FACE_BACK;
  120726. private static FACE_RIGHT;
  120727. private static FACE_LEFT;
  120728. private static FACE_DOWN;
  120729. private static FACE_UP;
  120730. /**
  120731. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120732. *
  120733. * @param float32Array The source data.
  120734. * @param inputWidth The width of the input panorama.
  120735. * @param inputHeight The height of the input panorama.
  120736. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120737. * @return The cubemap data
  120738. */
  120739. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120740. private static CreateCubemapTexture;
  120741. private static CalcProjectionSpherical;
  120742. }
  120743. }
  120744. declare module BABYLON {
  120745. /**
  120746. * Helper class dealing with the extraction of spherical polynomial dataArray
  120747. * from a cube map.
  120748. */
  120749. export class CubeMapToSphericalPolynomialTools {
  120750. private static FileFaces;
  120751. /**
  120752. * Converts a texture to the according Spherical Polynomial data.
  120753. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120754. *
  120755. * @param texture The texture to extract the information from.
  120756. * @return The Spherical Polynomial data.
  120757. */
  120758. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120759. /**
  120760. * Converts a cubemap to the according Spherical Polynomial data.
  120761. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120762. *
  120763. * @param cubeInfo The Cube map to extract the information from.
  120764. * @return The Spherical Polynomial data.
  120765. */
  120766. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120767. }
  120768. }
  120769. declare module BABYLON {
  120770. interface BaseTexture {
  120771. /**
  120772. * Get the polynomial representation of the texture data.
  120773. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120774. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120775. */
  120776. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120777. }
  120778. }
  120779. declare module BABYLON {
  120780. /** @hidden */
  120781. export var rgbdEncodePixelShader: {
  120782. name: string;
  120783. shader: string;
  120784. };
  120785. }
  120786. declare module BABYLON {
  120787. /** @hidden */
  120788. export var rgbdDecodePixelShader: {
  120789. name: string;
  120790. shader: string;
  120791. };
  120792. }
  120793. declare module BABYLON {
  120794. /**
  120795. * Raw texture data and descriptor sufficient for WebGL texture upload
  120796. */
  120797. export interface EnvironmentTextureInfo {
  120798. /**
  120799. * Version of the environment map
  120800. */
  120801. version: number;
  120802. /**
  120803. * Width of image
  120804. */
  120805. width: number;
  120806. /**
  120807. * Irradiance information stored in the file.
  120808. */
  120809. irradiance: any;
  120810. /**
  120811. * Specular information stored in the file.
  120812. */
  120813. specular: any;
  120814. }
  120815. /**
  120816. * Defines One Image in the file. It requires only the position in the file
  120817. * as well as the length.
  120818. */
  120819. interface BufferImageData {
  120820. /**
  120821. * Length of the image data.
  120822. */
  120823. length: number;
  120824. /**
  120825. * Position of the data from the null terminator delimiting the end of the JSON.
  120826. */
  120827. position: number;
  120828. }
  120829. /**
  120830. * Defines the specular data enclosed in the file.
  120831. * This corresponds to the version 1 of the data.
  120832. */
  120833. export interface EnvironmentTextureSpecularInfoV1 {
  120834. /**
  120835. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120836. */
  120837. specularDataPosition?: number;
  120838. /**
  120839. * This contains all the images data needed to reconstruct the cubemap.
  120840. */
  120841. mipmaps: Array<BufferImageData>;
  120842. /**
  120843. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120844. */
  120845. lodGenerationScale: number;
  120846. }
  120847. /**
  120848. * Sets of helpers addressing the serialization and deserialization of environment texture
  120849. * stored in a BabylonJS env file.
  120850. * Those files are usually stored as .env files.
  120851. */
  120852. export class EnvironmentTextureTools {
  120853. /**
  120854. * Magic number identifying the env file.
  120855. */
  120856. private static _MagicBytes;
  120857. /**
  120858. * Gets the environment info from an env file.
  120859. * @param data The array buffer containing the .env bytes.
  120860. * @returns the environment file info (the json header) if successfully parsed.
  120861. */
  120862. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120863. /**
  120864. * Creates an environment texture from a loaded cube texture.
  120865. * @param texture defines the cube texture to convert in env file
  120866. * @return a promise containing the environment data if succesfull.
  120867. */
  120868. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120869. /**
  120870. * Creates a JSON representation of the spherical data.
  120871. * @param texture defines the texture containing the polynomials
  120872. * @return the JSON representation of the spherical info
  120873. */
  120874. private static _CreateEnvTextureIrradiance;
  120875. /**
  120876. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120877. * @param data the image data
  120878. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120879. * @return the views described by info providing access to the underlying buffer
  120880. */
  120881. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120882. /**
  120883. * Uploads the texture info contained in the env file to the GPU.
  120884. * @param texture defines the internal texture to upload to
  120885. * @param data defines the data to load
  120886. * @param info defines the texture info retrieved through the GetEnvInfo method
  120887. * @returns a promise
  120888. */
  120889. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120890. private static _OnImageReadyAsync;
  120891. /**
  120892. * Uploads the levels of image data to the GPU.
  120893. * @param texture defines the internal texture to upload to
  120894. * @param imageData defines the array buffer views of image data [mipmap][face]
  120895. * @returns a promise
  120896. */
  120897. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120898. /**
  120899. * Uploads spherical polynomials information to the texture.
  120900. * @param texture defines the texture we are trying to upload the information to
  120901. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120902. */
  120903. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120904. /** @hidden */
  120905. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120906. }
  120907. }
  120908. declare module BABYLON {
  120909. /**
  120910. * Contains position and normal vectors for a vertex
  120911. */
  120912. export class PositionNormalVertex {
  120913. /** the position of the vertex (defaut: 0,0,0) */
  120914. position: Vector3;
  120915. /** the normal of the vertex (defaut: 0,1,0) */
  120916. normal: Vector3;
  120917. /**
  120918. * Creates a PositionNormalVertex
  120919. * @param position the position of the vertex (defaut: 0,0,0)
  120920. * @param normal the normal of the vertex (defaut: 0,1,0)
  120921. */
  120922. constructor(
  120923. /** the position of the vertex (defaut: 0,0,0) */
  120924. position?: Vector3,
  120925. /** the normal of the vertex (defaut: 0,1,0) */
  120926. normal?: Vector3);
  120927. /**
  120928. * Clones the PositionNormalVertex
  120929. * @returns the cloned PositionNormalVertex
  120930. */
  120931. clone(): PositionNormalVertex;
  120932. }
  120933. /**
  120934. * Contains position, normal and uv vectors for a vertex
  120935. */
  120936. export class PositionNormalTextureVertex {
  120937. /** the position of the vertex (defaut: 0,0,0) */
  120938. position: Vector3;
  120939. /** the normal of the vertex (defaut: 0,1,0) */
  120940. normal: Vector3;
  120941. /** the uv of the vertex (default: 0,0) */
  120942. uv: Vector2;
  120943. /**
  120944. * Creates a PositionNormalTextureVertex
  120945. * @param position the position of the vertex (defaut: 0,0,0)
  120946. * @param normal the normal of the vertex (defaut: 0,1,0)
  120947. * @param uv the uv of the vertex (default: 0,0)
  120948. */
  120949. constructor(
  120950. /** the position of the vertex (defaut: 0,0,0) */
  120951. position?: Vector3,
  120952. /** the normal of the vertex (defaut: 0,1,0) */
  120953. normal?: Vector3,
  120954. /** the uv of the vertex (default: 0,0) */
  120955. uv?: Vector2);
  120956. /**
  120957. * Clones the PositionNormalTextureVertex
  120958. * @returns the cloned PositionNormalTextureVertex
  120959. */
  120960. clone(): PositionNormalTextureVertex;
  120961. }
  120962. }
  120963. declare module BABYLON {
  120964. /** @hidden */
  120965. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120966. private _genericAttributeLocation;
  120967. private _varyingLocationCount;
  120968. private _varyingLocationMap;
  120969. private _replacements;
  120970. private _textureCount;
  120971. private _uniforms;
  120972. lineProcessor(line: string): string;
  120973. attributeProcessor(attribute: string): string;
  120974. varyingProcessor(varying: string, isFragment: boolean): string;
  120975. uniformProcessor(uniform: string): string;
  120976. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120977. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120978. }
  120979. }
  120980. declare module BABYLON {
  120981. /**
  120982. * Container for accessors for natively-stored mesh data buffers.
  120983. */
  120984. class NativeDataBuffer extends DataBuffer {
  120985. /**
  120986. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120987. */
  120988. nativeIndexBuffer?: any;
  120989. /**
  120990. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120991. */
  120992. nativeVertexBuffer?: any;
  120993. }
  120994. /** @hidden */
  120995. class NativeTexture extends InternalTexture {
  120996. getInternalTexture(): InternalTexture;
  120997. getViewCount(): number;
  120998. }
  120999. /** @hidden */
  121000. export class NativeEngine extends Engine {
  121001. private readonly _native;
  121002. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  121003. private readonly INVALID_HANDLE;
  121004. getHardwareScalingLevel(): number;
  121005. constructor();
  121006. /**
  121007. * Can be used to override the current requestAnimationFrame requester.
  121008. * @hidden
  121009. */
  121010. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121011. /**
  121012. * Override default engine behavior.
  121013. * @param color
  121014. * @param backBuffer
  121015. * @param depth
  121016. * @param stencil
  121017. */
  121018. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121019. /**
  121020. * Gets host document
  121021. * @returns the host document object
  121022. */
  121023. getHostDocument(): Nullable<Document>;
  121024. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121025. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  121026. createVertexBuffer(data: DataArray): NativeDataBuffer;
  121027. recordVertexArrayObject(vertexBuffers: {
  121028. [key: string]: VertexBuffer;
  121029. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121030. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121031. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  121032. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121033. /**
  121034. * Draw a list of indexed primitives
  121035. * @param fillMode defines the primitive to use
  121036. * @param indexStart defines the starting index
  121037. * @param indexCount defines the number of index to draw
  121038. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121039. */
  121040. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121041. /**
  121042. * Draw a list of unindexed primitives
  121043. * @param fillMode defines the primitive to use
  121044. * @param verticesStart defines the index of first vertex to draw
  121045. * @param verticesCount defines the count of vertices to draw
  121046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121047. */
  121048. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121049. createPipelineContext(): IPipelineContext;
  121050. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121051. /** @hidden */
  121052. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121053. /** @hidden */
  121054. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121055. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121056. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  121057. protected _setProgram(program: WebGLProgram): void;
  121058. _releaseEffect(effect: Effect): void;
  121059. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121060. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  121061. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  121062. bindSamplers(effect: Effect): void;
  121063. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  121064. getRenderWidth(useScreen?: boolean): number;
  121065. getRenderHeight(useScreen?: boolean): number;
  121066. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  121067. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121068. /**
  121069. * Set the z offset to apply to current rendering
  121070. * @param value defines the offset to apply
  121071. */
  121072. setZOffset(value: number): void;
  121073. /**
  121074. * Gets the current value of the zOffset
  121075. * @returns the current zOffset state
  121076. */
  121077. getZOffset(): number;
  121078. /**
  121079. * Enable or disable depth buffering
  121080. * @param enable defines the state to set
  121081. */
  121082. setDepthBuffer(enable: boolean): void;
  121083. /**
  121084. * Gets a boolean indicating if depth writing is enabled
  121085. * @returns the current depth writing state
  121086. */
  121087. getDepthWrite(): boolean;
  121088. /**
  121089. * Enable or disable depth writing
  121090. * @param enable defines the state to set
  121091. */
  121092. setDepthWrite(enable: boolean): void;
  121093. /**
  121094. * Enable or disable color writing
  121095. * @param enable defines the state to set
  121096. */
  121097. setColorWrite(enable: boolean): void;
  121098. /**
  121099. * Gets a boolean indicating if color writing is enabled
  121100. * @returns the current color writing state
  121101. */
  121102. getColorWrite(): boolean;
  121103. /**
  121104. * Sets alpha constants used by some alpha blending modes
  121105. * @param r defines the red component
  121106. * @param g defines the green component
  121107. * @param b defines the blue component
  121108. * @param a defines the alpha component
  121109. */
  121110. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121111. /**
  121112. * Sets the current alpha mode
  121113. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121114. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121115. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121116. */
  121117. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121118. /**
  121119. * Gets the current alpha mode
  121120. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121121. * @returns the current alpha mode
  121122. */
  121123. getAlphaMode(): number;
  121124. setInt(uniform: WebGLUniformLocation, int: number): void;
  121125. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121126. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121127. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121128. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121129. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121130. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121131. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121132. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121133. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121134. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121135. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121136. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121137. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121138. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121139. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121140. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121141. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121142. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121143. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121144. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121145. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121146. wipeCaches(bruteForce?: boolean): void;
  121147. _createTexture(): WebGLTexture;
  121148. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121149. /**
  121150. * Usually called from Texture.ts.
  121151. * Passed information to create a WebGLTexture
  121152. * @param urlArg defines a value which contains one of the following:
  121153. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121154. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121155. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121156. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121157. * @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)
  121158. * @param scene needed for loading to the correct scene
  121159. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121160. * @param onLoad optional callback to be called upon successful completion
  121161. * @param onError optional callback to be called upon failure
  121162. * @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
  121163. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121164. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121165. * @param forcedExtension defines the extension to use to pick the right loader
  121166. * @param mimeType defines an optional mime type
  121167. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121168. */
  121169. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  121170. /**
  121171. * Creates a cube texture
  121172. * @param rootUrl defines the url where the files to load is located
  121173. * @param scene defines the current scene
  121174. * @param files defines the list of files to load (1 per face)
  121175. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121176. * @param onLoad defines an optional callback raised when the texture is loaded
  121177. * @param onError defines an optional callback raised if there is an issue to load the texture
  121178. * @param format defines the format of the data
  121179. * @param forcedExtension defines the extension to use to pick the right loader
  121180. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121181. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121182. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121183. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121184. * @returns the cube texture as an InternalTexture
  121185. */
  121186. 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;
  121187. private _getSamplingFilter;
  121188. private static _GetNativeTextureFormat;
  121189. createRenderTargetTexture(size: number | {
  121190. width: number;
  121191. height: number;
  121192. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121193. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121194. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121195. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121196. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121197. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121198. /**
  121199. * Updates a dynamic vertex buffer.
  121200. * @param vertexBuffer the vertex buffer to update
  121201. * @param data the data used to update the vertex buffer
  121202. * @param byteOffset the byte offset of the data (optional)
  121203. * @param byteLength the byte length of the data (optional)
  121204. */
  121205. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121206. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121207. private _updateAnisotropicLevel;
  121208. private _getAddressMode;
  121209. /** @hidden */
  121210. _bindTexture(channel: number, texture: InternalTexture): void;
  121211. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121212. releaseEffects(): void;
  121213. /** @hidden */
  121214. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121215. /** @hidden */
  121216. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121217. /** @hidden */
  121218. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121219. /** @hidden */
  121220. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121221. }
  121222. }
  121223. declare module BABYLON {
  121224. /**
  121225. * Gather the list of clipboard event types as constants.
  121226. */
  121227. export class ClipboardEventTypes {
  121228. /**
  121229. * The clipboard event is fired when a copy command is active (pressed).
  121230. */
  121231. static readonly COPY: number;
  121232. /**
  121233. * The clipboard event is fired when a cut command is active (pressed).
  121234. */
  121235. static readonly CUT: number;
  121236. /**
  121237. * The clipboard event is fired when a paste command is active (pressed).
  121238. */
  121239. static readonly PASTE: number;
  121240. }
  121241. /**
  121242. * This class is used to store clipboard related info for the onClipboardObservable event.
  121243. */
  121244. export class ClipboardInfo {
  121245. /**
  121246. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121247. */
  121248. type: number;
  121249. /**
  121250. * Defines the related dom event
  121251. */
  121252. event: ClipboardEvent;
  121253. /**
  121254. *Creates an instance of ClipboardInfo.
  121255. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121256. * @param event Defines the related dom event
  121257. */
  121258. constructor(
  121259. /**
  121260. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121261. */
  121262. type: number,
  121263. /**
  121264. * Defines the related dom event
  121265. */
  121266. event: ClipboardEvent);
  121267. /**
  121268. * Get the clipboard event's type from the keycode.
  121269. * @param keyCode Defines the keyCode for the current keyboard event.
  121270. * @return {number}
  121271. */
  121272. static GetTypeFromCharacter(keyCode: number): number;
  121273. }
  121274. }
  121275. declare module BABYLON {
  121276. /**
  121277. * Google Daydream controller
  121278. */
  121279. export class DaydreamController extends WebVRController {
  121280. /**
  121281. * Base Url for the controller model.
  121282. */
  121283. static MODEL_BASE_URL: string;
  121284. /**
  121285. * File name for the controller model.
  121286. */
  121287. static MODEL_FILENAME: string;
  121288. /**
  121289. * Gamepad Id prefix used to identify Daydream Controller.
  121290. */
  121291. static readonly GAMEPAD_ID_PREFIX: string;
  121292. /**
  121293. * Creates a new DaydreamController from a gamepad
  121294. * @param vrGamepad the gamepad that the controller should be created from
  121295. */
  121296. constructor(vrGamepad: any);
  121297. /**
  121298. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121299. * @param scene scene in which to add meshes
  121300. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121301. */
  121302. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121303. /**
  121304. * Called once for each button that changed state since the last frame
  121305. * @param buttonIdx Which button index changed
  121306. * @param state New state of the button
  121307. * @param changes Which properties on the state changed since last frame
  121308. */
  121309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121310. }
  121311. }
  121312. declare module BABYLON {
  121313. /**
  121314. * Gear VR Controller
  121315. */
  121316. export class GearVRController extends WebVRController {
  121317. /**
  121318. * Base Url for the controller model.
  121319. */
  121320. static MODEL_BASE_URL: string;
  121321. /**
  121322. * File name for the controller model.
  121323. */
  121324. static MODEL_FILENAME: string;
  121325. /**
  121326. * Gamepad Id prefix used to identify this controller.
  121327. */
  121328. static readonly GAMEPAD_ID_PREFIX: string;
  121329. private readonly _buttonIndexToObservableNameMap;
  121330. /**
  121331. * Creates a new GearVRController from a gamepad
  121332. * @param vrGamepad the gamepad that the controller should be created from
  121333. */
  121334. constructor(vrGamepad: any);
  121335. /**
  121336. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121337. * @param scene scene in which to add meshes
  121338. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121339. */
  121340. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121341. /**
  121342. * Called once for each button that changed state since the last frame
  121343. * @param buttonIdx Which button index changed
  121344. * @param state New state of the button
  121345. * @param changes Which properties on the state changed since last frame
  121346. */
  121347. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121348. }
  121349. }
  121350. declare module BABYLON {
  121351. /**
  121352. * Generic Controller
  121353. */
  121354. export class GenericController extends WebVRController {
  121355. /**
  121356. * Base Url for the controller model.
  121357. */
  121358. static readonly MODEL_BASE_URL: string;
  121359. /**
  121360. * File name for the controller model.
  121361. */
  121362. static readonly MODEL_FILENAME: string;
  121363. /**
  121364. * Creates a new GenericController from a gamepad
  121365. * @param vrGamepad the gamepad that the controller should be created from
  121366. */
  121367. constructor(vrGamepad: any);
  121368. /**
  121369. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121370. * @param scene scene in which to add meshes
  121371. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121372. */
  121373. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121374. /**
  121375. * Called once for each button that changed state since the last frame
  121376. * @param buttonIdx Which button index changed
  121377. * @param state New state of the button
  121378. * @param changes Which properties on the state changed since last frame
  121379. */
  121380. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121381. }
  121382. }
  121383. declare module BABYLON {
  121384. /**
  121385. * Oculus Touch Controller
  121386. */
  121387. export class OculusTouchController extends WebVRController {
  121388. /**
  121389. * Base Url for the controller model.
  121390. */
  121391. static MODEL_BASE_URL: string;
  121392. /**
  121393. * File name for the left controller model.
  121394. */
  121395. static MODEL_LEFT_FILENAME: string;
  121396. /**
  121397. * File name for the right controller model.
  121398. */
  121399. static MODEL_RIGHT_FILENAME: string;
  121400. /**
  121401. * Base Url for the Quest controller model.
  121402. */
  121403. static QUEST_MODEL_BASE_URL: string;
  121404. /**
  121405. * @hidden
  121406. * If the controllers are running on a device that needs the updated Quest controller models
  121407. */
  121408. static _IsQuest: boolean;
  121409. /**
  121410. * Fired when the secondary trigger on this controller is modified
  121411. */
  121412. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121413. /**
  121414. * Fired when the thumb rest on this controller is modified
  121415. */
  121416. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121417. /**
  121418. * Creates a new OculusTouchController from a gamepad
  121419. * @param vrGamepad the gamepad that the controller should be created from
  121420. */
  121421. constructor(vrGamepad: any);
  121422. /**
  121423. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121424. * @param scene scene in which to add meshes
  121425. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121426. */
  121427. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121428. /**
  121429. * Fired when the A button on this controller is modified
  121430. */
  121431. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121432. /**
  121433. * Fired when the B button on this controller is modified
  121434. */
  121435. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121436. /**
  121437. * Fired when the X button on this controller is modified
  121438. */
  121439. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121440. /**
  121441. * Fired when the Y button on this controller is modified
  121442. */
  121443. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121444. /**
  121445. * Called once for each button that changed state since the last frame
  121446. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121447. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121448. * 2) secondary trigger (same)
  121449. * 3) A (right) X (left), touch, pressed = value
  121450. * 4) B / Y
  121451. * 5) thumb rest
  121452. * @param buttonIdx Which button index changed
  121453. * @param state New state of the button
  121454. * @param changes Which properties on the state changed since last frame
  121455. */
  121456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121457. }
  121458. }
  121459. declare module BABYLON {
  121460. /**
  121461. * Vive Controller
  121462. */
  121463. export class ViveController extends WebVRController {
  121464. /**
  121465. * Base Url for the controller model.
  121466. */
  121467. static MODEL_BASE_URL: string;
  121468. /**
  121469. * File name for the controller model.
  121470. */
  121471. static MODEL_FILENAME: string;
  121472. /**
  121473. * Creates a new ViveController from a gamepad
  121474. * @param vrGamepad the gamepad that the controller should be created from
  121475. */
  121476. constructor(vrGamepad: any);
  121477. /**
  121478. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121479. * @param scene scene in which to add meshes
  121480. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121481. */
  121482. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121483. /**
  121484. * Fired when the left button on this controller is modified
  121485. */
  121486. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121487. /**
  121488. * Fired when the right button on this controller is modified
  121489. */
  121490. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121491. /**
  121492. * Fired when the menu button on this controller is modified
  121493. */
  121494. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121495. /**
  121496. * Called once for each button that changed state since the last frame
  121497. * Vive mapping:
  121498. * 0: touchpad
  121499. * 1: trigger
  121500. * 2: left AND right buttons
  121501. * 3: menu button
  121502. * @param buttonIdx Which button index changed
  121503. * @param state New state of the button
  121504. * @param changes Which properties on the state changed since last frame
  121505. */
  121506. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121507. }
  121508. }
  121509. declare module BABYLON {
  121510. /**
  121511. * Defines the WindowsMotionController object that the state of the windows motion controller
  121512. */
  121513. export class WindowsMotionController extends WebVRController {
  121514. /**
  121515. * The base url used to load the left and right controller models
  121516. */
  121517. static MODEL_BASE_URL: string;
  121518. /**
  121519. * The name of the left controller model file
  121520. */
  121521. static MODEL_LEFT_FILENAME: string;
  121522. /**
  121523. * The name of the right controller model file
  121524. */
  121525. static MODEL_RIGHT_FILENAME: string;
  121526. /**
  121527. * The controller name prefix for this controller type
  121528. */
  121529. static readonly GAMEPAD_ID_PREFIX: string;
  121530. /**
  121531. * The controller id pattern for this controller type
  121532. */
  121533. private static readonly GAMEPAD_ID_PATTERN;
  121534. private _loadedMeshInfo;
  121535. protected readonly _mapping: {
  121536. buttons: string[];
  121537. buttonMeshNames: {
  121538. 'trigger': string;
  121539. 'menu': string;
  121540. 'grip': string;
  121541. 'thumbstick': string;
  121542. 'trackpad': string;
  121543. };
  121544. buttonObservableNames: {
  121545. 'trigger': string;
  121546. 'menu': string;
  121547. 'grip': string;
  121548. 'thumbstick': string;
  121549. 'trackpad': string;
  121550. };
  121551. axisMeshNames: string[];
  121552. pointingPoseMeshName: string;
  121553. };
  121554. /**
  121555. * Fired when the trackpad on this controller is clicked
  121556. */
  121557. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121558. /**
  121559. * Fired when the trackpad on this controller is modified
  121560. */
  121561. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121562. /**
  121563. * The current x and y values of this controller's trackpad
  121564. */
  121565. trackpad: StickValues;
  121566. /**
  121567. * Creates a new WindowsMotionController from a gamepad
  121568. * @param vrGamepad the gamepad that the controller should be created from
  121569. */
  121570. constructor(vrGamepad: any);
  121571. /**
  121572. * Fired when the trigger on this controller is modified
  121573. */
  121574. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121575. /**
  121576. * Fired when the menu button on this controller is modified
  121577. */
  121578. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121579. /**
  121580. * Fired when the grip button on this controller is modified
  121581. */
  121582. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121583. /**
  121584. * Fired when the thumbstick button on this controller is modified
  121585. */
  121586. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121587. /**
  121588. * Fired when the touchpad button on this controller is modified
  121589. */
  121590. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121591. /**
  121592. * Fired when the touchpad values on this controller are modified
  121593. */
  121594. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121595. protected _updateTrackpad(): void;
  121596. /**
  121597. * Called once per frame by the engine.
  121598. */
  121599. update(): void;
  121600. /**
  121601. * Called once for each button that changed state since the last frame
  121602. * @param buttonIdx Which button index changed
  121603. * @param state New state of the button
  121604. * @param changes Which properties on the state changed since last frame
  121605. */
  121606. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121607. /**
  121608. * Moves the buttons on the controller mesh based on their current state
  121609. * @param buttonName the name of the button to move
  121610. * @param buttonValue the value of the button which determines the buttons new position
  121611. */
  121612. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121613. /**
  121614. * Moves the axis on the controller mesh based on its current state
  121615. * @param axis the index of the axis
  121616. * @param axisValue the value of the axis which determines the meshes new position
  121617. * @hidden
  121618. */
  121619. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121620. /**
  121621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121622. * @param scene scene in which to add meshes
  121623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121624. */
  121625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121626. /**
  121627. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121628. * can be transformed by button presses and axes values, based on this._mapping.
  121629. *
  121630. * @param scene scene in which the meshes exist
  121631. * @param meshes list of meshes that make up the controller model to process
  121632. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121633. */
  121634. private processModel;
  121635. private createMeshInfo;
  121636. /**
  121637. * Gets the ray of the controller in the direction the controller is pointing
  121638. * @param length the length the resulting ray should be
  121639. * @returns a ray in the direction the controller is pointing
  121640. */
  121641. getForwardRay(length?: number): Ray;
  121642. /**
  121643. * Disposes of the controller
  121644. */
  121645. dispose(): void;
  121646. }
  121647. /**
  121648. * This class represents a new windows motion controller in XR.
  121649. */
  121650. export class XRWindowsMotionController extends WindowsMotionController {
  121651. /**
  121652. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121653. */
  121654. protected readonly _mapping: {
  121655. buttons: string[];
  121656. buttonMeshNames: {
  121657. 'trigger': string;
  121658. 'menu': string;
  121659. 'grip': string;
  121660. 'thumbstick': string;
  121661. 'trackpad': string;
  121662. };
  121663. buttonObservableNames: {
  121664. 'trigger': string;
  121665. 'menu': string;
  121666. 'grip': string;
  121667. 'thumbstick': string;
  121668. 'trackpad': string;
  121669. };
  121670. axisMeshNames: string[];
  121671. pointingPoseMeshName: string;
  121672. };
  121673. /**
  121674. * Construct a new XR-Based windows motion controller
  121675. *
  121676. * @param gamepadInfo the gamepad object from the browser
  121677. */
  121678. constructor(gamepadInfo: any);
  121679. /**
  121680. * holds the thumbstick values (X,Y)
  121681. */
  121682. thumbstickValues: StickValues;
  121683. /**
  121684. * Fired when the thumbstick on this controller is clicked
  121685. */
  121686. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121687. /**
  121688. * Fired when the thumbstick on this controller is modified
  121689. */
  121690. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121691. /**
  121692. * Fired when the touchpad button on this controller is modified
  121693. */
  121694. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121695. /**
  121696. * Fired when the touchpad values on this controller are modified
  121697. */
  121698. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121699. /**
  121700. * Fired when the thumbstick button on this controller is modified
  121701. * here to prevent breaking changes
  121702. */
  121703. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121704. /**
  121705. * updating the thumbstick(!) and not the trackpad.
  121706. * This is named this way due to the difference between WebVR and XR and to avoid
  121707. * changing the parent class.
  121708. */
  121709. protected _updateTrackpad(): void;
  121710. /**
  121711. * Disposes the class with joy
  121712. */
  121713. dispose(): void;
  121714. }
  121715. }
  121716. declare module BABYLON {
  121717. /**
  121718. * Class containing static functions to help procedurally build meshes
  121719. */
  121720. export class PolyhedronBuilder {
  121721. /**
  121722. * Creates a polyhedron mesh
  121723. * * 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
  121724. * * The parameter `size` (positive float, default 1) sets the polygon size
  121725. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121726. * * 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`
  121727. * * 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
  121728. * * 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)`)
  121729. * * 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
  121730. * * 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
  121731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121734. * @param name defines the name of the mesh
  121735. * @param options defines the options used to create the mesh
  121736. * @param scene defines the hosting scene
  121737. * @returns the polyhedron mesh
  121738. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121739. */
  121740. static CreatePolyhedron(name: string, options: {
  121741. type?: number;
  121742. size?: number;
  121743. sizeX?: number;
  121744. sizeY?: number;
  121745. sizeZ?: number;
  121746. custom?: any;
  121747. faceUV?: Vector4[];
  121748. faceColors?: Color4[];
  121749. flat?: boolean;
  121750. updatable?: boolean;
  121751. sideOrientation?: number;
  121752. frontUVs?: Vector4;
  121753. backUVs?: Vector4;
  121754. }, scene?: Nullable<Scene>): Mesh;
  121755. }
  121756. }
  121757. declare module BABYLON {
  121758. /**
  121759. * Gizmo that enables scaling a mesh along 3 axis
  121760. */
  121761. export class ScaleGizmo extends Gizmo {
  121762. /**
  121763. * Internal gizmo used for interactions on the x axis
  121764. */
  121765. xGizmo: AxisScaleGizmo;
  121766. /**
  121767. * Internal gizmo used for interactions on the y axis
  121768. */
  121769. yGizmo: AxisScaleGizmo;
  121770. /**
  121771. * Internal gizmo used for interactions on the z axis
  121772. */
  121773. zGizmo: AxisScaleGizmo;
  121774. /**
  121775. * Internal gizmo used to scale all axis equally
  121776. */
  121777. uniformScaleGizmo: AxisScaleGizmo;
  121778. private _meshAttached;
  121779. private _updateGizmoRotationToMatchAttachedMesh;
  121780. private _snapDistance;
  121781. private _scaleRatio;
  121782. private _uniformScalingMesh;
  121783. private _octahedron;
  121784. private _sensitivity;
  121785. /** Fires an event when any of it's sub gizmos are dragged */
  121786. onDragStartObservable: Observable<unknown>;
  121787. /** Fires an event when any of it's sub gizmos are released from dragging */
  121788. onDragEndObservable: Observable<unknown>;
  121789. get attachedMesh(): Nullable<AbstractMesh>;
  121790. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121791. /**
  121792. * Creates a ScaleGizmo
  121793. * @param gizmoLayer The utility layer the gizmo will be added to
  121794. */
  121795. constructor(gizmoLayer?: UtilityLayerRenderer);
  121796. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121797. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121798. /**
  121799. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121800. */
  121801. set snapDistance(value: number);
  121802. get snapDistance(): number;
  121803. /**
  121804. * Ratio for the scale of the gizmo (Default: 1)
  121805. */
  121806. set scaleRatio(value: number);
  121807. get scaleRatio(): number;
  121808. /**
  121809. * Sensitivity factor for dragging (Default: 1)
  121810. */
  121811. set sensitivity(value: number);
  121812. get sensitivity(): number;
  121813. /**
  121814. * Disposes of the gizmo
  121815. */
  121816. dispose(): void;
  121817. }
  121818. }
  121819. declare module BABYLON {
  121820. /**
  121821. * Single axis scale gizmo
  121822. */
  121823. export class AxisScaleGizmo extends Gizmo {
  121824. /**
  121825. * Drag behavior responsible for the gizmos dragging interactions
  121826. */
  121827. dragBehavior: PointerDragBehavior;
  121828. private _pointerObserver;
  121829. /**
  121830. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121831. */
  121832. snapDistance: number;
  121833. /**
  121834. * Event that fires each time the gizmo snaps to a new location.
  121835. * * snapDistance is the the change in distance
  121836. */
  121837. onSnapObservable: Observable<{
  121838. snapDistance: number;
  121839. }>;
  121840. /**
  121841. * If the scaling operation should be done on all axis (default: false)
  121842. */
  121843. uniformScaling: boolean;
  121844. /**
  121845. * Custom sensitivity value for the drag strength
  121846. */
  121847. sensitivity: number;
  121848. private _isEnabled;
  121849. private _parent;
  121850. private _arrow;
  121851. private _coloredMaterial;
  121852. private _hoverMaterial;
  121853. /**
  121854. * Creates an AxisScaleGizmo
  121855. * @param gizmoLayer The utility layer the gizmo will be added to
  121856. * @param dragAxis The axis which the gizmo will be able to scale on
  121857. * @param color The color of the gizmo
  121858. */
  121859. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121860. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121861. /**
  121862. * If the gizmo is enabled
  121863. */
  121864. set isEnabled(value: boolean);
  121865. get isEnabled(): boolean;
  121866. /**
  121867. * Disposes of the gizmo
  121868. */
  121869. dispose(): void;
  121870. /**
  121871. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121872. * @param mesh The mesh to replace the default mesh of the gizmo
  121873. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121874. */
  121875. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121876. }
  121877. }
  121878. declare module BABYLON {
  121879. /**
  121880. * Bounding box gizmo
  121881. */
  121882. export class BoundingBoxGizmo extends Gizmo {
  121883. private _lineBoundingBox;
  121884. private _rotateSpheresParent;
  121885. private _scaleBoxesParent;
  121886. private _boundingDimensions;
  121887. private _renderObserver;
  121888. private _pointerObserver;
  121889. private _scaleDragSpeed;
  121890. private _tmpQuaternion;
  121891. private _tmpVector;
  121892. private _tmpRotationMatrix;
  121893. /**
  121894. * 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)
  121895. */
  121896. ignoreChildren: boolean;
  121897. /**
  121898. * 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)
  121899. */
  121900. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121901. /**
  121902. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121903. */
  121904. rotationSphereSize: number;
  121905. /**
  121906. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121907. */
  121908. scaleBoxSize: number;
  121909. /**
  121910. * 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)
  121911. */
  121912. fixedDragMeshScreenSize: boolean;
  121913. /**
  121914. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121915. */
  121916. fixedDragMeshScreenSizeDistanceFactor: number;
  121917. /**
  121918. * Fired when a rotation sphere or scale box is dragged
  121919. */
  121920. onDragStartObservable: Observable<{}>;
  121921. /**
  121922. * Fired when a scale box is dragged
  121923. */
  121924. onScaleBoxDragObservable: Observable<{}>;
  121925. /**
  121926. * Fired when a scale box drag is ended
  121927. */
  121928. onScaleBoxDragEndObservable: Observable<{}>;
  121929. /**
  121930. * Fired when a rotation sphere is dragged
  121931. */
  121932. onRotationSphereDragObservable: Observable<{}>;
  121933. /**
  121934. * Fired when a rotation sphere drag is ended
  121935. */
  121936. onRotationSphereDragEndObservable: Observable<{}>;
  121937. /**
  121938. * 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)
  121939. */
  121940. scalePivot: Nullable<Vector3>;
  121941. /**
  121942. * Mesh used as a pivot to rotate the attached mesh
  121943. */
  121944. private _anchorMesh;
  121945. private _existingMeshScale;
  121946. private _dragMesh;
  121947. private pointerDragBehavior;
  121948. private coloredMaterial;
  121949. private hoverColoredMaterial;
  121950. /**
  121951. * Sets the color of the bounding box gizmo
  121952. * @param color the color to set
  121953. */
  121954. setColor(color: Color3): void;
  121955. /**
  121956. * Creates an BoundingBoxGizmo
  121957. * @param gizmoLayer The utility layer the gizmo will be added to
  121958. * @param color The color of the gizmo
  121959. */
  121960. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121961. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121962. private _selectNode;
  121963. /**
  121964. * Updates the bounding box information for the Gizmo
  121965. */
  121966. updateBoundingBox(): void;
  121967. private _updateRotationSpheres;
  121968. private _updateScaleBoxes;
  121969. /**
  121970. * Enables rotation on the specified axis and disables rotation on the others
  121971. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121972. */
  121973. setEnabledRotationAxis(axis: string): void;
  121974. /**
  121975. * Enables/disables scaling
  121976. * @param enable if scaling should be enabled
  121977. */
  121978. setEnabledScaling(enable: boolean): void;
  121979. private _updateDummy;
  121980. /**
  121981. * Enables a pointer drag behavior on the bounding box of the gizmo
  121982. */
  121983. enableDragBehavior(): void;
  121984. /**
  121985. * Disposes of the gizmo
  121986. */
  121987. dispose(): void;
  121988. /**
  121989. * 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)
  121990. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121991. * @returns the bounding box mesh with the passed in mesh as a child
  121992. */
  121993. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121994. /**
  121995. * CustomMeshes are not supported by this gizmo
  121996. * @param mesh The mesh to replace the default mesh of the gizmo
  121997. */
  121998. setCustomMesh(mesh: Mesh): void;
  121999. }
  122000. }
  122001. declare module BABYLON {
  122002. /**
  122003. * Single plane rotation gizmo
  122004. */
  122005. export class PlaneRotationGizmo extends Gizmo {
  122006. /**
  122007. * Drag behavior responsible for the gizmos dragging interactions
  122008. */
  122009. dragBehavior: PointerDragBehavior;
  122010. private _pointerObserver;
  122011. /**
  122012. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  122013. */
  122014. snapDistance: number;
  122015. /**
  122016. * Event that fires each time the gizmo snaps to a new location.
  122017. * * snapDistance is the the change in distance
  122018. */
  122019. onSnapObservable: Observable<{
  122020. snapDistance: number;
  122021. }>;
  122022. private _isEnabled;
  122023. private _parent;
  122024. /**
  122025. * Creates a PlaneRotationGizmo
  122026. * @param gizmoLayer The utility layer the gizmo will be added to
  122027. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  122028. * @param color The color of the gizmo
  122029. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122030. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122031. */
  122032. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  122033. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122034. /**
  122035. * If the gizmo is enabled
  122036. */
  122037. set isEnabled(value: boolean);
  122038. get isEnabled(): boolean;
  122039. /**
  122040. * Disposes of the gizmo
  122041. */
  122042. dispose(): void;
  122043. }
  122044. }
  122045. declare module BABYLON {
  122046. /**
  122047. * Gizmo that enables rotating a mesh along 3 axis
  122048. */
  122049. export class RotationGizmo extends Gizmo {
  122050. /**
  122051. * Internal gizmo used for interactions on the x axis
  122052. */
  122053. xGizmo: PlaneRotationGizmo;
  122054. /**
  122055. * Internal gizmo used for interactions on the y axis
  122056. */
  122057. yGizmo: PlaneRotationGizmo;
  122058. /**
  122059. * Internal gizmo used for interactions on the z axis
  122060. */
  122061. zGizmo: PlaneRotationGizmo;
  122062. /** Fires an event when any of it's sub gizmos are dragged */
  122063. onDragStartObservable: Observable<unknown>;
  122064. /** Fires an event when any of it's sub gizmos are released from dragging */
  122065. onDragEndObservable: Observable<unknown>;
  122066. private _meshAttached;
  122067. get attachedMesh(): Nullable<AbstractMesh>;
  122068. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122069. /**
  122070. * Creates a RotationGizmo
  122071. * @param gizmoLayer The utility layer the gizmo will be added to
  122072. * @param tessellation Amount of tessellation to be used when creating rotation circles
  122073. * @param useEulerRotation Use and update Euler angle instead of quaternion
  122074. */
  122075. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  122076. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122077. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122078. /**
  122079. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122080. */
  122081. set snapDistance(value: number);
  122082. get snapDistance(): number;
  122083. /**
  122084. * Ratio for the scale of the gizmo (Default: 1)
  122085. */
  122086. set scaleRatio(value: number);
  122087. get scaleRatio(): number;
  122088. /**
  122089. * Disposes of the gizmo
  122090. */
  122091. dispose(): void;
  122092. /**
  122093. * CustomMeshes are not supported by this gizmo
  122094. * @param mesh The mesh to replace the default mesh of the gizmo
  122095. */
  122096. setCustomMesh(mesh: Mesh): void;
  122097. }
  122098. }
  122099. declare module BABYLON {
  122100. /**
  122101. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  122102. */
  122103. export class GizmoManager implements IDisposable {
  122104. private scene;
  122105. /**
  122106. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122107. */
  122108. gizmos: {
  122109. positionGizmo: Nullable<PositionGizmo>;
  122110. rotationGizmo: Nullable<RotationGizmo>;
  122111. scaleGizmo: Nullable<ScaleGizmo>;
  122112. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122113. };
  122114. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122115. clearGizmoOnEmptyPointerEvent: boolean;
  122116. /** Fires an event when the manager is attached to a mesh */
  122117. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122118. private _gizmosEnabled;
  122119. private _pointerObserver;
  122120. private _attachedMesh;
  122121. private _boundingBoxColor;
  122122. private _defaultUtilityLayer;
  122123. private _defaultKeepDepthUtilityLayer;
  122124. /**
  122125. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122126. */
  122127. boundingBoxDragBehavior: SixDofDragBehavior;
  122128. /**
  122129. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122130. */
  122131. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122132. /**
  122133. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122134. */
  122135. usePointerToAttachGizmos: boolean;
  122136. /**
  122137. * Utility layer that the bounding box gizmo belongs to
  122138. */
  122139. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122140. /**
  122141. * Utility layer that all gizmos besides bounding box belong to
  122142. */
  122143. get utilityLayer(): UtilityLayerRenderer;
  122144. /**
  122145. * Instatiates a gizmo manager
  122146. * @param scene the scene to overlay the gizmos on top of
  122147. */
  122148. constructor(scene: Scene);
  122149. /**
  122150. * Attaches a set of gizmos to the specified mesh
  122151. * @param mesh The mesh the gizmo's should be attached to
  122152. */
  122153. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122154. /**
  122155. * If the position gizmo is enabled
  122156. */
  122157. set positionGizmoEnabled(value: boolean);
  122158. get positionGizmoEnabled(): boolean;
  122159. /**
  122160. * If the rotation gizmo is enabled
  122161. */
  122162. set rotationGizmoEnabled(value: boolean);
  122163. get rotationGizmoEnabled(): boolean;
  122164. /**
  122165. * If the scale gizmo is enabled
  122166. */
  122167. set scaleGizmoEnabled(value: boolean);
  122168. get scaleGizmoEnabled(): boolean;
  122169. /**
  122170. * If the boundingBox gizmo is enabled
  122171. */
  122172. set boundingBoxGizmoEnabled(value: boolean);
  122173. get boundingBoxGizmoEnabled(): boolean;
  122174. /**
  122175. * Disposes of the gizmo manager
  122176. */
  122177. dispose(): void;
  122178. }
  122179. }
  122180. declare module BABYLON {
  122181. /**
  122182. * A directional light is defined by a direction (what a surprise!).
  122183. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122184. * 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.
  122185. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122186. */
  122187. export class DirectionalLight extends ShadowLight {
  122188. private _shadowFrustumSize;
  122189. /**
  122190. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122191. */
  122192. get shadowFrustumSize(): number;
  122193. /**
  122194. * Specifies a fix frustum size for the shadow generation.
  122195. */
  122196. set shadowFrustumSize(value: number);
  122197. private _shadowOrthoScale;
  122198. /**
  122199. * Gets the shadow projection scale against the optimal computed one.
  122200. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122201. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122202. */
  122203. get shadowOrthoScale(): number;
  122204. /**
  122205. * Sets the shadow projection scale against the optimal computed one.
  122206. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122207. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122208. */
  122209. set shadowOrthoScale(value: number);
  122210. /**
  122211. * Automatically compute the projection matrix to best fit (including all the casters)
  122212. * on each frame.
  122213. */
  122214. autoUpdateExtends: boolean;
  122215. /**
  122216. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122217. * on each frame. autoUpdateExtends must be set to true for this to work
  122218. */
  122219. autoCalcShadowZBounds: boolean;
  122220. private _orthoLeft;
  122221. private _orthoRight;
  122222. private _orthoTop;
  122223. private _orthoBottom;
  122224. /**
  122225. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122226. * The directional light is emitted from everywhere in the given direction.
  122227. * It can cast shadows.
  122228. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122229. * @param name The friendly name of the light
  122230. * @param direction The direction of the light
  122231. * @param scene The scene the light belongs to
  122232. */
  122233. constructor(name: string, direction: Vector3, scene: Scene);
  122234. /**
  122235. * Returns the string "DirectionalLight".
  122236. * @return The class name
  122237. */
  122238. getClassName(): string;
  122239. /**
  122240. * Returns the integer 1.
  122241. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122242. */
  122243. getTypeID(): number;
  122244. /**
  122245. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122246. * Returns the DirectionalLight Shadow projection matrix.
  122247. */
  122248. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122249. /**
  122250. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122251. * Returns the DirectionalLight Shadow projection matrix.
  122252. */
  122253. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122254. /**
  122255. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122256. * Returns the DirectionalLight Shadow projection matrix.
  122257. */
  122258. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122259. protected _buildUniformLayout(): void;
  122260. /**
  122261. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122262. * @param effect The effect to update
  122263. * @param lightIndex The index of the light in the effect to update
  122264. * @returns The directional light
  122265. */
  122266. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122267. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122268. /**
  122269. * Gets the minZ used for shadow according to both the scene and the light.
  122270. *
  122271. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122272. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122273. * @param activeCamera The camera we are returning the min for
  122274. * @returns the depth min z
  122275. */
  122276. getDepthMinZ(activeCamera: Camera): number;
  122277. /**
  122278. * Gets the maxZ used for shadow according to both the scene and the light.
  122279. *
  122280. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122281. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122282. * @param activeCamera The camera we are returning the max for
  122283. * @returns the depth max z
  122284. */
  122285. getDepthMaxZ(activeCamera: Camera): number;
  122286. /**
  122287. * Prepares the list of defines specific to the light type.
  122288. * @param defines the list of defines
  122289. * @param lightIndex defines the index of the light for the effect
  122290. */
  122291. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122292. }
  122293. }
  122294. declare module BABYLON {
  122295. /**
  122296. * Class containing static functions to help procedurally build meshes
  122297. */
  122298. export class HemisphereBuilder {
  122299. /**
  122300. * Creates a hemisphere mesh
  122301. * @param name defines the name of the mesh
  122302. * @param options defines the options used to create the mesh
  122303. * @param scene defines the hosting scene
  122304. * @returns the hemisphere mesh
  122305. */
  122306. static CreateHemisphere(name: string, options: {
  122307. segments?: number;
  122308. diameter?: number;
  122309. sideOrientation?: number;
  122310. }, scene: any): Mesh;
  122311. }
  122312. }
  122313. declare module BABYLON {
  122314. /**
  122315. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122316. * These values define a cone of light starting from the position, emitting toward the direction.
  122317. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122318. * and the exponent defines the speed of the decay of the light with distance (reach).
  122319. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122320. */
  122321. export class SpotLight extends ShadowLight {
  122322. private _angle;
  122323. private _innerAngle;
  122324. private _cosHalfAngle;
  122325. private _lightAngleScale;
  122326. private _lightAngleOffset;
  122327. /**
  122328. * Gets the cone angle of the spot light in Radians.
  122329. */
  122330. get angle(): number;
  122331. /**
  122332. * Sets the cone angle of the spot light in Radians.
  122333. */
  122334. set angle(value: number);
  122335. /**
  122336. * Only used in gltf falloff mode, this defines the angle where
  122337. * the directional falloff will start before cutting at angle which could be seen
  122338. * as outer angle.
  122339. */
  122340. get innerAngle(): number;
  122341. /**
  122342. * Only used in gltf falloff mode, this defines the angle where
  122343. * the directional falloff will start before cutting at angle which could be seen
  122344. * as outer angle.
  122345. */
  122346. set innerAngle(value: number);
  122347. private _shadowAngleScale;
  122348. /**
  122349. * Allows scaling the angle of the light for shadow generation only.
  122350. */
  122351. get shadowAngleScale(): number;
  122352. /**
  122353. * Allows scaling the angle of the light for shadow generation only.
  122354. */
  122355. set shadowAngleScale(value: number);
  122356. /**
  122357. * The light decay speed with the distance from the emission spot.
  122358. */
  122359. exponent: number;
  122360. private _projectionTextureMatrix;
  122361. /**
  122362. * Allows reading the projecton texture
  122363. */
  122364. get projectionTextureMatrix(): Matrix;
  122365. protected _projectionTextureLightNear: number;
  122366. /**
  122367. * Gets the near clip of the Spotlight for texture projection.
  122368. */
  122369. get projectionTextureLightNear(): number;
  122370. /**
  122371. * Sets the near clip of the Spotlight for texture projection.
  122372. */
  122373. set projectionTextureLightNear(value: number);
  122374. protected _projectionTextureLightFar: number;
  122375. /**
  122376. * Gets the far clip of the Spotlight for texture projection.
  122377. */
  122378. get projectionTextureLightFar(): number;
  122379. /**
  122380. * Sets the far clip of the Spotlight for texture projection.
  122381. */
  122382. set projectionTextureLightFar(value: number);
  122383. protected _projectionTextureUpDirection: Vector3;
  122384. /**
  122385. * Gets the Up vector of the Spotlight for texture projection.
  122386. */
  122387. get projectionTextureUpDirection(): Vector3;
  122388. /**
  122389. * Sets the Up vector of the Spotlight for texture projection.
  122390. */
  122391. set projectionTextureUpDirection(value: Vector3);
  122392. private _projectionTexture;
  122393. /**
  122394. * Gets the projection texture of the light.
  122395. */
  122396. get projectionTexture(): Nullable<BaseTexture>;
  122397. /**
  122398. * Sets the projection texture of the light.
  122399. */
  122400. set projectionTexture(value: Nullable<BaseTexture>);
  122401. private _projectionTextureViewLightDirty;
  122402. private _projectionTextureProjectionLightDirty;
  122403. private _projectionTextureDirty;
  122404. private _projectionTextureViewTargetVector;
  122405. private _projectionTextureViewLightMatrix;
  122406. private _projectionTextureProjectionLightMatrix;
  122407. private _projectionTextureScalingMatrix;
  122408. /**
  122409. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122410. * It can cast shadows.
  122411. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122412. * @param name The light friendly name
  122413. * @param position The position of the spot light in the scene
  122414. * @param direction The direction of the light in the scene
  122415. * @param angle The cone angle of the light in Radians
  122416. * @param exponent The light decay speed with the distance from the emission spot
  122417. * @param scene The scene the lights belongs to
  122418. */
  122419. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122420. /**
  122421. * Returns the string "SpotLight".
  122422. * @returns the class name
  122423. */
  122424. getClassName(): string;
  122425. /**
  122426. * Returns the integer 2.
  122427. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122428. */
  122429. getTypeID(): number;
  122430. /**
  122431. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122432. */
  122433. protected _setDirection(value: Vector3): void;
  122434. /**
  122435. * Overrides the position setter to recompute the projection texture view light Matrix.
  122436. */
  122437. protected _setPosition(value: Vector3): void;
  122438. /**
  122439. * 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.
  122440. * Returns the SpotLight.
  122441. */
  122442. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122443. protected _computeProjectionTextureViewLightMatrix(): void;
  122444. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122445. /**
  122446. * Main function for light texture projection matrix computing.
  122447. */
  122448. protected _computeProjectionTextureMatrix(): void;
  122449. protected _buildUniformLayout(): void;
  122450. private _computeAngleValues;
  122451. /**
  122452. * Sets the passed Effect "effect" with the Light textures.
  122453. * @param effect The effect to update
  122454. * @param lightIndex The index of the light in the effect to update
  122455. * @returns The light
  122456. */
  122457. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122458. /**
  122459. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122460. * @param effect The effect to update
  122461. * @param lightIndex The index of the light in the effect to update
  122462. * @returns The spot light
  122463. */
  122464. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122465. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122466. /**
  122467. * Disposes the light and the associated resources.
  122468. */
  122469. dispose(): void;
  122470. /**
  122471. * Prepares the list of defines specific to the light type.
  122472. * @param defines the list of defines
  122473. * @param lightIndex defines the index of the light for the effect
  122474. */
  122475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122476. }
  122477. }
  122478. declare module BABYLON {
  122479. /**
  122480. * Gizmo that enables viewing a light
  122481. */
  122482. export class LightGizmo extends Gizmo {
  122483. private _lightMesh;
  122484. private _material;
  122485. private _cachedPosition;
  122486. private _cachedForward;
  122487. private _attachedMeshParent;
  122488. /**
  122489. * Creates a LightGizmo
  122490. * @param gizmoLayer The utility layer the gizmo will be added to
  122491. */
  122492. constructor(gizmoLayer?: UtilityLayerRenderer);
  122493. private _light;
  122494. /**
  122495. * The light that the gizmo is attached to
  122496. */
  122497. set light(light: Nullable<Light>);
  122498. get light(): Nullable<Light>;
  122499. /**
  122500. * Gets the material used to render the light gizmo
  122501. */
  122502. get material(): StandardMaterial;
  122503. /**
  122504. * @hidden
  122505. * Updates the gizmo to match the attached mesh's position/rotation
  122506. */
  122507. protected _update(): void;
  122508. private static _Scale;
  122509. /**
  122510. * Creates the lines for a light mesh
  122511. */
  122512. private static _CreateLightLines;
  122513. /**
  122514. * Disposes of the light gizmo
  122515. */
  122516. dispose(): void;
  122517. private static _CreateHemisphericLightMesh;
  122518. private static _CreatePointLightMesh;
  122519. private static _CreateSpotLightMesh;
  122520. private static _CreateDirectionalLightMesh;
  122521. }
  122522. }
  122523. declare module BABYLON {
  122524. /** @hidden */
  122525. export var backgroundFragmentDeclaration: {
  122526. name: string;
  122527. shader: string;
  122528. };
  122529. }
  122530. declare module BABYLON {
  122531. /** @hidden */
  122532. export var backgroundUboDeclaration: {
  122533. name: string;
  122534. shader: string;
  122535. };
  122536. }
  122537. declare module BABYLON {
  122538. /** @hidden */
  122539. export var backgroundPixelShader: {
  122540. name: string;
  122541. shader: string;
  122542. };
  122543. }
  122544. declare module BABYLON {
  122545. /** @hidden */
  122546. export var backgroundVertexDeclaration: {
  122547. name: string;
  122548. shader: string;
  122549. };
  122550. }
  122551. declare module BABYLON {
  122552. /** @hidden */
  122553. export var backgroundVertexShader: {
  122554. name: string;
  122555. shader: string;
  122556. };
  122557. }
  122558. declare module BABYLON {
  122559. /**
  122560. * Background material used to create an efficient environement around your scene.
  122561. */
  122562. export class BackgroundMaterial extends PushMaterial {
  122563. /**
  122564. * Standard reflectance value at parallel view angle.
  122565. */
  122566. static StandardReflectance0: number;
  122567. /**
  122568. * Standard reflectance value at grazing angle.
  122569. */
  122570. static StandardReflectance90: number;
  122571. protected _primaryColor: Color3;
  122572. /**
  122573. * Key light Color (multiply against the environement texture)
  122574. */
  122575. primaryColor: Color3;
  122576. protected __perceptualColor: Nullable<Color3>;
  122577. /**
  122578. * Experimental Internal Use Only.
  122579. *
  122580. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122581. * This acts as a helper to set the primary color to a more "human friendly" value.
  122582. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122583. * output color as close as possible from the chosen value.
  122584. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122585. * part of lighting setup.)
  122586. */
  122587. get _perceptualColor(): Nullable<Color3>;
  122588. set _perceptualColor(value: Nullable<Color3>);
  122589. protected _primaryColorShadowLevel: float;
  122590. /**
  122591. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122592. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122593. */
  122594. get primaryColorShadowLevel(): float;
  122595. set primaryColorShadowLevel(value: float);
  122596. protected _primaryColorHighlightLevel: float;
  122597. /**
  122598. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122599. * The primary color is used at the level chosen to define what the white area would look.
  122600. */
  122601. get primaryColorHighlightLevel(): float;
  122602. set primaryColorHighlightLevel(value: float);
  122603. protected _reflectionTexture: Nullable<BaseTexture>;
  122604. /**
  122605. * Reflection Texture used in the material.
  122606. * Should be author in a specific way for the best result (refer to the documentation).
  122607. */
  122608. reflectionTexture: Nullable<BaseTexture>;
  122609. protected _reflectionBlur: float;
  122610. /**
  122611. * Reflection Texture level of blur.
  122612. *
  122613. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122614. * texture twice.
  122615. */
  122616. reflectionBlur: float;
  122617. protected _diffuseTexture: Nullable<BaseTexture>;
  122618. /**
  122619. * Diffuse Texture used in the material.
  122620. * Should be author in a specific way for the best result (refer to the documentation).
  122621. */
  122622. diffuseTexture: Nullable<BaseTexture>;
  122623. protected _shadowLights: Nullable<IShadowLight[]>;
  122624. /**
  122625. * Specify the list of lights casting shadow on the material.
  122626. * All scene shadow lights will be included if null.
  122627. */
  122628. shadowLights: Nullable<IShadowLight[]>;
  122629. protected _shadowLevel: float;
  122630. /**
  122631. * Helps adjusting the shadow to a softer level if required.
  122632. * 0 means black shadows and 1 means no shadows.
  122633. */
  122634. shadowLevel: float;
  122635. protected _sceneCenter: Vector3;
  122636. /**
  122637. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122638. * It is usually zero but might be interesting to modify according to your setup.
  122639. */
  122640. sceneCenter: Vector3;
  122641. protected _opacityFresnel: boolean;
  122642. /**
  122643. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122644. * This helps ensuring a nice transition when the camera goes under the ground.
  122645. */
  122646. opacityFresnel: boolean;
  122647. protected _reflectionFresnel: boolean;
  122648. /**
  122649. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122650. * This helps adding a mirror texture on the ground.
  122651. */
  122652. reflectionFresnel: boolean;
  122653. protected _reflectionFalloffDistance: number;
  122654. /**
  122655. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122656. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122657. */
  122658. reflectionFalloffDistance: number;
  122659. protected _reflectionAmount: number;
  122660. /**
  122661. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122662. */
  122663. reflectionAmount: number;
  122664. protected _reflectionReflectance0: number;
  122665. /**
  122666. * This specifies the weight of the reflection at grazing angle.
  122667. */
  122668. reflectionReflectance0: number;
  122669. protected _reflectionReflectance90: number;
  122670. /**
  122671. * This specifies the weight of the reflection at a perpendicular point of view.
  122672. */
  122673. reflectionReflectance90: number;
  122674. /**
  122675. * Sets the reflection reflectance fresnel values according to the default standard
  122676. * empirically know to work well :-)
  122677. */
  122678. set reflectionStandardFresnelWeight(value: number);
  122679. protected _useRGBColor: boolean;
  122680. /**
  122681. * Helps to directly use the maps channels instead of their level.
  122682. */
  122683. useRGBColor: boolean;
  122684. protected _enableNoise: boolean;
  122685. /**
  122686. * This helps reducing the banding effect that could occur on the background.
  122687. */
  122688. enableNoise: boolean;
  122689. /**
  122690. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122691. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122692. * Recommended to be keep at 1.0 except for special cases.
  122693. */
  122694. get fovMultiplier(): number;
  122695. set fovMultiplier(value: number);
  122696. private _fovMultiplier;
  122697. /**
  122698. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122699. */
  122700. useEquirectangularFOV: boolean;
  122701. private _maxSimultaneousLights;
  122702. /**
  122703. * Number of Simultaneous lights allowed on the material.
  122704. */
  122705. maxSimultaneousLights: int;
  122706. /**
  122707. * Default configuration related to image processing available in the Background Material.
  122708. */
  122709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122710. /**
  122711. * Keep track of the image processing observer to allow dispose and replace.
  122712. */
  122713. private _imageProcessingObserver;
  122714. /**
  122715. * Attaches a new image processing configuration to the PBR Material.
  122716. * @param configuration (if null the scene configuration will be use)
  122717. */
  122718. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122719. /**
  122720. * Gets the image processing configuration used either in this material.
  122721. */
  122722. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122723. /**
  122724. * Sets the Default image processing configuration used either in the this material.
  122725. *
  122726. * If sets to null, the scene one is in use.
  122727. */
  122728. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122729. /**
  122730. * Gets wether the color curves effect is enabled.
  122731. */
  122732. get cameraColorCurvesEnabled(): boolean;
  122733. /**
  122734. * Sets wether the color curves effect is enabled.
  122735. */
  122736. set cameraColorCurvesEnabled(value: boolean);
  122737. /**
  122738. * Gets wether the color grading effect is enabled.
  122739. */
  122740. get cameraColorGradingEnabled(): boolean;
  122741. /**
  122742. * Gets wether the color grading effect is enabled.
  122743. */
  122744. set cameraColorGradingEnabled(value: boolean);
  122745. /**
  122746. * Gets wether tonemapping is enabled or not.
  122747. */
  122748. get cameraToneMappingEnabled(): boolean;
  122749. /**
  122750. * Sets wether tonemapping is enabled or not
  122751. */
  122752. set cameraToneMappingEnabled(value: boolean);
  122753. /**
  122754. * The camera exposure used on this material.
  122755. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122756. * This corresponds to a photographic exposure.
  122757. */
  122758. get cameraExposure(): float;
  122759. /**
  122760. * The camera exposure used on this material.
  122761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122762. * This corresponds to a photographic exposure.
  122763. */
  122764. set cameraExposure(value: float);
  122765. /**
  122766. * Gets The camera contrast used on this material.
  122767. */
  122768. get cameraContrast(): float;
  122769. /**
  122770. * Sets The camera contrast used on this material.
  122771. */
  122772. set cameraContrast(value: float);
  122773. /**
  122774. * Gets the Color Grading 2D Lookup Texture.
  122775. */
  122776. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122777. /**
  122778. * Sets the Color Grading 2D Lookup Texture.
  122779. */
  122780. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122781. /**
  122782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122784. * 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;
  122785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122786. */
  122787. get cameraColorCurves(): Nullable<ColorCurves>;
  122788. /**
  122789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122791. * 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;
  122792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122793. */
  122794. set cameraColorCurves(value: Nullable<ColorCurves>);
  122795. /**
  122796. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122797. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122798. */
  122799. switchToBGR: boolean;
  122800. private _renderTargets;
  122801. private _reflectionControls;
  122802. private _white;
  122803. private _primaryShadowColor;
  122804. private _primaryHighlightColor;
  122805. /**
  122806. * Instantiates a Background Material in the given scene
  122807. * @param name The friendly name of the material
  122808. * @param scene The scene to add the material to
  122809. */
  122810. constructor(name: string, scene: Scene);
  122811. /**
  122812. * Gets a boolean indicating that current material needs to register RTT
  122813. */
  122814. get hasRenderTargetTextures(): boolean;
  122815. /**
  122816. * The entire material has been created in order to prevent overdraw.
  122817. * @returns false
  122818. */
  122819. needAlphaTesting(): boolean;
  122820. /**
  122821. * The entire material has been created in order to prevent overdraw.
  122822. * @returns true if blending is enable
  122823. */
  122824. needAlphaBlending(): boolean;
  122825. /**
  122826. * Checks wether the material is ready to be rendered for a given mesh.
  122827. * @param mesh The mesh to render
  122828. * @param subMesh The submesh to check against
  122829. * @param useInstances Specify wether or not the material is used with instances
  122830. * @returns true if all the dependencies are ready (Textures, Effects...)
  122831. */
  122832. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122833. /**
  122834. * Compute the primary color according to the chosen perceptual color.
  122835. */
  122836. private _computePrimaryColorFromPerceptualColor;
  122837. /**
  122838. * Compute the highlights and shadow colors according to their chosen levels.
  122839. */
  122840. private _computePrimaryColors;
  122841. /**
  122842. * Build the uniform buffer used in the material.
  122843. */
  122844. buildUniformLayout(): void;
  122845. /**
  122846. * Unbind the material.
  122847. */
  122848. unbind(): void;
  122849. /**
  122850. * Bind only the world matrix to the material.
  122851. * @param world The world matrix to bind.
  122852. */
  122853. bindOnlyWorldMatrix(world: Matrix): void;
  122854. /**
  122855. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122856. * @param world The world matrix to bind.
  122857. * @param subMesh The submesh to bind for.
  122858. */
  122859. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122860. /**
  122861. * Checks to see if a texture is used in the material.
  122862. * @param texture - Base texture to use.
  122863. * @returns - Boolean specifying if a texture is used in the material.
  122864. */
  122865. hasTexture(texture: BaseTexture): boolean;
  122866. /**
  122867. * Dispose the material.
  122868. * @param forceDisposeEffect Force disposal of the associated effect.
  122869. * @param forceDisposeTextures Force disposal of the associated textures.
  122870. */
  122871. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122872. /**
  122873. * Clones the material.
  122874. * @param name The cloned name.
  122875. * @returns The cloned material.
  122876. */
  122877. clone(name: string): BackgroundMaterial;
  122878. /**
  122879. * Serializes the current material to its JSON representation.
  122880. * @returns The JSON representation.
  122881. */
  122882. serialize(): any;
  122883. /**
  122884. * Gets the class name of the material
  122885. * @returns "BackgroundMaterial"
  122886. */
  122887. getClassName(): string;
  122888. /**
  122889. * Parse a JSON input to create back a background material.
  122890. * @param source The JSON data to parse
  122891. * @param scene The scene to create the parsed material in
  122892. * @param rootUrl The root url of the assets the material depends upon
  122893. * @returns the instantiated BackgroundMaterial.
  122894. */
  122895. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122896. }
  122897. }
  122898. declare module BABYLON {
  122899. /**
  122900. * Represents the different options available during the creation of
  122901. * a Environment helper.
  122902. *
  122903. * This can control the default ground, skybox and image processing setup of your scene.
  122904. */
  122905. export interface IEnvironmentHelperOptions {
  122906. /**
  122907. * Specifies whether or not to create a ground.
  122908. * True by default.
  122909. */
  122910. createGround: boolean;
  122911. /**
  122912. * Specifies the ground size.
  122913. * 15 by default.
  122914. */
  122915. groundSize: number;
  122916. /**
  122917. * The texture used on the ground for the main color.
  122918. * Comes from the BabylonJS CDN by default.
  122919. *
  122920. * Remarks: Can be either a texture or a url.
  122921. */
  122922. groundTexture: string | BaseTexture;
  122923. /**
  122924. * The color mixed in the ground texture by default.
  122925. * BabylonJS clearColor by default.
  122926. */
  122927. groundColor: Color3;
  122928. /**
  122929. * Specifies the ground opacity.
  122930. * 1 by default.
  122931. */
  122932. groundOpacity: number;
  122933. /**
  122934. * Enables the ground to receive shadows.
  122935. * True by default.
  122936. */
  122937. enableGroundShadow: boolean;
  122938. /**
  122939. * Helps preventing the shadow to be fully black on the ground.
  122940. * 0.5 by default.
  122941. */
  122942. groundShadowLevel: number;
  122943. /**
  122944. * Creates a mirror texture attach to the ground.
  122945. * false by default.
  122946. */
  122947. enableGroundMirror: boolean;
  122948. /**
  122949. * Specifies the ground mirror size ratio.
  122950. * 0.3 by default as the default kernel is 64.
  122951. */
  122952. groundMirrorSizeRatio: number;
  122953. /**
  122954. * Specifies the ground mirror blur kernel size.
  122955. * 64 by default.
  122956. */
  122957. groundMirrorBlurKernel: number;
  122958. /**
  122959. * Specifies the ground mirror visibility amount.
  122960. * 1 by default
  122961. */
  122962. groundMirrorAmount: number;
  122963. /**
  122964. * Specifies the ground mirror reflectance weight.
  122965. * This uses the standard weight of the background material to setup the fresnel effect
  122966. * of the mirror.
  122967. * 1 by default.
  122968. */
  122969. groundMirrorFresnelWeight: number;
  122970. /**
  122971. * Specifies the ground mirror Falloff distance.
  122972. * This can helps reducing the size of the reflection.
  122973. * 0 by Default.
  122974. */
  122975. groundMirrorFallOffDistance: number;
  122976. /**
  122977. * Specifies the ground mirror texture type.
  122978. * Unsigned Int by Default.
  122979. */
  122980. groundMirrorTextureType: number;
  122981. /**
  122982. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122983. * the shown objects.
  122984. */
  122985. groundYBias: number;
  122986. /**
  122987. * Specifies whether or not to create a skybox.
  122988. * True by default.
  122989. */
  122990. createSkybox: boolean;
  122991. /**
  122992. * Specifies the skybox size.
  122993. * 20 by default.
  122994. */
  122995. skyboxSize: number;
  122996. /**
  122997. * The texture used on the skybox for the main color.
  122998. * Comes from the BabylonJS CDN by default.
  122999. *
  123000. * Remarks: Can be either a texture or a url.
  123001. */
  123002. skyboxTexture: string | BaseTexture;
  123003. /**
  123004. * The color mixed in the skybox texture by default.
  123005. * BabylonJS clearColor by default.
  123006. */
  123007. skyboxColor: Color3;
  123008. /**
  123009. * The background rotation around the Y axis of the scene.
  123010. * This helps aligning the key lights of your scene with the background.
  123011. * 0 by default.
  123012. */
  123013. backgroundYRotation: number;
  123014. /**
  123015. * Compute automatically the size of the elements to best fit with the scene.
  123016. */
  123017. sizeAuto: boolean;
  123018. /**
  123019. * Default position of the rootMesh if autoSize is not true.
  123020. */
  123021. rootPosition: Vector3;
  123022. /**
  123023. * Sets up the image processing in the scene.
  123024. * true by default.
  123025. */
  123026. setupImageProcessing: boolean;
  123027. /**
  123028. * The texture used as your environment texture in the scene.
  123029. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  123030. *
  123031. * Remarks: Can be either a texture or a url.
  123032. */
  123033. environmentTexture: string | BaseTexture;
  123034. /**
  123035. * The value of the exposure to apply to the scene.
  123036. * 0.6 by default if setupImageProcessing is true.
  123037. */
  123038. cameraExposure: number;
  123039. /**
  123040. * The value of the contrast to apply to the scene.
  123041. * 1.6 by default if setupImageProcessing is true.
  123042. */
  123043. cameraContrast: number;
  123044. /**
  123045. * Specifies whether or not tonemapping should be enabled in the scene.
  123046. * true by default if setupImageProcessing is true.
  123047. */
  123048. toneMappingEnabled: boolean;
  123049. }
  123050. /**
  123051. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  123052. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  123053. * It also helps with the default setup of your imageProcessing configuration.
  123054. */
  123055. export class EnvironmentHelper {
  123056. /**
  123057. * Default ground texture URL.
  123058. */
  123059. private static _groundTextureCDNUrl;
  123060. /**
  123061. * Default skybox texture URL.
  123062. */
  123063. private static _skyboxTextureCDNUrl;
  123064. /**
  123065. * Default environment texture URL.
  123066. */
  123067. private static _environmentTextureCDNUrl;
  123068. /**
  123069. * Creates the default options for the helper.
  123070. */
  123071. private static _getDefaultOptions;
  123072. private _rootMesh;
  123073. /**
  123074. * Gets the root mesh created by the helper.
  123075. */
  123076. get rootMesh(): Mesh;
  123077. private _skybox;
  123078. /**
  123079. * Gets the skybox created by the helper.
  123080. */
  123081. get skybox(): Nullable<Mesh>;
  123082. private _skyboxTexture;
  123083. /**
  123084. * Gets the skybox texture created by the helper.
  123085. */
  123086. get skyboxTexture(): Nullable<BaseTexture>;
  123087. private _skyboxMaterial;
  123088. /**
  123089. * Gets the skybox material created by the helper.
  123090. */
  123091. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  123092. private _ground;
  123093. /**
  123094. * Gets the ground mesh created by the helper.
  123095. */
  123096. get ground(): Nullable<Mesh>;
  123097. private _groundTexture;
  123098. /**
  123099. * Gets the ground texture created by the helper.
  123100. */
  123101. get groundTexture(): Nullable<BaseTexture>;
  123102. private _groundMirror;
  123103. /**
  123104. * Gets the ground mirror created by the helper.
  123105. */
  123106. get groundMirror(): Nullable<MirrorTexture>;
  123107. /**
  123108. * Gets the ground mirror render list to helps pushing the meshes
  123109. * you wish in the ground reflection.
  123110. */
  123111. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123112. private _groundMaterial;
  123113. /**
  123114. * Gets the ground material created by the helper.
  123115. */
  123116. get groundMaterial(): Nullable<BackgroundMaterial>;
  123117. /**
  123118. * Stores the creation options.
  123119. */
  123120. private readonly _scene;
  123121. private _options;
  123122. /**
  123123. * This observable will be notified with any error during the creation of the environment,
  123124. * mainly texture creation errors.
  123125. */
  123126. onErrorObservable: Observable<{
  123127. message?: string;
  123128. exception?: any;
  123129. }>;
  123130. /**
  123131. * constructor
  123132. * @param options Defines the options we want to customize the helper
  123133. * @param scene The scene to add the material to
  123134. */
  123135. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123136. /**
  123137. * Updates the background according to the new options
  123138. * @param options
  123139. */
  123140. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123141. /**
  123142. * Sets the primary color of all the available elements.
  123143. * @param color the main color to affect to the ground and the background
  123144. */
  123145. setMainColor(color: Color3): void;
  123146. /**
  123147. * Setup the image processing according to the specified options.
  123148. */
  123149. private _setupImageProcessing;
  123150. /**
  123151. * Setup the environment texture according to the specified options.
  123152. */
  123153. private _setupEnvironmentTexture;
  123154. /**
  123155. * Setup the background according to the specified options.
  123156. */
  123157. private _setupBackground;
  123158. /**
  123159. * Get the scene sizes according to the setup.
  123160. */
  123161. private _getSceneSize;
  123162. /**
  123163. * Setup the ground according to the specified options.
  123164. */
  123165. private _setupGround;
  123166. /**
  123167. * Setup the ground material according to the specified options.
  123168. */
  123169. private _setupGroundMaterial;
  123170. /**
  123171. * Setup the ground diffuse texture according to the specified options.
  123172. */
  123173. private _setupGroundDiffuseTexture;
  123174. /**
  123175. * Setup the ground mirror texture according to the specified options.
  123176. */
  123177. private _setupGroundMirrorTexture;
  123178. /**
  123179. * Setup the ground to receive the mirror texture.
  123180. */
  123181. private _setupMirrorInGroundMaterial;
  123182. /**
  123183. * Setup the skybox according to the specified options.
  123184. */
  123185. private _setupSkybox;
  123186. /**
  123187. * Setup the skybox material according to the specified options.
  123188. */
  123189. private _setupSkyboxMaterial;
  123190. /**
  123191. * Setup the skybox reflection texture according to the specified options.
  123192. */
  123193. private _setupSkyboxReflectionTexture;
  123194. private _errorHandler;
  123195. /**
  123196. * Dispose all the elements created by the Helper.
  123197. */
  123198. dispose(): void;
  123199. }
  123200. }
  123201. declare module BABYLON {
  123202. /**
  123203. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123204. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123205. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123206. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123207. */
  123208. export class PhotoDome extends TransformNode {
  123209. /**
  123210. * Define the image as a Monoscopic panoramic 360 image.
  123211. */
  123212. static readonly MODE_MONOSCOPIC: number;
  123213. /**
  123214. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123215. */
  123216. static readonly MODE_TOPBOTTOM: number;
  123217. /**
  123218. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123219. */
  123220. static readonly MODE_SIDEBYSIDE: number;
  123221. private _useDirectMapping;
  123222. /**
  123223. * The texture being displayed on the sphere
  123224. */
  123225. protected _photoTexture: Texture;
  123226. /**
  123227. * Gets or sets the texture being displayed on the sphere
  123228. */
  123229. get photoTexture(): Texture;
  123230. set photoTexture(value: Texture);
  123231. /**
  123232. * Observable raised when an error occured while loading the 360 image
  123233. */
  123234. onLoadErrorObservable: Observable<string>;
  123235. /**
  123236. * The skybox material
  123237. */
  123238. protected _material: BackgroundMaterial;
  123239. /**
  123240. * The surface used for the skybox
  123241. */
  123242. protected _mesh: Mesh;
  123243. /**
  123244. * Gets the mesh used for the skybox.
  123245. */
  123246. get mesh(): Mesh;
  123247. /**
  123248. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123249. * Also see the options.resolution property.
  123250. */
  123251. get fovMultiplier(): number;
  123252. set fovMultiplier(value: number);
  123253. private _imageMode;
  123254. /**
  123255. * Gets or set the current video mode for the video. It can be:
  123256. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123257. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123258. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123259. */
  123260. get imageMode(): number;
  123261. set imageMode(value: number);
  123262. /**
  123263. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123264. * @param name Element's name, child elements will append suffixes for their own names.
  123265. * @param urlsOfPhoto defines the url of the photo to display
  123266. * @param options defines an object containing optional or exposed sub element properties
  123267. * @param onError defines a callback called when an error occured while loading the texture
  123268. */
  123269. constructor(name: string, urlOfPhoto: string, options: {
  123270. resolution?: number;
  123271. size?: number;
  123272. useDirectMapping?: boolean;
  123273. faceForward?: boolean;
  123274. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123275. private _onBeforeCameraRenderObserver;
  123276. private _changeImageMode;
  123277. /**
  123278. * Releases resources associated with this node.
  123279. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123280. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123281. */
  123282. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123283. }
  123284. }
  123285. declare module BABYLON {
  123286. /**
  123287. * Class used to host RGBD texture specific utilities
  123288. */
  123289. export class RGBDTextureTools {
  123290. /**
  123291. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123292. * @param texture the texture to expand.
  123293. */
  123294. static ExpandRGBDTexture(texture: Texture): void;
  123295. }
  123296. }
  123297. declare module BABYLON {
  123298. /**
  123299. * Class used to host texture specific utilities
  123300. */
  123301. export class BRDFTextureTools {
  123302. /**
  123303. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123304. * @param scene defines the hosting scene
  123305. * @returns the environment BRDF texture
  123306. */
  123307. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123308. private static _environmentBRDFBase64Texture;
  123309. }
  123310. }
  123311. declare module BABYLON {
  123312. /**
  123313. * @hidden
  123314. */
  123315. export interface IMaterialClearCoatDefines {
  123316. CLEARCOAT: boolean;
  123317. CLEARCOAT_DEFAULTIOR: boolean;
  123318. CLEARCOAT_TEXTURE: boolean;
  123319. CLEARCOAT_TEXTUREDIRECTUV: number;
  123320. CLEARCOAT_BUMP: boolean;
  123321. CLEARCOAT_BUMPDIRECTUV: number;
  123322. CLEARCOAT_TINT: boolean;
  123323. CLEARCOAT_TINT_TEXTURE: boolean;
  123324. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123325. /** @hidden */
  123326. _areTexturesDirty: boolean;
  123327. }
  123328. /**
  123329. * Define the code related to the clear coat parameters of the pbr material.
  123330. */
  123331. export class PBRClearCoatConfiguration {
  123332. /**
  123333. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123334. * The default fits with a polyurethane material.
  123335. */
  123336. private static readonly _DefaultIndexOfRefraction;
  123337. private _isEnabled;
  123338. /**
  123339. * Defines if the clear coat is enabled in the material.
  123340. */
  123341. isEnabled: boolean;
  123342. /**
  123343. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123344. */
  123345. intensity: number;
  123346. /**
  123347. * Defines the clear coat layer roughness.
  123348. */
  123349. roughness: number;
  123350. private _indexOfRefraction;
  123351. /**
  123352. * Defines the index of refraction of the clear coat.
  123353. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123354. * The default fits with a polyurethane material.
  123355. * Changing the default value is more performance intensive.
  123356. */
  123357. indexOfRefraction: number;
  123358. private _texture;
  123359. /**
  123360. * Stores the clear coat values in a texture.
  123361. */
  123362. texture: Nullable<BaseTexture>;
  123363. private _bumpTexture;
  123364. /**
  123365. * Define the clear coat specific bump texture.
  123366. */
  123367. bumpTexture: Nullable<BaseTexture>;
  123368. private _isTintEnabled;
  123369. /**
  123370. * Defines if the clear coat tint is enabled in the material.
  123371. */
  123372. isTintEnabled: boolean;
  123373. /**
  123374. * Defines the clear coat tint of the material.
  123375. * This is only use if tint is enabled
  123376. */
  123377. tintColor: Color3;
  123378. /**
  123379. * Defines the distance at which the tint color should be found in the
  123380. * clear coat media.
  123381. * This is only use if tint is enabled
  123382. */
  123383. tintColorAtDistance: number;
  123384. /**
  123385. * Defines the clear coat layer thickness.
  123386. * This is only use if tint is enabled
  123387. */
  123388. tintThickness: number;
  123389. private _tintTexture;
  123390. /**
  123391. * Stores the clear tint values in a texture.
  123392. * rgb is tint
  123393. * a is a thickness factor
  123394. */
  123395. tintTexture: Nullable<BaseTexture>;
  123396. /** @hidden */
  123397. private _internalMarkAllSubMeshesAsTexturesDirty;
  123398. /** @hidden */
  123399. _markAllSubMeshesAsTexturesDirty(): void;
  123400. /**
  123401. * Instantiate a new istance of clear coat configuration.
  123402. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123403. */
  123404. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123405. /**
  123406. * Gets wehter the submesh is ready to be used or not.
  123407. * @param defines the list of "defines" to update.
  123408. * @param scene defines the scene the material belongs to.
  123409. * @param engine defines the engine the material belongs to.
  123410. * @param disableBumpMap defines wether the material disables bump or not.
  123411. * @returns - boolean indicating that the submesh is ready or not.
  123412. */
  123413. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123414. /**
  123415. * Checks to see if a texture is used in the material.
  123416. * @param defines the list of "defines" to update.
  123417. * @param scene defines the scene to the material belongs to.
  123418. */
  123419. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123420. /**
  123421. * Binds the material data.
  123422. * @param uniformBuffer defines the Uniform buffer to fill in.
  123423. * @param scene defines the scene the material belongs to.
  123424. * @param engine defines the engine the material belongs to.
  123425. * @param disableBumpMap defines wether the material disables bump or not.
  123426. * @param isFrozen defines wether the material is frozen or not.
  123427. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123428. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123429. */
  123430. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123431. /**
  123432. * Checks to see if a texture is used in the material.
  123433. * @param texture - Base texture to use.
  123434. * @returns - Boolean specifying if a texture is used in the material.
  123435. */
  123436. hasTexture(texture: BaseTexture): boolean;
  123437. /**
  123438. * Returns an array of the actively used textures.
  123439. * @param activeTextures Array of BaseTextures
  123440. */
  123441. getActiveTextures(activeTextures: BaseTexture[]): void;
  123442. /**
  123443. * Returns the animatable textures.
  123444. * @param animatables Array of animatable textures.
  123445. */
  123446. getAnimatables(animatables: IAnimatable[]): void;
  123447. /**
  123448. * Disposes the resources of the material.
  123449. * @param forceDisposeTextures - Forces the disposal of all textures.
  123450. */
  123451. dispose(forceDisposeTextures?: boolean): void;
  123452. /**
  123453. * Get the current class name of the texture useful for serialization or dynamic coding.
  123454. * @returns "PBRClearCoatConfiguration"
  123455. */
  123456. getClassName(): string;
  123457. /**
  123458. * Add fallbacks to the effect fallbacks list.
  123459. * @param defines defines the Base texture to use.
  123460. * @param fallbacks defines the current fallback list.
  123461. * @param currentRank defines the current fallback rank.
  123462. * @returns the new fallback rank.
  123463. */
  123464. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123465. /**
  123466. * Add the required uniforms to the current list.
  123467. * @param uniforms defines the current uniform list.
  123468. */
  123469. static AddUniforms(uniforms: string[]): void;
  123470. /**
  123471. * Add the required samplers to the current list.
  123472. * @param samplers defines the current sampler list.
  123473. */
  123474. static AddSamplers(samplers: string[]): void;
  123475. /**
  123476. * Add the required uniforms to the current buffer.
  123477. * @param uniformBuffer defines the current uniform buffer.
  123478. */
  123479. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123480. /**
  123481. * Makes a duplicate of the current configuration into another one.
  123482. * @param clearCoatConfiguration define the config where to copy the info
  123483. */
  123484. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123485. /**
  123486. * Serializes this clear coat configuration.
  123487. * @returns - An object with the serialized config.
  123488. */
  123489. serialize(): any;
  123490. /**
  123491. * Parses a anisotropy Configuration from a serialized object.
  123492. * @param source - Serialized object.
  123493. * @param scene Defines the scene we are parsing for
  123494. * @param rootUrl Defines the rootUrl to load from
  123495. */
  123496. parse(source: any, scene: Scene, rootUrl: string): void;
  123497. }
  123498. }
  123499. declare module BABYLON {
  123500. /**
  123501. * @hidden
  123502. */
  123503. export interface IMaterialAnisotropicDefines {
  123504. ANISOTROPIC: boolean;
  123505. ANISOTROPIC_TEXTURE: boolean;
  123506. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123507. MAINUV1: boolean;
  123508. _areTexturesDirty: boolean;
  123509. _needUVs: boolean;
  123510. }
  123511. /**
  123512. * Define the code related to the anisotropic parameters of the pbr material.
  123513. */
  123514. export class PBRAnisotropicConfiguration {
  123515. private _isEnabled;
  123516. /**
  123517. * Defines if the anisotropy is enabled in the material.
  123518. */
  123519. isEnabled: boolean;
  123520. /**
  123521. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123522. */
  123523. intensity: number;
  123524. /**
  123525. * Defines if the effect is along the tangents, bitangents or in between.
  123526. * By default, the effect is "strectching" the highlights along the tangents.
  123527. */
  123528. direction: Vector2;
  123529. private _texture;
  123530. /**
  123531. * Stores the anisotropy values in a texture.
  123532. * rg is direction (like normal from -1 to 1)
  123533. * b is a intensity
  123534. */
  123535. texture: Nullable<BaseTexture>;
  123536. /** @hidden */
  123537. private _internalMarkAllSubMeshesAsTexturesDirty;
  123538. /** @hidden */
  123539. _markAllSubMeshesAsTexturesDirty(): void;
  123540. /**
  123541. * Instantiate a new istance of anisotropy configuration.
  123542. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123543. */
  123544. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123545. /**
  123546. * Specifies that the submesh is ready to be used.
  123547. * @param defines the list of "defines" to update.
  123548. * @param scene defines the scene the material belongs to.
  123549. * @returns - boolean indicating that the submesh is ready or not.
  123550. */
  123551. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123552. /**
  123553. * Checks to see if a texture is used in the material.
  123554. * @param defines the list of "defines" to update.
  123555. * @param mesh the mesh we are preparing the defines for.
  123556. * @param scene defines the scene the material belongs to.
  123557. */
  123558. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123559. /**
  123560. * Binds the material data.
  123561. * @param uniformBuffer defines the Uniform buffer to fill in.
  123562. * @param scene defines the scene the material belongs to.
  123563. * @param isFrozen defines wether the material is frozen or not.
  123564. */
  123565. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123566. /**
  123567. * Checks to see if a texture is used in the material.
  123568. * @param texture - Base texture to use.
  123569. * @returns - Boolean specifying if a texture is used in the material.
  123570. */
  123571. hasTexture(texture: BaseTexture): boolean;
  123572. /**
  123573. * Returns an array of the actively used textures.
  123574. * @param activeTextures Array of BaseTextures
  123575. */
  123576. getActiveTextures(activeTextures: BaseTexture[]): void;
  123577. /**
  123578. * Returns the animatable textures.
  123579. * @param animatables Array of animatable textures.
  123580. */
  123581. getAnimatables(animatables: IAnimatable[]): void;
  123582. /**
  123583. * Disposes the resources of the material.
  123584. * @param forceDisposeTextures - Forces the disposal of all textures.
  123585. */
  123586. dispose(forceDisposeTextures?: boolean): void;
  123587. /**
  123588. * Get the current class name of the texture useful for serialization or dynamic coding.
  123589. * @returns "PBRAnisotropicConfiguration"
  123590. */
  123591. getClassName(): string;
  123592. /**
  123593. * Add fallbacks to the effect fallbacks list.
  123594. * @param defines defines the Base texture to use.
  123595. * @param fallbacks defines the current fallback list.
  123596. * @param currentRank defines the current fallback rank.
  123597. * @returns the new fallback rank.
  123598. */
  123599. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123600. /**
  123601. * Add the required uniforms to the current list.
  123602. * @param uniforms defines the current uniform list.
  123603. */
  123604. static AddUniforms(uniforms: string[]): void;
  123605. /**
  123606. * Add the required uniforms to the current buffer.
  123607. * @param uniformBuffer defines the current uniform buffer.
  123608. */
  123609. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123610. /**
  123611. * Add the required samplers to the current list.
  123612. * @param samplers defines the current sampler list.
  123613. */
  123614. static AddSamplers(samplers: string[]): void;
  123615. /**
  123616. * Makes a duplicate of the current configuration into another one.
  123617. * @param anisotropicConfiguration define the config where to copy the info
  123618. */
  123619. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123620. /**
  123621. * Serializes this anisotropy configuration.
  123622. * @returns - An object with the serialized config.
  123623. */
  123624. serialize(): any;
  123625. /**
  123626. * Parses a anisotropy Configuration from a serialized object.
  123627. * @param source - Serialized object.
  123628. * @param scene Defines the scene we are parsing for
  123629. * @param rootUrl Defines the rootUrl to load from
  123630. */
  123631. parse(source: any, scene: Scene, rootUrl: string): void;
  123632. }
  123633. }
  123634. declare module BABYLON {
  123635. /**
  123636. * @hidden
  123637. */
  123638. export interface IMaterialBRDFDefines {
  123639. BRDF_V_HEIGHT_CORRELATED: boolean;
  123640. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123641. SPHERICAL_HARMONICS: boolean;
  123642. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123643. /** @hidden */
  123644. _areMiscDirty: boolean;
  123645. }
  123646. /**
  123647. * Define the code related to the BRDF parameters of the pbr material.
  123648. */
  123649. export class PBRBRDFConfiguration {
  123650. /**
  123651. * Default value used for the energy conservation.
  123652. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123653. */
  123654. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123655. /**
  123656. * Default value used for the Smith Visibility Height Correlated mode.
  123657. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123658. */
  123659. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123660. /**
  123661. * Default value used for the IBL diffuse part.
  123662. * This can help switching back to the polynomials mode globally which is a tiny bit
  123663. * less GPU intensive at the drawback of a lower quality.
  123664. */
  123665. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123666. /**
  123667. * Default value used for activating energy conservation for the specular workflow.
  123668. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123669. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123670. */
  123671. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123672. private _useEnergyConservation;
  123673. /**
  123674. * Defines if the material uses energy conservation.
  123675. */
  123676. useEnergyConservation: boolean;
  123677. private _useSmithVisibilityHeightCorrelated;
  123678. /**
  123679. * LEGACY Mode set to false
  123680. * Defines if the material uses height smith correlated visibility term.
  123681. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123682. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123683. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123684. * Not relying on height correlated will also disable energy conservation.
  123685. */
  123686. useSmithVisibilityHeightCorrelated: boolean;
  123687. private _useSphericalHarmonics;
  123688. /**
  123689. * LEGACY Mode set to false
  123690. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123691. * diffuse part of the IBL.
  123692. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123693. * to the ground truth.
  123694. */
  123695. useSphericalHarmonics: boolean;
  123696. private _useSpecularGlossinessInputEnergyConservation;
  123697. /**
  123698. * Defines if the material uses energy conservation, when the specular workflow is active.
  123699. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123700. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123701. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123702. */
  123703. useSpecularGlossinessInputEnergyConservation: boolean;
  123704. /** @hidden */
  123705. private _internalMarkAllSubMeshesAsMiscDirty;
  123706. /** @hidden */
  123707. _markAllSubMeshesAsMiscDirty(): void;
  123708. /**
  123709. * Instantiate a new istance of clear coat configuration.
  123710. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123711. */
  123712. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123713. /**
  123714. * Checks to see if a texture is used in the material.
  123715. * @param defines the list of "defines" to update.
  123716. */
  123717. prepareDefines(defines: IMaterialBRDFDefines): void;
  123718. /**
  123719. * Get the current class name of the texture useful for serialization or dynamic coding.
  123720. * @returns "PBRClearCoatConfiguration"
  123721. */
  123722. getClassName(): string;
  123723. /**
  123724. * Makes a duplicate of the current configuration into another one.
  123725. * @param brdfConfiguration define the config where to copy the info
  123726. */
  123727. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123728. /**
  123729. * Serializes this BRDF configuration.
  123730. * @returns - An object with the serialized config.
  123731. */
  123732. serialize(): any;
  123733. /**
  123734. * Parses a anisotropy Configuration from a serialized object.
  123735. * @param source - Serialized object.
  123736. * @param scene Defines the scene we are parsing for
  123737. * @param rootUrl Defines the rootUrl to load from
  123738. */
  123739. parse(source: any, scene: Scene, rootUrl: string): void;
  123740. }
  123741. }
  123742. declare module BABYLON {
  123743. /**
  123744. * @hidden
  123745. */
  123746. export interface IMaterialSheenDefines {
  123747. SHEEN: boolean;
  123748. SHEEN_TEXTURE: boolean;
  123749. SHEEN_TEXTUREDIRECTUV: number;
  123750. SHEEN_LINKWITHALBEDO: boolean;
  123751. /** @hidden */
  123752. _areTexturesDirty: boolean;
  123753. }
  123754. /**
  123755. * Define the code related to the Sheen parameters of the pbr material.
  123756. */
  123757. export class PBRSheenConfiguration {
  123758. private _isEnabled;
  123759. /**
  123760. * Defines if the material uses sheen.
  123761. */
  123762. isEnabled: boolean;
  123763. private _linkSheenWithAlbedo;
  123764. /**
  123765. * Defines if the sheen is linked to the sheen color.
  123766. */
  123767. linkSheenWithAlbedo: boolean;
  123768. /**
  123769. * Defines the sheen intensity.
  123770. */
  123771. intensity: number;
  123772. /**
  123773. * Defines the sheen color.
  123774. */
  123775. color: Color3;
  123776. private _texture;
  123777. /**
  123778. * Stores the sheen tint values in a texture.
  123779. * rgb is tint
  123780. * a is a intensity
  123781. */
  123782. texture: Nullable<BaseTexture>;
  123783. /** @hidden */
  123784. private _internalMarkAllSubMeshesAsTexturesDirty;
  123785. /** @hidden */
  123786. _markAllSubMeshesAsTexturesDirty(): void;
  123787. /**
  123788. * Instantiate a new istance of clear coat configuration.
  123789. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123790. */
  123791. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123792. /**
  123793. * Specifies that the submesh is ready to be used.
  123794. * @param defines the list of "defines" to update.
  123795. * @param scene defines the scene the material belongs to.
  123796. * @returns - boolean indicating that the submesh is ready or not.
  123797. */
  123798. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123799. /**
  123800. * Checks to see if a texture is used in the material.
  123801. * @param defines the list of "defines" to update.
  123802. * @param scene defines the scene the material belongs to.
  123803. */
  123804. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123805. /**
  123806. * Binds the material data.
  123807. * @param uniformBuffer defines the Uniform buffer to fill in.
  123808. * @param scene defines the scene the material belongs to.
  123809. * @param isFrozen defines wether the material is frozen or not.
  123810. */
  123811. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123812. /**
  123813. * Checks to see if a texture is used in the material.
  123814. * @param texture - Base texture to use.
  123815. * @returns - Boolean specifying if a texture is used in the material.
  123816. */
  123817. hasTexture(texture: BaseTexture): boolean;
  123818. /**
  123819. * Returns an array of the actively used textures.
  123820. * @param activeTextures Array of BaseTextures
  123821. */
  123822. getActiveTextures(activeTextures: BaseTexture[]): void;
  123823. /**
  123824. * Returns the animatable textures.
  123825. * @param animatables Array of animatable textures.
  123826. */
  123827. getAnimatables(animatables: IAnimatable[]): void;
  123828. /**
  123829. * Disposes the resources of the material.
  123830. * @param forceDisposeTextures - Forces the disposal of all textures.
  123831. */
  123832. dispose(forceDisposeTextures?: boolean): void;
  123833. /**
  123834. * Get the current class name of the texture useful for serialization or dynamic coding.
  123835. * @returns "PBRSheenConfiguration"
  123836. */
  123837. getClassName(): string;
  123838. /**
  123839. * Add fallbacks to the effect fallbacks list.
  123840. * @param defines defines the Base texture to use.
  123841. * @param fallbacks defines the current fallback list.
  123842. * @param currentRank defines the current fallback rank.
  123843. * @returns the new fallback rank.
  123844. */
  123845. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123846. /**
  123847. * Add the required uniforms to the current list.
  123848. * @param uniforms defines the current uniform list.
  123849. */
  123850. static AddUniforms(uniforms: string[]): void;
  123851. /**
  123852. * Add the required uniforms to the current buffer.
  123853. * @param uniformBuffer defines the current uniform buffer.
  123854. */
  123855. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123856. /**
  123857. * Add the required samplers to the current list.
  123858. * @param samplers defines the current sampler list.
  123859. */
  123860. static AddSamplers(samplers: string[]): void;
  123861. /**
  123862. * Makes a duplicate of the current configuration into another one.
  123863. * @param sheenConfiguration define the config where to copy the info
  123864. */
  123865. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123866. /**
  123867. * Serializes this BRDF configuration.
  123868. * @returns - An object with the serialized config.
  123869. */
  123870. serialize(): any;
  123871. /**
  123872. * Parses a anisotropy Configuration from a serialized object.
  123873. * @param source - Serialized object.
  123874. * @param scene Defines the scene we are parsing for
  123875. * @param rootUrl Defines the rootUrl to load from
  123876. */
  123877. parse(source: any, scene: Scene, rootUrl: string): void;
  123878. }
  123879. }
  123880. declare module BABYLON {
  123881. /**
  123882. * @hidden
  123883. */
  123884. export interface IMaterialSubSurfaceDefines {
  123885. SUBSURFACE: boolean;
  123886. SS_REFRACTION: boolean;
  123887. SS_TRANSLUCENCY: boolean;
  123888. SS_SCATERRING: boolean;
  123889. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123890. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123891. SS_REFRACTIONMAP_3D: boolean;
  123892. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123893. SS_LODINREFRACTIONALPHA: boolean;
  123894. SS_GAMMAREFRACTION: boolean;
  123895. SS_RGBDREFRACTION: boolean;
  123896. SS_LINEARSPECULARREFRACTION: boolean;
  123897. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123898. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123899. /** @hidden */
  123900. _areTexturesDirty: boolean;
  123901. }
  123902. /**
  123903. * Define the code related to the sub surface parameters of the pbr material.
  123904. */
  123905. export class PBRSubSurfaceConfiguration {
  123906. private _isRefractionEnabled;
  123907. /**
  123908. * Defines if the refraction is enabled in the material.
  123909. */
  123910. isRefractionEnabled: boolean;
  123911. private _isTranslucencyEnabled;
  123912. /**
  123913. * Defines if the translucency is enabled in the material.
  123914. */
  123915. isTranslucencyEnabled: boolean;
  123916. private _isScatteringEnabled;
  123917. /**
  123918. * Defines the refraction intensity of the material.
  123919. * The refraction when enabled replaces the Diffuse part of the material.
  123920. * The intensity helps transitionning between diffuse and refraction.
  123921. */
  123922. refractionIntensity: number;
  123923. /**
  123924. * Defines the translucency intensity of the material.
  123925. * When translucency has been enabled, this defines how much of the "translucency"
  123926. * is addded to the diffuse part of the material.
  123927. */
  123928. translucencyIntensity: number;
  123929. /**
  123930. * Defines the scattering intensity of the material.
  123931. * When scattering has been enabled, this defines how much of the "scattered light"
  123932. * is addded to the diffuse part of the material.
  123933. */
  123934. scatteringIntensity: number;
  123935. private _thicknessTexture;
  123936. /**
  123937. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123938. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123939. * 0 would mean minimumThickness
  123940. * 1 would mean maximumThickness
  123941. * The other channels might be use as a mask to vary the different effects intensity.
  123942. */
  123943. thicknessTexture: Nullable<BaseTexture>;
  123944. private _refractionTexture;
  123945. /**
  123946. * Defines the texture to use for refraction.
  123947. */
  123948. refractionTexture: Nullable<BaseTexture>;
  123949. private _indexOfRefraction;
  123950. /**
  123951. * Defines the index of refraction used in the material.
  123952. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123953. */
  123954. indexOfRefraction: number;
  123955. private _invertRefractionY;
  123956. /**
  123957. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123958. */
  123959. invertRefractionY: boolean;
  123960. private _linkRefractionWithTransparency;
  123961. /**
  123962. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123963. * Materials half opaque for instance using refraction could benefit from this control.
  123964. */
  123965. linkRefractionWithTransparency: boolean;
  123966. /**
  123967. * Defines the minimum thickness stored in the thickness map.
  123968. * If no thickness map is defined, this value will be used to simulate thickness.
  123969. */
  123970. minimumThickness: number;
  123971. /**
  123972. * Defines the maximum thickness stored in the thickness map.
  123973. */
  123974. maximumThickness: number;
  123975. /**
  123976. * Defines the volume tint of the material.
  123977. * This is used for both translucency and scattering.
  123978. */
  123979. tintColor: Color3;
  123980. /**
  123981. * Defines the distance at which the tint color should be found in the media.
  123982. * This is used for refraction only.
  123983. */
  123984. tintColorAtDistance: number;
  123985. /**
  123986. * Defines how far each channel transmit through the media.
  123987. * It is defined as a color to simplify it selection.
  123988. */
  123989. diffusionDistance: Color3;
  123990. private _useMaskFromThicknessTexture;
  123991. /**
  123992. * Stores the intensity of the different subsurface effects in the thickness texture.
  123993. * * the green channel is the translucency intensity.
  123994. * * the blue channel is the scattering intensity.
  123995. * * the alpha channel is the refraction intensity.
  123996. */
  123997. useMaskFromThicknessTexture: boolean;
  123998. /** @hidden */
  123999. private _internalMarkAllSubMeshesAsTexturesDirty;
  124000. /** @hidden */
  124001. _markAllSubMeshesAsTexturesDirty(): void;
  124002. /**
  124003. * Instantiate a new istance of sub surface configuration.
  124004. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124005. */
  124006. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124007. /**
  124008. * Gets wehter the submesh is ready to be used or not.
  124009. * @param defines the list of "defines" to update.
  124010. * @param scene defines the scene the material belongs to.
  124011. * @returns - boolean indicating that the submesh is ready or not.
  124012. */
  124013. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  124014. /**
  124015. * Checks to see if a texture is used in the material.
  124016. * @param defines the list of "defines" to update.
  124017. * @param scene defines the scene to the material belongs to.
  124018. */
  124019. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  124020. /**
  124021. * Binds the material data.
  124022. * @param uniformBuffer defines the Uniform buffer to fill in.
  124023. * @param scene defines the scene the material belongs to.
  124024. * @param engine defines the engine the material belongs to.
  124025. * @param isFrozen defines wether the material is frozen or not.
  124026. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  124027. */
  124028. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  124029. /**
  124030. * Unbinds the material from the mesh.
  124031. * @param activeEffect defines the effect that should be unbound from.
  124032. * @returns true if unbound, otherwise false
  124033. */
  124034. unbind(activeEffect: Effect): boolean;
  124035. /**
  124036. * Returns the texture used for refraction or null if none is used.
  124037. * @param scene defines the scene the material belongs to.
  124038. * @returns - Refraction texture if present. If no refraction texture and refraction
  124039. * is linked with transparency, returns environment texture. Otherwise, returns null.
  124040. */
  124041. private _getRefractionTexture;
  124042. /**
  124043. * Returns true if alpha blending should be disabled.
  124044. */
  124045. get disableAlphaBlending(): boolean;
  124046. /**
  124047. * Fills the list of render target textures.
  124048. * @param renderTargets the list of render targets to update
  124049. */
  124050. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  124051. /**
  124052. * Checks to see if a texture is used in the material.
  124053. * @param texture - Base texture to use.
  124054. * @returns - Boolean specifying if a texture is used in the material.
  124055. */
  124056. hasTexture(texture: BaseTexture): boolean;
  124057. /**
  124058. * Gets a boolean indicating that current material needs to register RTT
  124059. * @returns true if this uses a render target otherwise false.
  124060. */
  124061. hasRenderTargetTextures(): boolean;
  124062. /**
  124063. * Returns an array of the actively used textures.
  124064. * @param activeTextures Array of BaseTextures
  124065. */
  124066. getActiveTextures(activeTextures: BaseTexture[]): void;
  124067. /**
  124068. * Returns the animatable textures.
  124069. * @param animatables Array of animatable textures.
  124070. */
  124071. getAnimatables(animatables: IAnimatable[]): void;
  124072. /**
  124073. * Disposes the resources of the material.
  124074. * @param forceDisposeTextures - Forces the disposal of all textures.
  124075. */
  124076. dispose(forceDisposeTextures?: boolean): void;
  124077. /**
  124078. * Get the current class name of the texture useful for serialization or dynamic coding.
  124079. * @returns "PBRSubSurfaceConfiguration"
  124080. */
  124081. getClassName(): string;
  124082. /**
  124083. * Add fallbacks to the effect fallbacks list.
  124084. * @param defines defines the Base texture to use.
  124085. * @param fallbacks defines the current fallback list.
  124086. * @param currentRank defines the current fallback rank.
  124087. * @returns the new fallback rank.
  124088. */
  124089. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124090. /**
  124091. * Add the required uniforms to the current list.
  124092. * @param uniforms defines the current uniform list.
  124093. */
  124094. static AddUniforms(uniforms: string[]): void;
  124095. /**
  124096. * Add the required samplers to the current list.
  124097. * @param samplers defines the current sampler list.
  124098. */
  124099. static AddSamplers(samplers: string[]): void;
  124100. /**
  124101. * Add the required uniforms to the current buffer.
  124102. * @param uniformBuffer defines the current uniform buffer.
  124103. */
  124104. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124105. /**
  124106. * Makes a duplicate of the current configuration into another one.
  124107. * @param configuration define the config where to copy the info
  124108. */
  124109. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124110. /**
  124111. * Serializes this Sub Surface configuration.
  124112. * @returns - An object with the serialized config.
  124113. */
  124114. serialize(): any;
  124115. /**
  124116. * Parses a anisotropy Configuration from a serialized object.
  124117. * @param source - Serialized object.
  124118. * @param scene Defines the scene we are parsing for
  124119. * @param rootUrl Defines the rootUrl to load from
  124120. */
  124121. parse(source: any, scene: Scene, rootUrl: string): void;
  124122. }
  124123. }
  124124. declare module BABYLON {
  124125. /** @hidden */
  124126. export var pbrFragmentDeclaration: {
  124127. name: string;
  124128. shader: string;
  124129. };
  124130. }
  124131. declare module BABYLON {
  124132. /** @hidden */
  124133. export var pbrUboDeclaration: {
  124134. name: string;
  124135. shader: string;
  124136. };
  124137. }
  124138. declare module BABYLON {
  124139. /** @hidden */
  124140. export var pbrFragmentExtraDeclaration: {
  124141. name: string;
  124142. shader: string;
  124143. };
  124144. }
  124145. declare module BABYLON {
  124146. /** @hidden */
  124147. export var pbrFragmentSamplersDeclaration: {
  124148. name: string;
  124149. shader: string;
  124150. };
  124151. }
  124152. declare module BABYLON {
  124153. /** @hidden */
  124154. export var pbrHelperFunctions: {
  124155. name: string;
  124156. shader: string;
  124157. };
  124158. }
  124159. declare module BABYLON {
  124160. /** @hidden */
  124161. export var harmonicsFunctions: {
  124162. name: string;
  124163. shader: string;
  124164. };
  124165. }
  124166. declare module BABYLON {
  124167. /** @hidden */
  124168. export var pbrDirectLightingSetupFunctions: {
  124169. name: string;
  124170. shader: string;
  124171. };
  124172. }
  124173. declare module BABYLON {
  124174. /** @hidden */
  124175. export var pbrDirectLightingFalloffFunctions: {
  124176. name: string;
  124177. shader: string;
  124178. };
  124179. }
  124180. declare module BABYLON {
  124181. /** @hidden */
  124182. export var pbrBRDFFunctions: {
  124183. name: string;
  124184. shader: string;
  124185. };
  124186. }
  124187. declare module BABYLON {
  124188. /** @hidden */
  124189. export var pbrDirectLightingFunctions: {
  124190. name: string;
  124191. shader: string;
  124192. };
  124193. }
  124194. declare module BABYLON {
  124195. /** @hidden */
  124196. export var pbrIBLFunctions: {
  124197. name: string;
  124198. shader: string;
  124199. };
  124200. }
  124201. declare module BABYLON {
  124202. /** @hidden */
  124203. export var pbrDebug: {
  124204. name: string;
  124205. shader: string;
  124206. };
  124207. }
  124208. declare module BABYLON {
  124209. /** @hidden */
  124210. export var pbrPixelShader: {
  124211. name: string;
  124212. shader: string;
  124213. };
  124214. }
  124215. declare module BABYLON {
  124216. /** @hidden */
  124217. export var pbrVertexDeclaration: {
  124218. name: string;
  124219. shader: string;
  124220. };
  124221. }
  124222. declare module BABYLON {
  124223. /** @hidden */
  124224. export var pbrVertexShader: {
  124225. name: string;
  124226. shader: string;
  124227. };
  124228. }
  124229. declare module BABYLON {
  124230. /**
  124231. * Manages the defines for the PBR Material.
  124232. * @hidden
  124233. */
  124234. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124235. PBR: boolean;
  124236. MAINUV1: boolean;
  124237. MAINUV2: boolean;
  124238. UV1: boolean;
  124239. UV2: boolean;
  124240. ALBEDO: boolean;
  124241. GAMMAALBEDO: boolean;
  124242. ALBEDODIRECTUV: number;
  124243. VERTEXCOLOR: boolean;
  124244. AMBIENT: boolean;
  124245. AMBIENTDIRECTUV: number;
  124246. AMBIENTINGRAYSCALE: boolean;
  124247. OPACITY: boolean;
  124248. VERTEXALPHA: boolean;
  124249. OPACITYDIRECTUV: number;
  124250. OPACITYRGB: boolean;
  124251. ALPHATEST: boolean;
  124252. DEPTHPREPASS: boolean;
  124253. ALPHABLEND: boolean;
  124254. ALPHAFROMALBEDO: boolean;
  124255. ALPHATESTVALUE: string;
  124256. SPECULAROVERALPHA: boolean;
  124257. RADIANCEOVERALPHA: boolean;
  124258. ALPHAFRESNEL: boolean;
  124259. LINEARALPHAFRESNEL: boolean;
  124260. PREMULTIPLYALPHA: boolean;
  124261. EMISSIVE: boolean;
  124262. EMISSIVEDIRECTUV: number;
  124263. REFLECTIVITY: boolean;
  124264. REFLECTIVITYDIRECTUV: number;
  124265. SPECULARTERM: boolean;
  124266. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124267. MICROSURFACEAUTOMATIC: boolean;
  124268. LODBASEDMICROSFURACE: boolean;
  124269. MICROSURFACEMAP: boolean;
  124270. MICROSURFACEMAPDIRECTUV: number;
  124271. METALLICWORKFLOW: boolean;
  124272. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124273. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124274. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124275. AOSTOREINMETALMAPRED: boolean;
  124276. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124277. ENVIRONMENTBRDF: boolean;
  124278. ENVIRONMENTBRDF_RGBD: boolean;
  124279. NORMAL: boolean;
  124280. TANGENT: boolean;
  124281. BUMP: boolean;
  124282. BUMPDIRECTUV: number;
  124283. OBJECTSPACE_NORMALMAP: boolean;
  124284. PARALLAX: boolean;
  124285. PARALLAXOCCLUSION: boolean;
  124286. NORMALXYSCALE: boolean;
  124287. LIGHTMAP: boolean;
  124288. LIGHTMAPDIRECTUV: number;
  124289. USELIGHTMAPASSHADOWMAP: boolean;
  124290. GAMMALIGHTMAP: boolean;
  124291. RGBDLIGHTMAP: boolean;
  124292. REFLECTION: boolean;
  124293. REFLECTIONMAP_3D: boolean;
  124294. REFLECTIONMAP_SPHERICAL: boolean;
  124295. REFLECTIONMAP_PLANAR: boolean;
  124296. REFLECTIONMAP_CUBIC: boolean;
  124297. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124298. REFLECTIONMAP_PROJECTION: boolean;
  124299. REFLECTIONMAP_SKYBOX: boolean;
  124300. REFLECTIONMAP_EXPLICIT: boolean;
  124301. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124302. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124303. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124304. INVERTCUBICMAP: boolean;
  124305. USESPHERICALFROMREFLECTIONMAP: boolean;
  124306. USEIRRADIANCEMAP: boolean;
  124307. SPHERICAL_HARMONICS: boolean;
  124308. USESPHERICALINVERTEX: boolean;
  124309. REFLECTIONMAP_OPPOSITEZ: boolean;
  124310. LODINREFLECTIONALPHA: boolean;
  124311. GAMMAREFLECTION: boolean;
  124312. RGBDREFLECTION: boolean;
  124313. LINEARSPECULARREFLECTION: boolean;
  124314. RADIANCEOCCLUSION: boolean;
  124315. HORIZONOCCLUSION: boolean;
  124316. INSTANCES: boolean;
  124317. NUM_BONE_INFLUENCERS: number;
  124318. BonesPerMesh: number;
  124319. BONETEXTURE: boolean;
  124320. NONUNIFORMSCALING: boolean;
  124321. MORPHTARGETS: boolean;
  124322. MORPHTARGETS_NORMAL: boolean;
  124323. MORPHTARGETS_TANGENT: boolean;
  124324. MORPHTARGETS_UV: boolean;
  124325. NUM_MORPH_INFLUENCERS: number;
  124326. IMAGEPROCESSING: boolean;
  124327. VIGNETTE: boolean;
  124328. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124329. VIGNETTEBLENDMODEOPAQUE: boolean;
  124330. TONEMAPPING: boolean;
  124331. TONEMAPPING_ACES: boolean;
  124332. CONTRAST: boolean;
  124333. COLORCURVES: boolean;
  124334. COLORGRADING: boolean;
  124335. COLORGRADING3D: boolean;
  124336. SAMPLER3DGREENDEPTH: boolean;
  124337. SAMPLER3DBGRMAP: boolean;
  124338. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124339. EXPOSURE: boolean;
  124340. MULTIVIEW: boolean;
  124341. USEPHYSICALLIGHTFALLOFF: boolean;
  124342. USEGLTFLIGHTFALLOFF: boolean;
  124343. TWOSIDEDLIGHTING: boolean;
  124344. SHADOWFLOAT: boolean;
  124345. CLIPPLANE: boolean;
  124346. CLIPPLANE2: boolean;
  124347. CLIPPLANE3: boolean;
  124348. CLIPPLANE4: boolean;
  124349. CLIPPLANE5: boolean;
  124350. CLIPPLANE6: boolean;
  124351. POINTSIZE: boolean;
  124352. FOG: boolean;
  124353. LOGARITHMICDEPTH: boolean;
  124354. FORCENORMALFORWARD: boolean;
  124355. SPECULARAA: boolean;
  124356. CLEARCOAT: boolean;
  124357. CLEARCOAT_DEFAULTIOR: boolean;
  124358. CLEARCOAT_TEXTURE: boolean;
  124359. CLEARCOAT_TEXTUREDIRECTUV: number;
  124360. CLEARCOAT_BUMP: boolean;
  124361. CLEARCOAT_BUMPDIRECTUV: number;
  124362. CLEARCOAT_TINT: boolean;
  124363. CLEARCOAT_TINT_TEXTURE: boolean;
  124364. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124365. ANISOTROPIC: boolean;
  124366. ANISOTROPIC_TEXTURE: boolean;
  124367. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124368. BRDF_V_HEIGHT_CORRELATED: boolean;
  124369. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124370. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124371. SHEEN: boolean;
  124372. SHEEN_TEXTURE: boolean;
  124373. SHEEN_TEXTUREDIRECTUV: number;
  124374. SHEEN_LINKWITHALBEDO: boolean;
  124375. SUBSURFACE: boolean;
  124376. SS_REFRACTION: boolean;
  124377. SS_TRANSLUCENCY: boolean;
  124378. SS_SCATERRING: boolean;
  124379. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124380. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124381. SS_REFRACTIONMAP_3D: boolean;
  124382. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124383. SS_LODINREFRACTIONALPHA: boolean;
  124384. SS_GAMMAREFRACTION: boolean;
  124385. SS_RGBDREFRACTION: boolean;
  124386. SS_LINEARSPECULARREFRACTION: boolean;
  124387. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124388. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124389. UNLIT: boolean;
  124390. DEBUGMODE: number;
  124391. /**
  124392. * Initializes the PBR Material defines.
  124393. */
  124394. constructor();
  124395. /**
  124396. * Resets the PBR Material defines.
  124397. */
  124398. reset(): void;
  124399. }
  124400. /**
  124401. * The Physically based material base class of BJS.
  124402. *
  124403. * This offers the main features of a standard PBR material.
  124404. * For more information, please refer to the documentation :
  124405. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124406. */
  124407. export abstract class PBRBaseMaterial extends PushMaterial {
  124408. /**
  124409. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124410. */
  124411. static readonly PBRMATERIAL_OPAQUE: number;
  124412. /**
  124413. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124414. */
  124415. static readonly PBRMATERIAL_ALPHATEST: number;
  124416. /**
  124417. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124418. */
  124419. static readonly PBRMATERIAL_ALPHABLEND: number;
  124420. /**
  124421. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124422. * They are also discarded below the alpha cutoff threshold to improve performances.
  124423. */
  124424. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124425. /**
  124426. * Defines the default value of how much AO map is occluding the analytical lights
  124427. * (point spot...).
  124428. */
  124429. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124430. /**
  124431. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124432. */
  124433. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124434. /**
  124435. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124436. * to enhance interoperability with other engines.
  124437. */
  124438. static readonly LIGHTFALLOFF_GLTF: number;
  124439. /**
  124440. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124441. * to enhance interoperability with other materials.
  124442. */
  124443. static readonly LIGHTFALLOFF_STANDARD: number;
  124444. /**
  124445. * Intensity of the direct lights e.g. the four lights available in your scene.
  124446. * This impacts both the direct diffuse and specular highlights.
  124447. */
  124448. protected _directIntensity: number;
  124449. /**
  124450. * Intensity of the emissive part of the material.
  124451. * This helps controlling the emissive effect without modifying the emissive color.
  124452. */
  124453. protected _emissiveIntensity: number;
  124454. /**
  124455. * Intensity of the environment e.g. how much the environment will light the object
  124456. * either through harmonics for rough material or through the refelction for shiny ones.
  124457. */
  124458. protected _environmentIntensity: number;
  124459. /**
  124460. * This is a special control allowing the reduction of the specular highlights coming from the
  124461. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124462. */
  124463. protected _specularIntensity: number;
  124464. /**
  124465. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124466. */
  124467. private _lightingInfos;
  124468. /**
  124469. * Debug Control allowing disabling the bump map on this material.
  124470. */
  124471. protected _disableBumpMap: boolean;
  124472. /**
  124473. * AKA Diffuse Texture in standard nomenclature.
  124474. */
  124475. protected _albedoTexture: Nullable<BaseTexture>;
  124476. /**
  124477. * AKA Occlusion Texture in other nomenclature.
  124478. */
  124479. protected _ambientTexture: Nullable<BaseTexture>;
  124480. /**
  124481. * AKA Occlusion Texture Intensity in other nomenclature.
  124482. */
  124483. protected _ambientTextureStrength: number;
  124484. /**
  124485. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124486. * 1 means it completely occludes it
  124487. * 0 mean it has no impact
  124488. */
  124489. protected _ambientTextureImpactOnAnalyticalLights: number;
  124490. /**
  124491. * Stores the alpha values in a texture.
  124492. */
  124493. protected _opacityTexture: Nullable<BaseTexture>;
  124494. /**
  124495. * Stores the reflection values in a texture.
  124496. */
  124497. protected _reflectionTexture: Nullable<BaseTexture>;
  124498. /**
  124499. * Stores the emissive values in a texture.
  124500. */
  124501. protected _emissiveTexture: Nullable<BaseTexture>;
  124502. /**
  124503. * AKA Specular texture in other nomenclature.
  124504. */
  124505. protected _reflectivityTexture: Nullable<BaseTexture>;
  124506. /**
  124507. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124508. */
  124509. protected _metallicTexture: Nullable<BaseTexture>;
  124510. /**
  124511. * Specifies the metallic scalar of the metallic/roughness workflow.
  124512. * Can also be used to scale the metalness values of the metallic texture.
  124513. */
  124514. protected _metallic: Nullable<number>;
  124515. /**
  124516. * Specifies the roughness scalar of the metallic/roughness workflow.
  124517. * Can also be used to scale the roughness values of the metallic texture.
  124518. */
  124519. protected _roughness: Nullable<number>;
  124520. /**
  124521. * Specifies the an F0 factor to help configuring the material F0.
  124522. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124523. * to 0.5 the previously hard coded value stays the same.
  124524. * Can also be used to scale the F0 values of the metallic texture.
  124525. */
  124526. protected _metallicF0Factor: number;
  124527. /**
  124528. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124529. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124530. * your expectation as it multiplies with the texture data.
  124531. */
  124532. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124533. /**
  124534. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124535. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124536. */
  124537. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124538. /**
  124539. * Stores surface normal data used to displace a mesh in a texture.
  124540. */
  124541. protected _bumpTexture: Nullable<BaseTexture>;
  124542. /**
  124543. * Stores the pre-calculated light information of a mesh in a texture.
  124544. */
  124545. protected _lightmapTexture: Nullable<BaseTexture>;
  124546. /**
  124547. * The color of a material in ambient lighting.
  124548. */
  124549. protected _ambientColor: Color3;
  124550. /**
  124551. * AKA Diffuse Color in other nomenclature.
  124552. */
  124553. protected _albedoColor: Color3;
  124554. /**
  124555. * AKA Specular Color in other nomenclature.
  124556. */
  124557. protected _reflectivityColor: Color3;
  124558. /**
  124559. * The color applied when light is reflected from a material.
  124560. */
  124561. protected _reflectionColor: Color3;
  124562. /**
  124563. * The color applied when light is emitted from a material.
  124564. */
  124565. protected _emissiveColor: Color3;
  124566. /**
  124567. * AKA Glossiness in other nomenclature.
  124568. */
  124569. protected _microSurface: number;
  124570. /**
  124571. * Specifies that the material will use the light map as a show map.
  124572. */
  124573. protected _useLightmapAsShadowmap: boolean;
  124574. /**
  124575. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124576. * makes the reflect vector face the model (under horizon).
  124577. */
  124578. protected _useHorizonOcclusion: boolean;
  124579. /**
  124580. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124581. * too much the area relying on ambient texture to define their ambient occlusion.
  124582. */
  124583. protected _useRadianceOcclusion: boolean;
  124584. /**
  124585. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124586. */
  124587. protected _useAlphaFromAlbedoTexture: boolean;
  124588. /**
  124589. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124590. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124591. */
  124592. protected _useSpecularOverAlpha: boolean;
  124593. /**
  124594. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124595. */
  124596. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124597. /**
  124598. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124599. */
  124600. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124601. /**
  124602. * Specifies if the metallic texture contains the roughness information in its green channel.
  124603. */
  124604. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124605. /**
  124606. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124607. */
  124608. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124609. /**
  124610. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124611. */
  124612. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124613. /**
  124614. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124615. */
  124616. protected _useAmbientInGrayScale: boolean;
  124617. /**
  124618. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124619. * The material will try to infer what glossiness each pixel should be.
  124620. */
  124621. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124622. /**
  124623. * Defines the falloff type used in this material.
  124624. * It by default is Physical.
  124625. */
  124626. protected _lightFalloff: number;
  124627. /**
  124628. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124629. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124630. */
  124631. protected _useRadianceOverAlpha: boolean;
  124632. /**
  124633. * Allows using an object space normal map (instead of tangent space).
  124634. */
  124635. protected _useObjectSpaceNormalMap: boolean;
  124636. /**
  124637. * Allows using the bump map in parallax mode.
  124638. */
  124639. protected _useParallax: boolean;
  124640. /**
  124641. * Allows using the bump map in parallax occlusion mode.
  124642. */
  124643. protected _useParallaxOcclusion: boolean;
  124644. /**
  124645. * Controls the scale bias of the parallax mode.
  124646. */
  124647. protected _parallaxScaleBias: number;
  124648. /**
  124649. * If sets to true, disables all the lights affecting the material.
  124650. */
  124651. protected _disableLighting: boolean;
  124652. /**
  124653. * Number of Simultaneous lights allowed on the material.
  124654. */
  124655. protected _maxSimultaneousLights: number;
  124656. /**
  124657. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124658. */
  124659. protected _invertNormalMapX: boolean;
  124660. /**
  124661. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124662. */
  124663. protected _invertNormalMapY: boolean;
  124664. /**
  124665. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124666. */
  124667. protected _twoSidedLighting: boolean;
  124668. /**
  124669. * Defines the alpha limits in alpha test mode.
  124670. */
  124671. protected _alphaCutOff: number;
  124672. /**
  124673. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124674. */
  124675. protected _forceAlphaTest: boolean;
  124676. /**
  124677. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124678. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124679. */
  124680. protected _useAlphaFresnel: boolean;
  124681. /**
  124682. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124683. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124684. */
  124685. protected _useLinearAlphaFresnel: boolean;
  124686. /**
  124687. * The transparency mode of the material.
  124688. */
  124689. protected _transparencyMode: Nullable<number>;
  124690. /**
  124691. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124692. * from cos thetav and roughness:
  124693. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124694. */
  124695. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124696. /**
  124697. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124698. */
  124699. protected _forceIrradianceInFragment: boolean;
  124700. /**
  124701. * Force normal to face away from face.
  124702. */
  124703. protected _forceNormalForward: boolean;
  124704. /**
  124705. * Enables specular anti aliasing in the PBR shader.
  124706. * It will both interacts on the Geometry for analytical and IBL lighting.
  124707. * It also prefilter the roughness map based on the bump values.
  124708. */
  124709. protected _enableSpecularAntiAliasing: boolean;
  124710. /**
  124711. * Default configuration related to image processing available in the PBR Material.
  124712. */
  124713. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124714. /**
  124715. * Keep track of the image processing observer to allow dispose and replace.
  124716. */
  124717. private _imageProcessingObserver;
  124718. /**
  124719. * Attaches a new image processing configuration to the PBR Material.
  124720. * @param configuration
  124721. */
  124722. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124723. /**
  124724. * Stores the available render targets.
  124725. */
  124726. private _renderTargets;
  124727. /**
  124728. * Sets the global ambient color for the material used in lighting calculations.
  124729. */
  124730. private _globalAmbientColor;
  124731. /**
  124732. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124733. */
  124734. private _useLogarithmicDepth;
  124735. /**
  124736. * If set to true, no lighting calculations will be applied.
  124737. */
  124738. private _unlit;
  124739. private _debugMode;
  124740. /**
  124741. * @hidden
  124742. * This is reserved for the inspector.
  124743. * Defines the material debug mode.
  124744. * It helps seeing only some components of the material while troubleshooting.
  124745. */
  124746. debugMode: number;
  124747. /**
  124748. * @hidden
  124749. * This is reserved for the inspector.
  124750. * Specify from where on screen the debug mode should start.
  124751. * The value goes from -1 (full screen) to 1 (not visible)
  124752. * It helps with side by side comparison against the final render
  124753. * This defaults to -1
  124754. */
  124755. private debugLimit;
  124756. /**
  124757. * @hidden
  124758. * This is reserved for the inspector.
  124759. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124760. * You can use the factor to better multiply the final value.
  124761. */
  124762. private debugFactor;
  124763. /**
  124764. * Defines the clear coat layer parameters for the material.
  124765. */
  124766. readonly clearCoat: PBRClearCoatConfiguration;
  124767. /**
  124768. * Defines the anisotropic parameters for the material.
  124769. */
  124770. readonly anisotropy: PBRAnisotropicConfiguration;
  124771. /**
  124772. * Defines the BRDF parameters for the material.
  124773. */
  124774. readonly brdf: PBRBRDFConfiguration;
  124775. /**
  124776. * Defines the Sheen parameters for the material.
  124777. */
  124778. readonly sheen: PBRSheenConfiguration;
  124779. /**
  124780. * Defines the SubSurface parameters for the material.
  124781. */
  124782. readonly subSurface: PBRSubSurfaceConfiguration;
  124783. /**
  124784. * Custom callback helping to override the default shader used in the material.
  124785. */
  124786. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124787. protected _rebuildInParallel: boolean;
  124788. /**
  124789. * Instantiates a new PBRMaterial instance.
  124790. *
  124791. * @param name The material name
  124792. * @param scene The scene the material will be use in.
  124793. */
  124794. constructor(name: string, scene: Scene);
  124795. /**
  124796. * Gets a boolean indicating that current material needs to register RTT
  124797. */
  124798. get hasRenderTargetTextures(): boolean;
  124799. /**
  124800. * Gets the name of the material class.
  124801. */
  124802. getClassName(): string;
  124803. /**
  124804. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124805. */
  124806. get useLogarithmicDepth(): boolean;
  124807. /**
  124808. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124809. */
  124810. set useLogarithmicDepth(value: boolean);
  124811. /**
  124812. * Gets the current transparency mode.
  124813. */
  124814. get transparencyMode(): Nullable<number>;
  124815. /**
  124816. * Sets the transparency mode of the material.
  124817. *
  124818. * | Value | Type | Description |
  124819. * | ----- | ----------------------------------- | ----------- |
  124820. * | 0 | OPAQUE | |
  124821. * | 1 | ALPHATEST | |
  124822. * | 2 | ALPHABLEND | |
  124823. * | 3 | ALPHATESTANDBLEND | |
  124824. *
  124825. */
  124826. set transparencyMode(value: Nullable<number>);
  124827. /**
  124828. * Returns true if alpha blending should be disabled.
  124829. */
  124830. private get _disableAlphaBlending();
  124831. /**
  124832. * Specifies whether or not this material should be rendered in alpha blend mode.
  124833. */
  124834. needAlphaBlending(): boolean;
  124835. /**
  124836. * Specifies if the mesh will require alpha blending.
  124837. * @param mesh - BJS mesh.
  124838. */
  124839. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124840. /**
  124841. * Specifies whether or not this material should be rendered in alpha test mode.
  124842. */
  124843. needAlphaTesting(): boolean;
  124844. /**
  124845. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124846. */
  124847. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124848. /**
  124849. * Gets the texture used for the alpha test.
  124850. */
  124851. getAlphaTestTexture(): Nullable<BaseTexture>;
  124852. /**
  124853. * Specifies that the submesh is ready to be used.
  124854. * @param mesh - BJS mesh.
  124855. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124856. * @param useInstances - Specifies that instances should be used.
  124857. * @returns - boolean indicating that the submesh is ready or not.
  124858. */
  124859. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124860. /**
  124861. * Specifies if the material uses metallic roughness workflow.
  124862. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124863. */
  124864. isMetallicWorkflow(): boolean;
  124865. private _prepareEffect;
  124866. private _prepareDefines;
  124867. /**
  124868. * Force shader compilation
  124869. */
  124870. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124871. /**
  124872. * Initializes the uniform buffer layout for the shader.
  124873. */
  124874. buildUniformLayout(): void;
  124875. /**
  124876. * Unbinds the material from the mesh
  124877. */
  124878. unbind(): void;
  124879. /**
  124880. * Binds the submesh data.
  124881. * @param world - The world matrix.
  124882. * @param mesh - The BJS mesh.
  124883. * @param subMesh - A submesh of the BJS mesh.
  124884. */
  124885. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124886. /**
  124887. * Returns the animatable textures.
  124888. * @returns - Array of animatable textures.
  124889. */
  124890. getAnimatables(): IAnimatable[];
  124891. /**
  124892. * Returns the texture used for reflections.
  124893. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124894. */
  124895. private _getReflectionTexture;
  124896. /**
  124897. * Returns an array of the actively used textures.
  124898. * @returns - Array of BaseTextures
  124899. */
  124900. getActiveTextures(): BaseTexture[];
  124901. /**
  124902. * Checks to see if a texture is used in the material.
  124903. * @param texture - Base texture to use.
  124904. * @returns - Boolean specifying if a texture is used in the material.
  124905. */
  124906. hasTexture(texture: BaseTexture): boolean;
  124907. /**
  124908. * Disposes the resources of the material.
  124909. * @param forceDisposeEffect - Forces the disposal of effects.
  124910. * @param forceDisposeTextures - Forces the disposal of all textures.
  124911. */
  124912. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124913. }
  124914. }
  124915. declare module BABYLON {
  124916. /**
  124917. * The Physically based material of BJS.
  124918. *
  124919. * This offers the main features of a standard PBR material.
  124920. * For more information, please refer to the documentation :
  124921. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124922. */
  124923. export class PBRMaterial extends PBRBaseMaterial {
  124924. /**
  124925. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124926. */
  124927. static readonly PBRMATERIAL_OPAQUE: number;
  124928. /**
  124929. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124930. */
  124931. static readonly PBRMATERIAL_ALPHATEST: number;
  124932. /**
  124933. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124934. */
  124935. static readonly PBRMATERIAL_ALPHABLEND: number;
  124936. /**
  124937. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124938. * They are also discarded below the alpha cutoff threshold to improve performances.
  124939. */
  124940. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124941. /**
  124942. * Defines the default value of how much AO map is occluding the analytical lights
  124943. * (point spot...).
  124944. */
  124945. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124946. /**
  124947. * Intensity of the direct lights e.g. the four lights available in your scene.
  124948. * This impacts both the direct diffuse and specular highlights.
  124949. */
  124950. directIntensity: number;
  124951. /**
  124952. * Intensity of the emissive part of the material.
  124953. * This helps controlling the emissive effect without modifying the emissive color.
  124954. */
  124955. emissiveIntensity: number;
  124956. /**
  124957. * Intensity of the environment e.g. how much the environment will light the object
  124958. * either through harmonics for rough material or through the refelction for shiny ones.
  124959. */
  124960. environmentIntensity: number;
  124961. /**
  124962. * This is a special control allowing the reduction of the specular highlights coming from the
  124963. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124964. */
  124965. specularIntensity: number;
  124966. /**
  124967. * Debug Control allowing disabling the bump map on this material.
  124968. */
  124969. disableBumpMap: boolean;
  124970. /**
  124971. * AKA Diffuse Texture in standard nomenclature.
  124972. */
  124973. albedoTexture: BaseTexture;
  124974. /**
  124975. * AKA Occlusion Texture in other nomenclature.
  124976. */
  124977. ambientTexture: BaseTexture;
  124978. /**
  124979. * AKA Occlusion Texture Intensity in other nomenclature.
  124980. */
  124981. ambientTextureStrength: number;
  124982. /**
  124983. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124984. * 1 means it completely occludes it
  124985. * 0 mean it has no impact
  124986. */
  124987. ambientTextureImpactOnAnalyticalLights: number;
  124988. /**
  124989. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124990. */
  124991. opacityTexture: BaseTexture;
  124992. /**
  124993. * Stores the reflection values in a texture.
  124994. */
  124995. reflectionTexture: Nullable<BaseTexture>;
  124996. /**
  124997. * Stores the emissive values in a texture.
  124998. */
  124999. emissiveTexture: BaseTexture;
  125000. /**
  125001. * AKA Specular texture in other nomenclature.
  125002. */
  125003. reflectivityTexture: BaseTexture;
  125004. /**
  125005. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125006. */
  125007. metallicTexture: BaseTexture;
  125008. /**
  125009. * Specifies the metallic scalar of the metallic/roughness workflow.
  125010. * Can also be used to scale the metalness values of the metallic texture.
  125011. */
  125012. metallic: Nullable<number>;
  125013. /**
  125014. * Specifies the roughness scalar of the metallic/roughness workflow.
  125015. * Can also be used to scale the roughness values of the metallic texture.
  125016. */
  125017. roughness: Nullable<number>;
  125018. /**
  125019. * Specifies the an F0 factor to help configuring the material F0.
  125020. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125021. * to 0.5 the previously hard coded value stays the same.
  125022. * Can also be used to scale the F0 values of the metallic texture.
  125023. */
  125024. metallicF0Factor: number;
  125025. /**
  125026. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125027. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125028. * your expectation as it multiplies with the texture data.
  125029. */
  125030. useMetallicF0FactorFromMetallicTexture: boolean;
  125031. /**
  125032. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125033. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125034. */
  125035. microSurfaceTexture: BaseTexture;
  125036. /**
  125037. * Stores surface normal data used to displace a mesh in a texture.
  125038. */
  125039. bumpTexture: BaseTexture;
  125040. /**
  125041. * Stores the pre-calculated light information of a mesh in a texture.
  125042. */
  125043. lightmapTexture: BaseTexture;
  125044. /**
  125045. * Stores the refracted light information in a texture.
  125046. */
  125047. get refractionTexture(): Nullable<BaseTexture>;
  125048. set refractionTexture(value: Nullable<BaseTexture>);
  125049. /**
  125050. * The color of a material in ambient lighting.
  125051. */
  125052. ambientColor: Color3;
  125053. /**
  125054. * AKA Diffuse Color in other nomenclature.
  125055. */
  125056. albedoColor: Color3;
  125057. /**
  125058. * AKA Specular Color in other nomenclature.
  125059. */
  125060. reflectivityColor: Color3;
  125061. /**
  125062. * The color reflected from the material.
  125063. */
  125064. reflectionColor: Color3;
  125065. /**
  125066. * The color emitted from the material.
  125067. */
  125068. emissiveColor: Color3;
  125069. /**
  125070. * AKA Glossiness in other nomenclature.
  125071. */
  125072. microSurface: number;
  125073. /**
  125074. * source material index of refraction (IOR)' / 'destination material IOR.
  125075. */
  125076. get indexOfRefraction(): number;
  125077. set indexOfRefraction(value: number);
  125078. /**
  125079. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125080. */
  125081. get invertRefractionY(): boolean;
  125082. set invertRefractionY(value: boolean);
  125083. /**
  125084. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125085. * Materials half opaque for instance using refraction could benefit from this control.
  125086. */
  125087. get linkRefractionWithTransparency(): boolean;
  125088. set linkRefractionWithTransparency(value: boolean);
  125089. /**
  125090. * If true, the light map contains occlusion information instead of lighting info.
  125091. */
  125092. useLightmapAsShadowmap: boolean;
  125093. /**
  125094. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125095. */
  125096. useAlphaFromAlbedoTexture: boolean;
  125097. /**
  125098. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125099. */
  125100. forceAlphaTest: boolean;
  125101. /**
  125102. * Defines the alpha limits in alpha test mode.
  125103. */
  125104. alphaCutOff: number;
  125105. /**
  125106. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  125107. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125108. */
  125109. useSpecularOverAlpha: boolean;
  125110. /**
  125111. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125112. */
  125113. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125114. /**
  125115. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125116. */
  125117. useRoughnessFromMetallicTextureAlpha: boolean;
  125118. /**
  125119. * Specifies if the metallic texture contains the roughness information in its green channel.
  125120. */
  125121. useRoughnessFromMetallicTextureGreen: boolean;
  125122. /**
  125123. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125124. */
  125125. useMetallnessFromMetallicTextureBlue: boolean;
  125126. /**
  125127. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125128. */
  125129. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125130. /**
  125131. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125132. */
  125133. useAmbientInGrayScale: boolean;
  125134. /**
  125135. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125136. * The material will try to infer what glossiness each pixel should be.
  125137. */
  125138. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125139. /**
  125140. * BJS is using an harcoded light falloff based on a manually sets up range.
  125141. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125142. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125143. */
  125144. get usePhysicalLightFalloff(): boolean;
  125145. /**
  125146. * BJS is using an harcoded light falloff based on a manually sets up range.
  125147. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125148. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125149. */
  125150. set usePhysicalLightFalloff(value: boolean);
  125151. /**
  125152. * In order to support the falloff compatibility with gltf, a special mode has been added
  125153. * to reproduce the gltf light falloff.
  125154. */
  125155. get useGLTFLightFalloff(): boolean;
  125156. /**
  125157. * In order to support the falloff compatibility with gltf, a special mode has been added
  125158. * to reproduce the gltf light falloff.
  125159. */
  125160. set useGLTFLightFalloff(value: boolean);
  125161. /**
  125162. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125163. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125164. */
  125165. useRadianceOverAlpha: boolean;
  125166. /**
  125167. * Allows using an object space normal map (instead of tangent space).
  125168. */
  125169. useObjectSpaceNormalMap: boolean;
  125170. /**
  125171. * Allows using the bump map in parallax mode.
  125172. */
  125173. useParallax: boolean;
  125174. /**
  125175. * Allows using the bump map in parallax occlusion mode.
  125176. */
  125177. useParallaxOcclusion: boolean;
  125178. /**
  125179. * Controls the scale bias of the parallax mode.
  125180. */
  125181. parallaxScaleBias: number;
  125182. /**
  125183. * If sets to true, disables all the lights affecting the material.
  125184. */
  125185. disableLighting: boolean;
  125186. /**
  125187. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125188. */
  125189. forceIrradianceInFragment: boolean;
  125190. /**
  125191. * Number of Simultaneous lights allowed on the material.
  125192. */
  125193. maxSimultaneousLights: number;
  125194. /**
  125195. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125196. */
  125197. invertNormalMapX: boolean;
  125198. /**
  125199. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125200. */
  125201. invertNormalMapY: boolean;
  125202. /**
  125203. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125204. */
  125205. twoSidedLighting: boolean;
  125206. /**
  125207. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125208. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125209. */
  125210. useAlphaFresnel: boolean;
  125211. /**
  125212. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125213. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125214. */
  125215. useLinearAlphaFresnel: boolean;
  125216. /**
  125217. * Let user defines the brdf lookup texture used for IBL.
  125218. * A default 8bit version is embedded but you could point at :
  125219. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125220. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125221. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125222. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125223. */
  125224. environmentBRDFTexture: Nullable<BaseTexture>;
  125225. /**
  125226. * Force normal to face away from face.
  125227. */
  125228. forceNormalForward: boolean;
  125229. /**
  125230. * Enables specular anti aliasing in the PBR shader.
  125231. * It will both interacts on the Geometry for analytical and IBL lighting.
  125232. * It also prefilter the roughness map based on the bump values.
  125233. */
  125234. enableSpecularAntiAliasing: boolean;
  125235. /**
  125236. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125237. * makes the reflect vector face the model (under horizon).
  125238. */
  125239. useHorizonOcclusion: boolean;
  125240. /**
  125241. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125242. * too much the area relying on ambient texture to define their ambient occlusion.
  125243. */
  125244. useRadianceOcclusion: boolean;
  125245. /**
  125246. * If set to true, no lighting calculations will be applied.
  125247. */
  125248. unlit: boolean;
  125249. /**
  125250. * Gets the image processing configuration used either in this material.
  125251. */
  125252. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125253. /**
  125254. * Sets the Default image processing configuration used either in the this material.
  125255. *
  125256. * If sets to null, the scene one is in use.
  125257. */
  125258. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125259. /**
  125260. * Gets wether the color curves effect is enabled.
  125261. */
  125262. get cameraColorCurvesEnabled(): boolean;
  125263. /**
  125264. * Sets wether the color curves effect is enabled.
  125265. */
  125266. set cameraColorCurvesEnabled(value: boolean);
  125267. /**
  125268. * Gets wether the color grading effect is enabled.
  125269. */
  125270. get cameraColorGradingEnabled(): boolean;
  125271. /**
  125272. * Gets wether the color grading effect is enabled.
  125273. */
  125274. set cameraColorGradingEnabled(value: boolean);
  125275. /**
  125276. * Gets wether tonemapping is enabled or not.
  125277. */
  125278. get cameraToneMappingEnabled(): boolean;
  125279. /**
  125280. * Sets wether tonemapping is enabled or not
  125281. */
  125282. set cameraToneMappingEnabled(value: boolean);
  125283. /**
  125284. * The camera exposure used on this material.
  125285. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125286. * This corresponds to a photographic exposure.
  125287. */
  125288. get cameraExposure(): number;
  125289. /**
  125290. * The camera exposure used on this material.
  125291. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125292. * This corresponds to a photographic exposure.
  125293. */
  125294. set cameraExposure(value: number);
  125295. /**
  125296. * Gets The camera contrast used on this material.
  125297. */
  125298. get cameraContrast(): number;
  125299. /**
  125300. * Sets The camera contrast used on this material.
  125301. */
  125302. set cameraContrast(value: number);
  125303. /**
  125304. * Gets the Color Grading 2D Lookup Texture.
  125305. */
  125306. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125307. /**
  125308. * Sets the Color Grading 2D Lookup Texture.
  125309. */
  125310. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125311. /**
  125312. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125313. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125314. * 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;
  125315. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125316. */
  125317. get cameraColorCurves(): Nullable<ColorCurves>;
  125318. /**
  125319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125321. * 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;
  125322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125323. */
  125324. set cameraColorCurves(value: Nullable<ColorCurves>);
  125325. /**
  125326. * Instantiates a new PBRMaterial instance.
  125327. *
  125328. * @param name The material name
  125329. * @param scene The scene the material will be use in.
  125330. */
  125331. constructor(name: string, scene: Scene);
  125332. /**
  125333. * Returns the name of this material class.
  125334. */
  125335. getClassName(): string;
  125336. /**
  125337. * Makes a duplicate of the current material.
  125338. * @param name - name to use for the new material.
  125339. */
  125340. clone(name: string): PBRMaterial;
  125341. /**
  125342. * Serializes this PBR Material.
  125343. * @returns - An object with the serialized material.
  125344. */
  125345. serialize(): any;
  125346. /**
  125347. * Parses a PBR Material from a serialized object.
  125348. * @param source - Serialized object.
  125349. * @param scene - BJS scene instance.
  125350. * @param rootUrl - url for the scene object
  125351. * @returns - PBRMaterial
  125352. */
  125353. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125354. }
  125355. }
  125356. declare module BABYLON {
  125357. /**
  125358. * Direct draw surface info
  125359. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125360. */
  125361. export interface DDSInfo {
  125362. /**
  125363. * Width of the texture
  125364. */
  125365. width: number;
  125366. /**
  125367. * Width of the texture
  125368. */
  125369. height: number;
  125370. /**
  125371. * Number of Mipmaps for the texture
  125372. * @see https://en.wikipedia.org/wiki/Mipmap
  125373. */
  125374. mipmapCount: number;
  125375. /**
  125376. * If the textures format is a known fourCC format
  125377. * @see https://www.fourcc.org/
  125378. */
  125379. isFourCC: boolean;
  125380. /**
  125381. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125382. */
  125383. isRGB: boolean;
  125384. /**
  125385. * If the texture is a lumincance format
  125386. */
  125387. isLuminance: boolean;
  125388. /**
  125389. * If this is a cube texture
  125390. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125391. */
  125392. isCube: boolean;
  125393. /**
  125394. * If the texture is a compressed format eg. FOURCC_DXT1
  125395. */
  125396. isCompressed: boolean;
  125397. /**
  125398. * The dxgiFormat of the texture
  125399. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125400. */
  125401. dxgiFormat: number;
  125402. /**
  125403. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125404. */
  125405. textureType: number;
  125406. /**
  125407. * Sphericle polynomial created for the dds texture
  125408. */
  125409. sphericalPolynomial?: SphericalPolynomial;
  125410. }
  125411. /**
  125412. * Class used to provide DDS decompression tools
  125413. */
  125414. export class DDSTools {
  125415. /**
  125416. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125417. */
  125418. static StoreLODInAlphaChannel: boolean;
  125419. /**
  125420. * Gets DDS information from an array buffer
  125421. * @param data defines the array buffer view to read data from
  125422. * @returns the DDS information
  125423. */
  125424. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125425. private static _FloatView;
  125426. private static _Int32View;
  125427. private static _ToHalfFloat;
  125428. private static _FromHalfFloat;
  125429. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125430. private static _GetHalfFloatRGBAArrayBuffer;
  125431. private static _GetFloatRGBAArrayBuffer;
  125432. private static _GetFloatAsUIntRGBAArrayBuffer;
  125433. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125434. private static _GetRGBAArrayBuffer;
  125435. private static _ExtractLongWordOrder;
  125436. private static _GetRGBArrayBuffer;
  125437. private static _GetLuminanceArrayBuffer;
  125438. /**
  125439. * Uploads DDS Levels to a Babylon Texture
  125440. * @hidden
  125441. */
  125442. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125443. }
  125444. interface ThinEngine {
  125445. /**
  125446. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125447. * @param rootUrl defines the url where the file to load is located
  125448. * @param scene defines the current scene
  125449. * @param lodScale defines scale to apply to the mip map selection
  125450. * @param lodOffset defines offset to apply to the mip map selection
  125451. * @param onLoad defines an optional callback raised when the texture is loaded
  125452. * @param onError defines an optional callback raised if there is an issue to load the texture
  125453. * @param format defines the format of the data
  125454. * @param forcedExtension defines the extension to use to pick the right loader
  125455. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125456. * @returns the cube texture as an InternalTexture
  125457. */
  125458. 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;
  125459. }
  125460. }
  125461. declare module BABYLON {
  125462. /**
  125463. * Implementation of the DDS Texture Loader.
  125464. * @hidden
  125465. */
  125466. export class _DDSTextureLoader implements IInternalTextureLoader {
  125467. /**
  125468. * Defines wether the loader supports cascade loading the different faces.
  125469. */
  125470. readonly supportCascades: boolean;
  125471. /**
  125472. * This returns if the loader support the current file information.
  125473. * @param extension defines the file extension of the file being loaded
  125474. * @returns true if the loader can load the specified file
  125475. */
  125476. canLoad(extension: string): boolean;
  125477. /**
  125478. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125479. * @param data contains the texture data
  125480. * @param texture defines the BabylonJS internal texture
  125481. * @param createPolynomials will be true if polynomials have been requested
  125482. * @param onLoad defines the callback to trigger once the texture is ready
  125483. * @param onError defines the callback to trigger in case of error
  125484. */
  125485. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125486. /**
  125487. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125488. * @param data contains the texture data
  125489. * @param texture defines the BabylonJS internal texture
  125490. * @param callback defines the method to call once ready to upload
  125491. */
  125492. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125493. }
  125494. }
  125495. declare module BABYLON {
  125496. /**
  125497. * Implementation of the ENV Texture Loader.
  125498. * @hidden
  125499. */
  125500. export class _ENVTextureLoader implements IInternalTextureLoader {
  125501. /**
  125502. * Defines wether the loader supports cascade loading the different faces.
  125503. */
  125504. readonly supportCascades: boolean;
  125505. /**
  125506. * This returns if the loader support the current file information.
  125507. * @param extension defines the file extension of the file being loaded
  125508. * @returns true if the loader can load the specified file
  125509. */
  125510. canLoad(extension: string): boolean;
  125511. /**
  125512. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125513. * @param data contains the texture data
  125514. * @param texture defines the BabylonJS internal texture
  125515. * @param createPolynomials will be true if polynomials have been requested
  125516. * @param onLoad defines the callback to trigger once the texture is ready
  125517. * @param onError defines the callback to trigger in case of error
  125518. */
  125519. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125520. /**
  125521. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125522. * @param data contains the texture data
  125523. * @param texture defines the BabylonJS internal texture
  125524. * @param callback defines the method to call once ready to upload
  125525. */
  125526. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125527. }
  125528. }
  125529. declare module BABYLON {
  125530. /**
  125531. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125532. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125533. */
  125534. export class KhronosTextureContainer {
  125535. /** contents of the KTX container file */
  125536. data: ArrayBufferView;
  125537. private static HEADER_LEN;
  125538. private static COMPRESSED_2D;
  125539. private static COMPRESSED_3D;
  125540. private static TEX_2D;
  125541. private static TEX_3D;
  125542. /**
  125543. * Gets the openGL type
  125544. */
  125545. glType: number;
  125546. /**
  125547. * Gets the openGL type size
  125548. */
  125549. glTypeSize: number;
  125550. /**
  125551. * Gets the openGL format
  125552. */
  125553. glFormat: number;
  125554. /**
  125555. * Gets the openGL internal format
  125556. */
  125557. glInternalFormat: number;
  125558. /**
  125559. * Gets the base internal format
  125560. */
  125561. glBaseInternalFormat: number;
  125562. /**
  125563. * Gets image width in pixel
  125564. */
  125565. pixelWidth: number;
  125566. /**
  125567. * Gets image height in pixel
  125568. */
  125569. pixelHeight: number;
  125570. /**
  125571. * Gets image depth in pixels
  125572. */
  125573. pixelDepth: number;
  125574. /**
  125575. * Gets the number of array elements
  125576. */
  125577. numberOfArrayElements: number;
  125578. /**
  125579. * Gets the number of faces
  125580. */
  125581. numberOfFaces: number;
  125582. /**
  125583. * Gets the number of mipmap levels
  125584. */
  125585. numberOfMipmapLevels: number;
  125586. /**
  125587. * Gets the bytes of key value data
  125588. */
  125589. bytesOfKeyValueData: number;
  125590. /**
  125591. * Gets the load type
  125592. */
  125593. loadType: number;
  125594. /**
  125595. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125596. */
  125597. isInvalid: boolean;
  125598. /**
  125599. * Creates a new KhronosTextureContainer
  125600. * @param data contents of the KTX container file
  125601. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125602. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125603. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125604. */
  125605. constructor(
  125606. /** contents of the KTX container file */
  125607. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125608. /**
  125609. * Uploads KTX content to a Babylon Texture.
  125610. * It is assumed that the texture has already been created & is currently bound
  125611. * @hidden
  125612. */
  125613. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125614. private _upload2DCompressedLevels;
  125615. /**
  125616. * Checks if the given data starts with a KTX file identifier.
  125617. * @param data the data to check
  125618. * @returns true if the data is a KTX file or false otherwise
  125619. */
  125620. static IsValid(data: ArrayBufferView): boolean;
  125621. }
  125622. }
  125623. declare module BABYLON {
  125624. /**
  125625. * Class for loading KTX2 files
  125626. * !!! Experimental Extension Subject to Changes !!!
  125627. * @hidden
  125628. */
  125629. export class KhronosTextureContainer2 {
  125630. private static _ModulePromise;
  125631. private static _TranscodeFormat;
  125632. constructor(engine: ThinEngine);
  125633. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125634. private _determineTranscodeFormat;
  125635. /**
  125636. * Checks if the given data starts with a KTX2 file identifier.
  125637. * @param data the data to check
  125638. * @returns true if the data is a KTX2 file or false otherwise
  125639. */
  125640. static IsValid(data: ArrayBufferView): boolean;
  125641. }
  125642. }
  125643. declare module BABYLON {
  125644. /**
  125645. * Implementation of the KTX Texture Loader.
  125646. * @hidden
  125647. */
  125648. export class _KTXTextureLoader implements IInternalTextureLoader {
  125649. /**
  125650. * Defines wether the loader supports cascade loading the different faces.
  125651. */
  125652. readonly supportCascades: boolean;
  125653. /**
  125654. * This returns if the loader support the current file information.
  125655. * @param extension defines the file extension of the file being loaded
  125656. * @returns true if the loader can load the specified file
  125657. */
  125658. canLoad(extension: string): boolean;
  125659. /**
  125660. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125661. * @param data contains the texture data
  125662. * @param texture defines the BabylonJS internal texture
  125663. * @param createPolynomials will be true if polynomials have been requested
  125664. * @param onLoad defines the callback to trigger once the texture is ready
  125665. * @param onError defines the callback to trigger in case of error
  125666. */
  125667. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125668. /**
  125669. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125670. * @param data contains the texture data
  125671. * @param texture defines the BabylonJS internal texture
  125672. * @param callback defines the method to call once ready to upload
  125673. */
  125674. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125675. }
  125676. }
  125677. declare module BABYLON {
  125678. /** @hidden */
  125679. export var _forceSceneHelpersToBundle: boolean;
  125680. interface Scene {
  125681. /**
  125682. * Creates a default light for the scene.
  125683. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125684. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125685. */
  125686. createDefaultLight(replace?: boolean): void;
  125687. /**
  125688. * Creates a default camera for the scene.
  125689. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125690. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125691. * @param replace has default false, when true replaces the active camera in the scene
  125692. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125693. */
  125694. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125695. /**
  125696. * Creates a default camera and a default light.
  125697. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125698. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125699. * @param replace has the default false, when true replaces the active camera/light in the scene
  125700. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125701. */
  125702. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125703. /**
  125704. * Creates a new sky box
  125705. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125706. * @param environmentTexture defines the texture to use as environment texture
  125707. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125708. * @param scale defines the overall scale of the skybox
  125709. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125710. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125711. * @returns a new mesh holding the sky box
  125712. */
  125713. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125714. /**
  125715. * Creates a new environment
  125716. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125717. * @param options defines the options you can use to configure the environment
  125718. * @returns the new EnvironmentHelper
  125719. */
  125720. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125721. /**
  125722. * Creates a new VREXperienceHelper
  125723. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125724. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125725. * @returns a new VREXperienceHelper
  125726. */
  125727. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125728. /**
  125729. * Creates a new WebXRDefaultExperience
  125730. * @see http://doc.babylonjs.com/how_to/webxr
  125731. * @param options experience options
  125732. * @returns a promise for a new WebXRDefaultExperience
  125733. */
  125734. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125735. }
  125736. }
  125737. declare module BABYLON {
  125738. /**
  125739. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125740. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125741. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125742. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125743. */
  125744. export class VideoDome extends TransformNode {
  125745. /**
  125746. * Define the video source as a Monoscopic panoramic 360 video.
  125747. */
  125748. static readonly MODE_MONOSCOPIC: number;
  125749. /**
  125750. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125751. */
  125752. static readonly MODE_TOPBOTTOM: number;
  125753. /**
  125754. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125755. */
  125756. static readonly MODE_SIDEBYSIDE: number;
  125757. private _halfDome;
  125758. private _useDirectMapping;
  125759. /**
  125760. * The video texture being displayed on the sphere
  125761. */
  125762. protected _videoTexture: VideoTexture;
  125763. /**
  125764. * Gets the video texture being displayed on the sphere
  125765. */
  125766. get videoTexture(): VideoTexture;
  125767. /**
  125768. * The skybox material
  125769. */
  125770. protected _material: BackgroundMaterial;
  125771. /**
  125772. * The surface used for the skybox
  125773. */
  125774. protected _mesh: Mesh;
  125775. /**
  125776. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125777. */
  125778. private _halfDomeMask;
  125779. /**
  125780. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125781. * Also see the options.resolution property.
  125782. */
  125783. get fovMultiplier(): number;
  125784. set fovMultiplier(value: number);
  125785. private _videoMode;
  125786. /**
  125787. * Gets or set the current video mode for the video. It can be:
  125788. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125789. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125790. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125791. */
  125792. get videoMode(): number;
  125793. set videoMode(value: number);
  125794. /**
  125795. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125796. *
  125797. */
  125798. get halfDome(): boolean;
  125799. /**
  125800. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125801. */
  125802. set halfDome(enabled: boolean);
  125803. /**
  125804. * Oberserver used in Stereoscopic VR Mode.
  125805. */
  125806. private _onBeforeCameraRenderObserver;
  125807. /**
  125808. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125809. * @param name Element's name, child elements will append suffixes for their own names.
  125810. * @param urlsOrVideo defines the url(s) or the video element to use
  125811. * @param options An object containing optional or exposed sub element properties
  125812. */
  125813. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125814. resolution?: number;
  125815. clickToPlay?: boolean;
  125816. autoPlay?: boolean;
  125817. loop?: boolean;
  125818. size?: number;
  125819. poster?: string;
  125820. faceForward?: boolean;
  125821. useDirectMapping?: boolean;
  125822. halfDomeMode?: boolean;
  125823. }, scene: Scene);
  125824. private _changeVideoMode;
  125825. /**
  125826. * Releases resources associated with this node.
  125827. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125828. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125829. */
  125830. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125831. }
  125832. }
  125833. declare module BABYLON {
  125834. /**
  125835. * This class can be used to get instrumentation data from a Babylon engine
  125836. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125837. */
  125838. export class EngineInstrumentation implements IDisposable {
  125839. /**
  125840. * Define the instrumented engine.
  125841. */
  125842. engine: Engine;
  125843. private _captureGPUFrameTime;
  125844. private _gpuFrameTimeToken;
  125845. private _gpuFrameTime;
  125846. private _captureShaderCompilationTime;
  125847. private _shaderCompilationTime;
  125848. private _onBeginFrameObserver;
  125849. private _onEndFrameObserver;
  125850. private _onBeforeShaderCompilationObserver;
  125851. private _onAfterShaderCompilationObserver;
  125852. /**
  125853. * Gets the perf counter used for GPU frame time
  125854. */
  125855. get gpuFrameTimeCounter(): PerfCounter;
  125856. /**
  125857. * Gets the GPU frame time capture status
  125858. */
  125859. get captureGPUFrameTime(): boolean;
  125860. /**
  125861. * Enable or disable the GPU frame time capture
  125862. */
  125863. set captureGPUFrameTime(value: boolean);
  125864. /**
  125865. * Gets the perf counter used for shader compilation time
  125866. */
  125867. get shaderCompilationTimeCounter(): PerfCounter;
  125868. /**
  125869. * Gets the shader compilation time capture status
  125870. */
  125871. get captureShaderCompilationTime(): boolean;
  125872. /**
  125873. * Enable or disable the shader compilation time capture
  125874. */
  125875. set captureShaderCompilationTime(value: boolean);
  125876. /**
  125877. * Instantiates a new engine instrumentation.
  125878. * This class can be used to get instrumentation data from a Babylon engine
  125879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125880. * @param engine Defines the engine to instrument
  125881. */
  125882. constructor(
  125883. /**
  125884. * Define the instrumented engine.
  125885. */
  125886. engine: Engine);
  125887. /**
  125888. * Dispose and release associated resources.
  125889. */
  125890. dispose(): void;
  125891. }
  125892. }
  125893. declare module BABYLON {
  125894. /**
  125895. * This class can be used to get instrumentation data from a Babylon engine
  125896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125897. */
  125898. export class SceneInstrumentation implements IDisposable {
  125899. /**
  125900. * Defines the scene to instrument
  125901. */
  125902. scene: Scene;
  125903. private _captureActiveMeshesEvaluationTime;
  125904. private _activeMeshesEvaluationTime;
  125905. private _captureRenderTargetsRenderTime;
  125906. private _renderTargetsRenderTime;
  125907. private _captureFrameTime;
  125908. private _frameTime;
  125909. private _captureRenderTime;
  125910. private _renderTime;
  125911. private _captureInterFrameTime;
  125912. private _interFrameTime;
  125913. private _captureParticlesRenderTime;
  125914. private _particlesRenderTime;
  125915. private _captureSpritesRenderTime;
  125916. private _spritesRenderTime;
  125917. private _capturePhysicsTime;
  125918. private _physicsTime;
  125919. private _captureAnimationsTime;
  125920. private _animationsTime;
  125921. private _captureCameraRenderTime;
  125922. private _cameraRenderTime;
  125923. private _onBeforeActiveMeshesEvaluationObserver;
  125924. private _onAfterActiveMeshesEvaluationObserver;
  125925. private _onBeforeRenderTargetsRenderObserver;
  125926. private _onAfterRenderTargetsRenderObserver;
  125927. private _onAfterRenderObserver;
  125928. private _onBeforeDrawPhaseObserver;
  125929. private _onAfterDrawPhaseObserver;
  125930. private _onBeforeAnimationsObserver;
  125931. private _onBeforeParticlesRenderingObserver;
  125932. private _onAfterParticlesRenderingObserver;
  125933. private _onBeforeSpritesRenderingObserver;
  125934. private _onAfterSpritesRenderingObserver;
  125935. private _onBeforePhysicsObserver;
  125936. private _onAfterPhysicsObserver;
  125937. private _onAfterAnimationsObserver;
  125938. private _onBeforeCameraRenderObserver;
  125939. private _onAfterCameraRenderObserver;
  125940. /**
  125941. * Gets the perf counter used for active meshes evaluation time
  125942. */
  125943. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125944. /**
  125945. * Gets the active meshes evaluation time capture status
  125946. */
  125947. get captureActiveMeshesEvaluationTime(): boolean;
  125948. /**
  125949. * Enable or disable the active meshes evaluation time capture
  125950. */
  125951. set captureActiveMeshesEvaluationTime(value: boolean);
  125952. /**
  125953. * Gets the perf counter used for render targets render time
  125954. */
  125955. get renderTargetsRenderTimeCounter(): PerfCounter;
  125956. /**
  125957. * Gets the render targets render time capture status
  125958. */
  125959. get captureRenderTargetsRenderTime(): boolean;
  125960. /**
  125961. * Enable or disable the render targets render time capture
  125962. */
  125963. set captureRenderTargetsRenderTime(value: boolean);
  125964. /**
  125965. * Gets the perf counter used for particles render time
  125966. */
  125967. get particlesRenderTimeCounter(): PerfCounter;
  125968. /**
  125969. * Gets the particles render time capture status
  125970. */
  125971. get captureParticlesRenderTime(): boolean;
  125972. /**
  125973. * Enable or disable the particles render time capture
  125974. */
  125975. set captureParticlesRenderTime(value: boolean);
  125976. /**
  125977. * Gets the perf counter used for sprites render time
  125978. */
  125979. get spritesRenderTimeCounter(): PerfCounter;
  125980. /**
  125981. * Gets the sprites render time capture status
  125982. */
  125983. get captureSpritesRenderTime(): boolean;
  125984. /**
  125985. * Enable or disable the sprites render time capture
  125986. */
  125987. set captureSpritesRenderTime(value: boolean);
  125988. /**
  125989. * Gets the perf counter used for physics time
  125990. */
  125991. get physicsTimeCounter(): PerfCounter;
  125992. /**
  125993. * Gets the physics time capture status
  125994. */
  125995. get capturePhysicsTime(): boolean;
  125996. /**
  125997. * Enable or disable the physics time capture
  125998. */
  125999. set capturePhysicsTime(value: boolean);
  126000. /**
  126001. * Gets the perf counter used for animations time
  126002. */
  126003. get animationsTimeCounter(): PerfCounter;
  126004. /**
  126005. * Gets the animations time capture status
  126006. */
  126007. get captureAnimationsTime(): boolean;
  126008. /**
  126009. * Enable or disable the animations time capture
  126010. */
  126011. set captureAnimationsTime(value: boolean);
  126012. /**
  126013. * Gets the perf counter used for frame time capture
  126014. */
  126015. get frameTimeCounter(): PerfCounter;
  126016. /**
  126017. * Gets the frame time capture status
  126018. */
  126019. get captureFrameTime(): boolean;
  126020. /**
  126021. * Enable or disable the frame time capture
  126022. */
  126023. set captureFrameTime(value: boolean);
  126024. /**
  126025. * Gets the perf counter used for inter-frames time capture
  126026. */
  126027. get interFrameTimeCounter(): PerfCounter;
  126028. /**
  126029. * Gets the inter-frames time capture status
  126030. */
  126031. get captureInterFrameTime(): boolean;
  126032. /**
  126033. * Enable or disable the inter-frames time capture
  126034. */
  126035. set captureInterFrameTime(value: boolean);
  126036. /**
  126037. * Gets the perf counter used for render time capture
  126038. */
  126039. get renderTimeCounter(): PerfCounter;
  126040. /**
  126041. * Gets the render time capture status
  126042. */
  126043. get captureRenderTime(): boolean;
  126044. /**
  126045. * Enable or disable the render time capture
  126046. */
  126047. set captureRenderTime(value: boolean);
  126048. /**
  126049. * Gets the perf counter used for camera render time capture
  126050. */
  126051. get cameraRenderTimeCounter(): PerfCounter;
  126052. /**
  126053. * Gets the camera render time capture status
  126054. */
  126055. get captureCameraRenderTime(): boolean;
  126056. /**
  126057. * Enable or disable the camera render time capture
  126058. */
  126059. set captureCameraRenderTime(value: boolean);
  126060. /**
  126061. * Gets the perf counter used for draw calls
  126062. */
  126063. get drawCallsCounter(): PerfCounter;
  126064. /**
  126065. * Instantiates a new scene instrumentation.
  126066. * This class can be used to get instrumentation data from a Babylon engine
  126067. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126068. * @param scene Defines the scene to instrument
  126069. */
  126070. constructor(
  126071. /**
  126072. * Defines the scene to instrument
  126073. */
  126074. scene: Scene);
  126075. /**
  126076. * Dispose and release associated resources.
  126077. */
  126078. dispose(): void;
  126079. }
  126080. }
  126081. declare module BABYLON {
  126082. /** @hidden */
  126083. export var glowMapGenerationPixelShader: {
  126084. name: string;
  126085. shader: string;
  126086. };
  126087. }
  126088. declare module BABYLON {
  126089. /** @hidden */
  126090. export var glowMapGenerationVertexShader: {
  126091. name: string;
  126092. shader: string;
  126093. };
  126094. }
  126095. declare module BABYLON {
  126096. /**
  126097. * Effect layer options. This helps customizing the behaviour
  126098. * of the effect layer.
  126099. */
  126100. export interface IEffectLayerOptions {
  126101. /**
  126102. * Multiplication factor apply to the canvas size to compute the render target size
  126103. * used to generated the objects (the smaller the faster).
  126104. */
  126105. mainTextureRatio: number;
  126106. /**
  126107. * Enforces a fixed size texture to ensure effect stability across devices.
  126108. */
  126109. mainTextureFixedSize?: number;
  126110. /**
  126111. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126112. */
  126113. alphaBlendingMode: number;
  126114. /**
  126115. * The camera attached to the layer.
  126116. */
  126117. camera: Nullable<Camera>;
  126118. /**
  126119. * The rendering group to draw the layer in.
  126120. */
  126121. renderingGroupId: number;
  126122. }
  126123. /**
  126124. * The effect layer Helps adding post process effect blended with the main pass.
  126125. *
  126126. * This can be for instance use to generate glow or higlight effects on the scene.
  126127. *
  126128. * The effect layer class can not be used directly and is intented to inherited from to be
  126129. * customized per effects.
  126130. */
  126131. export abstract class EffectLayer {
  126132. private _vertexBuffers;
  126133. private _indexBuffer;
  126134. private _cachedDefines;
  126135. private _effectLayerMapGenerationEffect;
  126136. private _effectLayerOptions;
  126137. private _mergeEffect;
  126138. protected _scene: Scene;
  126139. protected _engine: Engine;
  126140. protected _maxSize: number;
  126141. protected _mainTextureDesiredSize: ISize;
  126142. protected _mainTexture: RenderTargetTexture;
  126143. protected _shouldRender: boolean;
  126144. protected _postProcesses: PostProcess[];
  126145. protected _textures: BaseTexture[];
  126146. protected _emissiveTextureAndColor: {
  126147. texture: Nullable<BaseTexture>;
  126148. color: Color4;
  126149. };
  126150. /**
  126151. * The name of the layer
  126152. */
  126153. name: string;
  126154. /**
  126155. * The clear color of the texture used to generate the glow map.
  126156. */
  126157. neutralColor: Color4;
  126158. /**
  126159. * Specifies whether the highlight layer is enabled or not.
  126160. */
  126161. isEnabled: boolean;
  126162. /**
  126163. * Gets the camera attached to the layer.
  126164. */
  126165. get camera(): Nullable<Camera>;
  126166. /**
  126167. * Gets the rendering group id the layer should render in.
  126168. */
  126169. get renderingGroupId(): number;
  126170. set renderingGroupId(renderingGroupId: number);
  126171. /**
  126172. * An event triggered when the effect layer has been disposed.
  126173. */
  126174. onDisposeObservable: Observable<EffectLayer>;
  126175. /**
  126176. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126177. */
  126178. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126179. /**
  126180. * An event triggered when the generated texture is being merged in the scene.
  126181. */
  126182. onBeforeComposeObservable: Observable<EffectLayer>;
  126183. /**
  126184. * An event triggered when the mesh is rendered into the effect render target.
  126185. */
  126186. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126187. /**
  126188. * An event triggered after the mesh has been rendered into the effect render target.
  126189. */
  126190. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126191. /**
  126192. * An event triggered when the generated texture has been merged in the scene.
  126193. */
  126194. onAfterComposeObservable: Observable<EffectLayer>;
  126195. /**
  126196. * An event triggered when the efffect layer changes its size.
  126197. */
  126198. onSizeChangedObservable: Observable<EffectLayer>;
  126199. /** @hidden */
  126200. static _SceneComponentInitialization: (scene: Scene) => void;
  126201. /**
  126202. * Instantiates a new effect Layer and references it in the scene.
  126203. * @param name The name of the layer
  126204. * @param scene The scene to use the layer in
  126205. */
  126206. constructor(
  126207. /** The Friendly of the effect in the scene */
  126208. name: string, scene: Scene);
  126209. /**
  126210. * Get the effect name of the layer.
  126211. * @return The effect name
  126212. */
  126213. abstract getEffectName(): string;
  126214. /**
  126215. * Checks for the readiness of the element composing the layer.
  126216. * @param subMesh the mesh to check for
  126217. * @param useInstances specify whether or not to use instances to render the mesh
  126218. * @return true if ready otherwise, false
  126219. */
  126220. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126221. /**
  126222. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126223. * @returns true if the effect requires stencil during the main canvas render pass.
  126224. */
  126225. abstract needStencil(): boolean;
  126226. /**
  126227. * Create the merge effect. This is the shader use to blit the information back
  126228. * to the main canvas at the end of the scene rendering.
  126229. * @returns The effect containing the shader used to merge the effect on the main canvas
  126230. */
  126231. protected abstract _createMergeEffect(): Effect;
  126232. /**
  126233. * Creates the render target textures and post processes used in the effect layer.
  126234. */
  126235. protected abstract _createTextureAndPostProcesses(): void;
  126236. /**
  126237. * Implementation specific of rendering the generating effect on the main canvas.
  126238. * @param effect The effect used to render through
  126239. */
  126240. protected abstract _internalRender(effect: Effect): void;
  126241. /**
  126242. * Sets the required values for both the emissive texture and and the main color.
  126243. */
  126244. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126245. /**
  126246. * Free any resources and references associated to a mesh.
  126247. * Internal use
  126248. * @param mesh The mesh to free.
  126249. */
  126250. abstract _disposeMesh(mesh: Mesh): void;
  126251. /**
  126252. * Serializes this layer (Glow or Highlight for example)
  126253. * @returns a serialized layer object
  126254. */
  126255. abstract serialize?(): any;
  126256. /**
  126257. * Initializes the effect layer with the required options.
  126258. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126259. */
  126260. protected _init(options: Partial<IEffectLayerOptions>): void;
  126261. /**
  126262. * Generates the index buffer of the full screen quad blending to the main canvas.
  126263. */
  126264. private _generateIndexBuffer;
  126265. /**
  126266. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126267. */
  126268. private _generateVertexBuffer;
  126269. /**
  126270. * Sets the main texture desired size which is the closest power of two
  126271. * of the engine canvas size.
  126272. */
  126273. private _setMainTextureSize;
  126274. /**
  126275. * Creates the main texture for the effect layer.
  126276. */
  126277. protected _createMainTexture(): void;
  126278. /**
  126279. * Adds specific effects defines.
  126280. * @param defines The defines to add specifics to.
  126281. */
  126282. protected _addCustomEffectDefines(defines: string[]): void;
  126283. /**
  126284. * Checks for the readiness of the element composing the layer.
  126285. * @param subMesh the mesh to check for
  126286. * @param useInstances specify whether or not to use instances to render the mesh
  126287. * @param emissiveTexture the associated emissive texture used to generate the glow
  126288. * @return true if ready otherwise, false
  126289. */
  126290. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126291. /**
  126292. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126293. */
  126294. render(): void;
  126295. /**
  126296. * Determine if a given mesh will be used in the current effect.
  126297. * @param mesh mesh to test
  126298. * @returns true if the mesh will be used
  126299. */
  126300. hasMesh(mesh: AbstractMesh): boolean;
  126301. /**
  126302. * Returns true if the layer contains information to display, otherwise false.
  126303. * @returns true if the glow layer should be rendered
  126304. */
  126305. shouldRender(): boolean;
  126306. /**
  126307. * Returns true if the mesh should render, otherwise false.
  126308. * @param mesh The mesh to render
  126309. * @returns true if it should render otherwise false
  126310. */
  126311. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126312. /**
  126313. * Returns true if the mesh can be rendered, otherwise false.
  126314. * @param mesh The mesh to render
  126315. * @param material The material used on the mesh
  126316. * @returns true if it can be rendered otherwise false
  126317. */
  126318. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126319. /**
  126320. * Returns true if the mesh should render, otherwise false.
  126321. * @param mesh The mesh to render
  126322. * @returns true if it should render otherwise false
  126323. */
  126324. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126325. /**
  126326. * Renders the submesh passed in parameter to the generation map.
  126327. */
  126328. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126329. /**
  126330. * Defines whether the current material of the mesh should be use to render the effect.
  126331. * @param mesh defines the current mesh to render
  126332. */
  126333. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126334. /**
  126335. * Rebuild the required buffers.
  126336. * @hidden Internal use only.
  126337. */
  126338. _rebuild(): void;
  126339. /**
  126340. * Dispose only the render target textures and post process.
  126341. */
  126342. private _disposeTextureAndPostProcesses;
  126343. /**
  126344. * Dispose the highlight layer and free resources.
  126345. */
  126346. dispose(): void;
  126347. /**
  126348. * Gets the class name of the effect layer
  126349. * @returns the string with the class name of the effect layer
  126350. */
  126351. getClassName(): string;
  126352. /**
  126353. * Creates an effect layer from parsed effect layer data
  126354. * @param parsedEffectLayer defines effect layer data
  126355. * @param scene defines the current scene
  126356. * @param rootUrl defines the root URL containing the effect layer information
  126357. * @returns a parsed effect Layer
  126358. */
  126359. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126360. }
  126361. }
  126362. declare module BABYLON {
  126363. interface AbstractScene {
  126364. /**
  126365. * The list of effect layers (highlights/glow) added to the scene
  126366. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126367. * @see http://doc.babylonjs.com/how_to/glow_layer
  126368. */
  126369. effectLayers: Array<EffectLayer>;
  126370. /**
  126371. * Removes the given effect layer from this scene.
  126372. * @param toRemove defines the effect layer to remove
  126373. * @returns the index of the removed effect layer
  126374. */
  126375. removeEffectLayer(toRemove: EffectLayer): number;
  126376. /**
  126377. * Adds the given effect layer to this scene
  126378. * @param newEffectLayer defines the effect layer to add
  126379. */
  126380. addEffectLayer(newEffectLayer: EffectLayer): void;
  126381. }
  126382. /**
  126383. * Defines the layer scene component responsible to manage any effect layers
  126384. * in a given scene.
  126385. */
  126386. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126387. /**
  126388. * The component name helpfull to identify the component in the list of scene components.
  126389. */
  126390. readonly name: string;
  126391. /**
  126392. * The scene the component belongs to.
  126393. */
  126394. scene: Scene;
  126395. private _engine;
  126396. private _renderEffects;
  126397. private _needStencil;
  126398. private _previousStencilState;
  126399. /**
  126400. * Creates a new instance of the component for the given scene
  126401. * @param scene Defines the scene to register the component in
  126402. */
  126403. constructor(scene: Scene);
  126404. /**
  126405. * Registers the component in a given scene
  126406. */
  126407. register(): void;
  126408. /**
  126409. * Rebuilds the elements related to this component in case of
  126410. * context lost for instance.
  126411. */
  126412. rebuild(): void;
  126413. /**
  126414. * Serializes the component data to the specified json object
  126415. * @param serializationObject The object to serialize to
  126416. */
  126417. serialize(serializationObject: any): void;
  126418. /**
  126419. * Adds all the elements from the container to the scene
  126420. * @param container the container holding the elements
  126421. */
  126422. addFromContainer(container: AbstractScene): void;
  126423. /**
  126424. * Removes all the elements in the container from the scene
  126425. * @param container contains the elements to remove
  126426. * @param dispose if the removed element should be disposed (default: false)
  126427. */
  126428. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126429. /**
  126430. * Disposes the component and the associated ressources.
  126431. */
  126432. dispose(): void;
  126433. private _isReadyForMesh;
  126434. private _renderMainTexture;
  126435. private _setStencil;
  126436. private _setStencilBack;
  126437. private _draw;
  126438. private _drawCamera;
  126439. private _drawRenderingGroup;
  126440. }
  126441. }
  126442. declare module BABYLON {
  126443. /** @hidden */
  126444. export var glowMapMergePixelShader: {
  126445. name: string;
  126446. shader: string;
  126447. };
  126448. }
  126449. declare module BABYLON {
  126450. /** @hidden */
  126451. export var glowMapMergeVertexShader: {
  126452. name: string;
  126453. shader: string;
  126454. };
  126455. }
  126456. declare module BABYLON {
  126457. interface AbstractScene {
  126458. /**
  126459. * Return a the first highlight layer of the scene with a given name.
  126460. * @param name The name of the highlight layer to look for.
  126461. * @return The highlight layer if found otherwise null.
  126462. */
  126463. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126464. }
  126465. /**
  126466. * Glow layer options. This helps customizing the behaviour
  126467. * of the glow layer.
  126468. */
  126469. export interface IGlowLayerOptions {
  126470. /**
  126471. * Multiplication factor apply to the canvas size to compute the render target size
  126472. * used to generated the glowing objects (the smaller the faster).
  126473. */
  126474. mainTextureRatio: number;
  126475. /**
  126476. * Enforces a fixed size texture to ensure resize independant blur.
  126477. */
  126478. mainTextureFixedSize?: number;
  126479. /**
  126480. * How big is the kernel of the blur texture.
  126481. */
  126482. blurKernelSize: number;
  126483. /**
  126484. * The camera attached to the layer.
  126485. */
  126486. camera: Nullable<Camera>;
  126487. /**
  126488. * Enable MSAA by chosing the number of samples.
  126489. */
  126490. mainTextureSamples?: number;
  126491. /**
  126492. * The rendering group to draw the layer in.
  126493. */
  126494. renderingGroupId: number;
  126495. }
  126496. /**
  126497. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126498. *
  126499. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126500. *
  126501. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126502. */
  126503. export class GlowLayer extends EffectLayer {
  126504. /**
  126505. * Effect Name of the layer.
  126506. */
  126507. static readonly EffectName: string;
  126508. /**
  126509. * The default blur kernel size used for the glow.
  126510. */
  126511. static DefaultBlurKernelSize: number;
  126512. /**
  126513. * The default texture size ratio used for the glow.
  126514. */
  126515. static DefaultTextureRatio: number;
  126516. /**
  126517. * Sets the kernel size of the blur.
  126518. */
  126519. set blurKernelSize(value: number);
  126520. /**
  126521. * Gets the kernel size of the blur.
  126522. */
  126523. get blurKernelSize(): number;
  126524. /**
  126525. * Sets the glow intensity.
  126526. */
  126527. set intensity(value: number);
  126528. /**
  126529. * Gets the glow intensity.
  126530. */
  126531. get intensity(): number;
  126532. private _options;
  126533. private _intensity;
  126534. private _horizontalBlurPostprocess1;
  126535. private _verticalBlurPostprocess1;
  126536. private _horizontalBlurPostprocess2;
  126537. private _verticalBlurPostprocess2;
  126538. private _blurTexture1;
  126539. private _blurTexture2;
  126540. private _postProcesses1;
  126541. private _postProcesses2;
  126542. private _includedOnlyMeshes;
  126543. private _excludedMeshes;
  126544. private _meshesUsingTheirOwnMaterials;
  126545. /**
  126546. * Callback used to let the user override the color selection on a per mesh basis
  126547. */
  126548. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126549. /**
  126550. * Callback used to let the user override the texture selection on a per mesh basis
  126551. */
  126552. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126553. /**
  126554. * Instantiates a new glow Layer and references it to the scene.
  126555. * @param name The name of the layer
  126556. * @param scene The scene to use the layer in
  126557. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126558. */
  126559. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126560. /**
  126561. * Get the effect name of the layer.
  126562. * @return The effect name
  126563. */
  126564. getEffectName(): string;
  126565. /**
  126566. * Create the merge effect. This is the shader use to blit the information back
  126567. * to the main canvas at the end of the scene rendering.
  126568. */
  126569. protected _createMergeEffect(): Effect;
  126570. /**
  126571. * Creates the render target textures and post processes used in the glow layer.
  126572. */
  126573. protected _createTextureAndPostProcesses(): void;
  126574. /**
  126575. * Checks for the readiness of the element composing the layer.
  126576. * @param subMesh the mesh to check for
  126577. * @param useInstances specify wether or not to use instances to render the mesh
  126578. * @param emissiveTexture the associated emissive texture used to generate the glow
  126579. * @return true if ready otherwise, false
  126580. */
  126581. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126582. /**
  126583. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126584. */
  126585. needStencil(): boolean;
  126586. /**
  126587. * Returns true if the mesh can be rendered, otherwise false.
  126588. * @param mesh The mesh to render
  126589. * @param material The material used on the mesh
  126590. * @returns true if it can be rendered otherwise false
  126591. */
  126592. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126593. /**
  126594. * Implementation specific of rendering the generating effect on the main canvas.
  126595. * @param effect The effect used to render through
  126596. */
  126597. protected _internalRender(effect: Effect): void;
  126598. /**
  126599. * Sets the required values for both the emissive texture and and the main color.
  126600. */
  126601. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126602. /**
  126603. * Returns true if the mesh should render, otherwise false.
  126604. * @param mesh The mesh to render
  126605. * @returns true if it should render otherwise false
  126606. */
  126607. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126608. /**
  126609. * Adds specific effects defines.
  126610. * @param defines The defines to add specifics to.
  126611. */
  126612. protected _addCustomEffectDefines(defines: string[]): void;
  126613. /**
  126614. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126615. * @param mesh The mesh to exclude from the glow layer
  126616. */
  126617. addExcludedMesh(mesh: Mesh): void;
  126618. /**
  126619. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126620. * @param mesh The mesh to remove
  126621. */
  126622. removeExcludedMesh(mesh: Mesh): void;
  126623. /**
  126624. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126625. * @param mesh The mesh to include in the glow layer
  126626. */
  126627. addIncludedOnlyMesh(mesh: Mesh): void;
  126628. /**
  126629. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126630. * @param mesh The mesh to remove
  126631. */
  126632. removeIncludedOnlyMesh(mesh: Mesh): void;
  126633. /**
  126634. * Determine if a given mesh will be used in the glow layer
  126635. * @param mesh The mesh to test
  126636. * @returns true if the mesh will be highlighted by the current glow layer
  126637. */
  126638. hasMesh(mesh: AbstractMesh): boolean;
  126639. /**
  126640. * Defines whether the current material of the mesh should be use to render the effect.
  126641. * @param mesh defines the current mesh to render
  126642. */
  126643. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126644. /**
  126645. * Add a mesh to be rendered through its own material and not with emissive only.
  126646. * @param mesh The mesh for which we need to use its material
  126647. */
  126648. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126649. /**
  126650. * Remove a mesh from being rendered through its own material and not with emissive only.
  126651. * @param mesh The mesh for which we need to not use its material
  126652. */
  126653. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126654. /**
  126655. * Free any resources and references associated to a mesh.
  126656. * Internal use
  126657. * @param mesh The mesh to free.
  126658. * @hidden
  126659. */
  126660. _disposeMesh(mesh: Mesh): void;
  126661. /**
  126662. * Gets the class name of the effect layer
  126663. * @returns the string with the class name of the effect layer
  126664. */
  126665. getClassName(): string;
  126666. /**
  126667. * Serializes this glow layer
  126668. * @returns a serialized glow layer object
  126669. */
  126670. serialize(): any;
  126671. /**
  126672. * Creates a Glow Layer from parsed glow layer data
  126673. * @param parsedGlowLayer defines glow layer data
  126674. * @param scene defines the current scene
  126675. * @param rootUrl defines the root URL containing the glow layer information
  126676. * @returns a parsed Glow Layer
  126677. */
  126678. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126679. }
  126680. }
  126681. declare module BABYLON {
  126682. /** @hidden */
  126683. export var glowBlurPostProcessPixelShader: {
  126684. name: string;
  126685. shader: string;
  126686. };
  126687. }
  126688. declare module BABYLON {
  126689. interface AbstractScene {
  126690. /**
  126691. * Return a the first highlight layer of the scene with a given name.
  126692. * @param name The name of the highlight layer to look for.
  126693. * @return The highlight layer if found otherwise null.
  126694. */
  126695. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126696. }
  126697. /**
  126698. * Highlight layer options. This helps customizing the behaviour
  126699. * of the highlight layer.
  126700. */
  126701. export interface IHighlightLayerOptions {
  126702. /**
  126703. * Multiplication factor apply to the canvas size to compute the render target size
  126704. * used to generated the glowing objects (the smaller the faster).
  126705. */
  126706. mainTextureRatio: number;
  126707. /**
  126708. * Enforces a fixed size texture to ensure resize independant blur.
  126709. */
  126710. mainTextureFixedSize?: number;
  126711. /**
  126712. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126713. * of the picture to blur (the smaller the faster).
  126714. */
  126715. blurTextureSizeRatio: number;
  126716. /**
  126717. * How big in texel of the blur texture is the vertical blur.
  126718. */
  126719. blurVerticalSize: number;
  126720. /**
  126721. * How big in texel of the blur texture is the horizontal blur.
  126722. */
  126723. blurHorizontalSize: number;
  126724. /**
  126725. * Alpha blending mode used to apply the blur. Default is combine.
  126726. */
  126727. alphaBlendingMode: number;
  126728. /**
  126729. * The camera attached to the layer.
  126730. */
  126731. camera: Nullable<Camera>;
  126732. /**
  126733. * Should we display highlight as a solid stroke?
  126734. */
  126735. isStroke?: boolean;
  126736. /**
  126737. * The rendering group to draw the layer in.
  126738. */
  126739. renderingGroupId: number;
  126740. }
  126741. /**
  126742. * The highlight layer Helps adding a glow effect around a mesh.
  126743. *
  126744. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126745. * glowy meshes to your scene.
  126746. *
  126747. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126748. */
  126749. export class HighlightLayer extends EffectLayer {
  126750. name: string;
  126751. /**
  126752. * Effect Name of the highlight layer.
  126753. */
  126754. static readonly EffectName: string;
  126755. /**
  126756. * The neutral color used during the preparation of the glow effect.
  126757. * This is black by default as the blend operation is a blend operation.
  126758. */
  126759. static NeutralColor: Color4;
  126760. /**
  126761. * Stencil value used for glowing meshes.
  126762. */
  126763. static GlowingMeshStencilReference: number;
  126764. /**
  126765. * Stencil value used for the other meshes in the scene.
  126766. */
  126767. static NormalMeshStencilReference: number;
  126768. /**
  126769. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126770. */
  126771. innerGlow: boolean;
  126772. /**
  126773. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126774. */
  126775. outerGlow: boolean;
  126776. /**
  126777. * Specifies the horizontal size of the blur.
  126778. */
  126779. set blurHorizontalSize(value: number);
  126780. /**
  126781. * Specifies the vertical size of the blur.
  126782. */
  126783. set blurVerticalSize(value: number);
  126784. /**
  126785. * Gets the horizontal size of the blur.
  126786. */
  126787. get blurHorizontalSize(): number;
  126788. /**
  126789. * Gets the vertical size of the blur.
  126790. */
  126791. get blurVerticalSize(): number;
  126792. /**
  126793. * An event triggered when the highlight layer is being blurred.
  126794. */
  126795. onBeforeBlurObservable: Observable<HighlightLayer>;
  126796. /**
  126797. * An event triggered when the highlight layer has been blurred.
  126798. */
  126799. onAfterBlurObservable: Observable<HighlightLayer>;
  126800. private _instanceGlowingMeshStencilReference;
  126801. private _options;
  126802. private _downSamplePostprocess;
  126803. private _horizontalBlurPostprocess;
  126804. private _verticalBlurPostprocess;
  126805. private _blurTexture;
  126806. private _meshes;
  126807. private _excludedMeshes;
  126808. /**
  126809. * Instantiates a new highlight Layer and references it to the scene..
  126810. * @param name The name of the layer
  126811. * @param scene The scene to use the layer in
  126812. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126813. */
  126814. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126815. /**
  126816. * Get the effect name of the layer.
  126817. * @return The effect name
  126818. */
  126819. getEffectName(): string;
  126820. /**
  126821. * Create the merge effect. This is the shader use to blit the information back
  126822. * to the main canvas at the end of the scene rendering.
  126823. */
  126824. protected _createMergeEffect(): Effect;
  126825. /**
  126826. * Creates the render target textures and post processes used in the highlight layer.
  126827. */
  126828. protected _createTextureAndPostProcesses(): void;
  126829. /**
  126830. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126831. */
  126832. needStencil(): boolean;
  126833. /**
  126834. * Checks for the readiness of the element composing the layer.
  126835. * @param subMesh the mesh to check for
  126836. * @param useInstances specify wether or not to use instances to render the mesh
  126837. * @param emissiveTexture the associated emissive texture used to generate the glow
  126838. * @return true if ready otherwise, false
  126839. */
  126840. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126841. /**
  126842. * Implementation specific of rendering the generating effect on the main canvas.
  126843. * @param effect The effect used to render through
  126844. */
  126845. protected _internalRender(effect: Effect): void;
  126846. /**
  126847. * Returns true if the layer contains information to display, otherwise false.
  126848. */
  126849. shouldRender(): boolean;
  126850. /**
  126851. * Returns true if the mesh should render, otherwise false.
  126852. * @param mesh The mesh to render
  126853. * @returns true if it should render otherwise false
  126854. */
  126855. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126856. /**
  126857. * Sets the required values for both the emissive texture and and the main color.
  126858. */
  126859. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126860. /**
  126861. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126862. * @param mesh The mesh to exclude from the highlight layer
  126863. */
  126864. addExcludedMesh(mesh: Mesh): void;
  126865. /**
  126866. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126867. * @param mesh The mesh to highlight
  126868. */
  126869. removeExcludedMesh(mesh: Mesh): void;
  126870. /**
  126871. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126872. * @param mesh mesh to test
  126873. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126874. */
  126875. hasMesh(mesh: AbstractMesh): boolean;
  126876. /**
  126877. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126878. * @param mesh The mesh to highlight
  126879. * @param color The color of the highlight
  126880. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126881. */
  126882. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126883. /**
  126884. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126885. * @param mesh The mesh to highlight
  126886. */
  126887. removeMesh(mesh: Mesh): void;
  126888. /**
  126889. * Remove all the meshes currently referenced in the highlight layer
  126890. */
  126891. removeAllMeshes(): void;
  126892. /**
  126893. * Force the stencil to the normal expected value for none glowing parts
  126894. */
  126895. private _defaultStencilReference;
  126896. /**
  126897. * Free any resources and references associated to a mesh.
  126898. * Internal use
  126899. * @param mesh The mesh to free.
  126900. * @hidden
  126901. */
  126902. _disposeMesh(mesh: Mesh): void;
  126903. /**
  126904. * Dispose the highlight layer and free resources.
  126905. */
  126906. dispose(): void;
  126907. /**
  126908. * Gets the class name of the effect layer
  126909. * @returns the string with the class name of the effect layer
  126910. */
  126911. getClassName(): string;
  126912. /**
  126913. * Serializes this Highlight layer
  126914. * @returns a serialized Highlight layer object
  126915. */
  126916. serialize(): any;
  126917. /**
  126918. * Creates a Highlight layer from parsed Highlight layer data
  126919. * @param parsedHightlightLayer defines the Highlight layer data
  126920. * @param scene defines the current scene
  126921. * @param rootUrl defines the root URL containing the Highlight layer information
  126922. * @returns a parsed Highlight layer
  126923. */
  126924. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126925. }
  126926. }
  126927. declare module BABYLON {
  126928. interface AbstractScene {
  126929. /**
  126930. * The list of layers (background and foreground) of the scene
  126931. */
  126932. layers: Array<Layer>;
  126933. }
  126934. /**
  126935. * Defines the layer scene component responsible to manage any layers
  126936. * in a given scene.
  126937. */
  126938. export class LayerSceneComponent implements ISceneComponent {
  126939. /**
  126940. * The component name helpfull to identify the component in the list of scene components.
  126941. */
  126942. readonly name: string;
  126943. /**
  126944. * The scene the component belongs to.
  126945. */
  126946. scene: Scene;
  126947. private _engine;
  126948. /**
  126949. * Creates a new instance of the component for the given scene
  126950. * @param scene Defines the scene to register the component in
  126951. */
  126952. constructor(scene: Scene);
  126953. /**
  126954. * Registers the component in a given scene
  126955. */
  126956. register(): void;
  126957. /**
  126958. * Rebuilds the elements related to this component in case of
  126959. * context lost for instance.
  126960. */
  126961. rebuild(): void;
  126962. /**
  126963. * Disposes the component and the associated ressources.
  126964. */
  126965. dispose(): void;
  126966. private _draw;
  126967. private _drawCameraPredicate;
  126968. private _drawCameraBackground;
  126969. private _drawCameraForeground;
  126970. private _drawRenderTargetPredicate;
  126971. private _drawRenderTargetBackground;
  126972. private _drawRenderTargetForeground;
  126973. /**
  126974. * Adds all the elements from the container to the scene
  126975. * @param container the container holding the elements
  126976. */
  126977. addFromContainer(container: AbstractScene): void;
  126978. /**
  126979. * Removes all the elements in the container from the scene
  126980. * @param container contains the elements to remove
  126981. * @param dispose if the removed element should be disposed (default: false)
  126982. */
  126983. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126984. }
  126985. }
  126986. declare module BABYLON {
  126987. /** @hidden */
  126988. export var layerPixelShader: {
  126989. name: string;
  126990. shader: string;
  126991. };
  126992. }
  126993. declare module BABYLON {
  126994. /** @hidden */
  126995. export var layerVertexShader: {
  126996. name: string;
  126997. shader: string;
  126998. };
  126999. }
  127000. declare module BABYLON {
  127001. /**
  127002. * This represents a full screen 2d layer.
  127003. * This can be useful to display a picture in the background of your scene for instance.
  127004. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127005. */
  127006. export class Layer {
  127007. /**
  127008. * Define the name of the layer.
  127009. */
  127010. name: string;
  127011. /**
  127012. * Define the texture the layer should display.
  127013. */
  127014. texture: Nullable<Texture>;
  127015. /**
  127016. * Is the layer in background or foreground.
  127017. */
  127018. isBackground: boolean;
  127019. /**
  127020. * Define the color of the layer (instead of texture).
  127021. */
  127022. color: Color4;
  127023. /**
  127024. * Define the scale of the layer in order to zoom in out of the texture.
  127025. */
  127026. scale: Vector2;
  127027. /**
  127028. * Define an offset for the layer in order to shift the texture.
  127029. */
  127030. offset: Vector2;
  127031. /**
  127032. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  127033. */
  127034. alphaBlendingMode: number;
  127035. /**
  127036. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  127037. * Alpha test will not mix with the background color in case of transparency.
  127038. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  127039. */
  127040. alphaTest: boolean;
  127041. /**
  127042. * Define a mask to restrict the layer to only some of the scene cameras.
  127043. */
  127044. layerMask: number;
  127045. /**
  127046. * Define the list of render target the layer is visible into.
  127047. */
  127048. renderTargetTextures: RenderTargetTexture[];
  127049. /**
  127050. * Define if the layer is only used in renderTarget or if it also
  127051. * renders in the main frame buffer of the canvas.
  127052. */
  127053. renderOnlyInRenderTargetTextures: boolean;
  127054. private _scene;
  127055. private _vertexBuffers;
  127056. private _indexBuffer;
  127057. private _effect;
  127058. private _previousDefines;
  127059. /**
  127060. * An event triggered when the layer is disposed.
  127061. */
  127062. onDisposeObservable: Observable<Layer>;
  127063. private _onDisposeObserver;
  127064. /**
  127065. * Back compatibility with callback before the onDisposeObservable existed.
  127066. * The set callback will be triggered when the layer has been disposed.
  127067. */
  127068. set onDispose(callback: () => void);
  127069. /**
  127070. * An event triggered before rendering the scene
  127071. */
  127072. onBeforeRenderObservable: Observable<Layer>;
  127073. private _onBeforeRenderObserver;
  127074. /**
  127075. * Back compatibility with callback before the onBeforeRenderObservable existed.
  127076. * The set callback will be triggered just before rendering the layer.
  127077. */
  127078. set onBeforeRender(callback: () => void);
  127079. /**
  127080. * An event triggered after rendering the scene
  127081. */
  127082. onAfterRenderObservable: Observable<Layer>;
  127083. private _onAfterRenderObserver;
  127084. /**
  127085. * Back compatibility with callback before the onAfterRenderObservable existed.
  127086. * The set callback will be triggered just after rendering the layer.
  127087. */
  127088. set onAfterRender(callback: () => void);
  127089. /**
  127090. * Instantiates a new layer.
  127091. * This represents a full screen 2d layer.
  127092. * This can be useful to display a picture in the background of your scene for instance.
  127093. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127094. * @param name Define the name of the layer in the scene
  127095. * @param imgUrl Define the url of the texture to display in the layer
  127096. * @param scene Define the scene the layer belongs to
  127097. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127098. * @param color Defines a color for the layer
  127099. */
  127100. constructor(
  127101. /**
  127102. * Define the name of the layer.
  127103. */
  127104. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127105. private _createIndexBuffer;
  127106. /** @hidden */
  127107. _rebuild(): void;
  127108. /**
  127109. * Renders the layer in the scene.
  127110. */
  127111. render(): void;
  127112. /**
  127113. * Disposes and releases the associated ressources.
  127114. */
  127115. dispose(): void;
  127116. }
  127117. }
  127118. declare module BABYLON {
  127119. /** @hidden */
  127120. export var lensFlarePixelShader: {
  127121. name: string;
  127122. shader: string;
  127123. };
  127124. }
  127125. declare module BABYLON {
  127126. /** @hidden */
  127127. export var lensFlareVertexShader: {
  127128. name: string;
  127129. shader: string;
  127130. };
  127131. }
  127132. declare module BABYLON {
  127133. /**
  127134. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127135. * It is usually composed of several `lensFlare`.
  127136. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127137. */
  127138. export class LensFlareSystem {
  127139. /**
  127140. * Define the name of the lens flare system
  127141. */
  127142. name: string;
  127143. /**
  127144. * List of lens flares used in this system.
  127145. */
  127146. lensFlares: LensFlare[];
  127147. /**
  127148. * Define a limit from the border the lens flare can be visible.
  127149. */
  127150. borderLimit: number;
  127151. /**
  127152. * Define a viewport border we do not want to see the lens flare in.
  127153. */
  127154. viewportBorder: number;
  127155. /**
  127156. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127157. */
  127158. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127159. /**
  127160. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127161. */
  127162. layerMask: number;
  127163. /**
  127164. * Define the id of the lens flare system in the scene.
  127165. * (equal to name by default)
  127166. */
  127167. id: string;
  127168. private _scene;
  127169. private _emitter;
  127170. private _vertexBuffers;
  127171. private _indexBuffer;
  127172. private _effect;
  127173. private _positionX;
  127174. private _positionY;
  127175. private _isEnabled;
  127176. /** @hidden */
  127177. static _SceneComponentInitialization: (scene: Scene) => void;
  127178. /**
  127179. * Instantiates a lens flare system.
  127180. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127181. * It is usually composed of several `lensFlare`.
  127182. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127183. * @param name Define the name of the lens flare system in the scene
  127184. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127185. * @param scene Define the scene the lens flare system belongs to
  127186. */
  127187. constructor(
  127188. /**
  127189. * Define the name of the lens flare system
  127190. */
  127191. name: string, emitter: any, scene: Scene);
  127192. /**
  127193. * Define if the lens flare system is enabled.
  127194. */
  127195. get isEnabled(): boolean;
  127196. set isEnabled(value: boolean);
  127197. /**
  127198. * Get the scene the effects belongs to.
  127199. * @returns the scene holding the lens flare system
  127200. */
  127201. getScene(): Scene;
  127202. /**
  127203. * Get the emitter of the lens flare system.
  127204. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127205. * @returns the emitter of the lens flare system
  127206. */
  127207. getEmitter(): any;
  127208. /**
  127209. * Set the emitter of the lens flare system.
  127210. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127211. * @param newEmitter Define the new emitter of the system
  127212. */
  127213. setEmitter(newEmitter: any): void;
  127214. /**
  127215. * Get the lens flare system emitter position.
  127216. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127217. * @returns the position
  127218. */
  127219. getEmitterPosition(): Vector3;
  127220. /**
  127221. * @hidden
  127222. */
  127223. computeEffectivePosition(globalViewport: Viewport): boolean;
  127224. /** @hidden */
  127225. _isVisible(): boolean;
  127226. /**
  127227. * @hidden
  127228. */
  127229. render(): boolean;
  127230. /**
  127231. * Dispose and release the lens flare with its associated resources.
  127232. */
  127233. dispose(): void;
  127234. /**
  127235. * Parse a lens flare system from a JSON repressentation
  127236. * @param parsedLensFlareSystem Define the JSON to parse
  127237. * @param scene Define the scene the parsed system should be instantiated in
  127238. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127239. * @returns the parsed system
  127240. */
  127241. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127242. /**
  127243. * Serialize the current Lens Flare System into a JSON representation.
  127244. * @returns the serialized JSON
  127245. */
  127246. serialize(): any;
  127247. }
  127248. }
  127249. declare module BABYLON {
  127250. /**
  127251. * This represents one of the lens effect in a `lensFlareSystem`.
  127252. * It controls one of the indiviual texture used in the effect.
  127253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127254. */
  127255. export class LensFlare {
  127256. /**
  127257. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127258. */
  127259. size: number;
  127260. /**
  127261. * 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.
  127262. */
  127263. position: number;
  127264. /**
  127265. * Define the lens color.
  127266. */
  127267. color: Color3;
  127268. /**
  127269. * Define the lens texture.
  127270. */
  127271. texture: Nullable<Texture>;
  127272. /**
  127273. * Define the alpha mode to render this particular lens.
  127274. */
  127275. alphaMode: number;
  127276. private _system;
  127277. /**
  127278. * Creates a new Lens Flare.
  127279. * This represents one of the lens effect in a `lensFlareSystem`.
  127280. * It controls one of the indiviual texture used in the effect.
  127281. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127282. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127283. * @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.
  127284. * @param color Define the lens color
  127285. * @param imgUrl Define the lens texture url
  127286. * @param system Define the `lensFlareSystem` this flare is part of
  127287. * @returns The newly created Lens Flare
  127288. */
  127289. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127290. /**
  127291. * Instantiates a new Lens Flare.
  127292. * This represents one of the lens effect in a `lensFlareSystem`.
  127293. * It controls one of the indiviual texture used in the effect.
  127294. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127295. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127296. * @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.
  127297. * @param color Define the lens color
  127298. * @param imgUrl Define the lens texture url
  127299. * @param system Define the `lensFlareSystem` this flare is part of
  127300. */
  127301. constructor(
  127302. /**
  127303. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127304. */
  127305. size: number,
  127306. /**
  127307. * 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.
  127308. */
  127309. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127310. /**
  127311. * Dispose and release the lens flare with its associated resources.
  127312. */
  127313. dispose(): void;
  127314. }
  127315. }
  127316. declare module BABYLON {
  127317. interface AbstractScene {
  127318. /**
  127319. * The list of lens flare system added to the scene
  127320. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127321. */
  127322. lensFlareSystems: Array<LensFlareSystem>;
  127323. /**
  127324. * Removes the given lens flare system from this scene.
  127325. * @param toRemove The lens flare system to remove
  127326. * @returns The index of the removed lens flare system
  127327. */
  127328. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127329. /**
  127330. * Adds the given lens flare system to this scene
  127331. * @param newLensFlareSystem The lens flare system to add
  127332. */
  127333. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127334. /**
  127335. * Gets a lens flare system using its name
  127336. * @param name defines the name to look for
  127337. * @returns the lens flare system or null if not found
  127338. */
  127339. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127340. /**
  127341. * Gets a lens flare system using its id
  127342. * @param id defines the id to look for
  127343. * @returns the lens flare system or null if not found
  127344. */
  127345. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127346. }
  127347. /**
  127348. * Defines the lens flare scene component responsible to manage any lens flares
  127349. * in a given scene.
  127350. */
  127351. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127352. /**
  127353. * The component name helpfull to identify the component in the list of scene components.
  127354. */
  127355. readonly name: string;
  127356. /**
  127357. * The scene the component belongs to.
  127358. */
  127359. scene: Scene;
  127360. /**
  127361. * Creates a new instance of the component for the given scene
  127362. * @param scene Defines the scene to register the component in
  127363. */
  127364. constructor(scene: Scene);
  127365. /**
  127366. * Registers the component in a given scene
  127367. */
  127368. register(): void;
  127369. /**
  127370. * Rebuilds the elements related to this component in case of
  127371. * context lost for instance.
  127372. */
  127373. rebuild(): void;
  127374. /**
  127375. * Adds all the elements from the container to the scene
  127376. * @param container the container holding the elements
  127377. */
  127378. addFromContainer(container: AbstractScene): void;
  127379. /**
  127380. * Removes all the elements in the container from the scene
  127381. * @param container contains the elements to remove
  127382. * @param dispose if the removed element should be disposed (default: false)
  127383. */
  127384. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127385. /**
  127386. * Serializes the component data to the specified json object
  127387. * @param serializationObject The object to serialize to
  127388. */
  127389. serialize(serializationObject: any): void;
  127390. /**
  127391. * Disposes the component and the associated ressources.
  127392. */
  127393. dispose(): void;
  127394. private _draw;
  127395. }
  127396. }
  127397. declare module BABYLON {
  127398. /** @hidden */
  127399. export var depthPixelShader: {
  127400. name: string;
  127401. shader: string;
  127402. };
  127403. }
  127404. declare module BABYLON {
  127405. /** @hidden */
  127406. export var depthVertexShader: {
  127407. name: string;
  127408. shader: string;
  127409. };
  127410. }
  127411. declare module BABYLON {
  127412. /**
  127413. * This represents a depth renderer in Babylon.
  127414. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127415. */
  127416. export class DepthRenderer {
  127417. private _scene;
  127418. private _depthMap;
  127419. private _effect;
  127420. private readonly _storeNonLinearDepth;
  127421. private readonly _clearColor;
  127422. /** Get if the depth renderer is using packed depth or not */
  127423. readonly isPacked: boolean;
  127424. private _cachedDefines;
  127425. private _camera;
  127426. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127427. enabled: boolean;
  127428. /**
  127429. * Specifiess that the depth renderer will only be used within
  127430. * the camera it is created for.
  127431. * This can help forcing its rendering during the camera processing.
  127432. */
  127433. useOnlyInActiveCamera: boolean;
  127434. /** @hidden */
  127435. static _SceneComponentInitialization: (scene: Scene) => void;
  127436. /**
  127437. * Instantiates a depth renderer
  127438. * @param scene The scene the renderer belongs to
  127439. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127440. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127441. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127442. */
  127443. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127444. /**
  127445. * Creates the depth rendering effect and checks if the effect is ready.
  127446. * @param subMesh The submesh to be used to render the depth map of
  127447. * @param useInstances If multiple world instances should be used
  127448. * @returns if the depth renderer is ready to render the depth map
  127449. */
  127450. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127451. /**
  127452. * Gets the texture which the depth map will be written to.
  127453. * @returns The depth map texture
  127454. */
  127455. getDepthMap(): RenderTargetTexture;
  127456. /**
  127457. * Disposes of the depth renderer.
  127458. */
  127459. dispose(): void;
  127460. }
  127461. }
  127462. declare module BABYLON {
  127463. /** @hidden */
  127464. export var minmaxReduxPixelShader: {
  127465. name: string;
  127466. shader: string;
  127467. };
  127468. }
  127469. declare module BABYLON {
  127470. /**
  127471. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127472. * and maximum values from all values of the texture.
  127473. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127474. * The source values are read from the red channel of the texture.
  127475. */
  127476. export class MinMaxReducer {
  127477. /**
  127478. * Observable triggered when the computation has been performed
  127479. */
  127480. onAfterReductionPerformed: Observable<{
  127481. min: number;
  127482. max: number;
  127483. }>;
  127484. protected _camera: Camera;
  127485. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127486. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127487. protected _postProcessManager: PostProcessManager;
  127488. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127489. protected _forceFullscreenViewport: boolean;
  127490. /**
  127491. * Creates a min/max reducer
  127492. * @param camera The camera to use for the post processes
  127493. */
  127494. constructor(camera: Camera);
  127495. /**
  127496. * Gets the texture used to read the values from.
  127497. */
  127498. get sourceTexture(): Nullable<RenderTargetTexture>;
  127499. /**
  127500. * Sets the source texture to read the values from.
  127501. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127502. * because in such textures '1' value must not be taken into account to compute the maximum
  127503. * as this value is used to clear the texture.
  127504. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127505. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127506. * @param depthRedux Indicates if the texture is a depth texture or not
  127507. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127508. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127509. */
  127510. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127511. /**
  127512. * Defines the refresh rate of the computation.
  127513. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127514. */
  127515. get refreshRate(): number;
  127516. set refreshRate(value: number);
  127517. protected _activated: boolean;
  127518. /**
  127519. * Gets the activation status of the reducer
  127520. */
  127521. get activated(): boolean;
  127522. /**
  127523. * Activates the reduction computation.
  127524. * When activated, the observers registered in onAfterReductionPerformed are
  127525. * called after the compuation is performed
  127526. */
  127527. activate(): void;
  127528. /**
  127529. * Deactivates the reduction computation.
  127530. */
  127531. deactivate(): void;
  127532. /**
  127533. * Disposes the min/max reducer
  127534. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  127535. */
  127536. dispose(disposeAll?: boolean): void;
  127537. }
  127538. }
  127539. declare module BABYLON {
  127540. /**
  127541. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127542. */
  127543. export class DepthReducer extends MinMaxReducer {
  127544. private _depthRenderer;
  127545. private _depthRendererId;
  127546. /**
  127547. * Gets the depth renderer used for the computation.
  127548. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127549. */
  127550. get depthRenderer(): Nullable<DepthRenderer>;
  127551. /**
  127552. * Creates a depth reducer
  127553. * @param camera The camera used to render the depth texture
  127554. */
  127555. constructor(camera: Camera);
  127556. /**
  127557. * Sets the depth renderer to use to generate the depth map
  127558. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127559. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127560. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127561. */
  127562. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127563. /** @hidden */
  127564. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127565. /**
  127566. * Activates the reduction computation.
  127567. * When activated, the observers registered in onAfterReductionPerformed are
  127568. * called after the compuation is performed
  127569. */
  127570. activate(): void;
  127571. /**
  127572. * Deactivates the reduction computation.
  127573. */
  127574. deactivate(): void;
  127575. /**
  127576. * Disposes the depth reducer
  127577. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  127578. */
  127579. dispose(disposeAll?: boolean): void;
  127580. }
  127581. }
  127582. declare module BABYLON {
  127583. /**
  127584. * A CSM implementation allowing casting shadows on large scenes.
  127585. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127586. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127587. */
  127588. export class CascadedShadowGenerator extends ShadowGenerator {
  127589. private static readonly frustumCornersNDCSpace;
  127590. /**
  127591. * Name of the CSM class
  127592. */
  127593. static CLASSNAME: string;
  127594. /**
  127595. * Defines the default number of cascades used by the CSM.
  127596. */
  127597. static readonly DEFAULT_CASCADES_COUNT: number;
  127598. /**
  127599. * Defines the minimum number of cascades used by the CSM.
  127600. */
  127601. static readonly MIN_CASCADES_COUNT: number;
  127602. /**
  127603. * Defines the maximum number of cascades used by the CSM.
  127604. */
  127605. static readonly MAX_CASCADES_COUNT: number;
  127606. protected _validateFilter(filter: number): number;
  127607. /**
  127608. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127609. */
  127610. penumbraDarkness: number;
  127611. private _numCascades;
  127612. /**
  127613. * Gets or set the number of cascades used by the CSM.
  127614. */
  127615. get numCascades(): number;
  127616. set numCascades(value: number);
  127617. /**
  127618. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127619. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127620. */
  127621. stabilizeCascades: boolean;
  127622. private _freezeShadowCastersBoundingInfo;
  127623. private _freezeShadowCastersBoundingInfoObservable;
  127624. /**
  127625. * Enables or disables the shadow casters bounding info computation.
  127626. * If your shadow casters don't move, you can disable this feature.
  127627. * If it is enabled, the bounding box computation is done every frame.
  127628. */
  127629. get freezeShadowCastersBoundingInfo(): boolean;
  127630. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127631. private _scbiMin;
  127632. private _scbiMax;
  127633. protected _computeShadowCastersBoundingInfo(): void;
  127634. protected _shadowCastersBoundingInfo: BoundingInfo;
  127635. /**
  127636. * Gets or sets the shadow casters bounding info.
  127637. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127638. * so that the system won't overwrite the bounds you provide
  127639. */
  127640. get shadowCastersBoundingInfo(): BoundingInfo;
  127641. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127642. protected _breaksAreDirty: boolean;
  127643. protected _minDistance: number;
  127644. protected _maxDistance: number;
  127645. /**
  127646. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127647. *
  127648. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127649. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127650. * @param min minimal distance for the breaks (default to 0.)
  127651. * @param max maximal distance for the breaks (default to 1.)
  127652. */
  127653. setMinMaxDistance(min: number, max: number): void;
  127654. /** Gets the minimal distance used in the cascade break computation */
  127655. get minDistance(): number;
  127656. /** Gets the maximal distance used in the cascade break computation */
  127657. get maxDistance(): number;
  127658. /**
  127659. * Gets the class name of that object
  127660. * @returns "CascadedShadowGenerator"
  127661. */
  127662. getClassName(): string;
  127663. private _cascadeMinExtents;
  127664. private _cascadeMaxExtents;
  127665. /**
  127666. * Gets a cascade minimum extents
  127667. * @param cascadeIndex index of the cascade
  127668. * @returns the minimum cascade extents
  127669. */
  127670. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127671. /**
  127672. * Gets a cascade maximum extents
  127673. * @param cascadeIndex index of the cascade
  127674. * @returns the maximum cascade extents
  127675. */
  127676. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127677. private _cascades;
  127678. private _currentLayer;
  127679. private _viewSpaceFrustumsZ;
  127680. private _viewMatrices;
  127681. private _projectionMatrices;
  127682. private _transformMatrices;
  127683. private _transformMatricesAsArray;
  127684. private _frustumLengths;
  127685. private _lightSizeUVCorrection;
  127686. private _depthCorrection;
  127687. private _frustumCornersWorldSpace;
  127688. private _frustumCenter;
  127689. private _shadowCameraPos;
  127690. private _shadowMaxZ;
  127691. /**
  127692. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127693. * It defaults to camera.maxZ
  127694. */
  127695. get shadowMaxZ(): number;
  127696. /**
  127697. * Sets the shadow max z distance.
  127698. */
  127699. set shadowMaxZ(value: number);
  127700. protected _debug: boolean;
  127701. /**
  127702. * Gets or sets the debug flag.
  127703. * When enabled, the cascades are materialized by different colors on the screen.
  127704. */
  127705. get debug(): boolean;
  127706. set debug(dbg: boolean);
  127707. private _depthClamp;
  127708. /**
  127709. * Gets or sets the depth clamping value.
  127710. *
  127711. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127712. * to account for the shadow casters far away.
  127713. *
  127714. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127715. */
  127716. get depthClamp(): boolean;
  127717. set depthClamp(value: boolean);
  127718. private _cascadeBlendPercentage;
  127719. /**
  127720. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127721. * It defaults to 0.1 (10% blending).
  127722. */
  127723. get cascadeBlendPercentage(): number;
  127724. set cascadeBlendPercentage(value: number);
  127725. private _lambda;
  127726. /**
  127727. * Gets or set the lambda parameter.
  127728. * This parameter is used to split the camera frustum and create the cascades.
  127729. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  127730. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127731. */
  127732. get lambda(): number;
  127733. set lambda(value: number);
  127734. /**
  127735. * Gets the view matrix corresponding to a given cascade
  127736. * @param cascadeNum cascade to retrieve the view matrix from
  127737. * @returns the cascade view matrix
  127738. */
  127739. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127740. /**
  127741. * Gets the projection matrix corresponding to a given cascade
  127742. * @param cascadeNum cascade to retrieve the projection matrix from
  127743. * @returns the cascade projection matrix
  127744. */
  127745. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127746. /**
  127747. * Gets the transformation matrix corresponding to a given cascade
  127748. * @param cascadeNum cascade to retrieve the transformation matrix from
  127749. * @returns the cascade transformation matrix
  127750. */
  127751. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127752. private _depthRenderer;
  127753. /**
  127754. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127755. *
  127756. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127757. *
  127758. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127759. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127760. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  127761. */
  127762. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127763. private _depthReducer;
  127764. private _autoCalcDepthBounds;
  127765. /**
  127766. * Gets or sets the autoCalcDepthBounds property.
  127767. *
  127768. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127769. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127770. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127771. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127772. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127773. */
  127774. get autoCalcDepthBounds(): boolean;
  127775. set autoCalcDepthBounds(value: boolean);
  127776. /**
  127777. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127778. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127779. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127780. * for setting the refresh rate on the renderer yourself!
  127781. */
  127782. get autoCalcDepthBoundsRefreshRate(): number;
  127783. set autoCalcDepthBoundsRefreshRate(value: number);
  127784. /**
  127785. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127786. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127787. * you change the camera near/far planes!
  127788. */
  127789. splitFrustum(): void;
  127790. private _splitFrustum;
  127791. private _computeMatrices;
  127792. private _computeFrustumInWorldSpace;
  127793. private _computeCascadeFrustum;
  127794. /** @hidden */
  127795. static _SceneComponentInitialization: (scene: Scene) => void;
  127796. /**
  127797. * Creates a Cascaded Shadow Generator object.
  127798. * A ShadowGenerator is the required tool to use the shadows.
  127799. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127800. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127801. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127802. * @param light The directional light object generating the shadows.
  127803. * @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.
  127804. */
  127805. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127806. protected _initializeGenerator(): void;
  127807. protected _createTargetRenderTexture(): void;
  127808. protected _initializeShadowMap(): void;
  127809. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127810. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127811. /**
  127812. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127813. * @param defines Defines of the material we want to update
  127814. * @param lightIndex Index of the light in the enabled light list of the material
  127815. */
  127816. prepareDefines(defines: any, lightIndex: number): void;
  127817. /**
  127818. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127819. * defined in the generator but impacting the effect).
  127820. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127821. * @param effect The effect we are binfing the information for
  127822. */
  127823. bindShadowLight(lightIndex: string, effect: Effect): void;
  127824. /**
  127825. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127826. * (eq to view projection * shadow projection matrices)
  127827. * @returns The transform matrix used to create the shadow map
  127828. */
  127829. getTransformMatrix(): Matrix;
  127830. /**
  127831. * Disposes the ShadowGenerator.
  127832. * Returns nothing.
  127833. */
  127834. dispose(): void;
  127835. /**
  127836. * Serializes the shadow generator setup to a json object.
  127837. * @returns The serialized JSON object
  127838. */
  127839. serialize(): any;
  127840. /**
  127841. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127842. * @param parsedShadowGenerator The JSON object to parse
  127843. * @param scene The scene to create the shadow map for
  127844. * @returns The parsed shadow generator
  127845. */
  127846. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127847. }
  127848. }
  127849. declare module BABYLON {
  127850. /**
  127851. * Defines the shadow generator component responsible to manage any shadow generators
  127852. * in a given scene.
  127853. */
  127854. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127855. /**
  127856. * The component name helpfull to identify the component in the list of scene components.
  127857. */
  127858. readonly name: string;
  127859. /**
  127860. * The scene the component belongs to.
  127861. */
  127862. scene: Scene;
  127863. /**
  127864. * Creates a new instance of the component for the given scene
  127865. * @param scene Defines the scene to register the component in
  127866. */
  127867. constructor(scene: Scene);
  127868. /**
  127869. * Registers the component in a given scene
  127870. */
  127871. register(): void;
  127872. /**
  127873. * Rebuilds the elements related to this component in case of
  127874. * context lost for instance.
  127875. */
  127876. rebuild(): void;
  127877. /**
  127878. * Serializes the component data to the specified json object
  127879. * @param serializationObject The object to serialize to
  127880. */
  127881. serialize(serializationObject: any): void;
  127882. /**
  127883. * Adds all the elements from the container to the scene
  127884. * @param container the container holding the elements
  127885. */
  127886. addFromContainer(container: AbstractScene): void;
  127887. /**
  127888. * Removes all the elements in the container from the scene
  127889. * @param container contains the elements to remove
  127890. * @param dispose if the removed element should be disposed (default: false)
  127891. */
  127892. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127893. /**
  127894. * Rebuilds the elements related to this component in case of
  127895. * context lost for instance.
  127896. */
  127897. dispose(): void;
  127898. private _gatherRenderTargets;
  127899. }
  127900. }
  127901. declare module BABYLON {
  127902. /**
  127903. * A point light is a light defined by an unique point in world space.
  127904. * The light is emitted in every direction from this point.
  127905. * A good example of a point light is a standard light bulb.
  127906. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127907. */
  127908. export class PointLight extends ShadowLight {
  127909. private _shadowAngle;
  127910. /**
  127911. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127912. * This specifies what angle the shadow will use to be created.
  127913. *
  127914. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127915. */
  127916. get shadowAngle(): number;
  127917. /**
  127918. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127919. * This specifies what angle the shadow will use to be created.
  127920. *
  127921. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127922. */
  127923. set shadowAngle(value: number);
  127924. /**
  127925. * Gets the direction if it has been set.
  127926. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127927. */
  127928. get direction(): Vector3;
  127929. /**
  127930. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127931. */
  127932. set direction(value: Vector3);
  127933. /**
  127934. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127935. * A PointLight emits the light in every direction.
  127936. * It can cast shadows.
  127937. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127938. * ```javascript
  127939. * var pointLight = new PointLight("pl", camera.position, scene);
  127940. * ```
  127941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127942. * @param name The light friendly name
  127943. * @param position The position of the point light in the scene
  127944. * @param scene The scene the lights belongs to
  127945. */
  127946. constructor(name: string, position: Vector3, scene: Scene);
  127947. /**
  127948. * Returns the string "PointLight"
  127949. * @returns the class name
  127950. */
  127951. getClassName(): string;
  127952. /**
  127953. * Returns the integer 0.
  127954. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127955. */
  127956. getTypeID(): number;
  127957. /**
  127958. * Specifies wether or not the shadowmap should be a cube texture.
  127959. * @returns true if the shadowmap needs to be a cube texture.
  127960. */
  127961. needCube(): boolean;
  127962. /**
  127963. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127964. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127965. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127966. */
  127967. getShadowDirection(faceIndex?: number): Vector3;
  127968. /**
  127969. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127970. * - fov = PI / 2
  127971. * - aspect ratio : 1.0
  127972. * - z-near and far equal to the active camera minZ and maxZ.
  127973. * Returns the PointLight.
  127974. */
  127975. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127976. protected _buildUniformLayout(): void;
  127977. /**
  127978. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127979. * @param effect The effect to update
  127980. * @param lightIndex The index of the light in the effect to update
  127981. * @returns The point light
  127982. */
  127983. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127984. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127985. /**
  127986. * Prepares the list of defines specific to the light type.
  127987. * @param defines the list of defines
  127988. * @param lightIndex defines the index of the light for the effect
  127989. */
  127990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127991. }
  127992. }
  127993. declare module BABYLON {
  127994. /**
  127995. * Header information of HDR texture files.
  127996. */
  127997. export interface HDRInfo {
  127998. /**
  127999. * The height of the texture in pixels.
  128000. */
  128001. height: number;
  128002. /**
  128003. * The width of the texture in pixels.
  128004. */
  128005. width: number;
  128006. /**
  128007. * The index of the beginning of the data in the binary file.
  128008. */
  128009. dataPosition: number;
  128010. }
  128011. /**
  128012. * This groups tools to convert HDR texture to native colors array.
  128013. */
  128014. export class HDRTools {
  128015. private static Ldexp;
  128016. private static Rgbe2float;
  128017. private static readStringLine;
  128018. /**
  128019. * Reads header information from an RGBE texture stored in a native array.
  128020. * More information on this format are available here:
  128021. * https://en.wikipedia.org/wiki/RGBE_image_format
  128022. *
  128023. * @param uint8array The binary file stored in native array.
  128024. * @return The header information.
  128025. */
  128026. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  128027. /**
  128028. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  128029. * This RGBE texture needs to store the information as a panorama.
  128030. *
  128031. * More information on this format are available here:
  128032. * https://en.wikipedia.org/wiki/RGBE_image_format
  128033. *
  128034. * @param buffer The binary file stored in an array buffer.
  128035. * @param size The expected size of the extracted cubemap.
  128036. * @return The Cube Map information.
  128037. */
  128038. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  128039. /**
  128040. * Returns the pixels data extracted from an RGBE texture.
  128041. * This pixels will be stored left to right up to down in the R G B order in one array.
  128042. *
  128043. * More information on this format are available here:
  128044. * https://en.wikipedia.org/wiki/RGBE_image_format
  128045. *
  128046. * @param uint8array The binary file stored in an array buffer.
  128047. * @param hdrInfo The header information of the file.
  128048. * @return The pixels data in RGB right to left up to down order.
  128049. */
  128050. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  128051. private static RGBE_ReadPixels_RLE;
  128052. }
  128053. }
  128054. declare module BABYLON {
  128055. /**
  128056. * This represents a texture coming from an HDR input.
  128057. *
  128058. * The only supported format is currently panorama picture stored in RGBE format.
  128059. * Example of such files can be found on HDRLib: http://hdrlib.com/
  128060. */
  128061. export class HDRCubeTexture extends BaseTexture {
  128062. private static _facesMapping;
  128063. private _generateHarmonics;
  128064. private _noMipmap;
  128065. private _textureMatrix;
  128066. private _size;
  128067. private _onLoad;
  128068. private _onError;
  128069. /**
  128070. * The texture URL.
  128071. */
  128072. url: string;
  128073. /**
  128074. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  128075. */
  128076. coordinatesMode: number;
  128077. protected _isBlocking: boolean;
  128078. /**
  128079. * Sets wether or not the texture is blocking during loading.
  128080. */
  128081. set isBlocking(value: boolean);
  128082. /**
  128083. * Gets wether or not the texture is blocking during loading.
  128084. */
  128085. get isBlocking(): boolean;
  128086. protected _rotationY: number;
  128087. /**
  128088. * Sets texture matrix rotation angle around Y axis in radians.
  128089. */
  128090. set rotationY(value: number);
  128091. /**
  128092. * Gets texture matrix rotation angle around Y axis radians.
  128093. */
  128094. get rotationY(): number;
  128095. /**
  128096. * Gets or sets the center of the bounding box associated with the cube texture
  128097. * It must define where the camera used to render the texture was set
  128098. */
  128099. boundingBoxPosition: Vector3;
  128100. private _boundingBoxSize;
  128101. /**
  128102. * Gets or sets the size of the bounding box associated with the cube texture
  128103. * When defined, the cubemap will switch to local mode
  128104. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128105. * @example https://www.babylonjs-playground.com/#RNASML
  128106. */
  128107. set boundingBoxSize(value: Vector3);
  128108. get boundingBoxSize(): Vector3;
  128109. /**
  128110. * Instantiates an HDRTexture from the following parameters.
  128111. *
  128112. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128113. * @param scene The scene the texture will be used in
  128114. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128115. * @param noMipmap Forces to not generate the mipmap if true
  128116. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128117. * @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)
  128118. * @param reserved Reserved flag for internal use.
  128119. */
  128120. 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>);
  128121. /**
  128122. * Get the current class name of the texture useful for serialization or dynamic coding.
  128123. * @returns "HDRCubeTexture"
  128124. */
  128125. getClassName(): string;
  128126. /**
  128127. * Occurs when the file is raw .hdr file.
  128128. */
  128129. private loadTexture;
  128130. clone(): HDRCubeTexture;
  128131. delayLoad(): void;
  128132. /**
  128133. * Get the texture reflection matrix used to rotate/transform the reflection.
  128134. * @returns the reflection matrix
  128135. */
  128136. getReflectionTextureMatrix(): Matrix;
  128137. /**
  128138. * Set the texture reflection matrix used to rotate/transform the reflection.
  128139. * @param value Define the reflection matrix to set
  128140. */
  128141. setReflectionTextureMatrix(value: Matrix): void;
  128142. /**
  128143. * Parses a JSON representation of an HDR Texture in order to create the texture
  128144. * @param parsedTexture Define the JSON representation
  128145. * @param scene Define the scene the texture should be created in
  128146. * @param rootUrl Define the root url in case we need to load relative dependencies
  128147. * @returns the newly created texture after parsing
  128148. */
  128149. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128150. serialize(): any;
  128151. }
  128152. }
  128153. declare module BABYLON {
  128154. /**
  128155. * Class used to control physics engine
  128156. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128157. */
  128158. export class PhysicsEngine implements IPhysicsEngine {
  128159. private _physicsPlugin;
  128160. /**
  128161. * Global value used to control the smallest number supported by the simulation
  128162. */
  128163. static Epsilon: number;
  128164. private _impostors;
  128165. private _joints;
  128166. private _subTimeStep;
  128167. /**
  128168. * Gets the gravity vector used by the simulation
  128169. */
  128170. gravity: Vector3;
  128171. /**
  128172. * Factory used to create the default physics plugin.
  128173. * @returns The default physics plugin
  128174. */
  128175. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128176. /**
  128177. * Creates a new Physics Engine
  128178. * @param gravity defines the gravity vector used by the simulation
  128179. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128180. */
  128181. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128182. /**
  128183. * Sets the gravity vector used by the simulation
  128184. * @param gravity defines the gravity vector to use
  128185. */
  128186. setGravity(gravity: Vector3): void;
  128187. /**
  128188. * Set the time step of the physics engine.
  128189. * Default is 1/60.
  128190. * To slow it down, enter 1/600 for example.
  128191. * To speed it up, 1/30
  128192. * @param newTimeStep defines the new timestep to apply to this world.
  128193. */
  128194. setTimeStep(newTimeStep?: number): void;
  128195. /**
  128196. * Get the time step of the physics engine.
  128197. * @returns the current time step
  128198. */
  128199. getTimeStep(): number;
  128200. /**
  128201. * Set the sub time step of the physics engine.
  128202. * Default is 0 meaning there is no sub steps
  128203. * To increase physics resolution precision, set a small value (like 1 ms)
  128204. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128205. */
  128206. setSubTimeStep(subTimeStep?: number): void;
  128207. /**
  128208. * Get the sub time step of the physics engine.
  128209. * @returns the current sub time step
  128210. */
  128211. getSubTimeStep(): number;
  128212. /**
  128213. * Release all resources
  128214. */
  128215. dispose(): void;
  128216. /**
  128217. * Gets the name of the current physics plugin
  128218. * @returns the name of the plugin
  128219. */
  128220. getPhysicsPluginName(): string;
  128221. /**
  128222. * Adding a new impostor for the impostor tracking.
  128223. * This will be done by the impostor itself.
  128224. * @param impostor the impostor to add
  128225. */
  128226. addImpostor(impostor: PhysicsImpostor): void;
  128227. /**
  128228. * Remove an impostor from the engine.
  128229. * This impostor and its mesh will not longer be updated by the physics engine.
  128230. * @param impostor the impostor to remove
  128231. */
  128232. removeImpostor(impostor: PhysicsImpostor): void;
  128233. /**
  128234. * Add a joint to the physics engine
  128235. * @param mainImpostor defines the main impostor to which the joint is added.
  128236. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128237. * @param joint defines the joint that will connect both impostors.
  128238. */
  128239. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128240. /**
  128241. * Removes a joint from the simulation
  128242. * @param mainImpostor defines the impostor used with the joint
  128243. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128244. * @param joint defines the joint to remove
  128245. */
  128246. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128247. /**
  128248. * Called by the scene. No need to call it.
  128249. * @param delta defines the timespam between frames
  128250. */
  128251. _step(delta: number): void;
  128252. /**
  128253. * Gets the current plugin used to run the simulation
  128254. * @returns current plugin
  128255. */
  128256. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128257. /**
  128258. * Gets the list of physic impostors
  128259. * @returns an array of PhysicsImpostor
  128260. */
  128261. getImpostors(): Array<PhysicsImpostor>;
  128262. /**
  128263. * Gets the impostor for a physics enabled object
  128264. * @param object defines the object impersonated by the impostor
  128265. * @returns the PhysicsImpostor or null if not found
  128266. */
  128267. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128268. /**
  128269. * Gets the impostor for a physics body object
  128270. * @param body defines physics body used by the impostor
  128271. * @returns the PhysicsImpostor or null if not found
  128272. */
  128273. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128274. /**
  128275. * Does a raycast in the physics world
  128276. * @param from when should the ray start?
  128277. * @param to when should the ray end?
  128278. * @returns PhysicsRaycastResult
  128279. */
  128280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128281. }
  128282. }
  128283. declare module BABYLON {
  128284. /** @hidden */
  128285. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128286. private _useDeltaForWorldStep;
  128287. world: any;
  128288. name: string;
  128289. private _physicsMaterials;
  128290. private _fixedTimeStep;
  128291. private _cannonRaycastResult;
  128292. private _raycastResult;
  128293. private _physicsBodysToRemoveAfterStep;
  128294. BJSCANNON: any;
  128295. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128296. setGravity(gravity: Vector3): void;
  128297. setTimeStep(timeStep: number): void;
  128298. getTimeStep(): number;
  128299. executeStep(delta: number): void;
  128300. private _removeMarkedPhysicsBodiesFromWorld;
  128301. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128302. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128303. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128304. private _processChildMeshes;
  128305. removePhysicsBody(impostor: PhysicsImpostor): void;
  128306. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128307. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128308. private _addMaterial;
  128309. private _checkWithEpsilon;
  128310. private _createShape;
  128311. private _createHeightmap;
  128312. private _minus90X;
  128313. private _plus90X;
  128314. private _tmpPosition;
  128315. private _tmpDeltaPosition;
  128316. private _tmpUnityRotation;
  128317. private _updatePhysicsBodyTransformation;
  128318. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128319. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128320. isSupported(): boolean;
  128321. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128322. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128323. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128324. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128325. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128326. getBodyMass(impostor: PhysicsImpostor): number;
  128327. getBodyFriction(impostor: PhysicsImpostor): number;
  128328. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128329. getBodyRestitution(impostor: PhysicsImpostor): number;
  128330. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128331. sleepBody(impostor: PhysicsImpostor): void;
  128332. wakeUpBody(impostor: PhysicsImpostor): void;
  128333. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128334. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128335. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128336. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128337. getRadius(impostor: PhysicsImpostor): number;
  128338. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128339. dispose(): void;
  128340. private _extendNamespace;
  128341. /**
  128342. * Does a raycast in the physics world
  128343. * @param from when should the ray start?
  128344. * @param to when should the ray end?
  128345. * @returns PhysicsRaycastResult
  128346. */
  128347. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128348. }
  128349. }
  128350. declare module BABYLON {
  128351. /** @hidden */
  128352. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128353. world: any;
  128354. name: string;
  128355. BJSOIMO: any;
  128356. private _raycastResult;
  128357. constructor(iterations?: number, oimoInjection?: any);
  128358. setGravity(gravity: Vector3): void;
  128359. setTimeStep(timeStep: number): void;
  128360. getTimeStep(): number;
  128361. private _tmpImpostorsArray;
  128362. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128363. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128364. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128365. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128366. private _tmpPositionVector;
  128367. removePhysicsBody(impostor: PhysicsImpostor): void;
  128368. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128369. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128370. isSupported(): boolean;
  128371. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128372. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128373. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128374. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128375. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128376. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128377. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128378. getBodyMass(impostor: PhysicsImpostor): number;
  128379. getBodyFriction(impostor: PhysicsImpostor): number;
  128380. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128381. getBodyRestitution(impostor: PhysicsImpostor): number;
  128382. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128383. sleepBody(impostor: PhysicsImpostor): void;
  128384. wakeUpBody(impostor: PhysicsImpostor): void;
  128385. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128386. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128387. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128388. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128389. getRadius(impostor: PhysicsImpostor): number;
  128390. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128391. dispose(): void;
  128392. /**
  128393. * Does a raycast in the physics world
  128394. * @param from when should the ray start?
  128395. * @param to when should the ray end?
  128396. * @returns PhysicsRaycastResult
  128397. */
  128398. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128399. }
  128400. }
  128401. declare module BABYLON {
  128402. /**
  128403. * Class containing static functions to help procedurally build meshes
  128404. */
  128405. export class RibbonBuilder {
  128406. /**
  128407. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128408. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128409. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128410. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128411. * * 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
  128412. * * 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
  128413. * * 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
  128414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128417. * * 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
  128418. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128419. * * 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
  128420. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128422. * @param name defines the name of the mesh
  128423. * @param options defines the options used to create the mesh
  128424. * @param scene defines the hosting scene
  128425. * @returns the ribbon mesh
  128426. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128428. */
  128429. static CreateRibbon(name: string, options: {
  128430. pathArray: Vector3[][];
  128431. closeArray?: boolean;
  128432. closePath?: boolean;
  128433. offset?: number;
  128434. updatable?: boolean;
  128435. sideOrientation?: number;
  128436. frontUVs?: Vector4;
  128437. backUVs?: Vector4;
  128438. instance?: Mesh;
  128439. invertUV?: boolean;
  128440. uvs?: Vector2[];
  128441. colors?: Color4[];
  128442. }, scene?: Nullable<Scene>): Mesh;
  128443. }
  128444. }
  128445. declare module BABYLON {
  128446. /**
  128447. * Class containing static functions to help procedurally build meshes
  128448. */
  128449. export class ShapeBuilder {
  128450. /**
  128451. * 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.
  128452. * * 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.
  128453. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128454. * * 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.
  128455. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128456. * * 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
  128457. * * 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
  128458. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128463. * @param name defines the name of the mesh
  128464. * @param options defines the options used to create the mesh
  128465. * @param scene defines the hosting scene
  128466. * @returns the extruded shape mesh
  128467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128469. */
  128470. static ExtrudeShape(name: string, options: {
  128471. shape: Vector3[];
  128472. path: Vector3[];
  128473. scale?: number;
  128474. rotation?: number;
  128475. cap?: number;
  128476. updatable?: boolean;
  128477. sideOrientation?: number;
  128478. frontUVs?: Vector4;
  128479. backUVs?: Vector4;
  128480. instance?: Mesh;
  128481. invertUV?: boolean;
  128482. }, scene?: Nullable<Scene>): Mesh;
  128483. /**
  128484. * Creates an custom extruded shape mesh.
  128485. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128486. * * 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.
  128487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128488. * * 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
  128489. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128490. * * 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
  128491. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128492. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128493. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128494. * * 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
  128495. * * 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
  128496. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128501. * @param name defines the name of the mesh
  128502. * @param options defines the options used to create the mesh
  128503. * @param scene defines the hosting scene
  128504. * @returns the custom extruded shape mesh
  128505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128506. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128508. */
  128509. static ExtrudeShapeCustom(name: string, options: {
  128510. shape: Vector3[];
  128511. path: Vector3[];
  128512. scaleFunction?: any;
  128513. rotationFunction?: any;
  128514. ribbonCloseArray?: boolean;
  128515. ribbonClosePath?: boolean;
  128516. cap?: number;
  128517. updatable?: boolean;
  128518. sideOrientation?: number;
  128519. frontUVs?: Vector4;
  128520. backUVs?: Vector4;
  128521. instance?: Mesh;
  128522. invertUV?: boolean;
  128523. }, scene?: Nullable<Scene>): Mesh;
  128524. private static _ExtrudeShapeGeneric;
  128525. }
  128526. }
  128527. declare module BABYLON {
  128528. /**
  128529. * AmmoJS Physics plugin
  128530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128531. * @see https://github.com/kripken/ammo.js/
  128532. */
  128533. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128534. private _useDeltaForWorldStep;
  128535. /**
  128536. * Reference to the Ammo library
  128537. */
  128538. bjsAMMO: any;
  128539. /**
  128540. * Created ammoJS world which physics bodies are added to
  128541. */
  128542. world: any;
  128543. /**
  128544. * Name of the plugin
  128545. */
  128546. name: string;
  128547. private _timeStep;
  128548. private _fixedTimeStep;
  128549. private _maxSteps;
  128550. private _tmpQuaternion;
  128551. private _tmpAmmoTransform;
  128552. private _tmpAmmoQuaternion;
  128553. private _tmpAmmoConcreteContactResultCallback;
  128554. private _collisionConfiguration;
  128555. private _dispatcher;
  128556. private _overlappingPairCache;
  128557. private _solver;
  128558. private _softBodySolver;
  128559. private _tmpAmmoVectorA;
  128560. private _tmpAmmoVectorB;
  128561. private _tmpAmmoVectorC;
  128562. private _tmpAmmoVectorD;
  128563. private _tmpContactCallbackResult;
  128564. private _tmpAmmoVectorRCA;
  128565. private _tmpAmmoVectorRCB;
  128566. private _raycastResult;
  128567. private static readonly DISABLE_COLLISION_FLAG;
  128568. private static readonly KINEMATIC_FLAG;
  128569. private static readonly DISABLE_DEACTIVATION_FLAG;
  128570. /**
  128571. * Initializes the ammoJS plugin
  128572. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128573. * @param ammoInjection can be used to inject your own ammo reference
  128574. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128575. */
  128576. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128577. /**
  128578. * Sets the gravity of the physics world (m/(s^2))
  128579. * @param gravity Gravity to set
  128580. */
  128581. setGravity(gravity: Vector3): void;
  128582. /**
  128583. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128584. * @param timeStep timestep to use in seconds
  128585. */
  128586. setTimeStep(timeStep: number): void;
  128587. /**
  128588. * 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)
  128589. * @param fixedTimeStep fixedTimeStep to use in seconds
  128590. */
  128591. setFixedTimeStep(fixedTimeStep: number): void;
  128592. /**
  128593. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128594. * @param maxSteps the maximum number of steps by the physics engine per frame
  128595. */
  128596. setMaxSteps(maxSteps: number): void;
  128597. /**
  128598. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128599. * @returns the current timestep in seconds
  128600. */
  128601. getTimeStep(): number;
  128602. /**
  128603. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128604. */
  128605. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128606. private _isImpostorInContact;
  128607. private _isImpostorPairInContact;
  128608. private _stepSimulation;
  128609. /**
  128610. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128611. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128612. * After the step the babylon meshes are set to the position of the physics imposters
  128613. * @param delta amount of time to step forward
  128614. * @param impostors array of imposters to update before/after the step
  128615. */
  128616. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128617. /**
  128618. * Update babylon mesh to match physics world object
  128619. * @param impostor imposter to match
  128620. */
  128621. private _afterSoftStep;
  128622. /**
  128623. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128624. * @param impostor imposter to match
  128625. */
  128626. private _ropeStep;
  128627. /**
  128628. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128629. * @param impostor imposter to match
  128630. */
  128631. private _softbodyOrClothStep;
  128632. private _tmpVector;
  128633. private _tmpMatrix;
  128634. /**
  128635. * Applies an impulse on the imposter
  128636. * @param impostor imposter to apply impulse to
  128637. * @param force amount of force to be applied to the imposter
  128638. * @param contactPoint the location to apply the impulse on the imposter
  128639. */
  128640. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128641. /**
  128642. * Applies a force on the imposter
  128643. * @param impostor imposter to apply force
  128644. * @param force amount of force to be applied to the imposter
  128645. * @param contactPoint the location to apply the force on the imposter
  128646. */
  128647. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128648. /**
  128649. * Creates a physics body using the plugin
  128650. * @param impostor the imposter to create the physics body on
  128651. */
  128652. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128653. /**
  128654. * Removes the physics body from the imposter and disposes of the body's memory
  128655. * @param impostor imposter to remove the physics body from
  128656. */
  128657. removePhysicsBody(impostor: PhysicsImpostor): void;
  128658. /**
  128659. * Generates a joint
  128660. * @param impostorJoint the imposter joint to create the joint with
  128661. */
  128662. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128663. /**
  128664. * Removes a joint
  128665. * @param impostorJoint the imposter joint to remove the joint from
  128666. */
  128667. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128668. private _addMeshVerts;
  128669. /**
  128670. * Initialise the soft body vertices to match its object's (mesh) vertices
  128671. * Softbody vertices (nodes) are in world space and to match this
  128672. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128673. * @param impostor to create the softbody for
  128674. */
  128675. private _softVertexData;
  128676. /**
  128677. * Create an impostor's soft body
  128678. * @param impostor to create the softbody for
  128679. */
  128680. private _createSoftbody;
  128681. /**
  128682. * Create cloth for an impostor
  128683. * @param impostor to create the softbody for
  128684. */
  128685. private _createCloth;
  128686. /**
  128687. * Create rope for an impostor
  128688. * @param impostor to create the softbody for
  128689. */
  128690. private _createRope;
  128691. /**
  128692. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128693. * @param impostor to create the custom physics shape for
  128694. */
  128695. private _createCustom;
  128696. private _addHullVerts;
  128697. private _createShape;
  128698. /**
  128699. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128700. * @param impostor imposter containing the physics body and babylon object
  128701. */
  128702. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128703. /**
  128704. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128705. * @param impostor imposter containing the physics body and babylon object
  128706. * @param newPosition new position
  128707. * @param newRotation new rotation
  128708. */
  128709. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128710. /**
  128711. * If this plugin is supported
  128712. * @returns true if its supported
  128713. */
  128714. isSupported(): boolean;
  128715. /**
  128716. * Sets the linear velocity of the physics body
  128717. * @param impostor imposter to set the velocity on
  128718. * @param velocity velocity to set
  128719. */
  128720. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128721. /**
  128722. * Sets the angular velocity of the physics body
  128723. * @param impostor imposter to set the velocity on
  128724. * @param velocity velocity to set
  128725. */
  128726. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128727. /**
  128728. * gets the linear velocity
  128729. * @param impostor imposter to get linear velocity from
  128730. * @returns linear velocity
  128731. */
  128732. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128733. /**
  128734. * gets the angular velocity
  128735. * @param impostor imposter to get angular velocity from
  128736. * @returns angular velocity
  128737. */
  128738. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128739. /**
  128740. * Sets the mass of physics body
  128741. * @param impostor imposter to set the mass on
  128742. * @param mass mass to set
  128743. */
  128744. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128745. /**
  128746. * Gets the mass of the physics body
  128747. * @param impostor imposter to get the mass from
  128748. * @returns mass
  128749. */
  128750. getBodyMass(impostor: PhysicsImpostor): number;
  128751. /**
  128752. * Gets friction of the impostor
  128753. * @param impostor impostor to get friction from
  128754. * @returns friction value
  128755. */
  128756. getBodyFriction(impostor: PhysicsImpostor): number;
  128757. /**
  128758. * Sets friction of the impostor
  128759. * @param impostor impostor to set friction on
  128760. * @param friction friction value
  128761. */
  128762. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128763. /**
  128764. * Gets restitution of the impostor
  128765. * @param impostor impostor to get restitution from
  128766. * @returns restitution value
  128767. */
  128768. getBodyRestitution(impostor: PhysicsImpostor): number;
  128769. /**
  128770. * Sets resitution of the impostor
  128771. * @param impostor impostor to set resitution on
  128772. * @param restitution resitution value
  128773. */
  128774. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128775. /**
  128776. * Gets pressure inside the impostor
  128777. * @param impostor impostor to get pressure from
  128778. * @returns pressure value
  128779. */
  128780. getBodyPressure(impostor: PhysicsImpostor): number;
  128781. /**
  128782. * Sets pressure inside a soft body impostor
  128783. * Cloth and rope must remain 0 pressure
  128784. * @param impostor impostor to set pressure on
  128785. * @param pressure pressure value
  128786. */
  128787. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128788. /**
  128789. * Gets stiffness of the impostor
  128790. * @param impostor impostor to get stiffness from
  128791. * @returns pressure value
  128792. */
  128793. getBodyStiffness(impostor: PhysicsImpostor): number;
  128794. /**
  128795. * Sets stiffness of the impostor
  128796. * @param impostor impostor to set stiffness on
  128797. * @param stiffness stiffness value from 0 to 1
  128798. */
  128799. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128800. /**
  128801. * Gets velocityIterations of the impostor
  128802. * @param impostor impostor to get velocity iterations from
  128803. * @returns velocityIterations value
  128804. */
  128805. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128806. /**
  128807. * Sets velocityIterations of the impostor
  128808. * @param impostor impostor to set velocity iterations on
  128809. * @param velocityIterations velocityIterations value
  128810. */
  128811. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128812. /**
  128813. * Gets positionIterations of the impostor
  128814. * @param impostor impostor to get position iterations from
  128815. * @returns positionIterations value
  128816. */
  128817. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128818. /**
  128819. * Sets positionIterations of the impostor
  128820. * @param impostor impostor to set position on
  128821. * @param positionIterations positionIterations value
  128822. */
  128823. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128824. /**
  128825. * Append an anchor to a cloth object
  128826. * @param impostor is the cloth impostor to add anchor to
  128827. * @param otherImpostor is the rigid impostor to anchor to
  128828. * @param width ratio across width from 0 to 1
  128829. * @param height ratio up height from 0 to 1
  128830. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128831. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128832. */
  128833. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128834. /**
  128835. * Append an hook to a rope object
  128836. * @param impostor is the rope impostor to add hook to
  128837. * @param otherImpostor is the rigid impostor to hook to
  128838. * @param length ratio along the rope from 0 to 1
  128839. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128840. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128841. */
  128842. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128843. /**
  128844. * Sleeps the physics body and stops it from being active
  128845. * @param impostor impostor to sleep
  128846. */
  128847. sleepBody(impostor: PhysicsImpostor): void;
  128848. /**
  128849. * Activates the physics body
  128850. * @param impostor impostor to activate
  128851. */
  128852. wakeUpBody(impostor: PhysicsImpostor): void;
  128853. /**
  128854. * Updates the distance parameters of the joint
  128855. * @param joint joint to update
  128856. * @param maxDistance maximum distance of the joint
  128857. * @param minDistance minimum distance of the joint
  128858. */
  128859. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128860. /**
  128861. * Sets a motor on the joint
  128862. * @param joint joint to set motor on
  128863. * @param speed speed of the motor
  128864. * @param maxForce maximum force of the motor
  128865. * @param motorIndex index of the motor
  128866. */
  128867. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128868. /**
  128869. * Sets the motors limit
  128870. * @param joint joint to set limit on
  128871. * @param upperLimit upper limit
  128872. * @param lowerLimit lower limit
  128873. */
  128874. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128875. /**
  128876. * Syncs the position and rotation of a mesh with the impostor
  128877. * @param mesh mesh to sync
  128878. * @param impostor impostor to update the mesh with
  128879. */
  128880. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128881. /**
  128882. * Gets the radius of the impostor
  128883. * @param impostor impostor to get radius from
  128884. * @returns the radius
  128885. */
  128886. getRadius(impostor: PhysicsImpostor): number;
  128887. /**
  128888. * Gets the box size of the impostor
  128889. * @param impostor impostor to get box size from
  128890. * @param result the resulting box size
  128891. */
  128892. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128893. /**
  128894. * Disposes of the impostor
  128895. */
  128896. dispose(): void;
  128897. /**
  128898. * Does a raycast in the physics world
  128899. * @param from when should the ray start?
  128900. * @param to when should the ray end?
  128901. * @returns PhysicsRaycastResult
  128902. */
  128903. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128904. }
  128905. }
  128906. declare module BABYLON {
  128907. interface AbstractScene {
  128908. /**
  128909. * The list of reflection probes added to the scene
  128910. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128911. */
  128912. reflectionProbes: Array<ReflectionProbe>;
  128913. /**
  128914. * Removes the given reflection probe from this scene.
  128915. * @param toRemove The reflection probe to remove
  128916. * @returns The index of the removed reflection probe
  128917. */
  128918. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128919. /**
  128920. * Adds the given reflection probe to this scene.
  128921. * @param newReflectionProbe The reflection probe to add
  128922. */
  128923. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128924. }
  128925. /**
  128926. * Class used to generate realtime reflection / refraction cube textures
  128927. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128928. */
  128929. export class ReflectionProbe {
  128930. /** defines the name of the probe */
  128931. name: string;
  128932. private _scene;
  128933. private _renderTargetTexture;
  128934. private _projectionMatrix;
  128935. private _viewMatrix;
  128936. private _target;
  128937. private _add;
  128938. private _attachedMesh;
  128939. private _invertYAxis;
  128940. /** Gets or sets probe position (center of the cube map) */
  128941. position: Vector3;
  128942. /**
  128943. * Creates a new reflection probe
  128944. * @param name defines the name of the probe
  128945. * @param size defines the texture resolution (for each face)
  128946. * @param scene defines the hosting scene
  128947. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128948. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128949. */
  128950. constructor(
  128951. /** defines the name of the probe */
  128952. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128953. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128954. get samples(): number;
  128955. set samples(value: number);
  128956. /** Gets or sets the refresh rate to use (on every frame by default) */
  128957. get refreshRate(): number;
  128958. set refreshRate(value: number);
  128959. /**
  128960. * Gets the hosting scene
  128961. * @returns a Scene
  128962. */
  128963. getScene(): Scene;
  128964. /** Gets the internal CubeTexture used to render to */
  128965. get cubeTexture(): RenderTargetTexture;
  128966. /** Gets the list of meshes to render */
  128967. get renderList(): Nullable<AbstractMesh[]>;
  128968. /**
  128969. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128970. * @param mesh defines the mesh to attach to
  128971. */
  128972. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128973. /**
  128974. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128975. * @param renderingGroupId The rendering group id corresponding to its index
  128976. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128977. */
  128978. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128979. /**
  128980. * Clean all associated resources
  128981. */
  128982. dispose(): void;
  128983. /**
  128984. * Converts the reflection probe information to a readable string for debug purpose.
  128985. * @param fullDetails Supports for multiple levels of logging within scene loading
  128986. * @returns the human readable reflection probe info
  128987. */
  128988. toString(fullDetails?: boolean): string;
  128989. /**
  128990. * Get the class name of the relfection probe.
  128991. * @returns "ReflectionProbe"
  128992. */
  128993. getClassName(): string;
  128994. /**
  128995. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128996. * @returns The JSON representation of the texture
  128997. */
  128998. serialize(): any;
  128999. /**
  129000. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  129001. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  129002. * @param scene Define the scene the parsed reflection probe should be instantiated in
  129003. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  129004. * @returns The parsed reflection probe if successful
  129005. */
  129006. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  129007. }
  129008. }
  129009. declare module BABYLON {
  129010. /** @hidden */
  129011. export var _BabylonLoaderRegistered: boolean;
  129012. /**
  129013. * Helps setting up some configuration for the babylon file loader.
  129014. */
  129015. export class BabylonFileLoaderConfiguration {
  129016. /**
  129017. * The loader does not allow injecting custom physix engine into the plugins.
  129018. * Unfortunately in ES6, we need to manually inject them into the plugin.
  129019. * So you could set this variable to your engine import to make it work.
  129020. */
  129021. static LoaderInjectedPhysicsEngine: any;
  129022. }
  129023. }
  129024. declare module BABYLON {
  129025. /**
  129026. * The Physically based simple base material of BJS.
  129027. *
  129028. * This enables better naming and convention enforcements on top of the pbrMaterial.
  129029. * It is used as the base class for both the specGloss and metalRough conventions.
  129030. */
  129031. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  129032. /**
  129033. * Number of Simultaneous lights allowed on the material.
  129034. */
  129035. maxSimultaneousLights: number;
  129036. /**
  129037. * If sets to true, disables all the lights affecting the material.
  129038. */
  129039. disableLighting: boolean;
  129040. /**
  129041. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  129042. */
  129043. environmentTexture: BaseTexture;
  129044. /**
  129045. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  129046. */
  129047. invertNormalMapX: boolean;
  129048. /**
  129049. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  129050. */
  129051. invertNormalMapY: boolean;
  129052. /**
  129053. * Normal map used in the model.
  129054. */
  129055. normalTexture: BaseTexture;
  129056. /**
  129057. * Emissivie color used to self-illuminate the model.
  129058. */
  129059. emissiveColor: Color3;
  129060. /**
  129061. * Emissivie texture used to self-illuminate the model.
  129062. */
  129063. emissiveTexture: BaseTexture;
  129064. /**
  129065. * Occlusion Channel Strenght.
  129066. */
  129067. occlusionStrength: number;
  129068. /**
  129069. * Occlusion Texture of the material (adding extra occlusion effects).
  129070. */
  129071. occlusionTexture: BaseTexture;
  129072. /**
  129073. * Defines the alpha limits in alpha test mode.
  129074. */
  129075. alphaCutOff: number;
  129076. /**
  129077. * Gets the current double sided mode.
  129078. */
  129079. get doubleSided(): boolean;
  129080. /**
  129081. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  129082. */
  129083. set doubleSided(value: boolean);
  129084. /**
  129085. * Stores the pre-calculated light information of a mesh in a texture.
  129086. */
  129087. lightmapTexture: BaseTexture;
  129088. /**
  129089. * If true, the light map contains occlusion information instead of lighting info.
  129090. */
  129091. useLightmapAsShadowmap: boolean;
  129092. /**
  129093. * Instantiates a new PBRMaterial instance.
  129094. *
  129095. * @param name The material name
  129096. * @param scene The scene the material will be use in.
  129097. */
  129098. constructor(name: string, scene: Scene);
  129099. getClassName(): string;
  129100. }
  129101. }
  129102. declare module BABYLON {
  129103. /**
  129104. * The PBR material of BJS following the metal roughness convention.
  129105. *
  129106. * This fits to the PBR convention in the GLTF definition:
  129107. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129108. */
  129109. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129110. /**
  129111. * The base color has two different interpretations depending on the value of metalness.
  129112. * When the material is a metal, the base color is the specific measured reflectance value
  129113. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129114. * of the material.
  129115. */
  129116. baseColor: Color3;
  129117. /**
  129118. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129119. * well as opacity information in the alpha channel.
  129120. */
  129121. baseTexture: BaseTexture;
  129122. /**
  129123. * Specifies the metallic scalar value of the material.
  129124. * Can also be used to scale the metalness values of the metallic texture.
  129125. */
  129126. metallic: number;
  129127. /**
  129128. * Specifies the roughness scalar value of the material.
  129129. * Can also be used to scale the roughness values of the metallic texture.
  129130. */
  129131. roughness: number;
  129132. /**
  129133. * Texture containing both the metallic value in the B channel and the
  129134. * roughness value in the G channel to keep better precision.
  129135. */
  129136. metallicRoughnessTexture: BaseTexture;
  129137. /**
  129138. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129139. *
  129140. * @param name The material name
  129141. * @param scene The scene the material will be use in.
  129142. */
  129143. constructor(name: string, scene: Scene);
  129144. /**
  129145. * Return the currrent class name of the material.
  129146. */
  129147. getClassName(): string;
  129148. /**
  129149. * Makes a duplicate of the current material.
  129150. * @param name - name to use for the new material.
  129151. */
  129152. clone(name: string): PBRMetallicRoughnessMaterial;
  129153. /**
  129154. * Serialize the material to a parsable JSON object.
  129155. */
  129156. serialize(): any;
  129157. /**
  129158. * Parses a JSON object correponding to the serialize function.
  129159. */
  129160. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129161. }
  129162. }
  129163. declare module BABYLON {
  129164. /**
  129165. * The PBR material of BJS following the specular glossiness convention.
  129166. *
  129167. * This fits to the PBR convention in the GLTF definition:
  129168. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129169. */
  129170. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129171. /**
  129172. * Specifies the diffuse color of the material.
  129173. */
  129174. diffuseColor: Color3;
  129175. /**
  129176. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129177. * channel.
  129178. */
  129179. diffuseTexture: BaseTexture;
  129180. /**
  129181. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129182. */
  129183. specularColor: Color3;
  129184. /**
  129185. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129186. */
  129187. glossiness: number;
  129188. /**
  129189. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129190. */
  129191. specularGlossinessTexture: BaseTexture;
  129192. /**
  129193. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129194. *
  129195. * @param name The material name
  129196. * @param scene The scene the material will be use in.
  129197. */
  129198. constructor(name: string, scene: Scene);
  129199. /**
  129200. * Return the currrent class name of the material.
  129201. */
  129202. getClassName(): string;
  129203. /**
  129204. * Makes a duplicate of the current material.
  129205. * @param name - name to use for the new material.
  129206. */
  129207. clone(name: string): PBRSpecularGlossinessMaterial;
  129208. /**
  129209. * Serialize the material to a parsable JSON object.
  129210. */
  129211. serialize(): any;
  129212. /**
  129213. * Parses a JSON object correponding to the serialize function.
  129214. */
  129215. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129216. }
  129217. }
  129218. declare module BABYLON {
  129219. /**
  129220. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129221. * It can help converting any input color in a desired output one. This can then be used to create effects
  129222. * from sepia, black and white to sixties or futuristic rendering...
  129223. *
  129224. * The only supported format is currently 3dl.
  129225. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129226. */
  129227. export class ColorGradingTexture extends BaseTexture {
  129228. /**
  129229. * The current texture matrix. (will always be identity in color grading texture)
  129230. */
  129231. private _textureMatrix;
  129232. /**
  129233. * The texture URL.
  129234. */
  129235. url: string;
  129236. /**
  129237. * Empty line regex stored for GC.
  129238. */
  129239. private static _noneEmptyLineRegex;
  129240. private _engine;
  129241. /**
  129242. * Instantiates a ColorGradingTexture from the following parameters.
  129243. *
  129244. * @param url The location of the color gradind data (currently only supporting 3dl)
  129245. * @param scene The scene the texture will be used in
  129246. */
  129247. constructor(url: string, scene: Scene);
  129248. /**
  129249. * Returns the texture matrix used in most of the material.
  129250. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129251. */
  129252. getTextureMatrix(): Matrix;
  129253. /**
  129254. * Occurs when the file being loaded is a .3dl LUT file.
  129255. */
  129256. private load3dlTexture;
  129257. /**
  129258. * Starts the loading process of the texture.
  129259. */
  129260. private loadTexture;
  129261. /**
  129262. * Clones the color gradind texture.
  129263. */
  129264. clone(): ColorGradingTexture;
  129265. /**
  129266. * Called during delayed load for textures.
  129267. */
  129268. delayLoad(): void;
  129269. /**
  129270. * Parses a color grading texture serialized by Babylon.
  129271. * @param parsedTexture The texture information being parsedTexture
  129272. * @param scene The scene to load the texture in
  129273. * @param rootUrl The root url of the data assets to load
  129274. * @return A color gradind texture
  129275. */
  129276. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129277. /**
  129278. * Serializes the LUT texture to json format.
  129279. */
  129280. serialize(): any;
  129281. }
  129282. }
  129283. declare module BABYLON {
  129284. /**
  129285. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129286. */
  129287. export class EquiRectangularCubeTexture extends BaseTexture {
  129288. /** The six faces of the cube. */
  129289. private static _FacesMapping;
  129290. private _noMipmap;
  129291. private _onLoad;
  129292. private _onError;
  129293. /** The size of the cubemap. */
  129294. private _size;
  129295. /** The buffer of the image. */
  129296. private _buffer;
  129297. /** The width of the input image. */
  129298. private _width;
  129299. /** The height of the input image. */
  129300. private _height;
  129301. /** The URL to the image. */
  129302. url: string;
  129303. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129304. coordinatesMode: number;
  129305. /**
  129306. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129307. * @param url The location of the image
  129308. * @param scene The scene the texture will be used in
  129309. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129310. * @param noMipmap Forces to not generate the mipmap if true
  129311. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129312. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129313. * @param onLoad — defines a callback called when texture is loaded
  129314. * @param onError — defines a callback called if there is an error
  129315. */
  129316. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129317. /**
  129318. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129319. */
  129320. private loadImage;
  129321. /**
  129322. * Convert the image buffer into a cubemap and create a CubeTexture.
  129323. */
  129324. private loadTexture;
  129325. /**
  129326. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129327. * @param buffer The ArrayBuffer that should be converted.
  129328. * @returns The buffer as Float32Array.
  129329. */
  129330. private getFloat32ArrayFromArrayBuffer;
  129331. /**
  129332. * Get the current class name of the texture useful for serialization or dynamic coding.
  129333. * @returns "EquiRectangularCubeTexture"
  129334. */
  129335. getClassName(): string;
  129336. /**
  129337. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129338. * @returns A clone of the current EquiRectangularCubeTexture.
  129339. */
  129340. clone(): EquiRectangularCubeTexture;
  129341. }
  129342. }
  129343. declare module BABYLON {
  129344. /**
  129345. * Based on jsTGALoader - Javascript loader for TGA file
  129346. * By Vincent Thibault
  129347. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129348. */
  129349. export class TGATools {
  129350. private static _TYPE_INDEXED;
  129351. private static _TYPE_RGB;
  129352. private static _TYPE_GREY;
  129353. private static _TYPE_RLE_INDEXED;
  129354. private static _TYPE_RLE_RGB;
  129355. private static _TYPE_RLE_GREY;
  129356. private static _ORIGIN_MASK;
  129357. private static _ORIGIN_SHIFT;
  129358. private static _ORIGIN_BL;
  129359. private static _ORIGIN_BR;
  129360. private static _ORIGIN_UL;
  129361. private static _ORIGIN_UR;
  129362. /**
  129363. * Gets the header of a TGA file
  129364. * @param data defines the TGA data
  129365. * @returns the header
  129366. */
  129367. static GetTGAHeader(data: Uint8Array): any;
  129368. /**
  129369. * Uploads TGA content to a Babylon Texture
  129370. * @hidden
  129371. */
  129372. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129373. /** @hidden */
  129374. 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;
  129375. /** @hidden */
  129376. 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;
  129377. /** @hidden */
  129378. 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;
  129379. /** @hidden */
  129380. 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;
  129381. /** @hidden */
  129382. 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;
  129383. /** @hidden */
  129384. 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;
  129385. }
  129386. }
  129387. declare module BABYLON {
  129388. /**
  129389. * Implementation of the TGA Texture Loader.
  129390. * @hidden
  129391. */
  129392. export class _TGATextureLoader implements IInternalTextureLoader {
  129393. /**
  129394. * Defines wether the loader supports cascade loading the different faces.
  129395. */
  129396. readonly supportCascades: boolean;
  129397. /**
  129398. * This returns if the loader support the current file information.
  129399. * @param extension defines the file extension of the file being loaded
  129400. * @returns true if the loader can load the specified file
  129401. */
  129402. canLoad(extension: string): boolean;
  129403. /**
  129404. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129405. * @param data contains the texture data
  129406. * @param texture defines the BabylonJS internal texture
  129407. * @param createPolynomials will be true if polynomials have been requested
  129408. * @param onLoad defines the callback to trigger once the texture is ready
  129409. * @param onError defines the callback to trigger in case of error
  129410. */
  129411. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129412. /**
  129413. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129414. * @param data contains the texture data
  129415. * @param texture defines the BabylonJS internal texture
  129416. * @param callback defines the method to call once ready to upload
  129417. */
  129418. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129419. }
  129420. }
  129421. declare module BABYLON {
  129422. /**
  129423. * Info about the .basis files
  129424. */
  129425. class BasisFileInfo {
  129426. /**
  129427. * If the file has alpha
  129428. */
  129429. hasAlpha: boolean;
  129430. /**
  129431. * Info about each image of the basis file
  129432. */
  129433. images: Array<{
  129434. levels: Array<{
  129435. width: number;
  129436. height: number;
  129437. transcodedPixels: ArrayBufferView;
  129438. }>;
  129439. }>;
  129440. }
  129441. /**
  129442. * Result of transcoding a basis file
  129443. */
  129444. class TranscodeResult {
  129445. /**
  129446. * Info about the .basis file
  129447. */
  129448. fileInfo: BasisFileInfo;
  129449. /**
  129450. * Format to use when loading the file
  129451. */
  129452. format: number;
  129453. }
  129454. /**
  129455. * Configuration options for the Basis transcoder
  129456. */
  129457. export class BasisTranscodeConfiguration {
  129458. /**
  129459. * Supported compression formats used to determine the supported output format of the transcoder
  129460. */
  129461. supportedCompressionFormats?: {
  129462. /**
  129463. * etc1 compression format
  129464. */
  129465. etc1?: boolean;
  129466. /**
  129467. * s3tc compression format
  129468. */
  129469. s3tc?: boolean;
  129470. /**
  129471. * pvrtc compression format
  129472. */
  129473. pvrtc?: boolean;
  129474. /**
  129475. * etc2 compression format
  129476. */
  129477. etc2?: boolean;
  129478. };
  129479. /**
  129480. * If mipmap levels should be loaded for transcoded images (Default: true)
  129481. */
  129482. loadMipmapLevels?: boolean;
  129483. /**
  129484. * Index of a single image to load (Default: all images)
  129485. */
  129486. loadSingleImage?: number;
  129487. }
  129488. /**
  129489. * Used to load .Basis files
  129490. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129491. */
  129492. export class BasisTools {
  129493. private static _IgnoreSupportedFormats;
  129494. /**
  129495. * URL to use when loading the basis transcoder
  129496. */
  129497. static JSModuleURL: string;
  129498. /**
  129499. * URL to use when loading the wasm module for the transcoder
  129500. */
  129501. static WasmModuleURL: string;
  129502. /**
  129503. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129504. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129505. * @returns internal format corresponding to the Basis format
  129506. */
  129507. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129508. private static _WorkerPromise;
  129509. private static _Worker;
  129510. private static _actionId;
  129511. private static _CreateWorkerAsync;
  129512. /**
  129513. * Transcodes a loaded image file to compressed pixel data
  129514. * @param data image data to transcode
  129515. * @param config configuration options for the transcoding
  129516. * @returns a promise resulting in the transcoded image
  129517. */
  129518. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129519. /**
  129520. * Loads a texture from the transcode result
  129521. * @param texture texture load to
  129522. * @param transcodeResult the result of transcoding the basis file to load from
  129523. */
  129524. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129525. }
  129526. }
  129527. declare module BABYLON {
  129528. /**
  129529. * Loader for .basis file format
  129530. */
  129531. export class _BasisTextureLoader implements IInternalTextureLoader {
  129532. /**
  129533. * Defines whether the loader supports cascade loading the different faces.
  129534. */
  129535. readonly supportCascades: boolean;
  129536. /**
  129537. * This returns if the loader support the current file information.
  129538. * @param extension defines the file extension of the file being loaded
  129539. * @returns true if the loader can load the specified file
  129540. */
  129541. canLoad(extension: string): boolean;
  129542. /**
  129543. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129544. * @param data contains the texture data
  129545. * @param texture defines the BabylonJS internal texture
  129546. * @param createPolynomials will be true if polynomials have been requested
  129547. * @param onLoad defines the callback to trigger once the texture is ready
  129548. * @param onError defines the callback to trigger in case of error
  129549. */
  129550. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129551. /**
  129552. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129553. * @param data contains the texture data
  129554. * @param texture defines the BabylonJS internal texture
  129555. * @param callback defines the method to call once ready to upload
  129556. */
  129557. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129558. }
  129559. }
  129560. declare module BABYLON {
  129561. /**
  129562. * 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.
  129563. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129564. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129565. */
  129566. export class CustomProceduralTexture extends ProceduralTexture {
  129567. private _animate;
  129568. private _time;
  129569. private _config;
  129570. private _texturePath;
  129571. /**
  129572. * Instantiates a new Custom Procedural Texture.
  129573. * 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.
  129574. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129575. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129576. * @param name Define the name of the texture
  129577. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129578. * @param size Define the size of the texture to create
  129579. * @param scene Define the scene the texture belongs to
  129580. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129581. * @param generateMipMaps Define if the texture should creates mip maps or not
  129582. */
  129583. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129584. private _loadJson;
  129585. /**
  129586. * Is the texture ready to be used ? (rendered at least once)
  129587. * @returns true if ready, otherwise, false.
  129588. */
  129589. isReady(): boolean;
  129590. /**
  129591. * Render the texture to its associated render target.
  129592. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129593. */
  129594. render(useCameraPostProcess?: boolean): void;
  129595. /**
  129596. * Update the list of dependant textures samplers in the shader.
  129597. */
  129598. updateTextures(): void;
  129599. /**
  129600. * Update the uniform values of the procedural texture in the shader.
  129601. */
  129602. updateShaderUniforms(): void;
  129603. /**
  129604. * Define if the texture animates or not.
  129605. */
  129606. get animate(): boolean;
  129607. set animate(value: boolean);
  129608. }
  129609. }
  129610. declare module BABYLON {
  129611. /** @hidden */
  129612. export var noisePixelShader: {
  129613. name: string;
  129614. shader: string;
  129615. };
  129616. }
  129617. declare module BABYLON {
  129618. /**
  129619. * Class used to generate noise procedural textures
  129620. */
  129621. export class NoiseProceduralTexture extends ProceduralTexture {
  129622. private _time;
  129623. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129624. brightness: number;
  129625. /** Defines the number of octaves to process */
  129626. octaves: number;
  129627. /** Defines the level of persistence (0.8 by default) */
  129628. persistence: number;
  129629. /** Gets or sets animation speed factor (default is 1) */
  129630. animationSpeedFactor: number;
  129631. /**
  129632. * Creates a new NoiseProceduralTexture
  129633. * @param name defines the name fo the texture
  129634. * @param size defines the size of the texture (default is 256)
  129635. * @param scene defines the hosting scene
  129636. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129637. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129638. */
  129639. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129640. private _updateShaderUniforms;
  129641. protected _getDefines(): string;
  129642. /** Generate the current state of the procedural texture */
  129643. render(useCameraPostProcess?: boolean): void;
  129644. /**
  129645. * Serializes this noise procedural texture
  129646. * @returns a serialized noise procedural texture object
  129647. */
  129648. serialize(): any;
  129649. /**
  129650. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129651. * @param parsedTexture defines parsed texture data
  129652. * @param scene defines the current scene
  129653. * @param rootUrl defines the root URL containing noise procedural texture information
  129654. * @returns a parsed NoiseProceduralTexture
  129655. */
  129656. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129657. }
  129658. }
  129659. declare module BABYLON {
  129660. /**
  129661. * Raw cube texture where the raw buffers are passed in
  129662. */
  129663. export class RawCubeTexture extends CubeTexture {
  129664. /**
  129665. * Creates a cube texture where the raw buffers are passed in.
  129666. * @param scene defines the scene the texture is attached to
  129667. * @param data defines the array of data to use to create each face
  129668. * @param size defines the size of the textures
  129669. * @param format defines the format of the data
  129670. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129671. * @param generateMipMaps defines if the engine should generate the mip levels
  129672. * @param invertY defines if data must be stored with Y axis inverted
  129673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129674. * @param compression defines the compression used (null by default)
  129675. */
  129676. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129677. /**
  129678. * Updates the raw cube texture.
  129679. * @param data defines the data to store
  129680. * @param format defines the data format
  129681. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129682. * @param invertY defines if data must be stored with Y axis inverted
  129683. * @param compression defines the compression used (null by default)
  129684. * @param level defines which level of the texture to update
  129685. */
  129686. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129687. /**
  129688. * Updates a raw cube texture with RGBD encoded data.
  129689. * @param data defines the array of data [mipmap][face] to use to create each face
  129690. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129691. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129692. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129693. * @returns a promsie that resolves when the operation is complete
  129694. */
  129695. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129696. /**
  129697. * Clones the raw cube texture.
  129698. * @return a new cube texture
  129699. */
  129700. clone(): CubeTexture;
  129701. /** @hidden */
  129702. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129703. }
  129704. }
  129705. declare module BABYLON {
  129706. /**
  129707. * Class used to store 3D textures containing user data
  129708. */
  129709. export class RawTexture3D extends Texture {
  129710. /** Gets or sets the texture format to use */
  129711. format: number;
  129712. private _engine;
  129713. /**
  129714. * Create a new RawTexture3D
  129715. * @param data defines the data of the texture
  129716. * @param width defines the width of the texture
  129717. * @param height defines the height of the texture
  129718. * @param depth defines the depth of the texture
  129719. * @param format defines the texture format to use
  129720. * @param scene defines the hosting scene
  129721. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129722. * @param invertY defines if texture must be stored with Y axis inverted
  129723. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129724. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129725. */
  129726. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129727. /** Gets or sets the texture format to use */
  129728. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129729. /**
  129730. * Update the texture with new data
  129731. * @param data defines the data to store in the texture
  129732. */
  129733. update(data: ArrayBufferView): void;
  129734. }
  129735. }
  129736. declare module BABYLON {
  129737. /**
  129738. * Class used to store 2D array textures containing user data
  129739. */
  129740. export class RawTexture2DArray extends Texture {
  129741. /** Gets or sets the texture format to use */
  129742. format: number;
  129743. private _engine;
  129744. /**
  129745. * Create a new RawTexture2DArray
  129746. * @param data defines the data of the texture
  129747. * @param width defines the width of the texture
  129748. * @param height defines the height of the texture
  129749. * @param depth defines the number of layers of the texture
  129750. * @param format defines the texture format to use
  129751. * @param scene defines the hosting scene
  129752. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129753. * @param invertY defines if texture must be stored with Y axis inverted
  129754. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129755. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129756. */
  129757. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129758. /** Gets or sets the texture format to use */
  129759. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129760. /**
  129761. * Update the texture with new data
  129762. * @param data defines the data to store in the texture
  129763. */
  129764. update(data: ArrayBufferView): void;
  129765. }
  129766. }
  129767. declare module BABYLON {
  129768. /**
  129769. * Creates a refraction texture used by refraction channel of the standard material.
  129770. * It is like a mirror but to see through a material.
  129771. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129772. */
  129773. export class RefractionTexture extends RenderTargetTexture {
  129774. /**
  129775. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129776. * 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.
  129777. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129778. */
  129779. refractionPlane: Plane;
  129780. /**
  129781. * Define how deep under the surface we should see.
  129782. */
  129783. depth: number;
  129784. /**
  129785. * Creates a refraction texture used by refraction channel of the standard material.
  129786. * It is like a mirror but to see through a material.
  129787. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129788. * @param name Define the texture name
  129789. * @param size Define the size of the underlying texture
  129790. * @param scene Define the scene the refraction belongs to
  129791. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129792. */
  129793. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129794. /**
  129795. * Clone the refraction texture.
  129796. * @returns the cloned texture
  129797. */
  129798. clone(): RefractionTexture;
  129799. /**
  129800. * Serialize the texture to a JSON representation you could use in Parse later on
  129801. * @returns the serialized JSON representation
  129802. */
  129803. serialize(): any;
  129804. }
  129805. }
  129806. declare module BABYLON {
  129807. /**
  129808. * Defines the options related to the creation of an HtmlElementTexture
  129809. */
  129810. export interface IHtmlElementTextureOptions {
  129811. /**
  129812. * Defines wether mip maps should be created or not.
  129813. */
  129814. generateMipMaps?: boolean;
  129815. /**
  129816. * Defines the sampling mode of the texture.
  129817. */
  129818. samplingMode?: number;
  129819. /**
  129820. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129821. */
  129822. engine: Nullable<ThinEngine>;
  129823. /**
  129824. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129825. */
  129826. scene: Nullable<Scene>;
  129827. }
  129828. /**
  129829. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129830. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129831. * is automatically managed.
  129832. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129833. * in your application.
  129834. *
  129835. * As the update is not automatic, you need to call them manually.
  129836. */
  129837. export class HtmlElementTexture extends BaseTexture {
  129838. /**
  129839. * The texture URL.
  129840. */
  129841. element: HTMLVideoElement | HTMLCanvasElement;
  129842. private static readonly DefaultOptions;
  129843. private _textureMatrix;
  129844. private _engine;
  129845. private _isVideo;
  129846. private _generateMipMaps;
  129847. private _samplingMode;
  129848. /**
  129849. * Instantiates a HtmlElementTexture from the following parameters.
  129850. *
  129851. * @param name Defines the name of the texture
  129852. * @param element Defines the video or canvas the texture is filled with
  129853. * @param options Defines the other none mandatory texture creation options
  129854. */
  129855. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129856. private _createInternalTexture;
  129857. /**
  129858. * Returns the texture matrix used in most of the material.
  129859. */
  129860. getTextureMatrix(): Matrix;
  129861. /**
  129862. * Updates the content of the texture.
  129863. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129864. */
  129865. update(invertY?: Nullable<boolean>): void;
  129866. }
  129867. }
  129868. declare module BABYLON {
  129869. /**
  129870. * Defines the basic options interface of a TexturePacker Frame
  129871. */
  129872. export interface ITexturePackerFrame {
  129873. /**
  129874. * The frame ID
  129875. */
  129876. id: number;
  129877. /**
  129878. * The frames Scale
  129879. */
  129880. scale: Vector2;
  129881. /**
  129882. * The Frames offset
  129883. */
  129884. offset: Vector2;
  129885. }
  129886. /**
  129887. * This is a support class for frame Data on texture packer sets.
  129888. */
  129889. export class TexturePackerFrame implements ITexturePackerFrame {
  129890. /**
  129891. * The frame ID
  129892. */
  129893. id: number;
  129894. /**
  129895. * The frames Scale
  129896. */
  129897. scale: Vector2;
  129898. /**
  129899. * The Frames offset
  129900. */
  129901. offset: Vector2;
  129902. /**
  129903. * Initializes a texture package frame.
  129904. * @param id The numerical frame identifier
  129905. * @param scale Scalar Vector2 for UV frame
  129906. * @param offset Vector2 for the frame position in UV units.
  129907. * @returns TexturePackerFrame
  129908. */
  129909. constructor(id: number, scale: Vector2, offset: Vector2);
  129910. }
  129911. }
  129912. declare module BABYLON {
  129913. /**
  129914. * Defines the basic options interface of a TexturePacker
  129915. */
  129916. export interface ITexturePackerOptions {
  129917. /**
  129918. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129919. */
  129920. map?: string[];
  129921. /**
  129922. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129923. */
  129924. uvsIn?: string;
  129925. /**
  129926. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129927. */
  129928. uvsOut?: string;
  129929. /**
  129930. * number representing the layout style. Defaults to LAYOUT_STRIP
  129931. */
  129932. layout?: number;
  129933. /**
  129934. * number of columns if using custom column count layout(2). This defaults to 4.
  129935. */
  129936. colnum?: number;
  129937. /**
  129938. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129939. */
  129940. updateInputMeshes?: boolean;
  129941. /**
  129942. * boolean flag to dispose all the source textures. Defaults to true.
  129943. */
  129944. disposeSources?: boolean;
  129945. /**
  129946. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129947. */
  129948. fillBlanks?: boolean;
  129949. /**
  129950. * string value representing the context fill style color. Defaults to 'black'.
  129951. */
  129952. customFillColor?: string;
  129953. /**
  129954. * Width and Height Value of each Frame in the TexturePacker Sets
  129955. */
  129956. frameSize?: number;
  129957. /**
  129958. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129959. */
  129960. paddingRatio?: number;
  129961. /**
  129962. * Number that declares the fill method for the padding gutter.
  129963. */
  129964. paddingMode?: number;
  129965. /**
  129966. * If in SUBUV_COLOR padding mode what color to use.
  129967. */
  129968. paddingColor?: Color3 | Color4;
  129969. }
  129970. /**
  129971. * Defines the basic interface of a TexturePacker JSON File
  129972. */
  129973. export interface ITexturePackerJSON {
  129974. /**
  129975. * The frame ID
  129976. */
  129977. name: string;
  129978. /**
  129979. * The base64 channel data
  129980. */
  129981. sets: any;
  129982. /**
  129983. * The options of the Packer
  129984. */
  129985. options: ITexturePackerOptions;
  129986. /**
  129987. * The frame data of the Packer
  129988. */
  129989. frames: Array<number>;
  129990. }
  129991. /**
  129992. * This is a support class that generates a series of packed texture sets.
  129993. * @see https://doc.babylonjs.com/babylon101/materials
  129994. */
  129995. export class TexturePacker {
  129996. /** Packer Layout Constant 0 */
  129997. static readonly LAYOUT_STRIP: number;
  129998. /** Packer Layout Constant 1 */
  129999. static readonly LAYOUT_POWER2: number;
  130000. /** Packer Layout Constant 2 */
  130001. static readonly LAYOUT_COLNUM: number;
  130002. /** Packer Layout Constant 0 */
  130003. static readonly SUBUV_WRAP: number;
  130004. /** Packer Layout Constant 1 */
  130005. static readonly SUBUV_EXTEND: number;
  130006. /** Packer Layout Constant 2 */
  130007. static readonly SUBUV_COLOR: number;
  130008. /** The Name of the Texture Package */
  130009. name: string;
  130010. /** The scene scope of the TexturePacker */
  130011. scene: Scene;
  130012. /** The Meshes to target */
  130013. meshes: AbstractMesh[];
  130014. /** Arguments passed with the Constructor */
  130015. options: ITexturePackerOptions;
  130016. /** The promise that is started upon initialization */
  130017. promise: Nullable<Promise<TexturePacker | string>>;
  130018. /** The Container object for the channel sets that are generated */
  130019. sets: object;
  130020. /** The Container array for the frames that are generated */
  130021. frames: TexturePackerFrame[];
  130022. /** The expected number of textures the system is parsing. */
  130023. private _expecting;
  130024. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  130025. private _paddingValue;
  130026. /**
  130027. * Initializes a texture package series from an array of meshes or a single mesh.
  130028. * @param name The name of the package
  130029. * @param meshes The target meshes to compose the package from
  130030. * @param options The arguments that texture packer should follow while building.
  130031. * @param scene The scene which the textures are scoped to.
  130032. * @returns TexturePacker
  130033. */
  130034. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  130035. /**
  130036. * Starts the package process
  130037. * @param resolve The promises resolution function
  130038. * @returns TexturePacker
  130039. */
  130040. private _createFrames;
  130041. /**
  130042. * Calculates the Size of the Channel Sets
  130043. * @returns Vector2
  130044. */
  130045. private _calculateSize;
  130046. /**
  130047. * Calculates the UV data for the frames.
  130048. * @param baseSize the base frameSize
  130049. * @param padding the base frame padding
  130050. * @param dtSize size of the Dynamic Texture for that channel
  130051. * @param dtUnits is 1/dtSize
  130052. * @param update flag to update the input meshes
  130053. */
  130054. private _calculateMeshUVFrames;
  130055. /**
  130056. * Calculates the frames Offset.
  130057. * @param index of the frame
  130058. * @returns Vector2
  130059. */
  130060. private _getFrameOffset;
  130061. /**
  130062. * Updates a Mesh to the frame data
  130063. * @param mesh that is the target
  130064. * @param frameID or the frame index
  130065. */
  130066. private _updateMeshUV;
  130067. /**
  130068. * Updates a Meshes materials to use the texture packer channels
  130069. * @param m is the mesh to target
  130070. * @param force all channels on the packer to be set.
  130071. */
  130072. private _updateTextureReferences;
  130073. /**
  130074. * Public method to set a Mesh to a frame
  130075. * @param m that is the target
  130076. * @param frameID or the frame index
  130077. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130078. */
  130079. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130080. /**
  130081. * Starts the async promise to compile the texture packer.
  130082. * @returns Promise<void>
  130083. */
  130084. processAsync(): Promise<void>;
  130085. /**
  130086. * Disposes all textures associated with this packer
  130087. */
  130088. dispose(): void;
  130089. /**
  130090. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130091. * @param imageType is the image type to use.
  130092. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130093. */
  130094. download(imageType?: string, quality?: number): void;
  130095. /**
  130096. * Public method to load a texturePacker JSON file.
  130097. * @param data of the JSON file in string format.
  130098. */
  130099. updateFromJSON(data: string): void;
  130100. }
  130101. }
  130102. declare module BABYLON {
  130103. /**
  130104. * Enum used to define the target of a block
  130105. */
  130106. export enum NodeMaterialBlockTargets {
  130107. /** Vertex shader */
  130108. Vertex = 1,
  130109. /** Fragment shader */
  130110. Fragment = 2,
  130111. /** Neutral */
  130112. Neutral = 4,
  130113. /** Vertex and Fragment */
  130114. VertexAndFragment = 3
  130115. }
  130116. }
  130117. declare module BABYLON {
  130118. /**
  130119. * Defines the kind of connection point for node based material
  130120. */
  130121. export enum NodeMaterialBlockConnectionPointTypes {
  130122. /** Float */
  130123. Float = 1,
  130124. /** Int */
  130125. Int = 2,
  130126. /** Vector2 */
  130127. Vector2 = 4,
  130128. /** Vector3 */
  130129. Vector3 = 8,
  130130. /** Vector4 */
  130131. Vector4 = 16,
  130132. /** Color3 */
  130133. Color3 = 32,
  130134. /** Color4 */
  130135. Color4 = 64,
  130136. /** Matrix */
  130137. Matrix = 128,
  130138. /** Detect type based on connection */
  130139. AutoDetect = 1024,
  130140. /** Output type that will be defined by input type */
  130141. BasedOnInput = 2048
  130142. }
  130143. }
  130144. declare module BABYLON {
  130145. /**
  130146. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130147. */
  130148. export enum NodeMaterialBlockConnectionPointMode {
  130149. /** Value is an uniform */
  130150. Uniform = 0,
  130151. /** Value is a mesh attribute */
  130152. Attribute = 1,
  130153. /** Value is a varying between vertex and fragment shaders */
  130154. Varying = 2,
  130155. /** Mode is undefined */
  130156. Undefined = 3
  130157. }
  130158. }
  130159. declare module BABYLON {
  130160. /**
  130161. * Enum used to define system values e.g. values automatically provided by the system
  130162. */
  130163. export enum NodeMaterialSystemValues {
  130164. /** World */
  130165. World = 1,
  130166. /** View */
  130167. View = 2,
  130168. /** Projection */
  130169. Projection = 3,
  130170. /** ViewProjection */
  130171. ViewProjection = 4,
  130172. /** WorldView */
  130173. WorldView = 5,
  130174. /** WorldViewProjection */
  130175. WorldViewProjection = 6,
  130176. /** CameraPosition */
  130177. CameraPosition = 7,
  130178. /** Fog Color */
  130179. FogColor = 8,
  130180. /** Delta time */
  130181. DeltaTime = 9
  130182. }
  130183. }
  130184. declare module BABYLON {
  130185. /**
  130186. * Root class for all node material optimizers
  130187. */
  130188. export class NodeMaterialOptimizer {
  130189. /**
  130190. * Function used to optimize a NodeMaterial graph
  130191. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130192. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130193. */
  130194. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130195. }
  130196. }
  130197. declare module BABYLON {
  130198. /**
  130199. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130200. */
  130201. export class TransformBlock extends NodeMaterialBlock {
  130202. /**
  130203. * Defines the value to use to complement W value to transform it to a Vector4
  130204. */
  130205. complementW: number;
  130206. /**
  130207. * Defines the value to use to complement z value to transform it to a Vector4
  130208. */
  130209. complementZ: number;
  130210. /**
  130211. * Creates a new TransformBlock
  130212. * @param name defines the block name
  130213. */
  130214. constructor(name: string);
  130215. /**
  130216. * Gets the current class name
  130217. * @returns the class name
  130218. */
  130219. getClassName(): string;
  130220. /**
  130221. * Gets the vector input
  130222. */
  130223. get vector(): NodeMaterialConnectionPoint;
  130224. /**
  130225. * Gets the output component
  130226. */
  130227. get output(): NodeMaterialConnectionPoint;
  130228. /**
  130229. * Gets the xyz output component
  130230. */
  130231. get xyz(): NodeMaterialConnectionPoint;
  130232. /**
  130233. * Gets the matrix transform input
  130234. */
  130235. get transform(): NodeMaterialConnectionPoint;
  130236. protected _buildBlock(state: NodeMaterialBuildState): this;
  130237. serialize(): any;
  130238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130239. protected _dumpPropertiesCode(): string;
  130240. }
  130241. }
  130242. declare module BABYLON {
  130243. /**
  130244. * Block used to output the vertex position
  130245. */
  130246. export class VertexOutputBlock extends NodeMaterialBlock {
  130247. /**
  130248. * Creates a new VertexOutputBlock
  130249. * @param name defines the block name
  130250. */
  130251. constructor(name: string);
  130252. /**
  130253. * Gets the current class name
  130254. * @returns the class name
  130255. */
  130256. getClassName(): string;
  130257. /**
  130258. * Gets the vector input component
  130259. */
  130260. get vector(): NodeMaterialConnectionPoint;
  130261. protected _buildBlock(state: NodeMaterialBuildState): this;
  130262. }
  130263. }
  130264. declare module BABYLON {
  130265. /**
  130266. * Block used to output the final color
  130267. */
  130268. export class FragmentOutputBlock extends NodeMaterialBlock {
  130269. /**
  130270. * Create a new FragmentOutputBlock
  130271. * @param name defines the block name
  130272. */
  130273. constructor(name: string);
  130274. /**
  130275. * Gets the current class name
  130276. * @returns the class name
  130277. */
  130278. getClassName(): string;
  130279. /**
  130280. * Gets the rgba input component
  130281. */
  130282. get rgba(): NodeMaterialConnectionPoint;
  130283. /**
  130284. * Gets the rgb input component
  130285. */
  130286. get rgb(): NodeMaterialConnectionPoint;
  130287. /**
  130288. * Gets the a input component
  130289. */
  130290. get a(): NodeMaterialConnectionPoint;
  130291. protected _buildBlock(state: NodeMaterialBuildState): this;
  130292. }
  130293. }
  130294. declare module BABYLON {
  130295. /**
  130296. * Block used to read a reflection texture from a sampler
  130297. */
  130298. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130299. private _define3DName;
  130300. private _defineCubicName;
  130301. private _defineExplicitName;
  130302. private _defineProjectionName;
  130303. private _defineLocalCubicName;
  130304. private _defineSphericalName;
  130305. private _definePlanarName;
  130306. private _defineEquirectangularName;
  130307. private _defineMirroredEquirectangularFixedName;
  130308. private _defineEquirectangularFixedName;
  130309. private _defineSkyboxName;
  130310. private _cubeSamplerName;
  130311. private _2DSamplerName;
  130312. private _positionUVWName;
  130313. private _directionWName;
  130314. private _reflectionCoordsName;
  130315. private _reflection2DCoordsName;
  130316. private _reflectionColorName;
  130317. private _reflectionMatrixName;
  130318. /**
  130319. * Gets or sets the texture associated with the node
  130320. */
  130321. texture: Nullable<BaseTexture>;
  130322. /**
  130323. * Create a new TextureBlock
  130324. * @param name defines the block name
  130325. */
  130326. constructor(name: string);
  130327. /**
  130328. * Gets the current class name
  130329. * @returns the class name
  130330. */
  130331. getClassName(): string;
  130332. /**
  130333. * Gets the world position input component
  130334. */
  130335. get position(): NodeMaterialConnectionPoint;
  130336. /**
  130337. * Gets the world position input component
  130338. */
  130339. get worldPosition(): NodeMaterialConnectionPoint;
  130340. /**
  130341. * Gets the world normal input component
  130342. */
  130343. get worldNormal(): NodeMaterialConnectionPoint;
  130344. /**
  130345. * Gets the world input component
  130346. */
  130347. get world(): NodeMaterialConnectionPoint;
  130348. /**
  130349. * Gets the camera (or eye) position component
  130350. */
  130351. get cameraPosition(): NodeMaterialConnectionPoint;
  130352. /**
  130353. * Gets the view input component
  130354. */
  130355. get view(): NodeMaterialConnectionPoint;
  130356. /**
  130357. * Gets the rgb output component
  130358. */
  130359. get rgb(): NodeMaterialConnectionPoint;
  130360. /**
  130361. * Gets the r output component
  130362. */
  130363. get r(): NodeMaterialConnectionPoint;
  130364. /**
  130365. * Gets the g output component
  130366. */
  130367. get g(): NodeMaterialConnectionPoint;
  130368. /**
  130369. * Gets the b output component
  130370. */
  130371. get b(): NodeMaterialConnectionPoint;
  130372. autoConfigure(material: NodeMaterial): void;
  130373. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130374. isReady(): boolean;
  130375. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130376. private _injectVertexCode;
  130377. private _writeOutput;
  130378. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130379. protected _dumpPropertiesCode(): string;
  130380. serialize(): any;
  130381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130382. }
  130383. }
  130384. declare module BABYLON {
  130385. /**
  130386. * Interface used to configure the node material editor
  130387. */
  130388. export interface INodeMaterialEditorOptions {
  130389. /** Define the URl to load node editor script */
  130390. editorURL?: string;
  130391. }
  130392. /** @hidden */
  130393. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130394. NORMAL: boolean;
  130395. TANGENT: boolean;
  130396. UV1: boolean;
  130397. /** BONES */
  130398. NUM_BONE_INFLUENCERS: number;
  130399. BonesPerMesh: number;
  130400. BONETEXTURE: boolean;
  130401. /** MORPH TARGETS */
  130402. MORPHTARGETS: boolean;
  130403. MORPHTARGETS_NORMAL: boolean;
  130404. MORPHTARGETS_TANGENT: boolean;
  130405. MORPHTARGETS_UV: boolean;
  130406. NUM_MORPH_INFLUENCERS: number;
  130407. /** IMAGE PROCESSING */
  130408. IMAGEPROCESSING: boolean;
  130409. VIGNETTE: boolean;
  130410. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130411. VIGNETTEBLENDMODEOPAQUE: boolean;
  130412. TONEMAPPING: boolean;
  130413. TONEMAPPING_ACES: boolean;
  130414. CONTRAST: boolean;
  130415. EXPOSURE: boolean;
  130416. COLORCURVES: boolean;
  130417. COLORGRADING: boolean;
  130418. COLORGRADING3D: boolean;
  130419. SAMPLER3DGREENDEPTH: boolean;
  130420. SAMPLER3DBGRMAP: boolean;
  130421. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130422. /** MISC. */
  130423. BUMPDIRECTUV: number;
  130424. constructor();
  130425. setValue(name: string, value: boolean): void;
  130426. }
  130427. /**
  130428. * Class used to configure NodeMaterial
  130429. */
  130430. export interface INodeMaterialOptions {
  130431. /**
  130432. * Defines if blocks should emit comments
  130433. */
  130434. emitComments: boolean;
  130435. }
  130436. /**
  130437. * Class used to create a node based material built by assembling shader blocks
  130438. */
  130439. export class NodeMaterial extends PushMaterial {
  130440. private static _BuildIdGenerator;
  130441. private _options;
  130442. private _vertexCompilationState;
  130443. private _fragmentCompilationState;
  130444. private _sharedData;
  130445. private _buildId;
  130446. private _buildWasSuccessful;
  130447. private _cachedWorldViewMatrix;
  130448. private _cachedWorldViewProjectionMatrix;
  130449. private _optimizers;
  130450. private _animationFrame;
  130451. /** Define the Url to load node editor script */
  130452. static EditorURL: string;
  130453. /** Define the Url to load snippets */
  130454. static SnippetUrl: string;
  130455. private BJSNODEMATERIALEDITOR;
  130456. /** Get the inspector from bundle or global */
  130457. private _getGlobalNodeMaterialEditor;
  130458. /**
  130459. * Gets or sets data used by visual editor
  130460. * @see https://nme.babylonjs.com
  130461. */
  130462. editorData: any;
  130463. /**
  130464. * 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)
  130465. */
  130466. ignoreAlpha: boolean;
  130467. /**
  130468. * Defines the maximum number of lights that can be used in the material
  130469. */
  130470. maxSimultaneousLights: number;
  130471. /**
  130472. * Observable raised when the material is built
  130473. */
  130474. onBuildObservable: Observable<NodeMaterial>;
  130475. /**
  130476. * Gets or sets the root nodes of the material vertex shader
  130477. */
  130478. _vertexOutputNodes: NodeMaterialBlock[];
  130479. /**
  130480. * Gets or sets the root nodes of the material fragment (pixel) shader
  130481. */
  130482. _fragmentOutputNodes: NodeMaterialBlock[];
  130483. /** Gets or sets options to control the node material overall behavior */
  130484. get options(): INodeMaterialOptions;
  130485. set options(options: INodeMaterialOptions);
  130486. /**
  130487. * Default configuration related to image processing available in the standard Material.
  130488. */
  130489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130490. /**
  130491. * Gets the image processing configuration used either in this material.
  130492. */
  130493. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130494. /**
  130495. * Sets the Default image processing configuration used either in the this material.
  130496. *
  130497. * If sets to null, the scene one is in use.
  130498. */
  130499. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130500. /**
  130501. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130502. */
  130503. attachedBlocks: NodeMaterialBlock[];
  130504. /**
  130505. * Create a new node based material
  130506. * @param name defines the material name
  130507. * @param scene defines the hosting scene
  130508. * @param options defines creation option
  130509. */
  130510. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130511. /**
  130512. * Gets the current class name of the material e.g. "NodeMaterial"
  130513. * @returns the class name
  130514. */
  130515. getClassName(): string;
  130516. /**
  130517. * Keep track of the image processing observer to allow dispose and replace.
  130518. */
  130519. private _imageProcessingObserver;
  130520. /**
  130521. * Attaches a new image processing configuration to the Standard Material.
  130522. * @param configuration
  130523. */
  130524. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130525. /**
  130526. * Get a block by its name
  130527. * @param name defines the name of the block to retrieve
  130528. * @returns the required block or null if not found
  130529. */
  130530. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130531. /**
  130532. * Get a block by its name
  130533. * @param predicate defines the predicate used to find the good candidate
  130534. * @returns the required block or null if not found
  130535. */
  130536. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130537. /**
  130538. * Get an input block by its name
  130539. * @param predicate defines the predicate used to find the good candidate
  130540. * @returns the required input block or null if not found
  130541. */
  130542. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130543. /**
  130544. * Gets the list of input blocks attached to this material
  130545. * @returns an array of InputBlocks
  130546. */
  130547. getInputBlocks(): InputBlock[];
  130548. /**
  130549. * Adds a new optimizer to the list of optimizers
  130550. * @param optimizer defines the optimizers to add
  130551. * @returns the current material
  130552. */
  130553. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130554. /**
  130555. * Remove an optimizer from the list of optimizers
  130556. * @param optimizer defines the optimizers to remove
  130557. * @returns the current material
  130558. */
  130559. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130560. /**
  130561. * Add a new block to the list of output nodes
  130562. * @param node defines the node to add
  130563. * @returns the current material
  130564. */
  130565. addOutputNode(node: NodeMaterialBlock): this;
  130566. /**
  130567. * Remove a block from the list of root nodes
  130568. * @param node defines the node to remove
  130569. * @returns the current material
  130570. */
  130571. removeOutputNode(node: NodeMaterialBlock): this;
  130572. private _addVertexOutputNode;
  130573. private _removeVertexOutputNode;
  130574. private _addFragmentOutputNode;
  130575. private _removeFragmentOutputNode;
  130576. /**
  130577. * Specifies if the material will require alpha blending
  130578. * @returns a boolean specifying if alpha blending is needed
  130579. */
  130580. needAlphaBlending(): boolean;
  130581. /**
  130582. * Specifies if this material should be rendered in alpha test mode
  130583. * @returns a boolean specifying if an alpha test is needed.
  130584. */
  130585. needAlphaTesting(): boolean;
  130586. private _initializeBlock;
  130587. private _resetDualBlocks;
  130588. /**
  130589. * Remove a block from the current node material
  130590. * @param block defines the block to remove
  130591. */
  130592. removeBlock(block: NodeMaterialBlock): void;
  130593. /**
  130594. * Build the material and generates the inner effect
  130595. * @param verbose defines if the build should log activity
  130596. */
  130597. build(verbose?: boolean): void;
  130598. /**
  130599. * Runs an otpimization phase to try to improve the shader code
  130600. */
  130601. optimize(): void;
  130602. private _prepareDefinesForAttributes;
  130603. /**
  130604. * Get if the submesh is ready to be used and all its information available.
  130605. * Child classes can use it to update shaders
  130606. * @param mesh defines the mesh to check
  130607. * @param subMesh defines which submesh to check
  130608. * @param useInstances specifies that instances should be used
  130609. * @returns a boolean indicating that the submesh is ready or not
  130610. */
  130611. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130612. /**
  130613. * Get a string representing the shaders built by the current node graph
  130614. */
  130615. get compiledShaders(): string;
  130616. /**
  130617. * Binds the world matrix to the material
  130618. * @param world defines the world transformation matrix
  130619. */
  130620. bindOnlyWorldMatrix(world: Matrix): void;
  130621. /**
  130622. * Binds the submesh to this material by preparing the effect and shader to draw
  130623. * @param world defines the world transformation matrix
  130624. * @param mesh defines the mesh containing the submesh
  130625. * @param subMesh defines the submesh to bind the material to
  130626. */
  130627. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130628. /**
  130629. * Gets the active textures from the material
  130630. * @returns an array of textures
  130631. */
  130632. getActiveTextures(): BaseTexture[];
  130633. /**
  130634. * Gets the list of texture blocks
  130635. * @returns an array of texture blocks
  130636. */
  130637. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130638. /**
  130639. * Specifies if the material uses a texture
  130640. * @param texture defines the texture to check against the material
  130641. * @returns a boolean specifying if the material uses the texture
  130642. */
  130643. hasTexture(texture: BaseTexture): boolean;
  130644. /**
  130645. * Disposes the material
  130646. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130647. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130648. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130649. */
  130650. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130651. /** Creates the node editor window. */
  130652. private _createNodeEditor;
  130653. /**
  130654. * Launch the node material editor
  130655. * @param config Define the configuration of the editor
  130656. * @return a promise fulfilled when the node editor is visible
  130657. */
  130658. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130659. /**
  130660. * Clear the current material
  130661. */
  130662. clear(): void;
  130663. /**
  130664. * Clear the current material and set it to a default state
  130665. */
  130666. setToDefault(): void;
  130667. /**
  130668. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130669. * @param url defines the url to load from
  130670. * @returns a promise that will fullfil when the material is fully loaded
  130671. */
  130672. loadAsync(url: string): Promise<void>;
  130673. private _gatherBlocks;
  130674. /**
  130675. * Generate a string containing the code declaration required to create an equivalent of this material
  130676. * @returns a string
  130677. */
  130678. generateCode(): string;
  130679. /**
  130680. * Serializes this material in a JSON representation
  130681. * @returns the serialized material object
  130682. */
  130683. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130684. private _restoreConnections;
  130685. /**
  130686. * Clear the current graph and load a new one from a serialization object
  130687. * @param source defines the JSON representation of the material
  130688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130689. */
  130690. loadFromSerialization(source: any, rootUrl?: string): void;
  130691. /**
  130692. * Creates a node material from parsed material data
  130693. * @param source defines the JSON representation of the material
  130694. * @param scene defines the hosting scene
  130695. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130696. * @returns a new node material
  130697. */
  130698. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130699. /**
  130700. * Creates a node material from a snippet saved in a remote file
  130701. * @param name defines the name of the material to create
  130702. * @param url defines the url to load from
  130703. * @param scene defines the hosting scene
  130704. * @returns a promise that will resolve to the new node material
  130705. */
  130706. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130707. /**
  130708. * Creates a node material from a snippet saved by the node material editor
  130709. * @param snippetId defines the snippet to load
  130710. * @param scene defines the hosting scene
  130711. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130712. * @returns a promise that will resolve to the new node material
  130713. */
  130714. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130715. /**
  130716. * Creates a new node material set to default basic configuration
  130717. * @param name defines the name of the material
  130718. * @param scene defines the hosting scene
  130719. * @returns a new NodeMaterial
  130720. */
  130721. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130722. }
  130723. }
  130724. declare module BABYLON {
  130725. /**
  130726. * Block used to read a texture from a sampler
  130727. */
  130728. export class TextureBlock extends NodeMaterialBlock {
  130729. private _defineName;
  130730. private _linearDefineName;
  130731. private _tempTextureRead;
  130732. private _samplerName;
  130733. private _transformedUVName;
  130734. private _textureTransformName;
  130735. private _textureInfoName;
  130736. private _mainUVName;
  130737. private _mainUVDefineName;
  130738. /**
  130739. * Gets or sets the texture associated with the node
  130740. */
  130741. texture: Nullable<Texture>;
  130742. /**
  130743. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130744. */
  130745. convertToGammaSpace: boolean;
  130746. /**
  130747. * Create a new TextureBlock
  130748. * @param name defines the block name
  130749. */
  130750. constructor(name: string);
  130751. /**
  130752. * Gets the current class name
  130753. * @returns the class name
  130754. */
  130755. getClassName(): string;
  130756. /**
  130757. * Gets the uv input component
  130758. */
  130759. get uv(): NodeMaterialConnectionPoint;
  130760. /**
  130761. * Gets the rgba output component
  130762. */
  130763. get rgba(): NodeMaterialConnectionPoint;
  130764. /**
  130765. * Gets the rgb output component
  130766. */
  130767. get rgb(): NodeMaterialConnectionPoint;
  130768. /**
  130769. * Gets the r output component
  130770. */
  130771. get r(): NodeMaterialConnectionPoint;
  130772. /**
  130773. * Gets the g output component
  130774. */
  130775. get g(): NodeMaterialConnectionPoint;
  130776. /**
  130777. * Gets the b output component
  130778. */
  130779. get b(): NodeMaterialConnectionPoint;
  130780. /**
  130781. * Gets the a output component
  130782. */
  130783. get a(): NodeMaterialConnectionPoint;
  130784. get target(): NodeMaterialBlockTargets;
  130785. autoConfigure(material: NodeMaterial): void;
  130786. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130788. isReady(): boolean;
  130789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130790. private get _isMixed();
  130791. private _injectVertexCode;
  130792. private _writeTextureRead;
  130793. private _writeOutput;
  130794. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130795. protected _dumpPropertiesCode(): string;
  130796. serialize(): any;
  130797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130798. }
  130799. }
  130800. declare module BABYLON {
  130801. /**
  130802. * Class used to store shared data between 2 NodeMaterialBuildState
  130803. */
  130804. export class NodeMaterialBuildStateSharedData {
  130805. /**
  130806. * Gets the list of emitted varyings
  130807. */
  130808. temps: string[];
  130809. /**
  130810. * Gets the list of emitted varyings
  130811. */
  130812. varyings: string[];
  130813. /**
  130814. * Gets the varying declaration string
  130815. */
  130816. varyingDeclaration: string;
  130817. /**
  130818. * Input blocks
  130819. */
  130820. inputBlocks: InputBlock[];
  130821. /**
  130822. * Input blocks
  130823. */
  130824. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130825. /**
  130826. * Bindable blocks (Blocks that need to set data to the effect)
  130827. */
  130828. bindableBlocks: NodeMaterialBlock[];
  130829. /**
  130830. * List of blocks that can provide a compilation fallback
  130831. */
  130832. blocksWithFallbacks: NodeMaterialBlock[];
  130833. /**
  130834. * List of blocks that can provide a define update
  130835. */
  130836. blocksWithDefines: NodeMaterialBlock[];
  130837. /**
  130838. * List of blocks that can provide a repeatable content
  130839. */
  130840. repeatableContentBlocks: NodeMaterialBlock[];
  130841. /**
  130842. * List of blocks that can provide a dynamic list of uniforms
  130843. */
  130844. dynamicUniformBlocks: NodeMaterialBlock[];
  130845. /**
  130846. * List of blocks that can block the isReady function for the material
  130847. */
  130848. blockingBlocks: NodeMaterialBlock[];
  130849. /**
  130850. * Gets the list of animated inputs
  130851. */
  130852. animatedInputs: InputBlock[];
  130853. /**
  130854. * Build Id used to avoid multiple recompilations
  130855. */
  130856. buildId: number;
  130857. /** List of emitted variables */
  130858. variableNames: {
  130859. [key: string]: number;
  130860. };
  130861. /** List of emitted defines */
  130862. defineNames: {
  130863. [key: string]: number;
  130864. };
  130865. /** Should emit comments? */
  130866. emitComments: boolean;
  130867. /** Emit build activity */
  130868. verbose: boolean;
  130869. /** Gets or sets the hosting scene */
  130870. scene: Scene;
  130871. /**
  130872. * Gets the compilation hints emitted at compilation time
  130873. */
  130874. hints: {
  130875. needWorldViewMatrix: boolean;
  130876. needWorldViewProjectionMatrix: boolean;
  130877. needAlphaBlending: boolean;
  130878. needAlphaTesting: boolean;
  130879. };
  130880. /**
  130881. * List of compilation checks
  130882. */
  130883. checks: {
  130884. emitVertex: boolean;
  130885. emitFragment: boolean;
  130886. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130887. };
  130888. /** Creates a new shared data */
  130889. constructor();
  130890. /**
  130891. * Emits console errors and exceptions if there is a failing check
  130892. */
  130893. emitErrors(): void;
  130894. }
  130895. }
  130896. declare module BABYLON {
  130897. /**
  130898. * Class used to store node based material build state
  130899. */
  130900. export class NodeMaterialBuildState {
  130901. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130902. supportUniformBuffers: boolean;
  130903. /**
  130904. * Gets the list of emitted attributes
  130905. */
  130906. attributes: string[];
  130907. /**
  130908. * Gets the list of emitted uniforms
  130909. */
  130910. uniforms: string[];
  130911. /**
  130912. * Gets the list of emitted constants
  130913. */
  130914. constants: string[];
  130915. /**
  130916. * Gets the list of emitted samplers
  130917. */
  130918. samplers: string[];
  130919. /**
  130920. * Gets the list of emitted functions
  130921. */
  130922. functions: {
  130923. [key: string]: string;
  130924. };
  130925. /**
  130926. * Gets the list of emitted extensions
  130927. */
  130928. extensions: {
  130929. [key: string]: string;
  130930. };
  130931. /**
  130932. * Gets the target of the compilation state
  130933. */
  130934. target: NodeMaterialBlockTargets;
  130935. /**
  130936. * Gets the list of emitted counters
  130937. */
  130938. counters: {
  130939. [key: string]: number;
  130940. };
  130941. /**
  130942. * Shared data between multiple NodeMaterialBuildState instances
  130943. */
  130944. sharedData: NodeMaterialBuildStateSharedData;
  130945. /** @hidden */
  130946. _vertexState: NodeMaterialBuildState;
  130947. /** @hidden */
  130948. _attributeDeclaration: string;
  130949. /** @hidden */
  130950. _uniformDeclaration: string;
  130951. /** @hidden */
  130952. _constantDeclaration: string;
  130953. /** @hidden */
  130954. _samplerDeclaration: string;
  130955. /** @hidden */
  130956. _varyingTransfer: string;
  130957. private _repeatableContentAnchorIndex;
  130958. /** @hidden */
  130959. _builtCompilationString: string;
  130960. /**
  130961. * Gets the emitted compilation strings
  130962. */
  130963. compilationString: string;
  130964. /**
  130965. * Finalize the compilation strings
  130966. * @param state defines the current compilation state
  130967. */
  130968. finalize(state: NodeMaterialBuildState): void;
  130969. /** @hidden */
  130970. get _repeatableContentAnchor(): string;
  130971. /** @hidden */
  130972. _getFreeVariableName(prefix: string): string;
  130973. /** @hidden */
  130974. _getFreeDefineName(prefix: string): string;
  130975. /** @hidden */
  130976. _excludeVariableName(name: string): void;
  130977. /** @hidden */
  130978. _emit2DSampler(name: string): void;
  130979. /** @hidden */
  130980. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130981. /** @hidden */
  130982. _emitExtension(name: string, extension: string): void;
  130983. /** @hidden */
  130984. _emitFunction(name: string, code: string, comments: string): void;
  130985. /** @hidden */
  130986. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130987. replaceStrings?: {
  130988. search: RegExp;
  130989. replace: string;
  130990. }[];
  130991. repeatKey?: string;
  130992. }): string;
  130993. /** @hidden */
  130994. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130995. repeatKey?: string;
  130996. removeAttributes?: boolean;
  130997. removeUniforms?: boolean;
  130998. removeVaryings?: boolean;
  130999. removeIfDef?: boolean;
  131000. replaceStrings?: {
  131001. search: RegExp;
  131002. replace: string;
  131003. }[];
  131004. }, storeKey?: string): void;
  131005. /** @hidden */
  131006. _registerTempVariable(name: string): boolean;
  131007. /** @hidden */
  131008. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  131009. /** @hidden */
  131010. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  131011. /** @hidden */
  131012. _emitFloat(value: number): string;
  131013. }
  131014. }
  131015. declare module BABYLON {
  131016. /**
  131017. * Defines a block that can be used inside a node based material
  131018. */
  131019. export class NodeMaterialBlock {
  131020. private _buildId;
  131021. private _buildTarget;
  131022. private _target;
  131023. private _isFinalMerger;
  131024. private _isInput;
  131025. protected _isUnique: boolean;
  131026. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  131027. inputsAreExclusive: boolean;
  131028. /** @hidden */
  131029. _codeVariableName: string;
  131030. /** @hidden */
  131031. _inputs: NodeMaterialConnectionPoint[];
  131032. /** @hidden */
  131033. _outputs: NodeMaterialConnectionPoint[];
  131034. /** @hidden */
  131035. _preparationId: number;
  131036. /**
  131037. * Gets or sets the name of the block
  131038. */
  131039. name: string;
  131040. /**
  131041. * Gets or sets the unique id of the node
  131042. */
  131043. uniqueId: number;
  131044. /**
  131045. * Gets or sets the comments associated with this block
  131046. */
  131047. comments: string;
  131048. /**
  131049. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  131050. */
  131051. get isUnique(): boolean;
  131052. /**
  131053. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131054. */
  131055. get isFinalMerger(): boolean;
  131056. /**
  131057. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131058. */
  131059. get isInput(): boolean;
  131060. /**
  131061. * Gets or sets the build Id
  131062. */
  131063. get buildId(): number;
  131064. set buildId(value: number);
  131065. /**
  131066. * Gets or sets the target of the block
  131067. */
  131068. get target(): NodeMaterialBlockTargets;
  131069. set target(value: NodeMaterialBlockTargets);
  131070. /**
  131071. * Gets the list of input points
  131072. */
  131073. get inputs(): NodeMaterialConnectionPoint[];
  131074. /** Gets the list of output points */
  131075. get outputs(): NodeMaterialConnectionPoint[];
  131076. /**
  131077. * Find an input by its name
  131078. * @param name defines the name of the input to look for
  131079. * @returns the input or null if not found
  131080. */
  131081. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131082. /**
  131083. * Find an output by its name
  131084. * @param name defines the name of the outputto look for
  131085. * @returns the output or null if not found
  131086. */
  131087. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131088. /**
  131089. * Creates a new NodeMaterialBlock
  131090. * @param name defines the block name
  131091. * @param target defines the target of that block (Vertex by default)
  131092. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131093. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131094. */
  131095. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131096. /**
  131097. * Initialize the block and prepare the context for build
  131098. * @param state defines the state that will be used for the build
  131099. */
  131100. initialize(state: NodeMaterialBuildState): void;
  131101. /**
  131102. * Bind data to effect. Will only be called for blocks with isBindable === true
  131103. * @param effect defines the effect to bind data to
  131104. * @param nodeMaterial defines the hosting NodeMaterial
  131105. * @param mesh defines the mesh that will be rendered
  131106. */
  131107. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131108. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131109. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131110. protected _writeFloat(value: number): string;
  131111. /**
  131112. * Gets the current class name e.g. "NodeMaterialBlock"
  131113. * @returns the class name
  131114. */
  131115. getClassName(): string;
  131116. /**
  131117. * Register a new input. Must be called inside a block constructor
  131118. * @param name defines the connection point name
  131119. * @param type defines the connection point type
  131120. * @param isOptional defines a boolean indicating that this input can be omitted
  131121. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131122. * @returns the current block
  131123. */
  131124. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131125. /**
  131126. * Register a new output. Must be called inside a block constructor
  131127. * @param name defines the connection point name
  131128. * @param type defines the connection point type
  131129. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131130. * @returns the current block
  131131. */
  131132. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131133. /**
  131134. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131135. * @param forOutput defines an optional connection point to check compatibility with
  131136. * @returns the first available input or null
  131137. */
  131138. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131139. /**
  131140. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131141. * @param forBlock defines an optional block to check compatibility with
  131142. * @returns the first available input or null
  131143. */
  131144. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131145. /**
  131146. * Gets the sibling of the given output
  131147. * @param current defines the current output
  131148. * @returns the next output in the list or null
  131149. */
  131150. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131151. /**
  131152. * Connect current block with another block
  131153. * @param other defines the block to connect with
  131154. * @param options define the various options to help pick the right connections
  131155. * @returns the current block
  131156. */
  131157. connectTo(other: NodeMaterialBlock, options?: {
  131158. input?: string;
  131159. output?: string;
  131160. outputSwizzle?: string;
  131161. }): this | undefined;
  131162. protected _buildBlock(state: NodeMaterialBuildState): void;
  131163. /**
  131164. * Add uniforms, samplers and uniform buffers at compilation time
  131165. * @param state defines the state to update
  131166. * @param nodeMaterial defines the node material requesting the update
  131167. * @param defines defines the material defines to update
  131168. * @param uniformBuffers defines the list of uniform buffer names
  131169. */
  131170. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131171. /**
  131172. * Add potential fallbacks if shader compilation fails
  131173. * @param mesh defines the mesh to be rendered
  131174. * @param fallbacks defines the current prioritized list of fallbacks
  131175. */
  131176. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131177. /**
  131178. * Initialize defines for shader compilation
  131179. * @param mesh defines the mesh to be rendered
  131180. * @param nodeMaterial defines the node material requesting the update
  131181. * @param defines defines the material defines to update
  131182. * @param useInstances specifies that instances should be used
  131183. */
  131184. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131185. /**
  131186. * Update defines for shader compilation
  131187. * @param mesh defines the mesh to be rendered
  131188. * @param nodeMaterial defines the node material requesting the update
  131189. * @param defines defines the material defines to update
  131190. * @param useInstances specifies that instances should be used
  131191. */
  131192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131193. /**
  131194. * Lets the block try to connect some inputs automatically
  131195. * @param material defines the hosting NodeMaterial
  131196. */
  131197. autoConfigure(material: NodeMaterial): void;
  131198. /**
  131199. * Function called when a block is declared as repeatable content generator
  131200. * @param vertexShaderState defines the current compilation state for the vertex shader
  131201. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131202. * @param mesh defines the mesh to be rendered
  131203. * @param defines defines the material defines to update
  131204. */
  131205. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131206. /**
  131207. * Checks if the block is ready
  131208. * @param mesh defines the mesh to be rendered
  131209. * @param nodeMaterial defines the node material requesting the update
  131210. * @param defines defines the material defines to update
  131211. * @param useInstances specifies that instances should be used
  131212. * @returns true if the block is ready
  131213. */
  131214. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131215. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131216. private _processBuild;
  131217. /**
  131218. * Compile the current node and generate the shader code
  131219. * @param state defines the current compilation state (uniforms, samplers, current string)
  131220. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131221. * @returns true if already built
  131222. */
  131223. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131224. protected _inputRename(name: string): string;
  131225. protected _outputRename(name: string): string;
  131226. protected _dumpPropertiesCode(): string;
  131227. /** @hidden */
  131228. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131229. /** @hidden */
  131230. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131231. /**
  131232. * Clone the current block to a new identical block
  131233. * @param scene defines the hosting scene
  131234. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131235. * @returns a copy of the current block
  131236. */
  131237. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131238. /**
  131239. * Serializes this block in a JSON representation
  131240. * @returns the serialized block object
  131241. */
  131242. serialize(): any;
  131243. /** @hidden */
  131244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131245. /**
  131246. * Release resources
  131247. */
  131248. dispose(): void;
  131249. }
  131250. }
  131251. declare module BABYLON {
  131252. /**
  131253. * Enum defining the type of animations supported by InputBlock
  131254. */
  131255. export enum AnimatedInputBlockTypes {
  131256. /** No animation */
  131257. None = 0,
  131258. /** Time based animation. Will only work for floats */
  131259. Time = 1
  131260. }
  131261. }
  131262. declare module BABYLON {
  131263. /**
  131264. * Block used to expose an input value
  131265. */
  131266. export class InputBlock extends NodeMaterialBlock {
  131267. private _mode;
  131268. private _associatedVariableName;
  131269. private _storedValue;
  131270. private _valueCallback;
  131271. private _type;
  131272. private _animationType;
  131273. /** Gets or set a value used to limit the range of float values */
  131274. min: number;
  131275. /** Gets or set a value used to limit the range of float values */
  131276. max: number;
  131277. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131278. isBoolean: boolean;
  131279. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131280. matrixMode: number;
  131281. /** @hidden */
  131282. _systemValue: Nullable<NodeMaterialSystemValues>;
  131283. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131284. visibleInInspector: boolean;
  131285. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131286. isConstant: boolean;
  131287. /** Gets or sets the group to use to display this block in the Inspector */
  131288. groupInInspector: string;
  131289. /** Gets an observable raised when the value is changed */
  131290. onValueChangedObservable: Observable<InputBlock>;
  131291. /**
  131292. * Gets or sets the connection point type (default is float)
  131293. */
  131294. get type(): NodeMaterialBlockConnectionPointTypes;
  131295. /**
  131296. * Creates a new InputBlock
  131297. * @param name defines the block name
  131298. * @param target defines the target of that block (Vertex by default)
  131299. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131300. */
  131301. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131302. /**
  131303. * Gets the output component
  131304. */
  131305. get output(): NodeMaterialConnectionPoint;
  131306. /**
  131307. * Set the source of this connection point to a vertex attribute
  131308. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131309. * @returns the current connection point
  131310. */
  131311. setAsAttribute(attributeName?: string): InputBlock;
  131312. /**
  131313. * Set the source of this connection point to a system value
  131314. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131315. * @returns the current connection point
  131316. */
  131317. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131318. /**
  131319. * Gets or sets the value of that point.
  131320. * Please note that this value will be ignored if valueCallback is defined
  131321. */
  131322. get value(): any;
  131323. set value(value: any);
  131324. /**
  131325. * Gets or sets a callback used to get the value of that point.
  131326. * Please note that setting this value will force the connection point to ignore the value property
  131327. */
  131328. get valueCallback(): () => any;
  131329. set valueCallback(value: () => any);
  131330. /**
  131331. * Gets or sets the associated variable name in the shader
  131332. */
  131333. get associatedVariableName(): string;
  131334. set associatedVariableName(value: string);
  131335. /** Gets or sets the type of animation applied to the input */
  131336. get animationType(): AnimatedInputBlockTypes;
  131337. set animationType(value: AnimatedInputBlockTypes);
  131338. /**
  131339. * Gets a boolean indicating that this connection point not defined yet
  131340. */
  131341. get isUndefined(): boolean;
  131342. /**
  131343. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131344. * In this case the connection point name must be the name of the uniform to use.
  131345. * Can only be set on inputs
  131346. */
  131347. get isUniform(): boolean;
  131348. set isUniform(value: boolean);
  131349. /**
  131350. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131351. * In this case the connection point name must be the name of the attribute to use
  131352. * Can only be set on inputs
  131353. */
  131354. get isAttribute(): boolean;
  131355. set isAttribute(value: boolean);
  131356. /**
  131357. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131358. * Can only be set on exit points
  131359. */
  131360. get isVarying(): boolean;
  131361. set isVarying(value: boolean);
  131362. /**
  131363. * Gets a boolean indicating that the current connection point is a system value
  131364. */
  131365. get isSystemValue(): boolean;
  131366. /**
  131367. * Gets or sets the current well known value or null if not defined as a system value
  131368. */
  131369. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131370. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131371. /**
  131372. * Gets the current class name
  131373. * @returns the class name
  131374. */
  131375. getClassName(): string;
  131376. /**
  131377. * Animate the input if animationType !== None
  131378. * @param scene defines the rendering scene
  131379. */
  131380. animate(scene: Scene): void;
  131381. private _emitDefine;
  131382. initialize(state: NodeMaterialBuildState): void;
  131383. /**
  131384. * Set the input block to its default value (based on its type)
  131385. */
  131386. setDefaultValue(): void;
  131387. private _emitConstant;
  131388. private _emit;
  131389. /** @hidden */
  131390. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131391. /** @hidden */
  131392. _transmit(effect: Effect, scene: Scene): void;
  131393. protected _buildBlock(state: NodeMaterialBuildState): void;
  131394. protected _dumpPropertiesCode(): string;
  131395. dispose(): void;
  131396. serialize(): any;
  131397. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131398. }
  131399. }
  131400. declare module BABYLON {
  131401. /**
  131402. * Enum used to define the compatibility state between two connection points
  131403. */
  131404. export enum NodeMaterialConnectionPointCompatibilityStates {
  131405. /** Points are compatibles */
  131406. Compatible = 0,
  131407. /** Points are incompatible because of their types */
  131408. TypeIncompatible = 1,
  131409. /** Points are incompatible because of their targets (vertex vs fragment) */
  131410. TargetIncompatible = 2
  131411. }
  131412. /**
  131413. * Defines the direction of a connection point
  131414. */
  131415. export enum NodeMaterialConnectionPointDirection {
  131416. /** Input */
  131417. Input = 0,
  131418. /** Output */
  131419. Output = 1
  131420. }
  131421. /**
  131422. * Defines a connection point for a block
  131423. */
  131424. export class NodeMaterialConnectionPoint {
  131425. /** @hidden */
  131426. _ownerBlock: NodeMaterialBlock;
  131427. /** @hidden */
  131428. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131429. private _endpoints;
  131430. private _associatedVariableName;
  131431. private _direction;
  131432. /** @hidden */
  131433. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131434. /** @hidden */
  131435. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131436. private _type;
  131437. /** @hidden */
  131438. _enforceAssociatedVariableName: boolean;
  131439. /** Gets the direction of the point */
  131440. get direction(): NodeMaterialConnectionPointDirection;
  131441. /**
  131442. * Gets or sets the additional types supported by this connection point
  131443. */
  131444. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131445. /**
  131446. * Gets or sets the additional types excluded by this connection point
  131447. */
  131448. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131449. /**
  131450. * Observable triggered when this point is connected
  131451. */
  131452. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131453. /**
  131454. * Gets or sets the associated variable name in the shader
  131455. */
  131456. get associatedVariableName(): string;
  131457. set associatedVariableName(value: string);
  131458. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131459. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131460. /**
  131461. * Gets or sets the connection point type (default is float)
  131462. */
  131463. get type(): NodeMaterialBlockConnectionPointTypes;
  131464. set type(value: NodeMaterialBlockConnectionPointTypes);
  131465. /**
  131466. * Gets or sets the connection point name
  131467. */
  131468. name: string;
  131469. /**
  131470. * Gets or sets a boolean indicating that this connection point can be omitted
  131471. */
  131472. isOptional: boolean;
  131473. /**
  131474. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131475. */
  131476. define: string;
  131477. /** @hidden */
  131478. _prioritizeVertex: boolean;
  131479. private _target;
  131480. /** Gets or sets the target of that connection point */
  131481. get target(): NodeMaterialBlockTargets;
  131482. set target(value: NodeMaterialBlockTargets);
  131483. /**
  131484. * Gets a boolean indicating that the current point is connected
  131485. */
  131486. get isConnected(): boolean;
  131487. /**
  131488. * Gets a boolean indicating that the current point is connected to an input block
  131489. */
  131490. get isConnectedToInputBlock(): boolean;
  131491. /**
  131492. * Gets a the connected input block (if any)
  131493. */
  131494. get connectInputBlock(): Nullable<InputBlock>;
  131495. /** Get the other side of the connection (if any) */
  131496. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131497. /** Get the block that owns this connection point */
  131498. get ownerBlock(): NodeMaterialBlock;
  131499. /** Get the block connected on the other side of this connection (if any) */
  131500. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131501. /** Get the block connected on the endpoints of this connection (if any) */
  131502. get connectedBlocks(): Array<NodeMaterialBlock>;
  131503. /** Gets the list of connected endpoints */
  131504. get endpoints(): NodeMaterialConnectionPoint[];
  131505. /** Gets a boolean indicating if that output point is connected to at least one input */
  131506. get hasEndpoints(): boolean;
  131507. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131508. get isConnectedInVertexShader(): boolean;
  131509. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131510. get isConnectedInFragmentShader(): boolean;
  131511. /**
  131512. * Creates a new connection point
  131513. * @param name defines the connection point name
  131514. * @param ownerBlock defines the block hosting this connection point
  131515. * @param direction defines the direction of the connection point
  131516. */
  131517. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131518. /**
  131519. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131520. * @returns the class name
  131521. */
  131522. getClassName(): string;
  131523. /**
  131524. * Gets a boolean indicating if the current point can be connected to another point
  131525. * @param connectionPoint defines the other connection point
  131526. * @returns a boolean
  131527. */
  131528. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131529. /**
  131530. * Gets a number indicating if the current point can be connected to another point
  131531. * @param connectionPoint defines the other connection point
  131532. * @returns a number defining the compatibility state
  131533. */
  131534. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131535. /**
  131536. * Connect this point to another connection point
  131537. * @param connectionPoint defines the other connection point
  131538. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131539. * @returns the current connection point
  131540. */
  131541. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131542. /**
  131543. * Disconnect this point from one of his endpoint
  131544. * @param endpoint defines the other connection point
  131545. * @returns the current connection point
  131546. */
  131547. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131548. /**
  131549. * Serializes this point in a JSON representation
  131550. * @returns the serialized point object
  131551. */
  131552. serialize(): any;
  131553. /**
  131554. * Release resources
  131555. */
  131556. dispose(): void;
  131557. }
  131558. }
  131559. declare module BABYLON {
  131560. /**
  131561. * Block used to add support for vertex skinning (bones)
  131562. */
  131563. export class BonesBlock extends NodeMaterialBlock {
  131564. /**
  131565. * Creates a new BonesBlock
  131566. * @param name defines the block name
  131567. */
  131568. constructor(name: string);
  131569. /**
  131570. * Initialize the block and prepare the context for build
  131571. * @param state defines the state that will be used for the build
  131572. */
  131573. initialize(state: NodeMaterialBuildState): void;
  131574. /**
  131575. * Gets the current class name
  131576. * @returns the class name
  131577. */
  131578. getClassName(): string;
  131579. /**
  131580. * Gets the matrix indices input component
  131581. */
  131582. get matricesIndices(): NodeMaterialConnectionPoint;
  131583. /**
  131584. * Gets the matrix weights input component
  131585. */
  131586. get matricesWeights(): NodeMaterialConnectionPoint;
  131587. /**
  131588. * Gets the extra matrix indices input component
  131589. */
  131590. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131591. /**
  131592. * Gets the extra matrix weights input component
  131593. */
  131594. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131595. /**
  131596. * Gets the world input component
  131597. */
  131598. get world(): NodeMaterialConnectionPoint;
  131599. /**
  131600. * Gets the output component
  131601. */
  131602. get output(): NodeMaterialConnectionPoint;
  131603. autoConfigure(material: NodeMaterial): void;
  131604. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131607. protected _buildBlock(state: NodeMaterialBuildState): this;
  131608. }
  131609. }
  131610. declare module BABYLON {
  131611. /**
  131612. * Block used to add support for instances
  131613. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131614. */
  131615. export class InstancesBlock extends NodeMaterialBlock {
  131616. /**
  131617. * Creates a new InstancesBlock
  131618. * @param name defines the block name
  131619. */
  131620. constructor(name: string);
  131621. /**
  131622. * Gets the current class name
  131623. * @returns the class name
  131624. */
  131625. getClassName(): string;
  131626. /**
  131627. * Gets the first world row input component
  131628. */
  131629. get world0(): NodeMaterialConnectionPoint;
  131630. /**
  131631. * Gets the second world row input component
  131632. */
  131633. get world1(): NodeMaterialConnectionPoint;
  131634. /**
  131635. * Gets the third world row input component
  131636. */
  131637. get world2(): NodeMaterialConnectionPoint;
  131638. /**
  131639. * Gets the forth world row input component
  131640. */
  131641. get world3(): NodeMaterialConnectionPoint;
  131642. /**
  131643. * Gets the world input component
  131644. */
  131645. get world(): NodeMaterialConnectionPoint;
  131646. /**
  131647. * Gets the output component
  131648. */
  131649. get output(): NodeMaterialConnectionPoint;
  131650. /**
  131651. * Gets the isntanceID component
  131652. */
  131653. get instanceID(): NodeMaterialConnectionPoint;
  131654. autoConfigure(material: NodeMaterial): void;
  131655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131656. protected _buildBlock(state: NodeMaterialBuildState): this;
  131657. }
  131658. }
  131659. declare module BABYLON {
  131660. /**
  131661. * Block used to add morph targets support to vertex shader
  131662. */
  131663. export class MorphTargetsBlock extends NodeMaterialBlock {
  131664. private _repeatableContentAnchor;
  131665. /**
  131666. * Create a new MorphTargetsBlock
  131667. * @param name defines the block name
  131668. */
  131669. constructor(name: string);
  131670. /**
  131671. * Gets the current class name
  131672. * @returns the class name
  131673. */
  131674. getClassName(): string;
  131675. /**
  131676. * Gets the position input component
  131677. */
  131678. get position(): NodeMaterialConnectionPoint;
  131679. /**
  131680. * Gets the normal input component
  131681. */
  131682. get normal(): NodeMaterialConnectionPoint;
  131683. /**
  131684. * Gets the tangent input component
  131685. */
  131686. get tangent(): NodeMaterialConnectionPoint;
  131687. /**
  131688. * Gets the tangent input component
  131689. */
  131690. get uv(): NodeMaterialConnectionPoint;
  131691. /**
  131692. * Gets the position output component
  131693. */
  131694. get positionOutput(): NodeMaterialConnectionPoint;
  131695. /**
  131696. * Gets the normal output component
  131697. */
  131698. get normalOutput(): NodeMaterialConnectionPoint;
  131699. /**
  131700. * Gets the tangent output component
  131701. */
  131702. get tangentOutput(): NodeMaterialConnectionPoint;
  131703. /**
  131704. * Gets the tangent output component
  131705. */
  131706. get uvOutput(): NodeMaterialConnectionPoint;
  131707. initialize(state: NodeMaterialBuildState): void;
  131708. autoConfigure(material: NodeMaterial): void;
  131709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131710. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131711. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131712. protected _buildBlock(state: NodeMaterialBuildState): this;
  131713. }
  131714. }
  131715. declare module BABYLON {
  131716. /**
  131717. * Block used to get data information from a light
  131718. */
  131719. export class LightInformationBlock extends NodeMaterialBlock {
  131720. private _lightDataUniformName;
  131721. private _lightColorUniformName;
  131722. private _lightTypeDefineName;
  131723. /**
  131724. * Gets or sets the light associated with this block
  131725. */
  131726. light: Nullable<Light>;
  131727. /**
  131728. * Creates a new LightInformationBlock
  131729. * @param name defines the block name
  131730. */
  131731. constructor(name: string);
  131732. /**
  131733. * Gets the current class name
  131734. * @returns the class name
  131735. */
  131736. getClassName(): string;
  131737. /**
  131738. * Gets the world position input component
  131739. */
  131740. get worldPosition(): NodeMaterialConnectionPoint;
  131741. /**
  131742. * Gets the direction output component
  131743. */
  131744. get direction(): NodeMaterialConnectionPoint;
  131745. /**
  131746. * Gets the direction output component
  131747. */
  131748. get color(): NodeMaterialConnectionPoint;
  131749. /**
  131750. * Gets the direction output component
  131751. */
  131752. get intensity(): NodeMaterialConnectionPoint;
  131753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131754. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131755. protected _buildBlock(state: NodeMaterialBuildState): this;
  131756. serialize(): any;
  131757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131758. }
  131759. }
  131760. declare module BABYLON {
  131761. /**
  131762. * Block used to add image processing support to fragment shader
  131763. */
  131764. export class ImageProcessingBlock extends NodeMaterialBlock {
  131765. /**
  131766. * Create a new ImageProcessingBlock
  131767. * @param name defines the block name
  131768. */
  131769. constructor(name: string);
  131770. /**
  131771. * Gets the current class name
  131772. * @returns the class name
  131773. */
  131774. getClassName(): string;
  131775. /**
  131776. * Gets the color input component
  131777. */
  131778. get color(): NodeMaterialConnectionPoint;
  131779. /**
  131780. * Gets the output component
  131781. */
  131782. get output(): NodeMaterialConnectionPoint;
  131783. /**
  131784. * Initialize the block and prepare the context for build
  131785. * @param state defines the state that will be used for the build
  131786. */
  131787. initialize(state: NodeMaterialBuildState): void;
  131788. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131789. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131790. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131791. protected _buildBlock(state: NodeMaterialBuildState): this;
  131792. }
  131793. }
  131794. declare module BABYLON {
  131795. /**
  131796. * Block used to pertub normals based on a normal map
  131797. */
  131798. export class PerturbNormalBlock extends NodeMaterialBlock {
  131799. private _tangentSpaceParameterName;
  131800. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131801. invertX: boolean;
  131802. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131803. invertY: boolean;
  131804. /**
  131805. * Create a new PerturbNormalBlock
  131806. * @param name defines the block name
  131807. */
  131808. constructor(name: string);
  131809. /**
  131810. * Gets the current class name
  131811. * @returns the class name
  131812. */
  131813. getClassName(): string;
  131814. /**
  131815. * Gets the world position input component
  131816. */
  131817. get worldPosition(): NodeMaterialConnectionPoint;
  131818. /**
  131819. * Gets the world normal input component
  131820. */
  131821. get worldNormal(): NodeMaterialConnectionPoint;
  131822. /**
  131823. * Gets the world tangent input component
  131824. */
  131825. get worldTangent(): NodeMaterialConnectionPoint;
  131826. /**
  131827. * Gets the uv input component
  131828. */
  131829. get uv(): NodeMaterialConnectionPoint;
  131830. /**
  131831. * Gets the normal map color input component
  131832. */
  131833. get normalMapColor(): NodeMaterialConnectionPoint;
  131834. /**
  131835. * Gets the strength input component
  131836. */
  131837. get strength(): NodeMaterialConnectionPoint;
  131838. /**
  131839. * Gets the output component
  131840. */
  131841. get output(): NodeMaterialConnectionPoint;
  131842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131844. autoConfigure(material: NodeMaterial): void;
  131845. protected _buildBlock(state: NodeMaterialBuildState): this;
  131846. protected _dumpPropertiesCode(): string;
  131847. serialize(): any;
  131848. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131849. }
  131850. }
  131851. declare module BABYLON {
  131852. /**
  131853. * Block used to discard a pixel if a value is smaller than a cutoff
  131854. */
  131855. export class DiscardBlock extends NodeMaterialBlock {
  131856. /**
  131857. * Create a new DiscardBlock
  131858. * @param name defines the block name
  131859. */
  131860. constructor(name: string);
  131861. /**
  131862. * Gets the current class name
  131863. * @returns the class name
  131864. */
  131865. getClassName(): string;
  131866. /**
  131867. * Gets the color input component
  131868. */
  131869. get value(): NodeMaterialConnectionPoint;
  131870. /**
  131871. * Gets the cutoff input component
  131872. */
  131873. get cutoff(): NodeMaterialConnectionPoint;
  131874. protected _buildBlock(state: NodeMaterialBuildState): this;
  131875. }
  131876. }
  131877. declare module BABYLON {
  131878. /**
  131879. * Block used to test if the fragment shader is front facing
  131880. */
  131881. export class FrontFacingBlock extends NodeMaterialBlock {
  131882. /**
  131883. * Creates a new FrontFacingBlock
  131884. * @param name defines the block name
  131885. */
  131886. constructor(name: string);
  131887. /**
  131888. * Gets the current class name
  131889. * @returns the class name
  131890. */
  131891. getClassName(): string;
  131892. /**
  131893. * Gets the output component
  131894. */
  131895. get output(): NodeMaterialConnectionPoint;
  131896. protected _buildBlock(state: NodeMaterialBuildState): this;
  131897. }
  131898. }
  131899. declare module BABYLON {
  131900. /**
  131901. * Block used to get the derivative value on x and y of a given input
  131902. */
  131903. export class DerivativeBlock extends NodeMaterialBlock {
  131904. /**
  131905. * Create a new DerivativeBlock
  131906. * @param name defines the block name
  131907. */
  131908. constructor(name: string);
  131909. /**
  131910. * Gets the current class name
  131911. * @returns the class name
  131912. */
  131913. getClassName(): string;
  131914. /**
  131915. * Gets the input component
  131916. */
  131917. get input(): NodeMaterialConnectionPoint;
  131918. /**
  131919. * Gets the derivative output on x
  131920. */
  131921. get dx(): NodeMaterialConnectionPoint;
  131922. /**
  131923. * Gets the derivative output on y
  131924. */
  131925. get dy(): NodeMaterialConnectionPoint;
  131926. protected _buildBlock(state: NodeMaterialBuildState): this;
  131927. }
  131928. }
  131929. declare module BABYLON {
  131930. /**
  131931. * Block used to add support for scene fog
  131932. */
  131933. export class FogBlock extends NodeMaterialBlock {
  131934. private _fogDistanceName;
  131935. private _fogParameters;
  131936. /**
  131937. * Create a new FogBlock
  131938. * @param name defines the block name
  131939. */
  131940. constructor(name: string);
  131941. /**
  131942. * Gets the current class name
  131943. * @returns the class name
  131944. */
  131945. getClassName(): string;
  131946. /**
  131947. * Gets the world position input component
  131948. */
  131949. get worldPosition(): NodeMaterialConnectionPoint;
  131950. /**
  131951. * Gets the view input component
  131952. */
  131953. get view(): NodeMaterialConnectionPoint;
  131954. /**
  131955. * Gets the color input component
  131956. */
  131957. get input(): NodeMaterialConnectionPoint;
  131958. /**
  131959. * Gets the fog color input component
  131960. */
  131961. get fogColor(): NodeMaterialConnectionPoint;
  131962. /**
  131963. * Gets the output component
  131964. */
  131965. get output(): NodeMaterialConnectionPoint;
  131966. autoConfigure(material: NodeMaterial): void;
  131967. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131968. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131969. protected _buildBlock(state: NodeMaterialBuildState): this;
  131970. }
  131971. }
  131972. declare module BABYLON {
  131973. /**
  131974. * Block used to add light in the fragment shader
  131975. */
  131976. export class LightBlock extends NodeMaterialBlock {
  131977. private _lightId;
  131978. /**
  131979. * Gets or sets the light associated with this block
  131980. */
  131981. light: Nullable<Light>;
  131982. /**
  131983. * Create a new LightBlock
  131984. * @param name defines the block name
  131985. */
  131986. constructor(name: string);
  131987. /**
  131988. * Gets the current class name
  131989. * @returns the class name
  131990. */
  131991. getClassName(): string;
  131992. /**
  131993. * Gets the world position input component
  131994. */
  131995. get worldPosition(): NodeMaterialConnectionPoint;
  131996. /**
  131997. * Gets the world normal input component
  131998. */
  131999. get worldNormal(): NodeMaterialConnectionPoint;
  132000. /**
  132001. * Gets the camera (or eye) position component
  132002. */
  132003. get cameraPosition(): NodeMaterialConnectionPoint;
  132004. /**
  132005. * Gets the glossiness component
  132006. */
  132007. get glossiness(): NodeMaterialConnectionPoint;
  132008. /**
  132009. * Gets the glossinness power component
  132010. */
  132011. get glossPower(): NodeMaterialConnectionPoint;
  132012. /**
  132013. * Gets the diffuse color component
  132014. */
  132015. get diffuseColor(): NodeMaterialConnectionPoint;
  132016. /**
  132017. * Gets the specular color component
  132018. */
  132019. get specularColor(): NodeMaterialConnectionPoint;
  132020. /**
  132021. * Gets the diffuse output component
  132022. */
  132023. get diffuseOutput(): NodeMaterialConnectionPoint;
  132024. /**
  132025. * Gets the specular output component
  132026. */
  132027. get specularOutput(): NodeMaterialConnectionPoint;
  132028. /**
  132029. * Gets the shadow output component
  132030. */
  132031. get shadow(): NodeMaterialConnectionPoint;
  132032. autoConfigure(material: NodeMaterial): void;
  132033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132034. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132035. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132036. private _injectVertexCode;
  132037. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132038. serialize(): any;
  132039. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132040. }
  132041. }
  132042. declare module BABYLON {
  132043. /**
  132044. * Block used to multiply 2 values
  132045. */
  132046. export class MultiplyBlock extends NodeMaterialBlock {
  132047. /**
  132048. * Creates a new MultiplyBlock
  132049. * @param name defines the block name
  132050. */
  132051. constructor(name: string);
  132052. /**
  132053. * Gets the current class name
  132054. * @returns the class name
  132055. */
  132056. getClassName(): string;
  132057. /**
  132058. * Gets the left operand input component
  132059. */
  132060. get left(): NodeMaterialConnectionPoint;
  132061. /**
  132062. * Gets the right operand input component
  132063. */
  132064. get right(): NodeMaterialConnectionPoint;
  132065. /**
  132066. * Gets the output component
  132067. */
  132068. get output(): NodeMaterialConnectionPoint;
  132069. protected _buildBlock(state: NodeMaterialBuildState): this;
  132070. }
  132071. }
  132072. declare module BABYLON {
  132073. /**
  132074. * Block used to add 2 vectors
  132075. */
  132076. export class AddBlock extends NodeMaterialBlock {
  132077. /**
  132078. * Creates a new AddBlock
  132079. * @param name defines the block name
  132080. */
  132081. constructor(name: string);
  132082. /**
  132083. * Gets the current class name
  132084. * @returns the class name
  132085. */
  132086. getClassName(): string;
  132087. /**
  132088. * Gets the left operand input component
  132089. */
  132090. get left(): NodeMaterialConnectionPoint;
  132091. /**
  132092. * Gets the right operand input component
  132093. */
  132094. get right(): NodeMaterialConnectionPoint;
  132095. /**
  132096. * Gets the output component
  132097. */
  132098. get output(): NodeMaterialConnectionPoint;
  132099. protected _buildBlock(state: NodeMaterialBuildState): this;
  132100. }
  132101. }
  132102. declare module BABYLON {
  132103. /**
  132104. * Block used to scale a vector by a float
  132105. */
  132106. export class ScaleBlock extends NodeMaterialBlock {
  132107. /**
  132108. * Creates a new ScaleBlock
  132109. * @param name defines the block name
  132110. */
  132111. constructor(name: string);
  132112. /**
  132113. * Gets the current class name
  132114. * @returns the class name
  132115. */
  132116. getClassName(): string;
  132117. /**
  132118. * Gets the input component
  132119. */
  132120. get input(): NodeMaterialConnectionPoint;
  132121. /**
  132122. * Gets the factor input component
  132123. */
  132124. get factor(): NodeMaterialConnectionPoint;
  132125. /**
  132126. * Gets the output component
  132127. */
  132128. get output(): NodeMaterialConnectionPoint;
  132129. protected _buildBlock(state: NodeMaterialBuildState): this;
  132130. }
  132131. }
  132132. declare module BABYLON {
  132133. /**
  132134. * Block used to clamp a float
  132135. */
  132136. export class ClampBlock extends NodeMaterialBlock {
  132137. /** Gets or sets the minimum range */
  132138. minimum: number;
  132139. /** Gets or sets the maximum range */
  132140. maximum: number;
  132141. /**
  132142. * Creates a new ClampBlock
  132143. * @param name defines the block name
  132144. */
  132145. constructor(name: string);
  132146. /**
  132147. * Gets the current class name
  132148. * @returns the class name
  132149. */
  132150. getClassName(): string;
  132151. /**
  132152. * Gets the value input component
  132153. */
  132154. get value(): NodeMaterialConnectionPoint;
  132155. /**
  132156. * Gets the output component
  132157. */
  132158. get output(): NodeMaterialConnectionPoint;
  132159. protected _buildBlock(state: NodeMaterialBuildState): this;
  132160. protected _dumpPropertiesCode(): string;
  132161. serialize(): any;
  132162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132163. }
  132164. }
  132165. declare module BABYLON {
  132166. /**
  132167. * Block used to apply a cross product between 2 vectors
  132168. */
  132169. export class CrossBlock extends NodeMaterialBlock {
  132170. /**
  132171. * Creates a new CrossBlock
  132172. * @param name defines the block name
  132173. */
  132174. constructor(name: string);
  132175. /**
  132176. * Gets the current class name
  132177. * @returns the class name
  132178. */
  132179. getClassName(): string;
  132180. /**
  132181. * Gets the left operand input component
  132182. */
  132183. get left(): NodeMaterialConnectionPoint;
  132184. /**
  132185. * Gets the right operand input component
  132186. */
  132187. get right(): NodeMaterialConnectionPoint;
  132188. /**
  132189. * Gets the output component
  132190. */
  132191. get output(): NodeMaterialConnectionPoint;
  132192. protected _buildBlock(state: NodeMaterialBuildState): this;
  132193. }
  132194. }
  132195. declare module BABYLON {
  132196. /**
  132197. * Block used to apply a dot product between 2 vectors
  132198. */
  132199. export class DotBlock extends NodeMaterialBlock {
  132200. /**
  132201. * Creates a new DotBlock
  132202. * @param name defines the block name
  132203. */
  132204. constructor(name: string);
  132205. /**
  132206. * Gets the current class name
  132207. * @returns the class name
  132208. */
  132209. getClassName(): string;
  132210. /**
  132211. * Gets the left operand input component
  132212. */
  132213. get left(): NodeMaterialConnectionPoint;
  132214. /**
  132215. * Gets the right operand input component
  132216. */
  132217. get right(): NodeMaterialConnectionPoint;
  132218. /**
  132219. * Gets the output component
  132220. */
  132221. get output(): NodeMaterialConnectionPoint;
  132222. protected _buildBlock(state: NodeMaterialBuildState): this;
  132223. }
  132224. }
  132225. declare module BABYLON {
  132226. /**
  132227. * Block used to remap a float from a range to a new one
  132228. */
  132229. export class RemapBlock extends NodeMaterialBlock {
  132230. /**
  132231. * Gets or sets the source range
  132232. */
  132233. sourceRange: Vector2;
  132234. /**
  132235. * Gets or sets the target range
  132236. */
  132237. targetRange: Vector2;
  132238. /**
  132239. * Creates a new RemapBlock
  132240. * @param name defines the block name
  132241. */
  132242. constructor(name: string);
  132243. /**
  132244. * Gets the current class name
  132245. * @returns the class name
  132246. */
  132247. getClassName(): string;
  132248. /**
  132249. * Gets the input component
  132250. */
  132251. get input(): NodeMaterialConnectionPoint;
  132252. /**
  132253. * Gets the source min input component
  132254. */
  132255. get sourceMin(): NodeMaterialConnectionPoint;
  132256. /**
  132257. * Gets the source max input component
  132258. */
  132259. get sourceMax(): NodeMaterialConnectionPoint;
  132260. /**
  132261. * Gets the target min input component
  132262. */
  132263. get targetMin(): NodeMaterialConnectionPoint;
  132264. /**
  132265. * Gets the target max input component
  132266. */
  132267. get targetMax(): NodeMaterialConnectionPoint;
  132268. /**
  132269. * Gets the output component
  132270. */
  132271. get output(): NodeMaterialConnectionPoint;
  132272. protected _buildBlock(state: NodeMaterialBuildState): this;
  132273. protected _dumpPropertiesCode(): string;
  132274. serialize(): any;
  132275. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132276. }
  132277. }
  132278. declare module BABYLON {
  132279. /**
  132280. * Block used to normalize a vector
  132281. */
  132282. export class NormalizeBlock extends NodeMaterialBlock {
  132283. /**
  132284. * Creates a new NormalizeBlock
  132285. * @param name defines the block name
  132286. */
  132287. constructor(name: string);
  132288. /**
  132289. * Gets the current class name
  132290. * @returns the class name
  132291. */
  132292. getClassName(): string;
  132293. /**
  132294. * Gets the input component
  132295. */
  132296. get input(): NodeMaterialConnectionPoint;
  132297. /**
  132298. * Gets the output component
  132299. */
  132300. get output(): NodeMaterialConnectionPoint;
  132301. protected _buildBlock(state: NodeMaterialBuildState): this;
  132302. }
  132303. }
  132304. declare module BABYLON {
  132305. /**
  132306. * Operations supported by the Trigonometry block
  132307. */
  132308. export enum TrigonometryBlockOperations {
  132309. /** Cos */
  132310. Cos = 0,
  132311. /** Sin */
  132312. Sin = 1,
  132313. /** Abs */
  132314. Abs = 2,
  132315. /** Exp */
  132316. Exp = 3,
  132317. /** Exp2 */
  132318. Exp2 = 4,
  132319. /** Round */
  132320. Round = 5,
  132321. /** Floor */
  132322. Floor = 6,
  132323. /** Ceiling */
  132324. Ceiling = 7,
  132325. /** Square root */
  132326. Sqrt = 8,
  132327. /** Log */
  132328. Log = 9,
  132329. /** Tangent */
  132330. Tan = 10,
  132331. /** Arc tangent */
  132332. ArcTan = 11,
  132333. /** Arc cosinus */
  132334. ArcCos = 12,
  132335. /** Arc sinus */
  132336. ArcSin = 13,
  132337. /** Fraction */
  132338. Fract = 14,
  132339. /** Sign */
  132340. Sign = 15,
  132341. /** To radians (from degrees) */
  132342. Radians = 16,
  132343. /** To degrees (from radians) */
  132344. Degrees = 17
  132345. }
  132346. /**
  132347. * Block used to apply trigonometry operation to floats
  132348. */
  132349. export class TrigonometryBlock extends NodeMaterialBlock {
  132350. /**
  132351. * Gets or sets the operation applied by the block
  132352. */
  132353. operation: TrigonometryBlockOperations;
  132354. /**
  132355. * Creates a new TrigonometryBlock
  132356. * @param name defines the block name
  132357. */
  132358. constructor(name: string);
  132359. /**
  132360. * Gets the current class name
  132361. * @returns the class name
  132362. */
  132363. getClassName(): string;
  132364. /**
  132365. * Gets the input component
  132366. */
  132367. get input(): NodeMaterialConnectionPoint;
  132368. /**
  132369. * Gets the output component
  132370. */
  132371. get output(): NodeMaterialConnectionPoint;
  132372. protected _buildBlock(state: NodeMaterialBuildState): this;
  132373. serialize(): any;
  132374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132375. protected _dumpPropertiesCode(): string;
  132376. }
  132377. }
  132378. declare module BABYLON {
  132379. /**
  132380. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132381. */
  132382. export class ColorMergerBlock extends NodeMaterialBlock {
  132383. /**
  132384. * Create a new ColorMergerBlock
  132385. * @param name defines the block name
  132386. */
  132387. constructor(name: string);
  132388. /**
  132389. * Gets the current class name
  132390. * @returns the class name
  132391. */
  132392. getClassName(): string;
  132393. /**
  132394. * Gets the rgb component (input)
  132395. */
  132396. get rgbIn(): NodeMaterialConnectionPoint;
  132397. /**
  132398. * Gets the r component (input)
  132399. */
  132400. get r(): NodeMaterialConnectionPoint;
  132401. /**
  132402. * Gets the g component (input)
  132403. */
  132404. get g(): NodeMaterialConnectionPoint;
  132405. /**
  132406. * Gets the b component (input)
  132407. */
  132408. get b(): NodeMaterialConnectionPoint;
  132409. /**
  132410. * Gets the a component (input)
  132411. */
  132412. get a(): NodeMaterialConnectionPoint;
  132413. /**
  132414. * Gets the rgba component (output)
  132415. */
  132416. get rgba(): NodeMaterialConnectionPoint;
  132417. /**
  132418. * Gets the rgb component (output)
  132419. */
  132420. get rgbOut(): NodeMaterialConnectionPoint;
  132421. /**
  132422. * Gets the rgb component (output)
  132423. * @deprecated Please use rgbOut instead.
  132424. */
  132425. get rgb(): NodeMaterialConnectionPoint;
  132426. protected _buildBlock(state: NodeMaterialBuildState): this;
  132427. }
  132428. }
  132429. declare module BABYLON {
  132430. /**
  132431. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132432. */
  132433. export class VectorMergerBlock extends NodeMaterialBlock {
  132434. /**
  132435. * Create a new VectorMergerBlock
  132436. * @param name defines the block name
  132437. */
  132438. constructor(name: string);
  132439. /**
  132440. * Gets the current class name
  132441. * @returns the class name
  132442. */
  132443. getClassName(): string;
  132444. /**
  132445. * Gets the xyz component (input)
  132446. */
  132447. get xyzIn(): NodeMaterialConnectionPoint;
  132448. /**
  132449. * Gets the xy component (input)
  132450. */
  132451. get xyIn(): NodeMaterialConnectionPoint;
  132452. /**
  132453. * Gets the x component (input)
  132454. */
  132455. get x(): NodeMaterialConnectionPoint;
  132456. /**
  132457. * Gets the y component (input)
  132458. */
  132459. get y(): NodeMaterialConnectionPoint;
  132460. /**
  132461. * Gets the z component (input)
  132462. */
  132463. get z(): NodeMaterialConnectionPoint;
  132464. /**
  132465. * Gets the w component (input)
  132466. */
  132467. get w(): NodeMaterialConnectionPoint;
  132468. /**
  132469. * Gets the xyzw component (output)
  132470. */
  132471. get xyzw(): NodeMaterialConnectionPoint;
  132472. /**
  132473. * Gets the xyz component (output)
  132474. */
  132475. get xyzOut(): NodeMaterialConnectionPoint;
  132476. /**
  132477. * Gets the xy component (output)
  132478. */
  132479. get xyOut(): NodeMaterialConnectionPoint;
  132480. /**
  132481. * Gets the xy component (output)
  132482. * @deprecated Please use xyOut instead.
  132483. */
  132484. get xy(): NodeMaterialConnectionPoint;
  132485. /**
  132486. * Gets the xyz component (output)
  132487. * @deprecated Please use xyzOut instead.
  132488. */
  132489. get xyz(): NodeMaterialConnectionPoint;
  132490. protected _buildBlock(state: NodeMaterialBuildState): this;
  132491. }
  132492. }
  132493. declare module BABYLON {
  132494. /**
  132495. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132496. */
  132497. export class ColorSplitterBlock extends NodeMaterialBlock {
  132498. /**
  132499. * Create a new ColorSplitterBlock
  132500. * @param name defines the block name
  132501. */
  132502. constructor(name: string);
  132503. /**
  132504. * Gets the current class name
  132505. * @returns the class name
  132506. */
  132507. getClassName(): string;
  132508. /**
  132509. * Gets the rgba component (input)
  132510. */
  132511. get rgba(): NodeMaterialConnectionPoint;
  132512. /**
  132513. * Gets the rgb component (input)
  132514. */
  132515. get rgbIn(): NodeMaterialConnectionPoint;
  132516. /**
  132517. * Gets the rgb component (output)
  132518. */
  132519. get rgbOut(): NodeMaterialConnectionPoint;
  132520. /**
  132521. * Gets the r component (output)
  132522. */
  132523. get r(): NodeMaterialConnectionPoint;
  132524. /**
  132525. * Gets the g component (output)
  132526. */
  132527. get g(): NodeMaterialConnectionPoint;
  132528. /**
  132529. * Gets the b component (output)
  132530. */
  132531. get b(): NodeMaterialConnectionPoint;
  132532. /**
  132533. * Gets the a component (output)
  132534. */
  132535. get a(): NodeMaterialConnectionPoint;
  132536. protected _inputRename(name: string): string;
  132537. protected _outputRename(name: string): string;
  132538. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132539. }
  132540. }
  132541. declare module BABYLON {
  132542. /**
  132543. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132544. */
  132545. export class VectorSplitterBlock extends NodeMaterialBlock {
  132546. /**
  132547. * Create a new VectorSplitterBlock
  132548. * @param name defines the block name
  132549. */
  132550. constructor(name: string);
  132551. /**
  132552. * Gets the current class name
  132553. * @returns the class name
  132554. */
  132555. getClassName(): string;
  132556. /**
  132557. * Gets the xyzw component (input)
  132558. */
  132559. get xyzw(): NodeMaterialConnectionPoint;
  132560. /**
  132561. * Gets the xyz component (input)
  132562. */
  132563. get xyzIn(): NodeMaterialConnectionPoint;
  132564. /**
  132565. * Gets the xy component (input)
  132566. */
  132567. get xyIn(): NodeMaterialConnectionPoint;
  132568. /**
  132569. * Gets the xyz component (output)
  132570. */
  132571. get xyzOut(): NodeMaterialConnectionPoint;
  132572. /**
  132573. * Gets the xy component (output)
  132574. */
  132575. get xyOut(): NodeMaterialConnectionPoint;
  132576. /**
  132577. * Gets the x component (output)
  132578. */
  132579. get x(): NodeMaterialConnectionPoint;
  132580. /**
  132581. * Gets the y component (output)
  132582. */
  132583. get y(): NodeMaterialConnectionPoint;
  132584. /**
  132585. * Gets the z component (output)
  132586. */
  132587. get z(): NodeMaterialConnectionPoint;
  132588. /**
  132589. * Gets the w component (output)
  132590. */
  132591. get w(): NodeMaterialConnectionPoint;
  132592. protected _inputRename(name: string): string;
  132593. protected _outputRename(name: string): string;
  132594. protected _buildBlock(state: NodeMaterialBuildState): this;
  132595. }
  132596. }
  132597. declare module BABYLON {
  132598. /**
  132599. * Block used to lerp between 2 values
  132600. */
  132601. export class LerpBlock extends NodeMaterialBlock {
  132602. /**
  132603. * Creates a new LerpBlock
  132604. * @param name defines the block name
  132605. */
  132606. constructor(name: string);
  132607. /**
  132608. * Gets the current class name
  132609. * @returns the class name
  132610. */
  132611. getClassName(): string;
  132612. /**
  132613. * Gets the left operand input component
  132614. */
  132615. get left(): NodeMaterialConnectionPoint;
  132616. /**
  132617. * Gets the right operand input component
  132618. */
  132619. get right(): NodeMaterialConnectionPoint;
  132620. /**
  132621. * Gets the gradient operand input component
  132622. */
  132623. get gradient(): NodeMaterialConnectionPoint;
  132624. /**
  132625. * Gets the output component
  132626. */
  132627. get output(): NodeMaterialConnectionPoint;
  132628. protected _buildBlock(state: NodeMaterialBuildState): this;
  132629. }
  132630. }
  132631. declare module BABYLON {
  132632. /**
  132633. * Block used to divide 2 vectors
  132634. */
  132635. export class DivideBlock extends NodeMaterialBlock {
  132636. /**
  132637. * Creates a new DivideBlock
  132638. * @param name defines the block name
  132639. */
  132640. constructor(name: string);
  132641. /**
  132642. * Gets the current class name
  132643. * @returns the class name
  132644. */
  132645. getClassName(): string;
  132646. /**
  132647. * Gets the left operand input component
  132648. */
  132649. get left(): NodeMaterialConnectionPoint;
  132650. /**
  132651. * Gets the right operand input component
  132652. */
  132653. get right(): NodeMaterialConnectionPoint;
  132654. /**
  132655. * Gets the output component
  132656. */
  132657. get output(): NodeMaterialConnectionPoint;
  132658. protected _buildBlock(state: NodeMaterialBuildState): this;
  132659. }
  132660. }
  132661. declare module BABYLON {
  132662. /**
  132663. * Block used to subtract 2 vectors
  132664. */
  132665. export class SubtractBlock extends NodeMaterialBlock {
  132666. /**
  132667. * Creates a new SubtractBlock
  132668. * @param name defines the block name
  132669. */
  132670. constructor(name: string);
  132671. /**
  132672. * Gets the current class name
  132673. * @returns the class name
  132674. */
  132675. getClassName(): string;
  132676. /**
  132677. * Gets the left operand input component
  132678. */
  132679. get left(): NodeMaterialConnectionPoint;
  132680. /**
  132681. * Gets the right operand input component
  132682. */
  132683. get right(): NodeMaterialConnectionPoint;
  132684. /**
  132685. * Gets the output component
  132686. */
  132687. get output(): NodeMaterialConnectionPoint;
  132688. protected _buildBlock(state: NodeMaterialBuildState): this;
  132689. }
  132690. }
  132691. declare module BABYLON {
  132692. /**
  132693. * Block used to step a value
  132694. */
  132695. export class StepBlock extends NodeMaterialBlock {
  132696. /**
  132697. * Creates a new StepBlock
  132698. * @param name defines the block name
  132699. */
  132700. constructor(name: string);
  132701. /**
  132702. * Gets the current class name
  132703. * @returns the class name
  132704. */
  132705. getClassName(): string;
  132706. /**
  132707. * Gets the value operand input component
  132708. */
  132709. get value(): NodeMaterialConnectionPoint;
  132710. /**
  132711. * Gets the edge operand input component
  132712. */
  132713. get edge(): NodeMaterialConnectionPoint;
  132714. /**
  132715. * Gets the output component
  132716. */
  132717. get output(): NodeMaterialConnectionPoint;
  132718. protected _buildBlock(state: NodeMaterialBuildState): this;
  132719. }
  132720. }
  132721. declare module BABYLON {
  132722. /**
  132723. * Block used to get the opposite (1 - x) of a value
  132724. */
  132725. export class OneMinusBlock extends NodeMaterialBlock {
  132726. /**
  132727. * Creates a new OneMinusBlock
  132728. * @param name defines the block name
  132729. */
  132730. constructor(name: string);
  132731. /**
  132732. * Gets the current class name
  132733. * @returns the class name
  132734. */
  132735. getClassName(): string;
  132736. /**
  132737. * Gets the input component
  132738. */
  132739. get input(): NodeMaterialConnectionPoint;
  132740. /**
  132741. * Gets the output component
  132742. */
  132743. get output(): NodeMaterialConnectionPoint;
  132744. protected _buildBlock(state: NodeMaterialBuildState): this;
  132745. }
  132746. }
  132747. declare module BABYLON {
  132748. /**
  132749. * Block used to get the view direction
  132750. */
  132751. export class ViewDirectionBlock extends NodeMaterialBlock {
  132752. /**
  132753. * Creates a new ViewDirectionBlock
  132754. * @param name defines the block name
  132755. */
  132756. constructor(name: string);
  132757. /**
  132758. * Gets the current class name
  132759. * @returns the class name
  132760. */
  132761. getClassName(): string;
  132762. /**
  132763. * Gets the world position component
  132764. */
  132765. get worldPosition(): NodeMaterialConnectionPoint;
  132766. /**
  132767. * Gets the camera position component
  132768. */
  132769. get cameraPosition(): NodeMaterialConnectionPoint;
  132770. /**
  132771. * Gets the output component
  132772. */
  132773. get output(): NodeMaterialConnectionPoint;
  132774. autoConfigure(material: NodeMaterial): void;
  132775. protected _buildBlock(state: NodeMaterialBuildState): this;
  132776. }
  132777. }
  132778. declare module BABYLON {
  132779. /**
  132780. * Block used to compute fresnel value
  132781. */
  132782. export class FresnelBlock extends NodeMaterialBlock {
  132783. /**
  132784. * Create a new FresnelBlock
  132785. * @param name defines the block name
  132786. */
  132787. constructor(name: string);
  132788. /**
  132789. * Gets the current class name
  132790. * @returns the class name
  132791. */
  132792. getClassName(): string;
  132793. /**
  132794. * Gets the world normal input component
  132795. */
  132796. get worldNormal(): NodeMaterialConnectionPoint;
  132797. /**
  132798. * Gets the view direction input component
  132799. */
  132800. get viewDirection(): NodeMaterialConnectionPoint;
  132801. /**
  132802. * Gets the bias input component
  132803. */
  132804. get bias(): NodeMaterialConnectionPoint;
  132805. /**
  132806. * Gets the camera (or eye) position component
  132807. */
  132808. get power(): NodeMaterialConnectionPoint;
  132809. /**
  132810. * Gets the fresnel output component
  132811. */
  132812. get fresnel(): NodeMaterialConnectionPoint;
  132813. autoConfigure(material: NodeMaterial): void;
  132814. protected _buildBlock(state: NodeMaterialBuildState): this;
  132815. }
  132816. }
  132817. declare module BABYLON {
  132818. /**
  132819. * Block used to get the max of 2 values
  132820. */
  132821. export class MaxBlock extends NodeMaterialBlock {
  132822. /**
  132823. * Creates a new MaxBlock
  132824. * @param name defines the block name
  132825. */
  132826. constructor(name: string);
  132827. /**
  132828. * Gets the current class name
  132829. * @returns the class name
  132830. */
  132831. getClassName(): string;
  132832. /**
  132833. * Gets the left operand input component
  132834. */
  132835. get left(): NodeMaterialConnectionPoint;
  132836. /**
  132837. * Gets the right operand input component
  132838. */
  132839. get right(): NodeMaterialConnectionPoint;
  132840. /**
  132841. * Gets the output component
  132842. */
  132843. get output(): NodeMaterialConnectionPoint;
  132844. protected _buildBlock(state: NodeMaterialBuildState): this;
  132845. }
  132846. }
  132847. declare module BABYLON {
  132848. /**
  132849. * Block used to get the min of 2 values
  132850. */
  132851. export class MinBlock extends NodeMaterialBlock {
  132852. /**
  132853. * Creates a new MinBlock
  132854. * @param name defines the block name
  132855. */
  132856. constructor(name: string);
  132857. /**
  132858. * Gets the current class name
  132859. * @returns the class name
  132860. */
  132861. getClassName(): string;
  132862. /**
  132863. * Gets the left operand input component
  132864. */
  132865. get left(): NodeMaterialConnectionPoint;
  132866. /**
  132867. * Gets the right operand input component
  132868. */
  132869. get right(): NodeMaterialConnectionPoint;
  132870. /**
  132871. * Gets the output component
  132872. */
  132873. get output(): NodeMaterialConnectionPoint;
  132874. protected _buildBlock(state: NodeMaterialBuildState): this;
  132875. }
  132876. }
  132877. declare module BABYLON {
  132878. /**
  132879. * Block used to get the distance between 2 values
  132880. */
  132881. export class DistanceBlock extends NodeMaterialBlock {
  132882. /**
  132883. * Creates a new DistanceBlock
  132884. * @param name defines the block name
  132885. */
  132886. constructor(name: string);
  132887. /**
  132888. * Gets the current class name
  132889. * @returns the class name
  132890. */
  132891. getClassName(): string;
  132892. /**
  132893. * Gets the left operand input component
  132894. */
  132895. get left(): NodeMaterialConnectionPoint;
  132896. /**
  132897. * Gets the right operand input component
  132898. */
  132899. get right(): NodeMaterialConnectionPoint;
  132900. /**
  132901. * Gets the output component
  132902. */
  132903. get output(): NodeMaterialConnectionPoint;
  132904. protected _buildBlock(state: NodeMaterialBuildState): this;
  132905. }
  132906. }
  132907. declare module BABYLON {
  132908. /**
  132909. * Block used to get the length of a vector
  132910. */
  132911. export class LengthBlock extends NodeMaterialBlock {
  132912. /**
  132913. * Creates a new LengthBlock
  132914. * @param name defines the block name
  132915. */
  132916. constructor(name: string);
  132917. /**
  132918. * Gets the current class name
  132919. * @returns the class name
  132920. */
  132921. getClassName(): string;
  132922. /**
  132923. * Gets the value input component
  132924. */
  132925. get value(): NodeMaterialConnectionPoint;
  132926. /**
  132927. * Gets the output component
  132928. */
  132929. get output(): NodeMaterialConnectionPoint;
  132930. protected _buildBlock(state: NodeMaterialBuildState): this;
  132931. }
  132932. }
  132933. declare module BABYLON {
  132934. /**
  132935. * Block used to get negative version of a value (i.e. x * -1)
  132936. */
  132937. export class NegateBlock extends NodeMaterialBlock {
  132938. /**
  132939. * Creates a new NegateBlock
  132940. * @param name defines the block name
  132941. */
  132942. constructor(name: string);
  132943. /**
  132944. * Gets the current class name
  132945. * @returns the class name
  132946. */
  132947. getClassName(): string;
  132948. /**
  132949. * Gets the value input component
  132950. */
  132951. get value(): NodeMaterialConnectionPoint;
  132952. /**
  132953. * Gets the output component
  132954. */
  132955. get output(): NodeMaterialConnectionPoint;
  132956. protected _buildBlock(state: NodeMaterialBuildState): this;
  132957. }
  132958. }
  132959. declare module BABYLON {
  132960. /**
  132961. * Block used to get the value of the first parameter raised to the power of the second
  132962. */
  132963. export class PowBlock extends NodeMaterialBlock {
  132964. /**
  132965. * Creates a new PowBlock
  132966. * @param name defines the block name
  132967. */
  132968. constructor(name: string);
  132969. /**
  132970. * Gets the current class name
  132971. * @returns the class name
  132972. */
  132973. getClassName(): string;
  132974. /**
  132975. * Gets the value operand input component
  132976. */
  132977. get value(): NodeMaterialConnectionPoint;
  132978. /**
  132979. * Gets the power operand input component
  132980. */
  132981. get power(): NodeMaterialConnectionPoint;
  132982. /**
  132983. * Gets the output component
  132984. */
  132985. get output(): NodeMaterialConnectionPoint;
  132986. protected _buildBlock(state: NodeMaterialBuildState): this;
  132987. }
  132988. }
  132989. declare module BABYLON {
  132990. /**
  132991. * Block used to get a random number
  132992. */
  132993. export class RandomNumberBlock extends NodeMaterialBlock {
  132994. /**
  132995. * Creates a new RandomNumberBlock
  132996. * @param name defines the block name
  132997. */
  132998. constructor(name: string);
  132999. /**
  133000. * Gets the current class name
  133001. * @returns the class name
  133002. */
  133003. getClassName(): string;
  133004. /**
  133005. * Gets the seed input component
  133006. */
  133007. get seed(): NodeMaterialConnectionPoint;
  133008. /**
  133009. * Gets the output component
  133010. */
  133011. get output(): NodeMaterialConnectionPoint;
  133012. protected _buildBlock(state: NodeMaterialBuildState): this;
  133013. }
  133014. }
  133015. declare module BABYLON {
  133016. /**
  133017. * Block used to compute arc tangent of 2 values
  133018. */
  133019. export class ArcTan2Block extends NodeMaterialBlock {
  133020. /**
  133021. * Creates a new ArcTan2Block
  133022. * @param name defines the block name
  133023. */
  133024. constructor(name: string);
  133025. /**
  133026. * Gets the current class name
  133027. * @returns the class name
  133028. */
  133029. getClassName(): string;
  133030. /**
  133031. * Gets the x operand input component
  133032. */
  133033. get x(): NodeMaterialConnectionPoint;
  133034. /**
  133035. * Gets the y operand input component
  133036. */
  133037. get y(): NodeMaterialConnectionPoint;
  133038. /**
  133039. * Gets the output component
  133040. */
  133041. get output(): NodeMaterialConnectionPoint;
  133042. protected _buildBlock(state: NodeMaterialBuildState): this;
  133043. }
  133044. }
  133045. declare module BABYLON {
  133046. /**
  133047. * Block used to smooth step a value
  133048. */
  133049. export class SmoothStepBlock extends NodeMaterialBlock {
  133050. /**
  133051. * Creates a new SmoothStepBlock
  133052. * @param name defines the block name
  133053. */
  133054. constructor(name: string);
  133055. /**
  133056. * Gets the current class name
  133057. * @returns the class name
  133058. */
  133059. getClassName(): string;
  133060. /**
  133061. * Gets the value operand input component
  133062. */
  133063. get value(): NodeMaterialConnectionPoint;
  133064. /**
  133065. * Gets the first edge operand input component
  133066. */
  133067. get edge0(): NodeMaterialConnectionPoint;
  133068. /**
  133069. * Gets the second edge operand input component
  133070. */
  133071. get edge1(): NodeMaterialConnectionPoint;
  133072. /**
  133073. * Gets the output component
  133074. */
  133075. get output(): NodeMaterialConnectionPoint;
  133076. protected _buildBlock(state: NodeMaterialBuildState): this;
  133077. }
  133078. }
  133079. declare module BABYLON {
  133080. /**
  133081. * Block used to get the reciprocal (1 / x) of a value
  133082. */
  133083. export class ReciprocalBlock extends NodeMaterialBlock {
  133084. /**
  133085. * Creates a new ReciprocalBlock
  133086. * @param name defines the block name
  133087. */
  133088. constructor(name: string);
  133089. /**
  133090. * Gets the current class name
  133091. * @returns the class name
  133092. */
  133093. getClassName(): string;
  133094. /**
  133095. * Gets the input component
  133096. */
  133097. get input(): NodeMaterialConnectionPoint;
  133098. /**
  133099. * Gets the output component
  133100. */
  133101. get output(): NodeMaterialConnectionPoint;
  133102. protected _buildBlock(state: NodeMaterialBuildState): this;
  133103. }
  133104. }
  133105. declare module BABYLON {
  133106. /**
  133107. * Block used to replace a color by another one
  133108. */
  133109. export class ReplaceColorBlock extends NodeMaterialBlock {
  133110. /**
  133111. * Creates a new ReplaceColorBlock
  133112. * @param name defines the block name
  133113. */
  133114. constructor(name: string);
  133115. /**
  133116. * Gets the current class name
  133117. * @returns the class name
  133118. */
  133119. getClassName(): string;
  133120. /**
  133121. * Gets the value input component
  133122. */
  133123. get value(): NodeMaterialConnectionPoint;
  133124. /**
  133125. * Gets the reference input component
  133126. */
  133127. get reference(): NodeMaterialConnectionPoint;
  133128. /**
  133129. * Gets the distance input component
  133130. */
  133131. get distance(): NodeMaterialConnectionPoint;
  133132. /**
  133133. * Gets the replacement input component
  133134. */
  133135. get replacement(): NodeMaterialConnectionPoint;
  133136. /**
  133137. * Gets the output component
  133138. */
  133139. get output(): NodeMaterialConnectionPoint;
  133140. protected _buildBlock(state: NodeMaterialBuildState): this;
  133141. }
  133142. }
  133143. declare module BABYLON {
  133144. /**
  133145. * Block used to posterize a value
  133146. * @see https://en.wikipedia.org/wiki/Posterization
  133147. */
  133148. export class PosterizeBlock extends NodeMaterialBlock {
  133149. /**
  133150. * Creates a new PosterizeBlock
  133151. * @param name defines the block name
  133152. */
  133153. constructor(name: string);
  133154. /**
  133155. * Gets the current class name
  133156. * @returns the class name
  133157. */
  133158. getClassName(): string;
  133159. /**
  133160. * Gets the value input component
  133161. */
  133162. get value(): NodeMaterialConnectionPoint;
  133163. /**
  133164. * Gets the steps input component
  133165. */
  133166. get steps(): NodeMaterialConnectionPoint;
  133167. /**
  133168. * Gets the output component
  133169. */
  133170. get output(): NodeMaterialConnectionPoint;
  133171. protected _buildBlock(state: NodeMaterialBuildState): this;
  133172. }
  133173. }
  133174. declare module BABYLON {
  133175. /**
  133176. * Operations supported by the Wave block
  133177. */
  133178. export enum WaveBlockKind {
  133179. /** SawTooth */
  133180. SawTooth = 0,
  133181. /** Square */
  133182. Square = 1,
  133183. /** Triangle */
  133184. Triangle = 2
  133185. }
  133186. /**
  133187. * Block used to apply wave operation to floats
  133188. */
  133189. export class WaveBlock extends NodeMaterialBlock {
  133190. /**
  133191. * Gets or sets the kibnd of wave to be applied by the block
  133192. */
  133193. kind: WaveBlockKind;
  133194. /**
  133195. * Creates a new WaveBlock
  133196. * @param name defines the block name
  133197. */
  133198. constructor(name: string);
  133199. /**
  133200. * Gets the current class name
  133201. * @returns the class name
  133202. */
  133203. getClassName(): string;
  133204. /**
  133205. * Gets the input component
  133206. */
  133207. get input(): NodeMaterialConnectionPoint;
  133208. /**
  133209. * Gets the output component
  133210. */
  133211. get output(): NodeMaterialConnectionPoint;
  133212. protected _buildBlock(state: NodeMaterialBuildState): this;
  133213. serialize(): any;
  133214. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133215. }
  133216. }
  133217. declare module BABYLON {
  133218. /**
  133219. * Class used to store a color step for the GradientBlock
  133220. */
  133221. export class GradientBlockColorStep {
  133222. /**
  133223. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133224. */
  133225. step: number;
  133226. /**
  133227. * Gets or sets the color associated with this step
  133228. */
  133229. color: Color3;
  133230. /**
  133231. * Creates a new GradientBlockColorStep
  133232. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133233. * @param color defines the color associated with this step
  133234. */
  133235. constructor(
  133236. /**
  133237. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133238. */
  133239. step: number,
  133240. /**
  133241. * Gets or sets the color associated with this step
  133242. */
  133243. color: Color3);
  133244. }
  133245. /**
  133246. * Block used to return a color from a gradient based on an input value between 0 and 1
  133247. */
  133248. export class GradientBlock extends NodeMaterialBlock {
  133249. /**
  133250. * Gets or sets the list of color steps
  133251. */
  133252. colorSteps: GradientBlockColorStep[];
  133253. /**
  133254. * Creates a new GradientBlock
  133255. * @param name defines the block name
  133256. */
  133257. constructor(name: string);
  133258. /**
  133259. * Gets the current class name
  133260. * @returns the class name
  133261. */
  133262. getClassName(): string;
  133263. /**
  133264. * Gets the gradient input component
  133265. */
  133266. get gradient(): NodeMaterialConnectionPoint;
  133267. /**
  133268. * Gets the output component
  133269. */
  133270. get output(): NodeMaterialConnectionPoint;
  133271. private _writeColorConstant;
  133272. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133273. serialize(): any;
  133274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133275. protected _dumpPropertiesCode(): string;
  133276. }
  133277. }
  133278. declare module BABYLON {
  133279. /**
  133280. * Block used to normalize lerp between 2 values
  133281. */
  133282. export class NLerpBlock extends NodeMaterialBlock {
  133283. /**
  133284. * Creates a new NLerpBlock
  133285. * @param name defines the block name
  133286. */
  133287. constructor(name: string);
  133288. /**
  133289. * Gets the current class name
  133290. * @returns the class name
  133291. */
  133292. getClassName(): string;
  133293. /**
  133294. * Gets the left operand input component
  133295. */
  133296. get left(): NodeMaterialConnectionPoint;
  133297. /**
  133298. * Gets the right operand input component
  133299. */
  133300. get right(): NodeMaterialConnectionPoint;
  133301. /**
  133302. * Gets the gradient operand input component
  133303. */
  133304. get gradient(): NodeMaterialConnectionPoint;
  133305. /**
  133306. * Gets the output component
  133307. */
  133308. get output(): NodeMaterialConnectionPoint;
  133309. protected _buildBlock(state: NodeMaterialBuildState): this;
  133310. }
  133311. }
  133312. declare module BABYLON {
  133313. /**
  133314. * block used to Generate a Worley Noise 3D Noise Pattern
  133315. */
  133316. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133317. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133318. manhattanDistance: boolean;
  133319. /**
  133320. * Creates a new WorleyNoise3DBlock
  133321. * @param name defines the block name
  133322. */
  133323. constructor(name: string);
  133324. /**
  133325. * Gets the current class name
  133326. * @returns the class name
  133327. */
  133328. getClassName(): string;
  133329. /**
  133330. * Gets the seed input component
  133331. */
  133332. get seed(): NodeMaterialConnectionPoint;
  133333. /**
  133334. * Gets the jitter input component
  133335. */
  133336. get jitter(): NodeMaterialConnectionPoint;
  133337. /**
  133338. * Gets the output component
  133339. */
  133340. get output(): NodeMaterialConnectionPoint;
  133341. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133342. /**
  133343. * Exposes the properties to the UI?
  133344. */
  133345. protected _dumpPropertiesCode(): string;
  133346. /**
  133347. * Exposes the properties to the Seralize?
  133348. */
  133349. serialize(): any;
  133350. /**
  133351. * Exposes the properties to the deseralize?
  133352. */
  133353. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133354. }
  133355. }
  133356. declare module BABYLON {
  133357. /**
  133358. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133359. */
  133360. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133361. /**
  133362. * Creates a new SimplexPerlin3DBlock
  133363. * @param name defines the block name
  133364. */
  133365. constructor(name: string);
  133366. /**
  133367. * Gets the current class name
  133368. * @returns the class name
  133369. */
  133370. getClassName(): string;
  133371. /**
  133372. * Gets the seed operand input component
  133373. */
  133374. get seed(): NodeMaterialConnectionPoint;
  133375. /**
  133376. * Gets the output component
  133377. */
  133378. get output(): NodeMaterialConnectionPoint;
  133379. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133380. }
  133381. }
  133382. declare module BABYLON {
  133383. /**
  133384. * Block used to blend normals
  133385. */
  133386. export class NormalBlendBlock extends NodeMaterialBlock {
  133387. /**
  133388. * Creates a new NormalBlendBlock
  133389. * @param name defines the block name
  133390. */
  133391. constructor(name: string);
  133392. /**
  133393. * Gets the current class name
  133394. * @returns the class name
  133395. */
  133396. getClassName(): string;
  133397. /**
  133398. * Gets the first input component
  133399. */
  133400. get normalMap0(): NodeMaterialConnectionPoint;
  133401. /**
  133402. * Gets the second input component
  133403. */
  133404. get normalMap1(): NodeMaterialConnectionPoint;
  133405. /**
  133406. * Gets the output component
  133407. */
  133408. get output(): NodeMaterialConnectionPoint;
  133409. protected _buildBlock(state: NodeMaterialBuildState): this;
  133410. }
  133411. }
  133412. declare module BABYLON {
  133413. /**
  133414. * Block used to rotate a 2d vector by a given angle
  133415. */
  133416. export class Rotate2dBlock extends NodeMaterialBlock {
  133417. /**
  133418. * Creates a new Rotate2dBlock
  133419. * @param name defines the block name
  133420. */
  133421. constructor(name: string);
  133422. /**
  133423. * Gets the current class name
  133424. * @returns the class name
  133425. */
  133426. getClassName(): string;
  133427. /**
  133428. * Gets the input vector
  133429. */
  133430. get input(): NodeMaterialConnectionPoint;
  133431. /**
  133432. * Gets the input angle
  133433. */
  133434. get angle(): NodeMaterialConnectionPoint;
  133435. /**
  133436. * Gets the output component
  133437. */
  133438. get output(): NodeMaterialConnectionPoint;
  133439. autoConfigure(material: NodeMaterial): void;
  133440. protected _buildBlock(state: NodeMaterialBuildState): this;
  133441. }
  133442. }
  133443. declare module BABYLON {
  133444. /**
  133445. * Block used to get the reflected vector from a direction and a normal
  133446. */
  133447. export class ReflectBlock extends NodeMaterialBlock {
  133448. /**
  133449. * Creates a new ReflectBlock
  133450. * @param name defines the block name
  133451. */
  133452. constructor(name: string);
  133453. /**
  133454. * Gets the current class name
  133455. * @returns the class name
  133456. */
  133457. getClassName(): string;
  133458. /**
  133459. * Gets the incident component
  133460. */
  133461. get incident(): NodeMaterialConnectionPoint;
  133462. /**
  133463. * Gets the normal component
  133464. */
  133465. get normal(): NodeMaterialConnectionPoint;
  133466. /**
  133467. * Gets the output component
  133468. */
  133469. get output(): NodeMaterialConnectionPoint;
  133470. protected _buildBlock(state: NodeMaterialBuildState): this;
  133471. }
  133472. }
  133473. declare module BABYLON {
  133474. /**
  133475. * Block used to get the refracted vector from a direction and a normal
  133476. */
  133477. export class RefractBlock extends NodeMaterialBlock {
  133478. /**
  133479. * Creates a new RefractBlock
  133480. * @param name defines the block name
  133481. */
  133482. constructor(name: string);
  133483. /**
  133484. * Gets the current class name
  133485. * @returns the class name
  133486. */
  133487. getClassName(): string;
  133488. /**
  133489. * Gets the incident component
  133490. */
  133491. get incident(): NodeMaterialConnectionPoint;
  133492. /**
  133493. * Gets the normal component
  133494. */
  133495. get normal(): NodeMaterialConnectionPoint;
  133496. /**
  133497. * Gets the index of refraction component
  133498. */
  133499. get ior(): NodeMaterialConnectionPoint;
  133500. /**
  133501. * Gets the output component
  133502. */
  133503. get output(): NodeMaterialConnectionPoint;
  133504. protected _buildBlock(state: NodeMaterialBuildState): this;
  133505. }
  133506. }
  133507. declare module BABYLON {
  133508. /**
  133509. * Block used to desaturate a color
  133510. */
  133511. export class DesaturateBlock extends NodeMaterialBlock {
  133512. /**
  133513. * Creates a new DesaturateBlock
  133514. * @param name defines the block name
  133515. */
  133516. constructor(name: string);
  133517. /**
  133518. * Gets the current class name
  133519. * @returns the class name
  133520. */
  133521. getClassName(): string;
  133522. /**
  133523. * Gets the color operand input component
  133524. */
  133525. get color(): NodeMaterialConnectionPoint;
  133526. /**
  133527. * Gets the level operand input component
  133528. */
  133529. get level(): NodeMaterialConnectionPoint;
  133530. /**
  133531. * Gets the output component
  133532. */
  133533. get output(): NodeMaterialConnectionPoint;
  133534. protected _buildBlock(state: NodeMaterialBuildState): this;
  133535. }
  133536. }
  133537. declare module BABYLON {
  133538. /**
  133539. * Effect Render Options
  133540. */
  133541. export interface IEffectRendererOptions {
  133542. /**
  133543. * Defines the vertices positions.
  133544. */
  133545. positions?: number[];
  133546. /**
  133547. * Defines the indices.
  133548. */
  133549. indices?: number[];
  133550. }
  133551. /**
  133552. * Helper class to render one or more effects
  133553. */
  133554. export class EffectRenderer {
  133555. private engine;
  133556. private static _DefaultOptions;
  133557. private _vertexBuffers;
  133558. private _indexBuffer;
  133559. private _ringBufferIndex;
  133560. private _ringScreenBuffer;
  133561. private _fullscreenViewport;
  133562. private _getNextFrameBuffer;
  133563. /**
  133564. * Creates an effect renderer
  133565. * @param engine the engine to use for rendering
  133566. * @param options defines the options of the effect renderer
  133567. */
  133568. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133569. /**
  133570. * Sets the current viewport in normalized coordinates 0-1
  133571. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133572. */
  133573. setViewport(viewport?: Viewport): void;
  133574. /**
  133575. * Binds the embedded attributes buffer to the effect.
  133576. * @param effect Defines the effect to bind the attributes for
  133577. */
  133578. bindBuffers(effect: Effect): void;
  133579. /**
  133580. * Sets the current effect wrapper to use during draw.
  133581. * The effect needs to be ready before calling this api.
  133582. * This also sets the default full screen position attribute.
  133583. * @param effectWrapper Defines the effect to draw with
  133584. */
  133585. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133586. /**
  133587. * Draws a full screen quad.
  133588. */
  133589. draw(): void;
  133590. /**
  133591. * renders one or more effects to a specified texture
  133592. * @param effectWrappers list of effects to renderer
  133593. * @param outputTexture texture to draw to, if null it will render to the screen
  133594. */
  133595. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133596. /**
  133597. * Disposes of the effect renderer
  133598. */
  133599. dispose(): void;
  133600. }
  133601. /**
  133602. * Options to create an EffectWrapper
  133603. */
  133604. interface EffectWrapperCreationOptions {
  133605. /**
  133606. * Engine to use to create the effect
  133607. */
  133608. engine: ThinEngine;
  133609. /**
  133610. * Fragment shader for the effect
  133611. */
  133612. fragmentShader: string;
  133613. /**
  133614. * Vertex shader for the effect
  133615. */
  133616. vertexShader?: string;
  133617. /**
  133618. * Attributes to use in the shader
  133619. */
  133620. attributeNames?: Array<string>;
  133621. /**
  133622. * Uniforms to use in the shader
  133623. */
  133624. uniformNames?: Array<string>;
  133625. /**
  133626. * Texture sampler names to use in the shader
  133627. */
  133628. samplerNames?: Array<string>;
  133629. /**
  133630. * The friendly name of the effect displayed in Spector.
  133631. */
  133632. name?: string;
  133633. }
  133634. /**
  133635. * Wraps an effect to be used for rendering
  133636. */
  133637. export class EffectWrapper {
  133638. /**
  133639. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133640. */
  133641. onApplyObservable: Observable<{}>;
  133642. /**
  133643. * The underlying effect
  133644. */
  133645. effect: Effect;
  133646. /**
  133647. * Creates an effect to be renderer
  133648. * @param creationOptions options to create the effect
  133649. */
  133650. constructor(creationOptions: EffectWrapperCreationOptions);
  133651. /**
  133652. * Disposes of the effect wrapper
  133653. */
  133654. dispose(): void;
  133655. }
  133656. }
  133657. declare module BABYLON {
  133658. /**
  133659. * Helper class to push actions to a pool of workers.
  133660. */
  133661. export class WorkerPool implements IDisposable {
  133662. private _workerInfos;
  133663. private _pendingActions;
  133664. /**
  133665. * Constructor
  133666. * @param workers Array of workers to use for actions
  133667. */
  133668. constructor(workers: Array<Worker>);
  133669. /**
  133670. * Terminates all workers and clears any pending actions.
  133671. */
  133672. dispose(): void;
  133673. /**
  133674. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133675. * pended until a worker has completed its action.
  133676. * @param action The action to perform. Call onComplete when the action is complete.
  133677. */
  133678. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133679. private _execute;
  133680. }
  133681. }
  133682. declare module BABYLON {
  133683. /**
  133684. * Configuration for Draco compression
  133685. */
  133686. export interface IDracoCompressionConfiguration {
  133687. /**
  133688. * Configuration for the decoder.
  133689. */
  133690. decoder: {
  133691. /**
  133692. * The url to the WebAssembly module.
  133693. */
  133694. wasmUrl?: string;
  133695. /**
  133696. * The url to the WebAssembly binary.
  133697. */
  133698. wasmBinaryUrl?: string;
  133699. /**
  133700. * The url to the fallback JavaScript module.
  133701. */
  133702. fallbackUrl?: string;
  133703. };
  133704. }
  133705. /**
  133706. * Draco compression (https://google.github.io/draco/)
  133707. *
  133708. * This class wraps the Draco module.
  133709. *
  133710. * **Encoder**
  133711. *
  133712. * The encoder is not currently implemented.
  133713. *
  133714. * **Decoder**
  133715. *
  133716. * 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.
  133717. *
  133718. * To update the configuration, use the following code:
  133719. * ```javascript
  133720. * DracoCompression.Configuration = {
  133721. * decoder: {
  133722. * wasmUrl: "<url to the WebAssembly library>",
  133723. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133724. * fallbackUrl: "<url to the fallback JavaScript library>",
  133725. * }
  133726. * };
  133727. * ```
  133728. *
  133729. * 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.
  133730. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133731. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133732. *
  133733. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133734. * ```javascript
  133735. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133736. * ```
  133737. *
  133738. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133739. */
  133740. export class DracoCompression implements IDisposable {
  133741. private _workerPoolPromise?;
  133742. private _decoderModulePromise?;
  133743. /**
  133744. * The configuration. Defaults to the following urls:
  133745. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133746. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133747. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133748. */
  133749. static Configuration: IDracoCompressionConfiguration;
  133750. /**
  133751. * Returns true if the decoder configuration is available.
  133752. */
  133753. static get DecoderAvailable(): boolean;
  133754. /**
  133755. * Default number of workers to create when creating the draco compression object.
  133756. */
  133757. static DefaultNumWorkers: number;
  133758. private static GetDefaultNumWorkers;
  133759. private static _Default;
  133760. /**
  133761. * Default instance for the draco compression object.
  133762. */
  133763. static get Default(): DracoCompression;
  133764. /**
  133765. * Constructor
  133766. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133767. */
  133768. constructor(numWorkers?: number);
  133769. /**
  133770. * Stop all async operations and release resources.
  133771. */
  133772. dispose(): void;
  133773. /**
  133774. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133775. * @returns a promise that resolves when ready
  133776. */
  133777. whenReadyAsync(): Promise<void>;
  133778. /**
  133779. * Decode Draco compressed mesh data to vertex data.
  133780. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133781. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133782. * @returns A promise that resolves with the decoded vertex data
  133783. */
  133784. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133785. [kind: string]: number;
  133786. }): Promise<VertexData>;
  133787. }
  133788. }
  133789. declare module BABYLON {
  133790. /**
  133791. * Class for building Constructive Solid Geometry
  133792. */
  133793. export class CSG {
  133794. private polygons;
  133795. /**
  133796. * The world matrix
  133797. */
  133798. matrix: Matrix;
  133799. /**
  133800. * Stores the position
  133801. */
  133802. position: Vector3;
  133803. /**
  133804. * Stores the rotation
  133805. */
  133806. rotation: Vector3;
  133807. /**
  133808. * Stores the rotation quaternion
  133809. */
  133810. rotationQuaternion: Nullable<Quaternion>;
  133811. /**
  133812. * Stores the scaling vector
  133813. */
  133814. scaling: Vector3;
  133815. /**
  133816. * Convert the Mesh to CSG
  133817. * @param mesh The Mesh to convert to CSG
  133818. * @returns A new CSG from the Mesh
  133819. */
  133820. static FromMesh(mesh: Mesh): CSG;
  133821. /**
  133822. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133823. * @param polygons Polygons used to construct a CSG solid
  133824. */
  133825. private static FromPolygons;
  133826. /**
  133827. * Clones, or makes a deep copy, of the CSG
  133828. * @returns A new CSG
  133829. */
  133830. clone(): CSG;
  133831. /**
  133832. * Unions this CSG with another CSG
  133833. * @param csg The CSG to union against this CSG
  133834. * @returns The unioned CSG
  133835. */
  133836. union(csg: CSG): CSG;
  133837. /**
  133838. * Unions this CSG with another CSG in place
  133839. * @param csg The CSG to union against this CSG
  133840. */
  133841. unionInPlace(csg: CSG): void;
  133842. /**
  133843. * Subtracts this CSG with another CSG
  133844. * @param csg The CSG to subtract against this CSG
  133845. * @returns A new CSG
  133846. */
  133847. subtract(csg: CSG): CSG;
  133848. /**
  133849. * Subtracts this CSG with another CSG in place
  133850. * @param csg The CSG to subtact against this CSG
  133851. */
  133852. subtractInPlace(csg: CSG): void;
  133853. /**
  133854. * Intersect this CSG with another CSG
  133855. * @param csg The CSG to intersect against this CSG
  133856. * @returns A new CSG
  133857. */
  133858. intersect(csg: CSG): CSG;
  133859. /**
  133860. * Intersects this CSG with another CSG in place
  133861. * @param csg The CSG to intersect against this CSG
  133862. */
  133863. intersectInPlace(csg: CSG): void;
  133864. /**
  133865. * Return a new CSG solid with solid and empty space switched. This solid is
  133866. * not modified.
  133867. * @returns A new CSG solid with solid and empty space switched
  133868. */
  133869. inverse(): CSG;
  133870. /**
  133871. * Inverses the CSG in place
  133872. */
  133873. inverseInPlace(): void;
  133874. /**
  133875. * This is used to keep meshes transformations so they can be restored
  133876. * when we build back a Babylon Mesh
  133877. * NB : All CSG operations are performed in world coordinates
  133878. * @param csg The CSG to copy the transform attributes from
  133879. * @returns This CSG
  133880. */
  133881. copyTransformAttributes(csg: CSG): CSG;
  133882. /**
  133883. * Build Raw mesh from CSG
  133884. * Coordinates here are in world space
  133885. * @param name The name of the mesh geometry
  133886. * @param scene The Scene
  133887. * @param keepSubMeshes Specifies if the submeshes should be kept
  133888. * @returns A new Mesh
  133889. */
  133890. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133891. /**
  133892. * Build Mesh from CSG taking material and transforms into account
  133893. * @param name The name of the Mesh
  133894. * @param material The material of the Mesh
  133895. * @param scene The Scene
  133896. * @param keepSubMeshes Specifies if submeshes should be kept
  133897. * @returns The new Mesh
  133898. */
  133899. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133900. }
  133901. }
  133902. declare module BABYLON {
  133903. /**
  133904. * Class used to create a trail following a mesh
  133905. */
  133906. export class TrailMesh extends Mesh {
  133907. private _generator;
  133908. private _autoStart;
  133909. private _running;
  133910. private _diameter;
  133911. private _length;
  133912. private _sectionPolygonPointsCount;
  133913. private _sectionVectors;
  133914. private _sectionNormalVectors;
  133915. private _beforeRenderObserver;
  133916. /**
  133917. * @constructor
  133918. * @param name The value used by scene.getMeshByName() to do a lookup.
  133919. * @param generator The mesh or transform node to generate a trail.
  133920. * @param scene The scene to add this mesh to.
  133921. * @param diameter Diameter of trailing mesh. Default is 1.
  133922. * @param length Length of trailing mesh. Default is 60.
  133923. * @param autoStart Automatically start trailing mesh. Default true.
  133924. */
  133925. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133926. /**
  133927. * "TrailMesh"
  133928. * @returns "TrailMesh"
  133929. */
  133930. getClassName(): string;
  133931. private _createMesh;
  133932. /**
  133933. * Start trailing mesh.
  133934. */
  133935. start(): void;
  133936. /**
  133937. * Stop trailing mesh.
  133938. */
  133939. stop(): void;
  133940. /**
  133941. * Update trailing mesh geometry.
  133942. */
  133943. update(): void;
  133944. /**
  133945. * Returns a new TrailMesh object.
  133946. * @param name is a string, the name given to the new mesh
  133947. * @param newGenerator use new generator object for cloned trail mesh
  133948. * @returns a new mesh
  133949. */
  133950. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133951. /**
  133952. * Serializes this trail mesh
  133953. * @param serializationObject object to write serialization to
  133954. */
  133955. serialize(serializationObject: any): void;
  133956. /**
  133957. * Parses a serialized trail mesh
  133958. * @param parsedMesh the serialized mesh
  133959. * @param scene the scene to create the trail mesh in
  133960. * @returns the created trail mesh
  133961. */
  133962. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133963. }
  133964. }
  133965. declare module BABYLON {
  133966. /**
  133967. * Class containing static functions to help procedurally build meshes
  133968. */
  133969. export class TiledBoxBuilder {
  133970. /**
  133971. * Creates a box mesh
  133972. * 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)
  133973. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133977. * @param name defines the name of the mesh
  133978. * @param options defines the options used to create the mesh
  133979. * @param scene defines the hosting scene
  133980. * @returns the box mesh
  133981. */
  133982. static CreateTiledBox(name: string, options: {
  133983. pattern?: number;
  133984. width?: number;
  133985. height?: number;
  133986. depth?: number;
  133987. tileSize?: number;
  133988. tileWidth?: number;
  133989. tileHeight?: number;
  133990. alignHorizontal?: number;
  133991. alignVertical?: number;
  133992. faceUV?: Vector4[];
  133993. faceColors?: Color4[];
  133994. sideOrientation?: number;
  133995. updatable?: boolean;
  133996. }, scene?: Nullable<Scene>): Mesh;
  133997. }
  133998. }
  133999. declare module BABYLON {
  134000. /**
  134001. * Class containing static functions to help procedurally build meshes
  134002. */
  134003. export class TorusKnotBuilder {
  134004. /**
  134005. * Creates a torus knot mesh
  134006. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134007. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134008. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134009. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134013. * @param name defines the name of the mesh
  134014. * @param options defines the options used to create the mesh
  134015. * @param scene defines the hosting scene
  134016. * @returns the torus knot mesh
  134017. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134018. */
  134019. static CreateTorusKnot(name: string, options: {
  134020. radius?: number;
  134021. tube?: number;
  134022. radialSegments?: number;
  134023. tubularSegments?: number;
  134024. p?: number;
  134025. q?: number;
  134026. updatable?: boolean;
  134027. sideOrientation?: number;
  134028. frontUVs?: Vector4;
  134029. backUVs?: Vector4;
  134030. }, scene: any): Mesh;
  134031. }
  134032. }
  134033. declare module BABYLON {
  134034. /**
  134035. * Polygon
  134036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  134037. */
  134038. export class Polygon {
  134039. /**
  134040. * Creates a rectangle
  134041. * @param xmin bottom X coord
  134042. * @param ymin bottom Y coord
  134043. * @param xmax top X coord
  134044. * @param ymax top Y coord
  134045. * @returns points that make the resulting rectation
  134046. */
  134047. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  134048. /**
  134049. * Creates a circle
  134050. * @param radius radius of circle
  134051. * @param cx scale in x
  134052. * @param cy scale in y
  134053. * @param numberOfSides number of sides that make up the circle
  134054. * @returns points that make the resulting circle
  134055. */
  134056. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134057. /**
  134058. * Creates a polygon from input string
  134059. * @param input Input polygon data
  134060. * @returns the parsed points
  134061. */
  134062. static Parse(input: string): Vector2[];
  134063. /**
  134064. * Starts building a polygon from x and y coordinates
  134065. * @param x x coordinate
  134066. * @param y y coordinate
  134067. * @returns the started path2
  134068. */
  134069. static StartingAt(x: number, y: number): Path2;
  134070. }
  134071. /**
  134072. * Builds a polygon
  134073. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134074. */
  134075. export class PolygonMeshBuilder {
  134076. private _points;
  134077. private _outlinepoints;
  134078. private _holes;
  134079. private _name;
  134080. private _scene;
  134081. private _epoints;
  134082. private _eholes;
  134083. private _addToepoint;
  134084. /**
  134085. * Babylon reference to the earcut plugin.
  134086. */
  134087. bjsEarcut: any;
  134088. /**
  134089. * Creates a PolygonMeshBuilder
  134090. * @param name name of the builder
  134091. * @param contours Path of the polygon
  134092. * @param scene scene to add to when creating the mesh
  134093. * @param earcutInjection can be used to inject your own earcut reference
  134094. */
  134095. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134096. /**
  134097. * Adds a whole within the polygon
  134098. * @param hole Array of points defining the hole
  134099. * @returns this
  134100. */
  134101. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134102. /**
  134103. * Creates the polygon
  134104. * @param updatable If the mesh should be updatable
  134105. * @param depth The depth of the mesh created
  134106. * @returns the created mesh
  134107. */
  134108. build(updatable?: boolean, depth?: number): Mesh;
  134109. /**
  134110. * Creates the polygon
  134111. * @param depth The depth of the mesh created
  134112. * @returns the created VertexData
  134113. */
  134114. buildVertexData(depth?: number): VertexData;
  134115. /**
  134116. * Adds a side to the polygon
  134117. * @param positions points that make the polygon
  134118. * @param normals normals of the polygon
  134119. * @param uvs uvs of the polygon
  134120. * @param indices indices of the polygon
  134121. * @param bounds bounds of the polygon
  134122. * @param points points of the polygon
  134123. * @param depth depth of the polygon
  134124. * @param flip flip of the polygon
  134125. */
  134126. private addSide;
  134127. }
  134128. }
  134129. declare module BABYLON {
  134130. /**
  134131. * Class containing static functions to help procedurally build meshes
  134132. */
  134133. export class PolygonBuilder {
  134134. /**
  134135. * Creates a polygon mesh
  134136. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134137. * * 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
  134138. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134141. * * Remember you can only change the shape positions, not their number when updating a polygon
  134142. * @param name defines the name of the mesh
  134143. * @param options defines the options used to create the mesh
  134144. * @param scene defines the hosting scene
  134145. * @param earcutInjection can be used to inject your own earcut reference
  134146. * @returns the polygon mesh
  134147. */
  134148. static CreatePolygon(name: string, options: {
  134149. shape: Vector3[];
  134150. holes?: Vector3[][];
  134151. depth?: number;
  134152. faceUV?: Vector4[];
  134153. faceColors?: Color4[];
  134154. updatable?: boolean;
  134155. sideOrientation?: number;
  134156. frontUVs?: Vector4;
  134157. backUVs?: Vector4;
  134158. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134159. /**
  134160. * Creates an extruded polygon mesh, with depth in the Y direction.
  134161. * * 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)
  134162. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134163. * @param name defines the name of the mesh
  134164. * @param options defines the options used to create the mesh
  134165. * @param scene defines the hosting scene
  134166. * @param earcutInjection can be used to inject your own earcut reference
  134167. * @returns the polygon mesh
  134168. */
  134169. static ExtrudePolygon(name: string, options: {
  134170. shape: Vector3[];
  134171. holes?: Vector3[][];
  134172. depth?: number;
  134173. faceUV?: Vector4[];
  134174. faceColors?: Color4[];
  134175. updatable?: boolean;
  134176. sideOrientation?: number;
  134177. frontUVs?: Vector4;
  134178. backUVs?: Vector4;
  134179. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134180. }
  134181. }
  134182. declare module BABYLON {
  134183. /**
  134184. * Class containing static functions to help procedurally build meshes
  134185. */
  134186. export class LatheBuilder {
  134187. /**
  134188. * Creates lathe mesh.
  134189. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134190. * * 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
  134191. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134192. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134193. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134194. * * 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
  134195. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134196. * * 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
  134197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134199. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134201. * @param name defines the name of the mesh
  134202. * @param options defines the options used to create the mesh
  134203. * @param scene defines the hosting scene
  134204. * @returns the lathe mesh
  134205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134206. */
  134207. static CreateLathe(name: string, options: {
  134208. shape: Vector3[];
  134209. radius?: number;
  134210. tessellation?: number;
  134211. clip?: number;
  134212. arc?: number;
  134213. closed?: boolean;
  134214. updatable?: boolean;
  134215. sideOrientation?: number;
  134216. frontUVs?: Vector4;
  134217. backUVs?: Vector4;
  134218. cap?: number;
  134219. invertUV?: boolean;
  134220. }, scene?: Nullable<Scene>): Mesh;
  134221. }
  134222. }
  134223. declare module BABYLON {
  134224. /**
  134225. * Class containing static functions to help procedurally build meshes
  134226. */
  134227. export class TiledPlaneBuilder {
  134228. /**
  134229. * Creates a tiled plane mesh
  134230. * * The parameter `pattern` will, depending on value, do nothing or
  134231. * * * flip (reflect about central vertical) alternate tiles across and up
  134232. * * * flip every tile on alternate rows
  134233. * * * rotate (180 degs) alternate tiles across and up
  134234. * * * rotate every tile on alternate rows
  134235. * * * flip and rotate alternate tiles across and up
  134236. * * * flip and rotate every tile on alternate rows
  134237. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134238. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134241. * * 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)
  134242. * * 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)
  134243. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134244. * @param name defines the name of the mesh
  134245. * @param options defines the options used to create the mesh
  134246. * @param scene defines the hosting scene
  134247. * @returns the box mesh
  134248. */
  134249. static CreateTiledPlane(name: string, options: {
  134250. pattern?: number;
  134251. tileSize?: number;
  134252. tileWidth?: number;
  134253. tileHeight?: number;
  134254. size?: number;
  134255. width?: number;
  134256. height?: number;
  134257. alignHorizontal?: number;
  134258. alignVertical?: number;
  134259. sideOrientation?: number;
  134260. frontUVs?: Vector4;
  134261. backUVs?: Vector4;
  134262. updatable?: boolean;
  134263. }, scene?: Nullable<Scene>): Mesh;
  134264. }
  134265. }
  134266. declare module BABYLON {
  134267. /**
  134268. * Class containing static functions to help procedurally build meshes
  134269. */
  134270. export class TubeBuilder {
  134271. /**
  134272. * Creates a tube mesh.
  134273. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134274. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134275. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134276. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134277. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134278. * * 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)
  134279. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134280. * * 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
  134281. * * 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
  134282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134284. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134286. * @param name defines the name of the mesh
  134287. * @param options defines the options used to create the mesh
  134288. * @param scene defines the hosting scene
  134289. * @returns the tube mesh
  134290. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134291. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134292. */
  134293. static CreateTube(name: string, options: {
  134294. path: Vector3[];
  134295. radius?: number;
  134296. tessellation?: number;
  134297. radiusFunction?: {
  134298. (i: number, distance: number): number;
  134299. };
  134300. cap?: number;
  134301. arc?: number;
  134302. updatable?: boolean;
  134303. sideOrientation?: number;
  134304. frontUVs?: Vector4;
  134305. backUVs?: Vector4;
  134306. instance?: Mesh;
  134307. invertUV?: boolean;
  134308. }, scene?: Nullable<Scene>): Mesh;
  134309. }
  134310. }
  134311. declare module BABYLON {
  134312. /**
  134313. * Class containing static functions to help procedurally build meshes
  134314. */
  134315. export class IcoSphereBuilder {
  134316. /**
  134317. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134318. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134319. * * 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`)
  134320. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134321. * * 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
  134322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134325. * @param name defines the name of the mesh
  134326. * @param options defines the options used to create the mesh
  134327. * @param scene defines the hosting scene
  134328. * @returns the icosahedron mesh
  134329. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134330. */
  134331. static CreateIcoSphere(name: string, options: {
  134332. radius?: number;
  134333. radiusX?: number;
  134334. radiusY?: number;
  134335. radiusZ?: number;
  134336. flat?: boolean;
  134337. subdivisions?: number;
  134338. sideOrientation?: number;
  134339. frontUVs?: Vector4;
  134340. backUVs?: Vector4;
  134341. updatable?: boolean;
  134342. }, scene?: Nullable<Scene>): Mesh;
  134343. }
  134344. }
  134345. declare module BABYLON {
  134346. /**
  134347. * Class containing static functions to help procedurally build meshes
  134348. */
  134349. export class DecalBuilder {
  134350. /**
  134351. * Creates a decal mesh.
  134352. * 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
  134353. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134354. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134355. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134356. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134357. * @param name defines the name of the mesh
  134358. * @param sourceMesh defines the mesh where the decal must be applied
  134359. * @param options defines the options used to create the mesh
  134360. * @param scene defines the hosting scene
  134361. * @returns the decal mesh
  134362. * @see https://doc.babylonjs.com/how_to/decals
  134363. */
  134364. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134365. position?: Vector3;
  134366. normal?: Vector3;
  134367. size?: Vector3;
  134368. angle?: number;
  134369. }): Mesh;
  134370. }
  134371. }
  134372. declare module BABYLON {
  134373. /**
  134374. * Class containing static functions to help procedurally build meshes
  134375. */
  134376. export class MeshBuilder {
  134377. /**
  134378. * Creates a box mesh
  134379. * * The parameter `size` sets the size (float) of each box side (default 1)
  134380. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134381. * * 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)
  134382. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134386. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134387. * @param name defines the name of the mesh
  134388. * @param options defines the options used to create the mesh
  134389. * @param scene defines the hosting scene
  134390. * @returns the box mesh
  134391. */
  134392. static CreateBox(name: string, options: {
  134393. size?: number;
  134394. width?: number;
  134395. height?: number;
  134396. depth?: number;
  134397. faceUV?: Vector4[];
  134398. faceColors?: Color4[];
  134399. sideOrientation?: number;
  134400. frontUVs?: Vector4;
  134401. backUVs?: Vector4;
  134402. updatable?: boolean;
  134403. }, scene?: Nullable<Scene>): Mesh;
  134404. /**
  134405. * Creates a tiled box mesh
  134406. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134408. * @param name defines the name of the mesh
  134409. * @param options defines the options used to create the mesh
  134410. * @param scene defines the hosting scene
  134411. * @returns the tiled box mesh
  134412. */
  134413. static CreateTiledBox(name: string, options: {
  134414. pattern?: number;
  134415. size?: number;
  134416. width?: number;
  134417. height?: number;
  134418. depth: number;
  134419. tileSize?: number;
  134420. tileWidth?: number;
  134421. tileHeight?: number;
  134422. faceUV?: Vector4[];
  134423. faceColors?: Color4[];
  134424. alignHorizontal?: number;
  134425. alignVertical?: number;
  134426. sideOrientation?: number;
  134427. updatable?: boolean;
  134428. }, scene?: Nullable<Scene>): Mesh;
  134429. /**
  134430. * Creates a sphere mesh
  134431. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134432. * * 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`)
  134433. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134434. * * 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
  134435. * * 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)
  134436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134439. * @param name defines the name of the mesh
  134440. * @param options defines the options used to create the mesh
  134441. * @param scene defines the hosting scene
  134442. * @returns the sphere mesh
  134443. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134444. */
  134445. static CreateSphere(name: string, options: {
  134446. segments?: number;
  134447. diameter?: number;
  134448. diameterX?: number;
  134449. diameterY?: number;
  134450. diameterZ?: number;
  134451. arc?: number;
  134452. slice?: number;
  134453. sideOrientation?: number;
  134454. frontUVs?: Vector4;
  134455. backUVs?: Vector4;
  134456. updatable?: boolean;
  134457. }, scene?: Nullable<Scene>): Mesh;
  134458. /**
  134459. * Creates a plane polygonal mesh. By default, this is a disc
  134460. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134461. * * 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
  134462. * * 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
  134463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134466. * @param name defines the name of the mesh
  134467. * @param options defines the options used to create the mesh
  134468. * @param scene defines the hosting scene
  134469. * @returns the plane polygonal mesh
  134470. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134471. */
  134472. static CreateDisc(name: string, options: {
  134473. radius?: number;
  134474. tessellation?: number;
  134475. arc?: number;
  134476. updatable?: boolean;
  134477. sideOrientation?: number;
  134478. frontUVs?: Vector4;
  134479. backUVs?: Vector4;
  134480. }, scene?: Nullable<Scene>): Mesh;
  134481. /**
  134482. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134483. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134484. * * 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`)
  134485. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134486. * * 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
  134487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134490. * @param name defines the name of the mesh
  134491. * @param options defines the options used to create the mesh
  134492. * @param scene defines the hosting scene
  134493. * @returns the icosahedron mesh
  134494. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134495. */
  134496. static CreateIcoSphere(name: string, options: {
  134497. radius?: number;
  134498. radiusX?: number;
  134499. radiusY?: number;
  134500. radiusZ?: number;
  134501. flat?: boolean;
  134502. subdivisions?: number;
  134503. sideOrientation?: number;
  134504. frontUVs?: Vector4;
  134505. backUVs?: Vector4;
  134506. updatable?: boolean;
  134507. }, scene?: Nullable<Scene>): Mesh;
  134508. /**
  134509. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134510. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134511. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134512. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134513. * * 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
  134514. * * 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
  134515. * * 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
  134516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134519. * * 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
  134520. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134521. * * 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
  134522. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134524. * @param name defines the name of the mesh
  134525. * @param options defines the options used to create the mesh
  134526. * @param scene defines the hosting scene
  134527. * @returns the ribbon mesh
  134528. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134529. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134530. */
  134531. static CreateRibbon(name: string, options: {
  134532. pathArray: Vector3[][];
  134533. closeArray?: boolean;
  134534. closePath?: boolean;
  134535. offset?: number;
  134536. updatable?: boolean;
  134537. sideOrientation?: number;
  134538. frontUVs?: Vector4;
  134539. backUVs?: Vector4;
  134540. instance?: Mesh;
  134541. invertUV?: boolean;
  134542. uvs?: Vector2[];
  134543. colors?: Color4[];
  134544. }, scene?: Nullable<Scene>): Mesh;
  134545. /**
  134546. * Creates a cylinder or a cone mesh
  134547. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134548. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134549. * * 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.
  134550. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134551. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134552. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134553. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134554. * * 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).
  134555. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134556. * * 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).
  134557. * * 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
  134558. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134559. * * 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
  134560. * * 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.
  134561. * * If `enclose` is false, a ring surface is one element.
  134562. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134563. * * 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
  134564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134567. * @param name defines the name of the mesh
  134568. * @param options defines the options used to create the mesh
  134569. * @param scene defines the hosting scene
  134570. * @returns the cylinder mesh
  134571. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134572. */
  134573. static CreateCylinder(name: string, options: {
  134574. height?: number;
  134575. diameterTop?: number;
  134576. diameterBottom?: number;
  134577. diameter?: number;
  134578. tessellation?: number;
  134579. subdivisions?: number;
  134580. arc?: number;
  134581. faceColors?: Color4[];
  134582. faceUV?: Vector4[];
  134583. updatable?: boolean;
  134584. hasRings?: boolean;
  134585. enclose?: boolean;
  134586. cap?: number;
  134587. sideOrientation?: number;
  134588. frontUVs?: Vector4;
  134589. backUVs?: Vector4;
  134590. }, scene?: Nullable<Scene>): Mesh;
  134591. /**
  134592. * Creates a torus mesh
  134593. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134594. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134595. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134599. * @param name defines the name of the mesh
  134600. * @param options defines the options used to create the mesh
  134601. * @param scene defines the hosting scene
  134602. * @returns the torus mesh
  134603. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134604. */
  134605. static CreateTorus(name: string, options: {
  134606. diameter?: number;
  134607. thickness?: number;
  134608. tessellation?: number;
  134609. updatable?: boolean;
  134610. sideOrientation?: number;
  134611. frontUVs?: Vector4;
  134612. backUVs?: Vector4;
  134613. }, scene?: Nullable<Scene>): Mesh;
  134614. /**
  134615. * Creates a torus knot mesh
  134616. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134617. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134618. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134619. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134623. * @param name defines the name of the mesh
  134624. * @param options defines the options used to create the mesh
  134625. * @param scene defines the hosting scene
  134626. * @returns the torus knot mesh
  134627. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134628. */
  134629. static CreateTorusKnot(name: string, options: {
  134630. radius?: number;
  134631. tube?: number;
  134632. radialSegments?: number;
  134633. tubularSegments?: number;
  134634. p?: number;
  134635. q?: number;
  134636. updatable?: boolean;
  134637. sideOrientation?: number;
  134638. frontUVs?: Vector4;
  134639. backUVs?: Vector4;
  134640. }, scene?: Nullable<Scene>): Mesh;
  134641. /**
  134642. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134643. * * 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
  134644. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134645. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134646. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134647. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134648. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134649. * * 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
  134650. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134653. * @param name defines the name of the new line system
  134654. * @param options defines the options used to create the line system
  134655. * @param scene defines the hosting scene
  134656. * @returns a new line system mesh
  134657. */
  134658. static CreateLineSystem(name: string, options: {
  134659. lines: Vector3[][];
  134660. updatable?: boolean;
  134661. instance?: Nullable<LinesMesh>;
  134662. colors?: Nullable<Color4[][]>;
  134663. useVertexAlpha?: boolean;
  134664. }, scene: Nullable<Scene>): LinesMesh;
  134665. /**
  134666. * Creates a line mesh
  134667. * 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
  134668. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134669. * * The parameter `points` is an array successive Vector3
  134670. * * 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
  134671. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134672. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134673. * * When updating an instance, remember that only point positions can change, not the number of points
  134674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134676. * @param name defines the name of the new line system
  134677. * @param options defines the options used to create the line system
  134678. * @param scene defines the hosting scene
  134679. * @returns a new line mesh
  134680. */
  134681. static CreateLines(name: string, options: {
  134682. points: Vector3[];
  134683. updatable?: boolean;
  134684. instance?: Nullable<LinesMesh>;
  134685. colors?: Color4[];
  134686. useVertexAlpha?: boolean;
  134687. }, scene?: Nullable<Scene>): LinesMesh;
  134688. /**
  134689. * Creates a dashed line mesh
  134690. * * 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
  134691. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134692. * * The parameter `points` is an array successive Vector3
  134693. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134694. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134695. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134696. * * 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
  134697. * * When updating an instance, remember that only point positions can change, not the number of points
  134698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134699. * @param name defines the name of the mesh
  134700. * @param options defines the options used to create the mesh
  134701. * @param scene defines the hosting scene
  134702. * @returns the dashed line mesh
  134703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134704. */
  134705. static CreateDashedLines(name: string, options: {
  134706. points: Vector3[];
  134707. dashSize?: number;
  134708. gapSize?: number;
  134709. dashNb?: number;
  134710. updatable?: boolean;
  134711. instance?: LinesMesh;
  134712. }, scene?: Nullable<Scene>): LinesMesh;
  134713. /**
  134714. * 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.
  134715. * * 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.
  134716. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134717. * * 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.
  134718. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134719. * * 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
  134720. * * 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
  134721. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134726. * @param name defines the name of the mesh
  134727. * @param options defines the options used to create the mesh
  134728. * @param scene defines the hosting scene
  134729. * @returns the extruded shape mesh
  134730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134732. */
  134733. static ExtrudeShape(name: string, options: {
  134734. shape: Vector3[];
  134735. path: Vector3[];
  134736. scale?: number;
  134737. rotation?: number;
  134738. cap?: number;
  134739. updatable?: boolean;
  134740. sideOrientation?: number;
  134741. frontUVs?: Vector4;
  134742. backUVs?: Vector4;
  134743. instance?: Mesh;
  134744. invertUV?: boolean;
  134745. }, scene?: Nullable<Scene>): Mesh;
  134746. /**
  134747. * Creates an custom extruded shape mesh.
  134748. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134749. * * 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.
  134750. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134751. * * 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
  134752. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134753. * * 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
  134754. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134755. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134756. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134757. * * 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
  134758. * * 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
  134759. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134762. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134764. * @param name defines the name of the mesh
  134765. * @param options defines the options used to create the mesh
  134766. * @param scene defines the hosting scene
  134767. * @returns the custom extruded shape mesh
  134768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134769. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134771. */
  134772. static ExtrudeShapeCustom(name: string, options: {
  134773. shape: Vector3[];
  134774. path: Vector3[];
  134775. scaleFunction?: any;
  134776. rotationFunction?: any;
  134777. ribbonCloseArray?: boolean;
  134778. ribbonClosePath?: boolean;
  134779. cap?: number;
  134780. updatable?: boolean;
  134781. sideOrientation?: number;
  134782. frontUVs?: Vector4;
  134783. backUVs?: Vector4;
  134784. instance?: Mesh;
  134785. invertUV?: boolean;
  134786. }, scene?: Nullable<Scene>): Mesh;
  134787. /**
  134788. * Creates lathe mesh.
  134789. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134790. * * 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
  134791. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134792. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134793. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134794. * * 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
  134795. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134796. * * 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
  134797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134801. * @param name defines the name of the mesh
  134802. * @param options defines the options used to create the mesh
  134803. * @param scene defines the hosting scene
  134804. * @returns the lathe mesh
  134805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134806. */
  134807. static CreateLathe(name: string, options: {
  134808. shape: Vector3[];
  134809. radius?: number;
  134810. tessellation?: number;
  134811. clip?: number;
  134812. arc?: number;
  134813. closed?: boolean;
  134814. updatable?: boolean;
  134815. sideOrientation?: number;
  134816. frontUVs?: Vector4;
  134817. backUVs?: Vector4;
  134818. cap?: number;
  134819. invertUV?: boolean;
  134820. }, scene?: Nullable<Scene>): Mesh;
  134821. /**
  134822. * Creates a tiled plane mesh
  134823. * * You can set a limited pattern arrangement with the tiles
  134824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134827. * @param name defines the name of the mesh
  134828. * @param options defines the options used to create the mesh
  134829. * @param scene defines the hosting scene
  134830. * @returns the plane mesh
  134831. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134832. */
  134833. static CreateTiledPlane(name: string, options: {
  134834. pattern?: number;
  134835. tileSize?: number;
  134836. tileWidth?: number;
  134837. tileHeight?: number;
  134838. size?: number;
  134839. width?: number;
  134840. height?: number;
  134841. alignHorizontal?: number;
  134842. alignVertical?: number;
  134843. sideOrientation?: number;
  134844. frontUVs?: Vector4;
  134845. backUVs?: Vector4;
  134846. updatable?: boolean;
  134847. }, scene?: Nullable<Scene>): Mesh;
  134848. /**
  134849. * Creates a plane mesh
  134850. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134851. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134852. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134856. * @param name defines the name of the mesh
  134857. * @param options defines the options used to create the mesh
  134858. * @param scene defines the hosting scene
  134859. * @returns the plane mesh
  134860. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134861. */
  134862. static CreatePlane(name: string, options: {
  134863. size?: number;
  134864. width?: number;
  134865. height?: number;
  134866. sideOrientation?: number;
  134867. frontUVs?: Vector4;
  134868. backUVs?: Vector4;
  134869. updatable?: boolean;
  134870. sourcePlane?: Plane;
  134871. }, scene?: Nullable<Scene>): Mesh;
  134872. /**
  134873. * Creates a ground mesh
  134874. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134875. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134877. * @param name defines the name of the mesh
  134878. * @param options defines the options used to create the mesh
  134879. * @param scene defines the hosting scene
  134880. * @returns the ground mesh
  134881. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134882. */
  134883. static CreateGround(name: string, options: {
  134884. width?: number;
  134885. height?: number;
  134886. subdivisions?: number;
  134887. subdivisionsX?: number;
  134888. subdivisionsY?: number;
  134889. updatable?: boolean;
  134890. }, scene?: Nullable<Scene>): Mesh;
  134891. /**
  134892. * Creates a tiled ground mesh
  134893. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134894. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134895. * * 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
  134896. * * 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
  134897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134898. * @param name defines the name of the mesh
  134899. * @param options defines the options used to create the mesh
  134900. * @param scene defines the hosting scene
  134901. * @returns the tiled ground mesh
  134902. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134903. */
  134904. static CreateTiledGround(name: string, options: {
  134905. xmin: number;
  134906. zmin: number;
  134907. xmax: number;
  134908. zmax: number;
  134909. subdivisions?: {
  134910. w: number;
  134911. h: number;
  134912. };
  134913. precision?: {
  134914. w: number;
  134915. h: number;
  134916. };
  134917. updatable?: boolean;
  134918. }, scene?: Nullable<Scene>): Mesh;
  134919. /**
  134920. * Creates a ground mesh from a height map
  134921. * * The parameter `url` sets the URL of the height map image resource.
  134922. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134923. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134924. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134925. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134926. * * 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.
  134927. * * 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).
  134928. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134930. * @param name defines the name of the mesh
  134931. * @param url defines the url to the height map
  134932. * @param options defines the options used to create the mesh
  134933. * @param scene defines the hosting scene
  134934. * @returns the ground mesh
  134935. * @see https://doc.babylonjs.com/babylon101/height_map
  134936. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134937. */
  134938. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134939. width?: number;
  134940. height?: number;
  134941. subdivisions?: number;
  134942. minHeight?: number;
  134943. maxHeight?: number;
  134944. colorFilter?: Color3;
  134945. alphaFilter?: number;
  134946. updatable?: boolean;
  134947. onReady?: (mesh: GroundMesh) => void;
  134948. }, scene?: Nullable<Scene>): GroundMesh;
  134949. /**
  134950. * Creates a polygon mesh
  134951. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134952. * * 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
  134953. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134956. * * Remember you can only change the shape positions, not their number when updating a polygon
  134957. * @param name defines the name of the mesh
  134958. * @param options defines the options used to create the mesh
  134959. * @param scene defines the hosting scene
  134960. * @param earcutInjection can be used to inject your own earcut reference
  134961. * @returns the polygon mesh
  134962. */
  134963. static CreatePolygon(name: string, options: {
  134964. shape: Vector3[];
  134965. holes?: Vector3[][];
  134966. depth?: number;
  134967. faceUV?: Vector4[];
  134968. faceColors?: Color4[];
  134969. updatable?: boolean;
  134970. sideOrientation?: number;
  134971. frontUVs?: Vector4;
  134972. backUVs?: Vector4;
  134973. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134974. /**
  134975. * Creates an extruded polygon mesh, with depth in the Y direction.
  134976. * * 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)
  134977. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134978. * @param name defines the name of the mesh
  134979. * @param options defines the options used to create the mesh
  134980. * @param scene defines the hosting scene
  134981. * @param earcutInjection can be used to inject your own earcut reference
  134982. * @returns the polygon mesh
  134983. */
  134984. static ExtrudePolygon(name: string, options: {
  134985. shape: Vector3[];
  134986. holes?: Vector3[][];
  134987. depth?: number;
  134988. faceUV?: Vector4[];
  134989. faceColors?: Color4[];
  134990. updatable?: boolean;
  134991. sideOrientation?: number;
  134992. frontUVs?: Vector4;
  134993. backUVs?: Vector4;
  134994. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134995. /**
  134996. * Creates a tube mesh.
  134997. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134998. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134999. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135000. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135001. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135002. * * 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)
  135003. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135004. * * 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
  135005. * * 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
  135006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135010. * @param name defines the name of the mesh
  135011. * @param options defines the options used to create the mesh
  135012. * @param scene defines the hosting scene
  135013. * @returns the tube mesh
  135014. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135015. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135016. */
  135017. static CreateTube(name: string, options: {
  135018. path: Vector3[];
  135019. radius?: number;
  135020. tessellation?: number;
  135021. radiusFunction?: {
  135022. (i: number, distance: number): number;
  135023. };
  135024. cap?: number;
  135025. arc?: number;
  135026. updatable?: boolean;
  135027. sideOrientation?: number;
  135028. frontUVs?: Vector4;
  135029. backUVs?: Vector4;
  135030. instance?: Mesh;
  135031. invertUV?: boolean;
  135032. }, scene?: Nullable<Scene>): Mesh;
  135033. /**
  135034. * Creates a polyhedron mesh
  135035. * * 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
  135036. * * The parameter `size` (positive float, default 1) sets the polygon size
  135037. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135038. * * 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`
  135039. * * 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
  135040. * * 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)`)
  135041. * * 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
  135042. * * 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
  135043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135046. * @param name defines the name of the mesh
  135047. * @param options defines the options used to create the mesh
  135048. * @param scene defines the hosting scene
  135049. * @returns the polyhedron mesh
  135050. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135051. */
  135052. static CreatePolyhedron(name: string, options: {
  135053. type?: number;
  135054. size?: number;
  135055. sizeX?: number;
  135056. sizeY?: number;
  135057. sizeZ?: number;
  135058. custom?: any;
  135059. faceUV?: Vector4[];
  135060. faceColors?: Color4[];
  135061. flat?: boolean;
  135062. updatable?: boolean;
  135063. sideOrientation?: number;
  135064. frontUVs?: Vector4;
  135065. backUVs?: Vector4;
  135066. }, scene?: Nullable<Scene>): Mesh;
  135067. /**
  135068. * Creates a decal mesh.
  135069. * 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
  135070. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135071. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135072. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135073. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135074. * @param name defines the name of the mesh
  135075. * @param sourceMesh defines the mesh where the decal must be applied
  135076. * @param options defines the options used to create the mesh
  135077. * @param scene defines the hosting scene
  135078. * @returns the decal mesh
  135079. * @see https://doc.babylonjs.com/how_to/decals
  135080. */
  135081. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135082. position?: Vector3;
  135083. normal?: Vector3;
  135084. size?: Vector3;
  135085. angle?: number;
  135086. }): Mesh;
  135087. }
  135088. }
  135089. declare module BABYLON {
  135090. /**
  135091. * A simplifier interface for future simplification implementations
  135092. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135093. */
  135094. export interface ISimplifier {
  135095. /**
  135096. * Simplification of a given mesh according to the given settings.
  135097. * Since this requires computation, it is assumed that the function runs async.
  135098. * @param settings The settings of the simplification, including quality and distance
  135099. * @param successCallback A callback that will be called after the mesh was simplified.
  135100. * @param errorCallback in case of an error, this callback will be called. optional.
  135101. */
  135102. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135103. }
  135104. /**
  135105. * Expected simplification settings.
  135106. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135107. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135108. */
  135109. export interface ISimplificationSettings {
  135110. /**
  135111. * Gets or sets the expected quality
  135112. */
  135113. quality: number;
  135114. /**
  135115. * Gets or sets the distance when this optimized version should be used
  135116. */
  135117. distance: number;
  135118. /**
  135119. * Gets an already optimized mesh
  135120. */
  135121. optimizeMesh?: boolean;
  135122. }
  135123. /**
  135124. * Class used to specify simplification options
  135125. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135126. */
  135127. export class SimplificationSettings implements ISimplificationSettings {
  135128. /** expected quality */
  135129. quality: number;
  135130. /** distance when this optimized version should be used */
  135131. distance: number;
  135132. /** already optimized mesh */
  135133. optimizeMesh?: boolean | undefined;
  135134. /**
  135135. * Creates a SimplificationSettings
  135136. * @param quality expected quality
  135137. * @param distance distance when this optimized version should be used
  135138. * @param optimizeMesh already optimized mesh
  135139. */
  135140. constructor(
  135141. /** expected quality */
  135142. quality: number,
  135143. /** distance when this optimized version should be used */
  135144. distance: number,
  135145. /** already optimized mesh */
  135146. optimizeMesh?: boolean | undefined);
  135147. }
  135148. /**
  135149. * Interface used to define a simplification task
  135150. */
  135151. export interface ISimplificationTask {
  135152. /**
  135153. * Array of settings
  135154. */
  135155. settings: Array<ISimplificationSettings>;
  135156. /**
  135157. * Simplification type
  135158. */
  135159. simplificationType: SimplificationType;
  135160. /**
  135161. * Mesh to simplify
  135162. */
  135163. mesh: Mesh;
  135164. /**
  135165. * Callback called on success
  135166. */
  135167. successCallback?: () => void;
  135168. /**
  135169. * Defines if parallel processing can be used
  135170. */
  135171. parallelProcessing: boolean;
  135172. }
  135173. /**
  135174. * Queue used to order the simplification tasks
  135175. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135176. */
  135177. export class SimplificationQueue {
  135178. private _simplificationArray;
  135179. /**
  135180. * Gets a boolean indicating that the process is still running
  135181. */
  135182. running: boolean;
  135183. /**
  135184. * Creates a new queue
  135185. */
  135186. constructor();
  135187. /**
  135188. * Adds a new simplification task
  135189. * @param task defines a task to add
  135190. */
  135191. addTask(task: ISimplificationTask): void;
  135192. /**
  135193. * Execute next task
  135194. */
  135195. executeNext(): void;
  135196. /**
  135197. * Execute a simplification task
  135198. * @param task defines the task to run
  135199. */
  135200. runSimplification(task: ISimplificationTask): void;
  135201. private getSimplifier;
  135202. }
  135203. /**
  135204. * The implemented types of simplification
  135205. * At the moment only Quadratic Error Decimation is implemented
  135206. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135207. */
  135208. export enum SimplificationType {
  135209. /** Quadratic error decimation */
  135210. QUADRATIC = 0
  135211. }
  135212. /**
  135213. * An implementation of the Quadratic Error simplification algorithm.
  135214. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  135215. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  135216. * @author RaananW
  135217. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135218. */
  135219. export class QuadraticErrorSimplification implements ISimplifier {
  135220. private _mesh;
  135221. private triangles;
  135222. private vertices;
  135223. private references;
  135224. private _reconstructedMesh;
  135225. /** Gets or sets the number pf sync interations */
  135226. syncIterations: number;
  135227. /** Gets or sets the aggressiveness of the simplifier */
  135228. aggressiveness: number;
  135229. /** Gets or sets the number of allowed iterations for decimation */
  135230. decimationIterations: number;
  135231. /** Gets or sets the espilon to use for bounding box computation */
  135232. boundingBoxEpsilon: number;
  135233. /**
  135234. * Creates a new QuadraticErrorSimplification
  135235. * @param _mesh defines the target mesh
  135236. */
  135237. constructor(_mesh: Mesh);
  135238. /**
  135239. * Simplification of a given mesh according to the given settings.
  135240. * Since this requires computation, it is assumed that the function runs async.
  135241. * @param settings The settings of the simplification, including quality and distance
  135242. * @param successCallback A callback that will be called after the mesh was simplified.
  135243. */
  135244. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  135245. private runDecimation;
  135246. private initWithMesh;
  135247. private init;
  135248. private reconstructMesh;
  135249. private initDecimatedMesh;
  135250. private isFlipped;
  135251. private updateTriangles;
  135252. private identifyBorder;
  135253. private updateMesh;
  135254. private vertexError;
  135255. private calculateError;
  135256. }
  135257. }
  135258. declare module BABYLON {
  135259. interface Scene {
  135260. /** @hidden (Backing field) */
  135261. _simplificationQueue: SimplificationQueue;
  135262. /**
  135263. * Gets or sets the simplification queue attached to the scene
  135264. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135265. */
  135266. simplificationQueue: SimplificationQueue;
  135267. }
  135268. interface Mesh {
  135269. /**
  135270. * Simplify the mesh according to the given array of settings.
  135271. * Function will return immediately and will simplify async
  135272. * @param settings a collection of simplification settings
  135273. * @param parallelProcessing should all levels calculate parallel or one after the other
  135274. * @param simplificationType the type of simplification to run
  135275. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135276. * @returns the current mesh
  135277. */
  135278. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135279. }
  135280. /**
  135281. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135282. * created in a scene
  135283. */
  135284. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135285. /**
  135286. * The component name helpfull to identify the component in the list of scene components.
  135287. */
  135288. readonly name: string;
  135289. /**
  135290. * The scene the component belongs to.
  135291. */
  135292. scene: Scene;
  135293. /**
  135294. * Creates a new instance of the component for the given scene
  135295. * @param scene Defines the scene to register the component in
  135296. */
  135297. constructor(scene: Scene);
  135298. /**
  135299. * Registers the component in a given scene
  135300. */
  135301. register(): void;
  135302. /**
  135303. * Rebuilds the elements related to this component in case of
  135304. * context lost for instance.
  135305. */
  135306. rebuild(): void;
  135307. /**
  135308. * Disposes the component and the associated ressources
  135309. */
  135310. dispose(): void;
  135311. private _beforeCameraUpdate;
  135312. }
  135313. }
  135314. declare module BABYLON {
  135315. /**
  135316. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135317. */
  135318. export interface INavigationEnginePlugin {
  135319. /**
  135320. * plugin name
  135321. */
  135322. name: string;
  135323. /**
  135324. * Creates a navigation mesh
  135325. * @param meshes array of all the geometry used to compute the navigatio mesh
  135326. * @param parameters bunch of parameters used to filter geometry
  135327. */
  135328. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135329. /**
  135330. * Create a navigation mesh debug mesh
  135331. * @param scene is where the mesh will be added
  135332. * @returns debug display mesh
  135333. */
  135334. createDebugNavMesh(scene: Scene): Mesh;
  135335. /**
  135336. * Get a navigation mesh constrained position, closest to the parameter position
  135337. * @param position world position
  135338. * @returns the closest point to position constrained by the navigation mesh
  135339. */
  135340. getClosestPoint(position: Vector3): Vector3;
  135341. /**
  135342. * Get a navigation mesh constrained position, within a particular radius
  135343. * @param position world position
  135344. * @param maxRadius the maximum distance to the constrained world position
  135345. * @returns the closest point to position constrained by the navigation mesh
  135346. */
  135347. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135348. /**
  135349. * Compute the final position from a segment made of destination-position
  135350. * @param position world position
  135351. * @param destination world position
  135352. * @returns the resulting point along the navmesh
  135353. */
  135354. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135355. /**
  135356. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135357. * @param start world position
  135358. * @param end world position
  135359. * @returns array containing world position composing the path
  135360. */
  135361. computePath(start: Vector3, end: Vector3): Vector3[];
  135362. /**
  135363. * If this plugin is supported
  135364. * @returns true if plugin is supported
  135365. */
  135366. isSupported(): boolean;
  135367. /**
  135368. * Create a new Crowd so you can add agents
  135369. * @param maxAgents the maximum agent count in the crowd
  135370. * @param maxAgentRadius the maximum radius an agent can have
  135371. * @param scene to attach the crowd to
  135372. * @returns the crowd you can add agents to
  135373. */
  135374. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135375. /**
  135376. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135377. * The queries will try to find a solution within those bounds
  135378. * default is (1,1,1)
  135379. * @param extent x,y,z value that define the extent around the queries point of reference
  135380. */
  135381. setDefaultQueryExtent(extent: Vector3): void;
  135382. /**
  135383. * Get the Bounding box extent specified by setDefaultQueryExtent
  135384. * @returns the box extent values
  135385. */
  135386. getDefaultQueryExtent(): Vector3;
  135387. /**
  135388. * Release all resources
  135389. */
  135390. dispose(): void;
  135391. }
  135392. /**
  135393. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135394. */
  135395. export interface ICrowd {
  135396. /**
  135397. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135398. * You can attach anything to that node. The node position is updated in the scene update tick.
  135399. * @param pos world position that will be constrained by the navigation mesh
  135400. * @param parameters agent parameters
  135401. * @param transform hooked to the agent that will be update by the scene
  135402. * @returns agent index
  135403. */
  135404. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135405. /**
  135406. * Returns the agent position in world space
  135407. * @param index agent index returned by addAgent
  135408. * @returns world space position
  135409. */
  135410. getAgentPosition(index: number): Vector3;
  135411. /**
  135412. * Gets the agent velocity in world space
  135413. * @param index agent index returned by addAgent
  135414. * @returns world space velocity
  135415. */
  135416. getAgentVelocity(index: number): Vector3;
  135417. /**
  135418. * remove a particular agent previously created
  135419. * @param index agent index returned by addAgent
  135420. */
  135421. removeAgent(index: number): void;
  135422. /**
  135423. * get the list of all agents attached to this crowd
  135424. * @returns list of agent indices
  135425. */
  135426. getAgents(): number[];
  135427. /**
  135428. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135429. * @param deltaTime in seconds
  135430. */
  135431. update(deltaTime: number): void;
  135432. /**
  135433. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135434. * @param index agent index returned by addAgent
  135435. * @param destination targeted world position
  135436. */
  135437. agentGoto(index: number, destination: Vector3): void;
  135438. /**
  135439. * Teleport the agent to a new position
  135440. * @param index agent index returned by addAgent
  135441. * @param destination targeted world position
  135442. */
  135443. agentTeleport(index: number, destination: Vector3): void;
  135444. /**
  135445. * Update agent parameters
  135446. * @param index agent index returned by addAgent
  135447. * @param parameters agent parameters
  135448. */
  135449. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135450. /**
  135451. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135452. * The queries will try to find a solution within those bounds
  135453. * default is (1,1,1)
  135454. * @param extent x,y,z value that define the extent around the queries point of reference
  135455. */
  135456. setDefaultQueryExtent(extent: Vector3): void;
  135457. /**
  135458. * Get the Bounding box extent specified by setDefaultQueryExtent
  135459. * @returns the box extent values
  135460. */
  135461. getDefaultQueryExtent(): Vector3;
  135462. /**
  135463. * Release all resources
  135464. */
  135465. dispose(): void;
  135466. }
  135467. /**
  135468. * Configures an agent
  135469. */
  135470. export interface IAgentParameters {
  135471. /**
  135472. * Agent radius. [Limit: >= 0]
  135473. */
  135474. radius: number;
  135475. /**
  135476. * Agent height. [Limit: > 0]
  135477. */
  135478. height: number;
  135479. /**
  135480. * Maximum allowed acceleration. [Limit: >= 0]
  135481. */
  135482. maxAcceleration: number;
  135483. /**
  135484. * Maximum allowed speed. [Limit: >= 0]
  135485. */
  135486. maxSpeed: number;
  135487. /**
  135488. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135489. */
  135490. collisionQueryRange: number;
  135491. /**
  135492. * The path visibility optimization range. [Limit: > 0]
  135493. */
  135494. pathOptimizationRange: number;
  135495. /**
  135496. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135497. */
  135498. separationWeight: number;
  135499. }
  135500. /**
  135501. * Configures the navigation mesh creation
  135502. */
  135503. export interface INavMeshParameters {
  135504. /**
  135505. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135506. */
  135507. cs: number;
  135508. /**
  135509. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135510. */
  135511. ch: number;
  135512. /**
  135513. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135514. */
  135515. walkableSlopeAngle: number;
  135516. /**
  135517. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135518. * be considered walkable. [Limit: >= 3] [Units: vx]
  135519. */
  135520. walkableHeight: number;
  135521. /**
  135522. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135523. */
  135524. walkableClimb: number;
  135525. /**
  135526. * The distance to erode/shrink the walkable area of the heightfield away from
  135527. * obstructions. [Limit: >=0] [Units: vx]
  135528. */
  135529. walkableRadius: number;
  135530. /**
  135531. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135532. */
  135533. maxEdgeLen: number;
  135534. /**
  135535. * The maximum distance a simplfied contour's border edges should deviate
  135536. * the original raw contour. [Limit: >=0] [Units: vx]
  135537. */
  135538. maxSimplificationError: number;
  135539. /**
  135540. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135541. */
  135542. minRegionArea: number;
  135543. /**
  135544. * Any regions with a span count smaller than this value will, if possible,
  135545. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135546. */
  135547. mergeRegionArea: number;
  135548. /**
  135549. * The maximum number of vertices allowed for polygons generated during the
  135550. * contour to polygon conversion process. [Limit: >= 3]
  135551. */
  135552. maxVertsPerPoly: number;
  135553. /**
  135554. * Sets the sampling distance to use when generating the detail mesh.
  135555. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135556. */
  135557. detailSampleDist: number;
  135558. /**
  135559. * The maximum distance the detail mesh surface should deviate from heightfield
  135560. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135561. */
  135562. detailSampleMaxError: number;
  135563. }
  135564. }
  135565. declare module BABYLON {
  135566. /**
  135567. * RecastJS navigation plugin
  135568. */
  135569. export class RecastJSPlugin implements INavigationEnginePlugin {
  135570. /**
  135571. * Reference to the Recast library
  135572. */
  135573. bjsRECAST: any;
  135574. /**
  135575. * plugin name
  135576. */
  135577. name: string;
  135578. /**
  135579. * the first navmesh created. We might extend this to support multiple navmeshes
  135580. */
  135581. navMesh: any;
  135582. /**
  135583. * Initializes the recastJS plugin
  135584. * @param recastInjection can be used to inject your own recast reference
  135585. */
  135586. constructor(recastInjection?: any);
  135587. /**
  135588. * Creates a navigation mesh
  135589. * @param meshes array of all the geometry used to compute the navigatio mesh
  135590. * @param parameters bunch of parameters used to filter geometry
  135591. */
  135592. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135593. /**
  135594. * Create a navigation mesh debug mesh
  135595. * @param scene is where the mesh will be added
  135596. * @returns debug display mesh
  135597. */
  135598. createDebugNavMesh(scene: Scene): Mesh;
  135599. /**
  135600. * Get a navigation mesh constrained position, closest to the parameter position
  135601. * @param position world position
  135602. * @returns the closest point to position constrained by the navigation mesh
  135603. */
  135604. getClosestPoint(position: Vector3): Vector3;
  135605. /**
  135606. * Get a navigation mesh constrained position, within a particular radius
  135607. * @param position world position
  135608. * @param maxRadius the maximum distance to the constrained world position
  135609. * @returns the closest point to position constrained by the navigation mesh
  135610. */
  135611. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135612. /**
  135613. * Compute the final position from a segment made of destination-position
  135614. * @param position world position
  135615. * @param destination world position
  135616. * @returns the resulting point along the navmesh
  135617. */
  135618. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135619. /**
  135620. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135621. * @param start world position
  135622. * @param end world position
  135623. * @returns array containing world position composing the path
  135624. */
  135625. computePath(start: Vector3, end: Vector3): Vector3[];
  135626. /**
  135627. * Create a new Crowd so you can add agents
  135628. * @param maxAgents the maximum agent count in the crowd
  135629. * @param maxAgentRadius the maximum radius an agent can have
  135630. * @param scene to attach the crowd to
  135631. * @returns the crowd you can add agents to
  135632. */
  135633. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135634. /**
  135635. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135636. * The queries will try to find a solution within those bounds
  135637. * default is (1,1,1)
  135638. * @param extent x,y,z value that define the extent around the queries point of reference
  135639. */
  135640. setDefaultQueryExtent(extent: Vector3): void;
  135641. /**
  135642. * Get the Bounding box extent specified by setDefaultQueryExtent
  135643. * @returns the box extent values
  135644. */
  135645. getDefaultQueryExtent(): Vector3;
  135646. /**
  135647. * Disposes
  135648. */
  135649. dispose(): void;
  135650. /**
  135651. * If this plugin is supported
  135652. * @returns true if plugin is supported
  135653. */
  135654. isSupported(): boolean;
  135655. }
  135656. /**
  135657. * Recast detour crowd implementation
  135658. */
  135659. export class RecastJSCrowd implements ICrowd {
  135660. /**
  135661. * Recast/detour plugin
  135662. */
  135663. bjsRECASTPlugin: RecastJSPlugin;
  135664. /**
  135665. * Link to the detour crowd
  135666. */
  135667. recastCrowd: any;
  135668. /**
  135669. * One transform per agent
  135670. */
  135671. transforms: TransformNode[];
  135672. /**
  135673. * All agents created
  135674. */
  135675. agents: number[];
  135676. /**
  135677. * Link to the scene is kept to unregister the crowd from the scene
  135678. */
  135679. private _scene;
  135680. /**
  135681. * Observer for crowd updates
  135682. */
  135683. private _onBeforeAnimationsObserver;
  135684. /**
  135685. * Constructor
  135686. * @param plugin recastJS plugin
  135687. * @param maxAgents the maximum agent count in the crowd
  135688. * @param maxAgentRadius the maximum radius an agent can have
  135689. * @param scene to attach the crowd to
  135690. * @returns the crowd you can add agents to
  135691. */
  135692. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135693. /**
  135694. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135695. * You can attach anything to that node. The node position is updated in the scene update tick.
  135696. * @param pos world position that will be constrained by the navigation mesh
  135697. * @param parameters agent parameters
  135698. * @param transform hooked to the agent that will be update by the scene
  135699. * @returns agent index
  135700. */
  135701. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135702. /**
  135703. * Returns the agent position in world space
  135704. * @param index agent index returned by addAgent
  135705. * @returns world space position
  135706. */
  135707. getAgentPosition(index: number): Vector3;
  135708. /**
  135709. * Returns the agent velocity in world space
  135710. * @param index agent index returned by addAgent
  135711. * @returns world space velocity
  135712. */
  135713. getAgentVelocity(index: number): Vector3;
  135714. /**
  135715. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135716. * @param index agent index returned by addAgent
  135717. * @param destination targeted world position
  135718. */
  135719. agentGoto(index: number, destination: Vector3): void;
  135720. /**
  135721. * Teleport the agent to a new position
  135722. * @param index agent index returned by addAgent
  135723. * @param destination targeted world position
  135724. */
  135725. agentTeleport(index: number, destination: Vector3): void;
  135726. /**
  135727. * Update agent parameters
  135728. * @param index agent index returned by addAgent
  135729. * @param parameters agent parameters
  135730. */
  135731. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135732. /**
  135733. * remove a particular agent previously created
  135734. * @param index agent index returned by addAgent
  135735. */
  135736. removeAgent(index: number): void;
  135737. /**
  135738. * get the list of all agents attached to this crowd
  135739. * @returns list of agent indices
  135740. */
  135741. getAgents(): number[];
  135742. /**
  135743. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135744. * @param deltaTime in seconds
  135745. */
  135746. update(deltaTime: number): void;
  135747. /**
  135748. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135749. * The queries will try to find a solution within those bounds
  135750. * default is (1,1,1)
  135751. * @param extent x,y,z value that define the extent around the queries point of reference
  135752. */
  135753. setDefaultQueryExtent(extent: Vector3): void;
  135754. /**
  135755. * Get the Bounding box extent specified by setDefaultQueryExtent
  135756. * @returns the box extent values
  135757. */
  135758. getDefaultQueryExtent(): Vector3;
  135759. /**
  135760. * Release all resources
  135761. */
  135762. dispose(): void;
  135763. }
  135764. }
  135765. declare module BABYLON {
  135766. /**
  135767. * Class used to enable access to IndexedDB
  135768. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135769. */
  135770. export class Database implements IOfflineProvider {
  135771. private _callbackManifestChecked;
  135772. private _currentSceneUrl;
  135773. private _db;
  135774. private _enableSceneOffline;
  135775. private _enableTexturesOffline;
  135776. private _manifestVersionFound;
  135777. private _mustUpdateRessources;
  135778. private _hasReachedQuota;
  135779. private _isSupported;
  135780. private _idbFactory;
  135781. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135782. private static IsUASupportingBlobStorage;
  135783. /**
  135784. * Gets a boolean indicating if Database storate is enabled (off by default)
  135785. */
  135786. static IDBStorageEnabled: boolean;
  135787. /**
  135788. * Gets a boolean indicating if scene must be saved in the database
  135789. */
  135790. get enableSceneOffline(): boolean;
  135791. /**
  135792. * Gets a boolean indicating if textures must be saved in the database
  135793. */
  135794. get enableTexturesOffline(): boolean;
  135795. /**
  135796. * Creates a new Database
  135797. * @param urlToScene defines the url to load the scene
  135798. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135799. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135800. */
  135801. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135802. private static _ParseURL;
  135803. private static _ReturnFullUrlLocation;
  135804. private _checkManifestFile;
  135805. /**
  135806. * Open the database and make it available
  135807. * @param successCallback defines the callback to call on success
  135808. * @param errorCallback defines the callback to call on error
  135809. */
  135810. open(successCallback: () => void, errorCallback: () => void): void;
  135811. /**
  135812. * Loads an image from the database
  135813. * @param url defines the url to load from
  135814. * @param image defines the target DOM image
  135815. */
  135816. loadImage(url: string, image: HTMLImageElement): void;
  135817. private _loadImageFromDBAsync;
  135818. private _saveImageIntoDBAsync;
  135819. private _checkVersionFromDB;
  135820. private _loadVersionFromDBAsync;
  135821. private _saveVersionIntoDBAsync;
  135822. /**
  135823. * Loads a file from database
  135824. * @param url defines the URL to load from
  135825. * @param sceneLoaded defines a callback to call on success
  135826. * @param progressCallBack defines a callback to call when progress changed
  135827. * @param errorCallback defines a callback to call on error
  135828. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135829. */
  135830. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135831. private _loadFileAsync;
  135832. private _saveFileAsync;
  135833. /**
  135834. * Validates if xhr data is correct
  135835. * @param xhr defines the request to validate
  135836. * @param dataType defines the expected data type
  135837. * @returns true if data is correct
  135838. */
  135839. private static _ValidateXHRData;
  135840. }
  135841. }
  135842. declare module BABYLON {
  135843. /** @hidden */
  135844. export var gpuUpdateParticlesPixelShader: {
  135845. name: string;
  135846. shader: string;
  135847. };
  135848. }
  135849. declare module BABYLON {
  135850. /** @hidden */
  135851. export var gpuUpdateParticlesVertexShader: {
  135852. name: string;
  135853. shader: string;
  135854. };
  135855. }
  135856. declare module BABYLON {
  135857. /** @hidden */
  135858. export var clipPlaneFragmentDeclaration2: {
  135859. name: string;
  135860. shader: string;
  135861. };
  135862. }
  135863. declare module BABYLON {
  135864. /** @hidden */
  135865. export var gpuRenderParticlesPixelShader: {
  135866. name: string;
  135867. shader: string;
  135868. };
  135869. }
  135870. declare module BABYLON {
  135871. /** @hidden */
  135872. export var clipPlaneVertexDeclaration2: {
  135873. name: string;
  135874. shader: string;
  135875. };
  135876. }
  135877. declare module BABYLON {
  135878. /** @hidden */
  135879. export var gpuRenderParticlesVertexShader: {
  135880. name: string;
  135881. shader: string;
  135882. };
  135883. }
  135884. declare module BABYLON {
  135885. /**
  135886. * This represents a GPU particle system in Babylon
  135887. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135888. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135889. */
  135890. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135891. /**
  135892. * The layer mask we are rendering the particles through.
  135893. */
  135894. layerMask: number;
  135895. private _capacity;
  135896. private _activeCount;
  135897. private _currentActiveCount;
  135898. private _accumulatedCount;
  135899. private _renderEffect;
  135900. private _updateEffect;
  135901. private _buffer0;
  135902. private _buffer1;
  135903. private _spriteBuffer;
  135904. private _updateVAO;
  135905. private _renderVAO;
  135906. private _targetIndex;
  135907. private _sourceBuffer;
  135908. private _targetBuffer;
  135909. private _engine;
  135910. private _currentRenderId;
  135911. private _started;
  135912. private _stopped;
  135913. private _timeDelta;
  135914. private _randomTexture;
  135915. private _randomTexture2;
  135916. private _attributesStrideSize;
  135917. private _updateEffectOptions;
  135918. private _randomTextureSize;
  135919. private _actualFrame;
  135920. private readonly _rawTextureWidth;
  135921. /**
  135922. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135923. */
  135924. static get IsSupported(): boolean;
  135925. /**
  135926. * An event triggered when the system is disposed.
  135927. */
  135928. onDisposeObservable: Observable<GPUParticleSystem>;
  135929. /**
  135930. * Gets the maximum number of particles active at the same time.
  135931. * @returns The max number of active particles.
  135932. */
  135933. getCapacity(): number;
  135934. /**
  135935. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135936. * to override the particles.
  135937. */
  135938. forceDepthWrite: boolean;
  135939. /**
  135940. * Gets or set the number of active particles
  135941. */
  135942. get activeParticleCount(): number;
  135943. set activeParticleCount(value: number);
  135944. private _preWarmDone;
  135945. /**
  135946. * Specifies if the particles are updated in emitter local space or world space.
  135947. * This is always false for GPU particles
  135948. */
  135949. get isLocal(): boolean;
  135950. set isLocal(value: boolean);
  135951. /**
  135952. * Is this system ready to be used/rendered
  135953. * @return true if the system is ready
  135954. */
  135955. isReady(): boolean;
  135956. /**
  135957. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135958. * @returns True if it has been started, otherwise false.
  135959. */
  135960. isStarted(): boolean;
  135961. /**
  135962. * Starts the particle system and begins to emit
  135963. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135964. */
  135965. start(delay?: number): void;
  135966. /**
  135967. * Stops the particle system.
  135968. */
  135969. stop(): void;
  135970. /**
  135971. * Remove all active particles
  135972. */
  135973. reset(): void;
  135974. /**
  135975. * Returns the string "GPUParticleSystem"
  135976. * @returns a string containing the class name
  135977. */
  135978. getClassName(): string;
  135979. private _colorGradientsTexture;
  135980. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135981. /**
  135982. * Adds a new color gradient
  135983. * @param gradient defines the gradient to use (between 0 and 1)
  135984. * @param color1 defines the color to affect to the specified gradient
  135985. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135986. * @returns the current particle system
  135987. */
  135988. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135989. /**
  135990. * Remove a specific color gradient
  135991. * @param gradient defines the gradient to remove
  135992. * @returns the current particle system
  135993. */
  135994. removeColorGradient(gradient: number): GPUParticleSystem;
  135995. private _angularSpeedGradientsTexture;
  135996. private _sizeGradientsTexture;
  135997. private _velocityGradientsTexture;
  135998. private _limitVelocityGradientsTexture;
  135999. private _dragGradientsTexture;
  136000. private _addFactorGradient;
  136001. /**
  136002. * Adds a new size gradient
  136003. * @param gradient defines the gradient to use (between 0 and 1)
  136004. * @param factor defines the size factor to affect to the specified gradient
  136005. * @returns the current particle system
  136006. */
  136007. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  136008. /**
  136009. * Remove a specific size gradient
  136010. * @param gradient defines the gradient to remove
  136011. * @returns the current particle system
  136012. */
  136013. removeSizeGradient(gradient: number): GPUParticleSystem;
  136014. /**
  136015. * Adds a new angular speed gradient
  136016. * @param gradient defines the gradient to use (between 0 and 1)
  136017. * @param factor defines the angular speed to affect to the specified gradient
  136018. * @returns the current particle system
  136019. */
  136020. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  136021. /**
  136022. * Remove a specific angular speed gradient
  136023. * @param gradient defines the gradient to remove
  136024. * @returns the current particle system
  136025. */
  136026. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  136027. /**
  136028. * Adds a new velocity gradient
  136029. * @param gradient defines the gradient to use (between 0 and 1)
  136030. * @param factor defines the velocity to affect to the specified gradient
  136031. * @returns the current particle system
  136032. */
  136033. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136034. /**
  136035. * Remove a specific velocity gradient
  136036. * @param gradient defines the gradient to remove
  136037. * @returns the current particle system
  136038. */
  136039. removeVelocityGradient(gradient: number): GPUParticleSystem;
  136040. /**
  136041. * Adds a new limit velocity gradient
  136042. * @param gradient defines the gradient to use (between 0 and 1)
  136043. * @param factor defines the limit velocity value to affect to the specified gradient
  136044. * @returns the current particle system
  136045. */
  136046. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  136047. /**
  136048. * Remove a specific limit velocity gradient
  136049. * @param gradient defines the gradient to remove
  136050. * @returns the current particle system
  136051. */
  136052. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  136053. /**
  136054. * Adds a new drag gradient
  136055. * @param gradient defines the gradient to use (between 0 and 1)
  136056. * @param factor defines the drag value to affect to the specified gradient
  136057. * @returns the current particle system
  136058. */
  136059. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  136060. /**
  136061. * Remove a specific drag gradient
  136062. * @param gradient defines the gradient to remove
  136063. * @returns the current particle system
  136064. */
  136065. removeDragGradient(gradient: number): GPUParticleSystem;
  136066. /**
  136067. * Not supported by GPUParticleSystem
  136068. * @param gradient defines the gradient to use (between 0 and 1)
  136069. * @param factor defines the emit rate value to affect to the specified gradient
  136070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136071. * @returns the current particle system
  136072. */
  136073. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136074. /**
  136075. * Not supported by GPUParticleSystem
  136076. * @param gradient defines the gradient to remove
  136077. * @returns the current particle system
  136078. */
  136079. removeEmitRateGradient(gradient: number): IParticleSystem;
  136080. /**
  136081. * Not supported by GPUParticleSystem
  136082. * @param gradient defines the gradient to use (between 0 and 1)
  136083. * @param factor defines the start size value to affect to the specified gradient
  136084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136085. * @returns the current particle system
  136086. */
  136087. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136088. /**
  136089. * Not supported by GPUParticleSystem
  136090. * @param gradient defines the gradient to remove
  136091. * @returns the current particle system
  136092. */
  136093. removeStartSizeGradient(gradient: number): IParticleSystem;
  136094. /**
  136095. * Not supported by GPUParticleSystem
  136096. * @param gradient defines the gradient to use (between 0 and 1)
  136097. * @param min defines the color remap minimal range
  136098. * @param max defines the color remap maximal range
  136099. * @returns the current particle system
  136100. */
  136101. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136102. /**
  136103. * Not supported by GPUParticleSystem
  136104. * @param gradient defines the gradient to remove
  136105. * @returns the current particle system
  136106. */
  136107. removeColorRemapGradient(): IParticleSystem;
  136108. /**
  136109. * Not supported by GPUParticleSystem
  136110. * @param gradient defines the gradient to use (between 0 and 1)
  136111. * @param min defines the alpha remap minimal range
  136112. * @param max defines the alpha remap maximal range
  136113. * @returns the current particle system
  136114. */
  136115. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136116. /**
  136117. * Not supported by GPUParticleSystem
  136118. * @param gradient defines the gradient to remove
  136119. * @returns the current particle system
  136120. */
  136121. removeAlphaRemapGradient(): IParticleSystem;
  136122. /**
  136123. * Not supported by GPUParticleSystem
  136124. * @param gradient defines the gradient to use (between 0 and 1)
  136125. * @param color defines the color to affect to the specified gradient
  136126. * @returns the current particle system
  136127. */
  136128. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136129. /**
  136130. * Not supported by GPUParticleSystem
  136131. * @param gradient defines the gradient to remove
  136132. * @returns the current particle system
  136133. */
  136134. removeRampGradient(): IParticleSystem;
  136135. /**
  136136. * Not supported by GPUParticleSystem
  136137. * @returns the list of ramp gradients
  136138. */
  136139. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136140. /**
  136141. * Not supported by GPUParticleSystem
  136142. * Gets or sets a boolean indicating that ramp gradients must be used
  136143. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136144. */
  136145. get useRampGradients(): boolean;
  136146. set useRampGradients(value: boolean);
  136147. /**
  136148. * Not supported by GPUParticleSystem
  136149. * @param gradient defines the gradient to use (between 0 and 1)
  136150. * @param factor defines the life time factor to affect to the specified gradient
  136151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136152. * @returns the current particle system
  136153. */
  136154. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136155. /**
  136156. * Not supported by GPUParticleSystem
  136157. * @param gradient defines the gradient to remove
  136158. * @returns the current particle system
  136159. */
  136160. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136161. /**
  136162. * Instantiates a GPU particle system.
  136163. * 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.
  136164. * @param name The name of the particle system
  136165. * @param options The options used to create the system
  136166. * @param scene The scene the particle system belongs to
  136167. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136168. */
  136169. constructor(name: string, options: Partial<{
  136170. capacity: number;
  136171. randomTextureSize: number;
  136172. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136173. protected _reset(): void;
  136174. private _createUpdateVAO;
  136175. private _createRenderVAO;
  136176. private _initialize;
  136177. /** @hidden */
  136178. _recreateUpdateEffect(): void;
  136179. /** @hidden */
  136180. _recreateRenderEffect(): void;
  136181. /**
  136182. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136183. * @param preWarm defines if we are in the pre-warmimg phase
  136184. */
  136185. animate(preWarm?: boolean): void;
  136186. private _createFactorGradientTexture;
  136187. private _createSizeGradientTexture;
  136188. private _createAngularSpeedGradientTexture;
  136189. private _createVelocityGradientTexture;
  136190. private _createLimitVelocityGradientTexture;
  136191. private _createDragGradientTexture;
  136192. private _createColorGradientTexture;
  136193. /**
  136194. * Renders the particle system in its current state
  136195. * @param preWarm defines if the system should only update the particles but not render them
  136196. * @returns the current number of particles
  136197. */
  136198. render(preWarm?: boolean): number;
  136199. /**
  136200. * Rebuilds the particle system
  136201. */
  136202. rebuild(): void;
  136203. private _releaseBuffers;
  136204. private _releaseVAOs;
  136205. /**
  136206. * Disposes the particle system and free the associated resources
  136207. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136208. */
  136209. dispose(disposeTexture?: boolean): void;
  136210. /**
  136211. * Clones the particle system.
  136212. * @param name The name of the cloned object
  136213. * @param newEmitter The new emitter to use
  136214. * @returns the cloned particle system
  136215. */
  136216. clone(name: string, newEmitter: any): GPUParticleSystem;
  136217. /**
  136218. * Serializes the particle system to a JSON object.
  136219. * @returns the JSON object
  136220. */
  136221. serialize(): any;
  136222. /**
  136223. * Parses a JSON object to create a GPU particle system.
  136224. * @param parsedParticleSystem The JSON object to parse
  136225. * @param scene The scene to create the particle system in
  136226. * @param rootUrl The root url to use to load external dependencies like texture
  136227. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136228. * @returns the parsed GPU particle system
  136229. */
  136230. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136231. }
  136232. }
  136233. declare module BABYLON {
  136234. /**
  136235. * Represents a set of particle systems working together to create a specific effect
  136236. */
  136237. export class ParticleSystemSet implements IDisposable {
  136238. /**
  136239. * Gets or sets base Assets URL
  136240. */
  136241. static BaseAssetsUrl: string;
  136242. private _emitterCreationOptions;
  136243. private _emitterNode;
  136244. /**
  136245. * Gets the particle system list
  136246. */
  136247. systems: IParticleSystem[];
  136248. /**
  136249. * Gets the emitter node used with this set
  136250. */
  136251. get emitterNode(): Nullable<TransformNode>;
  136252. /**
  136253. * Creates a new emitter mesh as a sphere
  136254. * @param options defines the options used to create the sphere
  136255. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136256. * @param scene defines the hosting scene
  136257. */
  136258. setEmitterAsSphere(options: {
  136259. diameter: number;
  136260. segments: number;
  136261. color: Color3;
  136262. }, renderingGroupId: number, scene: Scene): void;
  136263. /**
  136264. * Starts all particle systems of the set
  136265. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136266. */
  136267. start(emitter?: AbstractMesh): void;
  136268. /**
  136269. * Release all associated resources
  136270. */
  136271. dispose(): void;
  136272. /**
  136273. * Serialize the set into a JSON compatible object
  136274. * @returns a JSON compatible representation of the set
  136275. */
  136276. serialize(): any;
  136277. /**
  136278. * Parse a new ParticleSystemSet from a serialized source
  136279. * @param data defines a JSON compatible representation of the set
  136280. * @param scene defines the hosting scene
  136281. * @param gpu defines if we want GPU particles or CPU particles
  136282. * @returns a new ParticleSystemSet
  136283. */
  136284. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136285. }
  136286. }
  136287. declare module BABYLON {
  136288. /**
  136289. * This class is made for on one-liner static method to help creating particle system set.
  136290. */
  136291. export class ParticleHelper {
  136292. /**
  136293. * Gets or sets base Assets URL
  136294. */
  136295. static BaseAssetsUrl: string;
  136296. /**
  136297. * Create a default particle system that you can tweak
  136298. * @param emitter defines the emitter to use
  136299. * @param capacity defines the system capacity (default is 500 particles)
  136300. * @param scene defines the hosting scene
  136301. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136302. * @returns the new Particle system
  136303. */
  136304. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136305. /**
  136306. * This is the main static method (one-liner) of this helper to create different particle systems
  136307. * @param type This string represents the type to the particle system to create
  136308. * @param scene The scene where the particle system should live
  136309. * @param gpu If the system will use gpu
  136310. * @returns the ParticleSystemSet created
  136311. */
  136312. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136313. /**
  136314. * Static function used to export a particle system to a ParticleSystemSet variable.
  136315. * Please note that the emitter shape is not exported
  136316. * @param systems defines the particle systems to export
  136317. * @returns the created particle system set
  136318. */
  136319. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136320. }
  136321. }
  136322. declare module BABYLON {
  136323. interface Engine {
  136324. /**
  136325. * Create an effect to use with particle systems.
  136326. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136327. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136328. * @param uniformsNames defines a list of attribute names
  136329. * @param samplers defines an array of string used to represent textures
  136330. * @param defines defines the string containing the defines to use to compile the shaders
  136331. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136332. * @param onCompiled defines a function to call when the effect creation is successful
  136333. * @param onError defines a function to call when the effect creation has failed
  136334. * @returns the new Effect
  136335. */
  136336. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136337. }
  136338. interface Mesh {
  136339. /**
  136340. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136341. * @returns an array of IParticleSystem
  136342. */
  136343. getEmittedParticleSystems(): IParticleSystem[];
  136344. /**
  136345. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136346. * @returns an array of IParticleSystem
  136347. */
  136348. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136349. }
  136350. /**
  136351. * @hidden
  136352. */
  136353. export var _IDoNeedToBeInTheBuild: number;
  136354. }
  136355. declare module BABYLON {
  136356. /** Defines the 4 color options */
  136357. export enum PointColor {
  136358. /** color value */
  136359. Color = 2,
  136360. /** uv value */
  136361. UV = 1,
  136362. /** random value */
  136363. Random = 0,
  136364. /** stated value */
  136365. Stated = 3
  136366. }
  136367. /**
  136368. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136369. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  136370. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136371. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136372. *
  136373. * Full documentation here : TO BE ENTERED
  136374. */
  136375. export class PointsCloudSystem implements IDisposable {
  136376. /**
  136377. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136378. * Example : var p = SPS.particles[i];
  136379. */
  136380. particles: CloudPoint[];
  136381. /**
  136382. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136383. */
  136384. nbParticles: number;
  136385. /**
  136386. * This a counter for your own usage. It's not set by any SPS functions.
  136387. */
  136388. counter: number;
  136389. /**
  136390. * The PCS name. This name is also given to the underlying mesh.
  136391. */
  136392. name: string;
  136393. /**
  136394. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136395. */
  136396. mesh: Mesh;
  136397. /**
  136398. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136399. * Please read :
  136400. */
  136401. vars: any;
  136402. /**
  136403. * @hidden
  136404. */
  136405. _size: number;
  136406. private _scene;
  136407. private _promises;
  136408. private _positions;
  136409. private _indices;
  136410. private _normals;
  136411. private _colors;
  136412. private _uvs;
  136413. private _indices32;
  136414. private _positions32;
  136415. private _colors32;
  136416. private _uvs32;
  136417. private _updatable;
  136418. private _isVisibilityBoxLocked;
  136419. private _alwaysVisible;
  136420. private _groups;
  136421. private _groupCounter;
  136422. private _computeParticleColor;
  136423. private _computeParticleTexture;
  136424. private _computeParticleRotation;
  136425. private _computeBoundingBox;
  136426. private _isReady;
  136427. /**
  136428. * Creates a PCS (Points Cloud System) object
  136429. * @param name (String) is the PCS name, this will be the underlying mesh name
  136430. * @param pointSize (number) is the size for each point
  136431. * @param scene (Scene) is the scene in which the PCS is added
  136432. * @param options defines the options of the PCS e.g.
  136433. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136434. */
  136435. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136436. updatable?: boolean;
  136437. });
  136438. /**
  136439. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136440. * If no points were added to the PCS, the returned mesh is just a single point.
  136441. * @returns a promise for the created mesh
  136442. */
  136443. buildMeshAsync(): Promise<Mesh>;
  136444. /**
  136445. * @hidden
  136446. */
  136447. private _buildMesh;
  136448. private _addParticle;
  136449. private _randomUnitVector;
  136450. private _getColorIndicesForCoord;
  136451. private _setPointsColorOrUV;
  136452. private _colorFromTexture;
  136453. private _calculateDensity;
  136454. /**
  136455. * Adds points to the PCS in random positions within a unit sphere
  136456. * @param nb (positive integer) the number of particles to be created from this model
  136457. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136458. * @returns the number of groups in the system
  136459. */
  136460. addPoints(nb: number, pointFunction?: any): number;
  136461. /**
  136462. * Adds points to the PCS from the surface of the model shape
  136463. * @param mesh is any Mesh object that will be used as a surface model for the points
  136464. * @param nb (positive integer) the number of particles to be created from this model
  136465. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136466. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136467. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136468. * @returns the number of groups in the system
  136469. */
  136470. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136471. /**
  136472. * Adds points to the PCS inside the model shape
  136473. * @param mesh is any Mesh object that will be used as a surface model for the points
  136474. * @param nb (positive integer) the number of particles to be created from this model
  136475. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136476. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136477. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136478. * @returns the number of groups in the system
  136479. */
  136480. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136481. /**
  136482. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136483. * This method calls `updateParticle()` for each particle of the SPS.
  136484. * For an animated SPS, it is usually called within the render loop.
  136485. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136486. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136487. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136488. * @returns the PCS.
  136489. */
  136490. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136491. /**
  136492. * Disposes the PCS.
  136493. */
  136494. dispose(): void;
  136495. /**
  136496. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136497. * doc :
  136498. * @returns the PCS.
  136499. */
  136500. refreshVisibleSize(): PointsCloudSystem;
  136501. /**
  136502. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136503. * @param size the size (float) of the visibility box
  136504. * note : this doesn't lock the PCS mesh bounding box.
  136505. * doc :
  136506. */
  136507. setVisibilityBox(size: number): void;
  136508. /**
  136509. * Gets whether the PCS is always visible or not
  136510. * doc :
  136511. */
  136512. get isAlwaysVisible(): boolean;
  136513. /**
  136514. * Sets the PCS as always visible or not
  136515. * doc :
  136516. */
  136517. set isAlwaysVisible(val: boolean);
  136518. /**
  136519. * Tells to `setParticles()` to compute the particle rotations or not
  136520. * Default value : false. The PCS is faster when it's set to false
  136521. * Note : particle rotations are only applied to parent particles
  136522. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136523. */
  136524. set computeParticleRotation(val: boolean);
  136525. /**
  136526. * Tells to `setParticles()` to compute the particle colors or not.
  136527. * Default value : true. The PCS is faster when it's set to false.
  136528. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136529. */
  136530. set computeParticleColor(val: boolean);
  136531. set computeParticleTexture(val: boolean);
  136532. /**
  136533. * Gets if `setParticles()` computes the particle colors or not.
  136534. * Default value : false. The PCS is faster when it's set to false.
  136535. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136536. */
  136537. get computeParticleColor(): boolean;
  136538. /**
  136539. * Gets if `setParticles()` computes the particle textures or not.
  136540. * Default value : false. The PCS is faster when it's set to false.
  136541. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136542. */
  136543. get computeParticleTexture(): boolean;
  136544. /**
  136545. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136546. */
  136547. set computeBoundingBox(val: boolean);
  136548. /**
  136549. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136550. */
  136551. get computeBoundingBox(): boolean;
  136552. /**
  136553. * This function does nothing. It may be overwritten to set all the particle first values.
  136554. * The PCS doesn't call this function, you may have to call it by your own.
  136555. * doc :
  136556. */
  136557. initParticles(): void;
  136558. /**
  136559. * This function does nothing. It may be overwritten to recycle a particle
  136560. * The PCS doesn't call this function, you can to call it
  136561. * doc :
  136562. * @param particle The particle to recycle
  136563. * @returns the recycled particle
  136564. */
  136565. recycleParticle(particle: CloudPoint): CloudPoint;
  136566. /**
  136567. * Updates a particle : this function should be overwritten by the user.
  136568. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136569. * doc :
  136570. * @example : just set a particle position or velocity and recycle conditions
  136571. * @param particle The particle to update
  136572. * @returns the updated particle
  136573. */
  136574. updateParticle(particle: CloudPoint): CloudPoint;
  136575. /**
  136576. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136577. * This does nothing and may be overwritten by the user.
  136578. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136579. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136580. * @param update the boolean update value actually passed to setParticles()
  136581. */
  136582. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136583. /**
  136584. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136585. * This will be passed three parameters.
  136586. * This does nothing and may be overwritten by the user.
  136587. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136588. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136589. * @param update the boolean update value actually passed to setParticles()
  136590. */
  136591. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136592. }
  136593. }
  136594. declare module BABYLON {
  136595. /**
  136596. * Represents one particle of a points cloud system.
  136597. */
  136598. export class CloudPoint {
  136599. /**
  136600. * particle global index
  136601. */
  136602. idx: number;
  136603. /**
  136604. * The color of the particle
  136605. */
  136606. color: Nullable<Color4>;
  136607. /**
  136608. * The world space position of the particle.
  136609. */
  136610. position: Vector3;
  136611. /**
  136612. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136613. */
  136614. rotation: Vector3;
  136615. /**
  136616. * The world space rotation quaternion of the particle.
  136617. */
  136618. rotationQuaternion: Nullable<Quaternion>;
  136619. /**
  136620. * The uv of the particle.
  136621. */
  136622. uv: Nullable<Vector2>;
  136623. /**
  136624. * The current speed of the particle.
  136625. */
  136626. velocity: Vector3;
  136627. /**
  136628. * The pivot point in the particle local space.
  136629. */
  136630. pivot: Vector3;
  136631. /**
  136632. * Must the particle be translated from its pivot point in its local space ?
  136633. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136634. * Default : false
  136635. */
  136636. translateFromPivot: boolean;
  136637. /**
  136638. * Index of this particle in the global "positions" array (Internal use)
  136639. * @hidden
  136640. */
  136641. _pos: number;
  136642. /**
  136643. * @hidden Index of this particle in the global "indices" array (Internal use)
  136644. */
  136645. _ind: number;
  136646. /**
  136647. * Group this particle belongs to
  136648. */
  136649. _group: PointsGroup;
  136650. /**
  136651. * Group id of this particle
  136652. */
  136653. groupId: number;
  136654. /**
  136655. * Index of the particle in its group id (Internal use)
  136656. */
  136657. idxInGroup: number;
  136658. /**
  136659. * @hidden Particle BoundingInfo object (Internal use)
  136660. */
  136661. _boundingInfo: BoundingInfo;
  136662. /**
  136663. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136664. */
  136665. _pcs: PointsCloudSystem;
  136666. /**
  136667. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136668. */
  136669. _stillInvisible: boolean;
  136670. /**
  136671. * @hidden Last computed particle rotation matrix
  136672. */
  136673. _rotationMatrix: number[];
  136674. /**
  136675. * Parent particle Id, if any.
  136676. * Default null.
  136677. */
  136678. parentId: Nullable<number>;
  136679. /**
  136680. * @hidden Internal global position in the PCS.
  136681. */
  136682. _globalPosition: Vector3;
  136683. /**
  136684. * Creates a Point Cloud object.
  136685. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136686. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136687. * @param group (PointsGroup) is the group the particle belongs to
  136688. * @param groupId (integer) is the group identifier in the PCS.
  136689. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136690. * @param pcs defines the PCS it is associated to
  136691. */
  136692. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136693. /**
  136694. * get point size
  136695. */
  136696. get size(): Vector3;
  136697. /**
  136698. * Set point size
  136699. */
  136700. set size(scale: Vector3);
  136701. /**
  136702. * Legacy support, changed quaternion to rotationQuaternion
  136703. */
  136704. get quaternion(): Nullable<Quaternion>;
  136705. /**
  136706. * Legacy support, changed quaternion to rotationQuaternion
  136707. */
  136708. set quaternion(q: Nullable<Quaternion>);
  136709. /**
  136710. * Returns a boolean. True if the particle intersects a mesh, else false
  136711. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136712. * @param target is the object (point or mesh) what the intersection is computed against
  136713. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136714. * @returns true if it intersects
  136715. */
  136716. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136717. /**
  136718. * get the rotation matrix of the particle
  136719. * @hidden
  136720. */
  136721. getRotationMatrix(m: Matrix): void;
  136722. }
  136723. /**
  136724. * Represents a group of points in a points cloud system
  136725. * * PCS internal tool, don't use it manually.
  136726. */
  136727. export class PointsGroup {
  136728. /**
  136729. * The group id
  136730. * @hidden
  136731. */
  136732. groupID: number;
  136733. /**
  136734. * image data for group (internal use)
  136735. * @hidden
  136736. */
  136737. _groupImageData: Nullable<ArrayBufferView>;
  136738. /**
  136739. * Image Width (internal use)
  136740. * @hidden
  136741. */
  136742. _groupImgWidth: number;
  136743. /**
  136744. * Image Height (internal use)
  136745. * @hidden
  136746. */
  136747. _groupImgHeight: number;
  136748. /**
  136749. * Custom position function (internal use)
  136750. * @hidden
  136751. */
  136752. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136753. /**
  136754. * density per facet for surface points
  136755. * @hidden
  136756. */
  136757. _groupDensity: number[];
  136758. /**
  136759. * Only when points are colored by texture carries pointer to texture list array
  136760. * @hidden
  136761. */
  136762. _textureNb: number;
  136763. /**
  136764. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136765. * PCS internal tool, don't use it manually.
  136766. * @hidden
  136767. */
  136768. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136769. }
  136770. }
  136771. declare module BABYLON {
  136772. interface Scene {
  136773. /** @hidden (Backing field) */
  136774. _physicsEngine: Nullable<IPhysicsEngine>;
  136775. /** @hidden */
  136776. _physicsTimeAccumulator: number;
  136777. /**
  136778. * Gets the current physics engine
  136779. * @returns a IPhysicsEngine or null if none attached
  136780. */
  136781. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136782. /**
  136783. * Enables physics to the current scene
  136784. * @param gravity defines the scene's gravity for the physics engine
  136785. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136786. * @return a boolean indicating if the physics engine was initialized
  136787. */
  136788. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136789. /**
  136790. * Disables and disposes the physics engine associated with the scene
  136791. */
  136792. disablePhysicsEngine(): void;
  136793. /**
  136794. * Gets a boolean indicating if there is an active physics engine
  136795. * @returns a boolean indicating if there is an active physics engine
  136796. */
  136797. isPhysicsEnabled(): boolean;
  136798. /**
  136799. * Deletes a physics compound impostor
  136800. * @param compound defines the compound to delete
  136801. */
  136802. deleteCompoundImpostor(compound: any): void;
  136803. /**
  136804. * An event triggered when physic simulation is about to be run
  136805. */
  136806. onBeforePhysicsObservable: Observable<Scene>;
  136807. /**
  136808. * An event triggered when physic simulation has been done
  136809. */
  136810. onAfterPhysicsObservable: Observable<Scene>;
  136811. }
  136812. interface AbstractMesh {
  136813. /** @hidden */
  136814. _physicsImpostor: Nullable<PhysicsImpostor>;
  136815. /**
  136816. * Gets or sets impostor used for physic simulation
  136817. * @see http://doc.babylonjs.com/features/physics_engine
  136818. */
  136819. physicsImpostor: Nullable<PhysicsImpostor>;
  136820. /**
  136821. * Gets the current physics impostor
  136822. * @see http://doc.babylonjs.com/features/physics_engine
  136823. * @returns a physics impostor or null
  136824. */
  136825. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136826. /** Apply a physic impulse to the mesh
  136827. * @param force defines the force to apply
  136828. * @param contactPoint defines where to apply the force
  136829. * @returns the current mesh
  136830. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136831. */
  136832. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136833. /**
  136834. * Creates a physic joint between two meshes
  136835. * @param otherMesh defines the other mesh to use
  136836. * @param pivot1 defines the pivot to use on this mesh
  136837. * @param pivot2 defines the pivot to use on the other mesh
  136838. * @param options defines additional options (can be plugin dependent)
  136839. * @returns the current mesh
  136840. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136841. */
  136842. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136843. /** @hidden */
  136844. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136845. }
  136846. /**
  136847. * Defines the physics engine scene component responsible to manage a physics engine
  136848. */
  136849. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136850. /**
  136851. * The component name helpful to identify the component in the list of scene components.
  136852. */
  136853. readonly name: string;
  136854. /**
  136855. * The scene the component belongs to.
  136856. */
  136857. scene: Scene;
  136858. /**
  136859. * Creates a new instance of the component for the given scene
  136860. * @param scene Defines the scene to register the component in
  136861. */
  136862. constructor(scene: Scene);
  136863. /**
  136864. * Registers the component in a given scene
  136865. */
  136866. register(): void;
  136867. /**
  136868. * Rebuilds the elements related to this component in case of
  136869. * context lost for instance.
  136870. */
  136871. rebuild(): void;
  136872. /**
  136873. * Disposes the component and the associated ressources
  136874. */
  136875. dispose(): void;
  136876. }
  136877. }
  136878. declare module BABYLON {
  136879. /**
  136880. * A helper for physics simulations
  136881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136882. */
  136883. export class PhysicsHelper {
  136884. private _scene;
  136885. private _physicsEngine;
  136886. /**
  136887. * Initializes the Physics helper
  136888. * @param scene Babylon.js scene
  136889. */
  136890. constructor(scene: Scene);
  136891. /**
  136892. * Applies a radial explosion impulse
  136893. * @param origin the origin of the explosion
  136894. * @param radiusOrEventOptions the radius or the options of radial explosion
  136895. * @param strength the explosion strength
  136896. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136897. * @returns A physics radial explosion event, or null
  136898. */
  136899. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136900. /**
  136901. * Applies a radial explosion force
  136902. * @param origin the origin of the explosion
  136903. * @param radiusOrEventOptions the radius or the options of radial explosion
  136904. * @param strength the explosion strength
  136905. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136906. * @returns A physics radial explosion event, or null
  136907. */
  136908. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136909. /**
  136910. * Creates a gravitational field
  136911. * @param origin the origin of the explosion
  136912. * @param radiusOrEventOptions the radius or the options of radial explosion
  136913. * @param strength the explosion strength
  136914. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136915. * @returns A physics gravitational field event, or null
  136916. */
  136917. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136918. /**
  136919. * Creates a physics updraft event
  136920. * @param origin the origin of the updraft
  136921. * @param radiusOrEventOptions the radius or the options of the updraft
  136922. * @param strength the strength of the updraft
  136923. * @param height the height of the updraft
  136924. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136925. * @returns A physics updraft event, or null
  136926. */
  136927. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136928. /**
  136929. * Creates a physics vortex event
  136930. * @param origin the of the vortex
  136931. * @param radiusOrEventOptions the radius or the options of the vortex
  136932. * @param strength the strength of the vortex
  136933. * @param height the height of the vortex
  136934. * @returns a Physics vortex event, or null
  136935. * A physics vortex event or null
  136936. */
  136937. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136938. }
  136939. /**
  136940. * Represents a physics radial explosion event
  136941. */
  136942. class PhysicsRadialExplosionEvent {
  136943. private _scene;
  136944. private _options;
  136945. private _sphere;
  136946. private _dataFetched;
  136947. /**
  136948. * Initializes a radial explosioin event
  136949. * @param _scene BabylonJS scene
  136950. * @param _options The options for the vortex event
  136951. */
  136952. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136953. /**
  136954. * Returns the data related to the radial explosion event (sphere).
  136955. * @returns The radial explosion event data
  136956. */
  136957. getData(): PhysicsRadialExplosionEventData;
  136958. /**
  136959. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136960. * @param impostor A physics imposter
  136961. * @param origin the origin of the explosion
  136962. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136963. */
  136964. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136965. /**
  136966. * Triggers affecterd impostors callbacks
  136967. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136968. */
  136969. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136970. /**
  136971. * Disposes the sphere.
  136972. * @param force Specifies if the sphere should be disposed by force
  136973. */
  136974. dispose(force?: boolean): void;
  136975. /*** Helpers ***/
  136976. private _prepareSphere;
  136977. private _intersectsWithSphere;
  136978. }
  136979. /**
  136980. * Represents a gravitational field event
  136981. */
  136982. class PhysicsGravitationalFieldEvent {
  136983. private _physicsHelper;
  136984. private _scene;
  136985. private _origin;
  136986. private _options;
  136987. private _tickCallback;
  136988. private _sphere;
  136989. private _dataFetched;
  136990. /**
  136991. * Initializes the physics gravitational field event
  136992. * @param _physicsHelper A physics helper
  136993. * @param _scene BabylonJS scene
  136994. * @param _origin The origin position of the gravitational field event
  136995. * @param _options The options for the vortex event
  136996. */
  136997. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136998. /**
  136999. * Returns the data related to the gravitational field event (sphere).
  137000. * @returns A gravitational field event
  137001. */
  137002. getData(): PhysicsGravitationalFieldEventData;
  137003. /**
  137004. * Enables the gravitational field.
  137005. */
  137006. enable(): void;
  137007. /**
  137008. * Disables the gravitational field.
  137009. */
  137010. disable(): void;
  137011. /**
  137012. * Disposes the sphere.
  137013. * @param force The force to dispose from the gravitational field event
  137014. */
  137015. dispose(force?: boolean): void;
  137016. private _tick;
  137017. }
  137018. /**
  137019. * Represents a physics updraft event
  137020. */
  137021. class PhysicsUpdraftEvent {
  137022. private _scene;
  137023. private _origin;
  137024. private _options;
  137025. private _physicsEngine;
  137026. private _originTop;
  137027. private _originDirection;
  137028. private _tickCallback;
  137029. private _cylinder;
  137030. private _cylinderPosition;
  137031. private _dataFetched;
  137032. /**
  137033. * Initializes the physics updraft event
  137034. * @param _scene BabylonJS scene
  137035. * @param _origin The origin position of the updraft
  137036. * @param _options The options for the updraft event
  137037. */
  137038. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  137039. /**
  137040. * Returns the data related to the updraft event (cylinder).
  137041. * @returns A physics updraft event
  137042. */
  137043. getData(): PhysicsUpdraftEventData;
  137044. /**
  137045. * Enables the updraft.
  137046. */
  137047. enable(): void;
  137048. /**
  137049. * Disables the updraft.
  137050. */
  137051. disable(): void;
  137052. /**
  137053. * Disposes the cylinder.
  137054. * @param force Specifies if the updraft should be disposed by force
  137055. */
  137056. dispose(force?: boolean): void;
  137057. private getImpostorHitData;
  137058. private _tick;
  137059. /*** Helpers ***/
  137060. private _prepareCylinder;
  137061. private _intersectsWithCylinder;
  137062. }
  137063. /**
  137064. * Represents a physics vortex event
  137065. */
  137066. class PhysicsVortexEvent {
  137067. private _scene;
  137068. private _origin;
  137069. private _options;
  137070. private _physicsEngine;
  137071. private _originTop;
  137072. private _tickCallback;
  137073. private _cylinder;
  137074. private _cylinderPosition;
  137075. private _dataFetched;
  137076. /**
  137077. * Initializes the physics vortex event
  137078. * @param _scene The BabylonJS scene
  137079. * @param _origin The origin position of the vortex
  137080. * @param _options The options for the vortex event
  137081. */
  137082. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  137083. /**
  137084. * Returns the data related to the vortex event (cylinder).
  137085. * @returns The physics vortex event data
  137086. */
  137087. getData(): PhysicsVortexEventData;
  137088. /**
  137089. * Enables the vortex.
  137090. */
  137091. enable(): void;
  137092. /**
  137093. * Disables the cortex.
  137094. */
  137095. disable(): void;
  137096. /**
  137097. * Disposes the sphere.
  137098. * @param force
  137099. */
  137100. dispose(force?: boolean): void;
  137101. private getImpostorHitData;
  137102. private _tick;
  137103. /*** Helpers ***/
  137104. private _prepareCylinder;
  137105. private _intersectsWithCylinder;
  137106. }
  137107. /**
  137108. * Options fot the radial explosion event
  137109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137110. */
  137111. export class PhysicsRadialExplosionEventOptions {
  137112. /**
  137113. * The radius of the sphere for the radial explosion.
  137114. */
  137115. radius: number;
  137116. /**
  137117. * The strenth of the explosion.
  137118. */
  137119. strength: number;
  137120. /**
  137121. * The strenght of the force in correspondence to the distance of the affected object
  137122. */
  137123. falloff: PhysicsRadialImpulseFalloff;
  137124. /**
  137125. * Sphere options for the radial explosion.
  137126. */
  137127. sphere: {
  137128. segments: number;
  137129. diameter: number;
  137130. };
  137131. /**
  137132. * Sphere options for the radial explosion.
  137133. */
  137134. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137135. }
  137136. /**
  137137. * Options fot the updraft event
  137138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137139. */
  137140. export class PhysicsUpdraftEventOptions {
  137141. /**
  137142. * The radius of the cylinder for the vortex
  137143. */
  137144. radius: number;
  137145. /**
  137146. * The strenth of the updraft.
  137147. */
  137148. strength: number;
  137149. /**
  137150. * The height of the cylinder for the updraft.
  137151. */
  137152. height: number;
  137153. /**
  137154. * The mode for the the updraft.
  137155. */
  137156. updraftMode: PhysicsUpdraftMode;
  137157. }
  137158. /**
  137159. * Options fot the vortex event
  137160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137161. */
  137162. export class PhysicsVortexEventOptions {
  137163. /**
  137164. * The radius of the cylinder for the vortex
  137165. */
  137166. radius: number;
  137167. /**
  137168. * The strenth of the vortex.
  137169. */
  137170. strength: number;
  137171. /**
  137172. * The height of the cylinder for the vortex.
  137173. */
  137174. height: number;
  137175. /**
  137176. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137177. */
  137178. centripetalForceThreshold: number;
  137179. /**
  137180. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137181. */
  137182. centripetalForceMultiplier: number;
  137183. /**
  137184. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137185. */
  137186. centrifugalForceMultiplier: number;
  137187. /**
  137188. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137189. */
  137190. updraftForceMultiplier: number;
  137191. }
  137192. /**
  137193. * The strenght of the force in correspondence to the distance of the affected object
  137194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137195. */
  137196. export enum PhysicsRadialImpulseFalloff {
  137197. /** Defines that impulse is constant in strength across it's whole radius */
  137198. Constant = 0,
  137199. /** Defines that impulse gets weaker if it's further from the origin */
  137200. Linear = 1
  137201. }
  137202. /**
  137203. * The strength of the force in correspondence to the distance of the affected object
  137204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137205. */
  137206. export enum PhysicsUpdraftMode {
  137207. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137208. Center = 0,
  137209. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137210. Perpendicular = 1
  137211. }
  137212. /**
  137213. * Interface for a physics hit data
  137214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137215. */
  137216. export interface PhysicsHitData {
  137217. /**
  137218. * The force applied at the contact point
  137219. */
  137220. force: Vector3;
  137221. /**
  137222. * The contact point
  137223. */
  137224. contactPoint: Vector3;
  137225. /**
  137226. * The distance from the origin to the contact point
  137227. */
  137228. distanceFromOrigin: number;
  137229. }
  137230. /**
  137231. * Interface for radial explosion event data
  137232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137233. */
  137234. export interface PhysicsRadialExplosionEventData {
  137235. /**
  137236. * A sphere used for the radial explosion event
  137237. */
  137238. sphere: Mesh;
  137239. }
  137240. /**
  137241. * Interface for gravitational field event data
  137242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137243. */
  137244. export interface PhysicsGravitationalFieldEventData {
  137245. /**
  137246. * A sphere mesh used for the gravitational field event
  137247. */
  137248. sphere: Mesh;
  137249. }
  137250. /**
  137251. * Interface for updraft event data
  137252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137253. */
  137254. export interface PhysicsUpdraftEventData {
  137255. /**
  137256. * A cylinder used for the updraft event
  137257. */
  137258. cylinder: Mesh;
  137259. }
  137260. /**
  137261. * Interface for vortex event data
  137262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137263. */
  137264. export interface PhysicsVortexEventData {
  137265. /**
  137266. * A cylinder used for the vortex event
  137267. */
  137268. cylinder: Mesh;
  137269. }
  137270. /**
  137271. * Interface for an affected physics impostor
  137272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137273. */
  137274. export interface PhysicsAffectedImpostorWithData {
  137275. /**
  137276. * The impostor affected by the effect
  137277. */
  137278. impostor: PhysicsImpostor;
  137279. /**
  137280. * The data about the hit/horce from the explosion
  137281. */
  137282. hitData: PhysicsHitData;
  137283. }
  137284. }
  137285. declare module BABYLON {
  137286. /** @hidden */
  137287. export var blackAndWhitePixelShader: {
  137288. name: string;
  137289. shader: string;
  137290. };
  137291. }
  137292. declare module BABYLON {
  137293. /**
  137294. * Post process used to render in black and white
  137295. */
  137296. export class BlackAndWhitePostProcess extends PostProcess {
  137297. /**
  137298. * Linear about to convert he result to black and white (default: 1)
  137299. */
  137300. degree: number;
  137301. /**
  137302. * Creates a black and white post process
  137303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137304. * @param name The name of the effect.
  137305. * @param options The required width/height ratio to downsize to before computing the render pass.
  137306. * @param camera The camera to apply the render pass to.
  137307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137308. * @param engine The engine which the post process will be applied. (default: current engine)
  137309. * @param reusable If the post process can be reused on the same frame. (default: false)
  137310. */
  137311. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137312. }
  137313. }
  137314. declare module BABYLON {
  137315. /**
  137316. * This represents a set of one or more post processes in Babylon.
  137317. * A post process can be used to apply a shader to a texture after it is rendered.
  137318. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137319. */
  137320. export class PostProcessRenderEffect {
  137321. private _postProcesses;
  137322. private _getPostProcesses;
  137323. private _singleInstance;
  137324. private _cameras;
  137325. private _indicesForCamera;
  137326. /**
  137327. * Name of the effect
  137328. * @hidden
  137329. */
  137330. _name: string;
  137331. /**
  137332. * Instantiates a post process render effect.
  137333. * A post process can be used to apply a shader to a texture after it is rendered.
  137334. * @param engine The engine the effect is tied to
  137335. * @param name The name of the effect
  137336. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137337. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137338. */
  137339. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137340. /**
  137341. * Checks if all the post processes in the effect are supported.
  137342. */
  137343. get isSupported(): boolean;
  137344. /**
  137345. * Updates the current state of the effect
  137346. * @hidden
  137347. */
  137348. _update(): void;
  137349. /**
  137350. * Attaches the effect on cameras
  137351. * @param cameras The camera to attach to.
  137352. * @hidden
  137353. */
  137354. _attachCameras(cameras: Camera): void;
  137355. /**
  137356. * Attaches the effect on cameras
  137357. * @param cameras The camera to attach to.
  137358. * @hidden
  137359. */
  137360. _attachCameras(cameras: Camera[]): void;
  137361. /**
  137362. * Detaches the effect on cameras
  137363. * @param cameras The camera to detatch from.
  137364. * @hidden
  137365. */
  137366. _detachCameras(cameras: Camera): void;
  137367. /**
  137368. * Detatches the effect on cameras
  137369. * @param cameras The camera to detatch from.
  137370. * @hidden
  137371. */
  137372. _detachCameras(cameras: Camera[]): void;
  137373. /**
  137374. * Enables the effect on given cameras
  137375. * @param cameras The camera to enable.
  137376. * @hidden
  137377. */
  137378. _enable(cameras: Camera): void;
  137379. /**
  137380. * Enables the effect on given cameras
  137381. * @param cameras The camera to enable.
  137382. * @hidden
  137383. */
  137384. _enable(cameras: Nullable<Camera[]>): void;
  137385. /**
  137386. * Disables the effect on the given cameras
  137387. * @param cameras The camera to disable.
  137388. * @hidden
  137389. */
  137390. _disable(cameras: Camera): void;
  137391. /**
  137392. * Disables the effect on the given cameras
  137393. * @param cameras The camera to disable.
  137394. * @hidden
  137395. */
  137396. _disable(cameras: Nullable<Camera[]>): void;
  137397. /**
  137398. * Gets a list of the post processes contained in the effect.
  137399. * @param camera The camera to get the post processes on.
  137400. * @returns The list of the post processes in the effect.
  137401. */
  137402. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137403. }
  137404. }
  137405. declare module BABYLON {
  137406. /** @hidden */
  137407. export var extractHighlightsPixelShader: {
  137408. name: string;
  137409. shader: string;
  137410. };
  137411. }
  137412. declare module BABYLON {
  137413. /**
  137414. * 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.
  137415. */
  137416. export class ExtractHighlightsPostProcess extends PostProcess {
  137417. /**
  137418. * The luminance threshold, pixels below this value will be set to black.
  137419. */
  137420. threshold: number;
  137421. /** @hidden */
  137422. _exposure: number;
  137423. /**
  137424. * Post process which has the input texture to be used when performing highlight extraction
  137425. * @hidden
  137426. */
  137427. _inputPostProcess: Nullable<PostProcess>;
  137428. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137429. }
  137430. }
  137431. declare module BABYLON {
  137432. /** @hidden */
  137433. export var bloomMergePixelShader: {
  137434. name: string;
  137435. shader: string;
  137436. };
  137437. }
  137438. declare module BABYLON {
  137439. /**
  137440. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137441. */
  137442. export class BloomMergePostProcess extends PostProcess {
  137443. /** Weight of the bloom to be added to the original input. */
  137444. weight: number;
  137445. /**
  137446. * Creates a new instance of @see BloomMergePostProcess
  137447. * @param name The name of the effect.
  137448. * @param originalFromInput Post process which's input will be used for the merge.
  137449. * @param blurred Blurred highlights post process which's output will be used.
  137450. * @param weight Weight of the bloom to be added to the original input.
  137451. * @param options The required width/height ratio to downsize to before computing the render pass.
  137452. * @param camera The camera to apply the render pass to.
  137453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137454. * @param engine The engine which the post process will be applied. (default: current engine)
  137455. * @param reusable If the post process can be reused on the same frame. (default: false)
  137456. * @param textureType Type of textures used when performing the post process. (default: 0)
  137457. * @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)
  137458. */
  137459. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137460. /** Weight of the bloom to be added to the original input. */
  137461. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137462. }
  137463. }
  137464. declare module BABYLON {
  137465. /**
  137466. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137467. */
  137468. export class BloomEffect extends PostProcessRenderEffect {
  137469. private bloomScale;
  137470. /**
  137471. * @hidden Internal
  137472. */
  137473. _effects: Array<PostProcess>;
  137474. /**
  137475. * @hidden Internal
  137476. */
  137477. _downscale: ExtractHighlightsPostProcess;
  137478. private _blurX;
  137479. private _blurY;
  137480. private _merge;
  137481. /**
  137482. * The luminance threshold to find bright areas of the image to bloom.
  137483. */
  137484. get threshold(): number;
  137485. set threshold(value: number);
  137486. /**
  137487. * The strength of the bloom.
  137488. */
  137489. get weight(): number;
  137490. set weight(value: number);
  137491. /**
  137492. * Specifies the size of the bloom blur kernel, relative to the final output size
  137493. */
  137494. get kernel(): number;
  137495. set kernel(value: number);
  137496. /**
  137497. * Creates a new instance of @see BloomEffect
  137498. * @param scene The scene the effect belongs to.
  137499. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137500. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137501. * @param bloomWeight The the strength of bloom.
  137502. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137503. * @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)
  137504. */
  137505. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137506. /**
  137507. * Disposes each of the internal effects for a given camera.
  137508. * @param camera The camera to dispose the effect on.
  137509. */
  137510. disposeEffects(camera: Camera): void;
  137511. /**
  137512. * @hidden Internal
  137513. */
  137514. _updateEffects(): void;
  137515. /**
  137516. * Internal
  137517. * @returns if all the contained post processes are ready.
  137518. * @hidden
  137519. */
  137520. _isReady(): boolean;
  137521. }
  137522. }
  137523. declare module BABYLON {
  137524. /** @hidden */
  137525. export var chromaticAberrationPixelShader: {
  137526. name: string;
  137527. shader: string;
  137528. };
  137529. }
  137530. declare module BABYLON {
  137531. /**
  137532. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137533. */
  137534. export class ChromaticAberrationPostProcess extends PostProcess {
  137535. /**
  137536. * The amount of seperation of rgb channels (default: 30)
  137537. */
  137538. aberrationAmount: number;
  137539. /**
  137540. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137541. */
  137542. radialIntensity: number;
  137543. /**
  137544. * 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))
  137545. */
  137546. direction: Vector2;
  137547. /**
  137548. * 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))
  137549. */
  137550. centerPosition: Vector2;
  137551. /**
  137552. * Creates a new instance ChromaticAberrationPostProcess
  137553. * @param name The name of the effect.
  137554. * @param screenWidth The width of the screen to apply the effect on.
  137555. * @param screenHeight The height of the screen to apply the effect on.
  137556. * @param options The required width/height ratio to downsize to before computing the render pass.
  137557. * @param camera The camera to apply the render pass to.
  137558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137559. * @param engine The engine which the post process will be applied. (default: current engine)
  137560. * @param reusable If the post process can be reused on the same frame. (default: false)
  137561. * @param textureType Type of textures used when performing the post process. (default: 0)
  137562. * @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)
  137563. */
  137564. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137565. }
  137566. }
  137567. declare module BABYLON {
  137568. /** @hidden */
  137569. export var circleOfConfusionPixelShader: {
  137570. name: string;
  137571. shader: string;
  137572. };
  137573. }
  137574. declare module BABYLON {
  137575. /**
  137576. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137577. */
  137578. export class CircleOfConfusionPostProcess extends PostProcess {
  137579. /**
  137580. * 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.
  137581. */
  137582. lensSize: number;
  137583. /**
  137584. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137585. */
  137586. fStop: number;
  137587. /**
  137588. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137589. */
  137590. focusDistance: number;
  137591. /**
  137592. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137593. */
  137594. focalLength: number;
  137595. private _depthTexture;
  137596. /**
  137597. * Creates a new instance CircleOfConfusionPostProcess
  137598. * @param name The name of the effect.
  137599. * @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.
  137600. * @param options The required width/height ratio to downsize to before computing the render pass.
  137601. * @param camera The camera to apply the render pass to.
  137602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137603. * @param engine The engine which the post process will be applied. (default: current engine)
  137604. * @param reusable If the post process can be reused on the same frame. (default: false)
  137605. * @param textureType Type of textures used when performing the post process. (default: 0)
  137606. * @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)
  137607. */
  137608. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137609. /**
  137610. * 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.
  137611. */
  137612. set depthTexture(value: RenderTargetTexture);
  137613. }
  137614. }
  137615. declare module BABYLON {
  137616. /** @hidden */
  137617. export var colorCorrectionPixelShader: {
  137618. name: string;
  137619. shader: string;
  137620. };
  137621. }
  137622. declare module BABYLON {
  137623. /**
  137624. *
  137625. * This post-process allows the modification of rendered colors by using
  137626. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137627. *
  137628. * The object needs to be provided an url to a texture containing the color
  137629. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137630. * Use an image editing software to tweak the LUT to match your needs.
  137631. *
  137632. * For an example of a color LUT, see here:
  137633. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137634. * For explanations on color grading, see here:
  137635. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137636. *
  137637. */
  137638. export class ColorCorrectionPostProcess extends PostProcess {
  137639. private _colorTableTexture;
  137640. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137641. }
  137642. }
  137643. declare module BABYLON {
  137644. /** @hidden */
  137645. export var convolutionPixelShader: {
  137646. name: string;
  137647. shader: string;
  137648. };
  137649. }
  137650. declare module BABYLON {
  137651. /**
  137652. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137653. * input texture to perform effects such as edge detection or sharpening
  137654. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137655. */
  137656. export class ConvolutionPostProcess extends PostProcess {
  137657. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137658. kernel: number[];
  137659. /**
  137660. * Creates a new instance ConvolutionPostProcess
  137661. * @param name The name of the effect.
  137662. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137663. * @param options The required width/height ratio to downsize to before computing the render pass.
  137664. * @param camera The camera to apply the render pass to.
  137665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137666. * @param engine The engine which the post process will be applied. (default: current engine)
  137667. * @param reusable If the post process can be reused on the same frame. (default: false)
  137668. * @param textureType Type of textures used when performing the post process. (default: 0)
  137669. */
  137670. constructor(name: string,
  137671. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137672. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137673. /**
  137674. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137675. */
  137676. static EdgeDetect0Kernel: number[];
  137677. /**
  137678. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137679. */
  137680. static EdgeDetect1Kernel: number[];
  137681. /**
  137682. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137683. */
  137684. static EdgeDetect2Kernel: number[];
  137685. /**
  137686. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137687. */
  137688. static SharpenKernel: number[];
  137689. /**
  137690. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137691. */
  137692. static EmbossKernel: number[];
  137693. /**
  137694. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137695. */
  137696. static GaussianKernel: number[];
  137697. }
  137698. }
  137699. declare module BABYLON {
  137700. /**
  137701. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137702. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137703. * based on samples that have a large difference in distance than the center pixel.
  137704. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137705. */
  137706. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137707. direction: Vector2;
  137708. /**
  137709. * Creates a new instance CircleOfConfusionPostProcess
  137710. * @param name The name of the effect.
  137711. * @param scene The scene the effect belongs to.
  137712. * @param direction The direction the blur should be applied.
  137713. * @param kernel The size of the kernel used to blur.
  137714. * @param options The required width/height ratio to downsize to before computing the render pass.
  137715. * @param camera The camera to apply the render pass to.
  137716. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137717. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137719. * @param engine The engine which the post process will be applied. (default: current engine)
  137720. * @param reusable If the post process can be reused on the same frame. (default: false)
  137721. * @param textureType Type of textures used when performing the post process. (default: 0)
  137722. * @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)
  137723. */
  137724. 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);
  137725. }
  137726. }
  137727. declare module BABYLON {
  137728. /** @hidden */
  137729. export var depthOfFieldMergePixelShader: {
  137730. name: string;
  137731. shader: string;
  137732. };
  137733. }
  137734. declare module BABYLON {
  137735. /**
  137736. * Options to be set when merging outputs from the default pipeline.
  137737. */
  137738. export class DepthOfFieldMergePostProcessOptions {
  137739. /**
  137740. * The original image to merge on top of
  137741. */
  137742. originalFromInput: PostProcess;
  137743. /**
  137744. * Parameters to perform the merge of the depth of field effect
  137745. */
  137746. depthOfField?: {
  137747. circleOfConfusion: PostProcess;
  137748. blurSteps: Array<PostProcess>;
  137749. };
  137750. /**
  137751. * Parameters to perform the merge of bloom effect
  137752. */
  137753. bloom?: {
  137754. blurred: PostProcess;
  137755. weight: number;
  137756. };
  137757. }
  137758. /**
  137759. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137760. */
  137761. export class DepthOfFieldMergePostProcess extends PostProcess {
  137762. private blurSteps;
  137763. /**
  137764. * Creates a new instance of DepthOfFieldMergePostProcess
  137765. * @param name The name of the effect.
  137766. * @param originalFromInput Post process which's input will be used for the merge.
  137767. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137768. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137769. * @param options The required width/height ratio to downsize to before computing the render pass.
  137770. * @param camera The camera to apply the render pass to.
  137771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137772. * @param engine The engine which the post process will be applied. (default: current engine)
  137773. * @param reusable If the post process can be reused on the same frame. (default: false)
  137774. * @param textureType Type of textures used when performing the post process. (default: 0)
  137775. * @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)
  137776. */
  137777. 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);
  137778. /**
  137779. * Updates the effect with the current post process compile time values and recompiles the shader.
  137780. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137781. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137782. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137783. * @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
  137784. * @param onCompiled Called when the shader has been compiled.
  137785. * @param onError Called if there is an error when compiling a shader.
  137786. */
  137787. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137788. }
  137789. }
  137790. declare module BABYLON {
  137791. /**
  137792. * Specifies the level of max blur that should be applied when using the depth of field effect
  137793. */
  137794. export enum DepthOfFieldEffectBlurLevel {
  137795. /**
  137796. * Subtle blur
  137797. */
  137798. Low = 0,
  137799. /**
  137800. * Medium blur
  137801. */
  137802. Medium = 1,
  137803. /**
  137804. * Large blur
  137805. */
  137806. High = 2
  137807. }
  137808. /**
  137809. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137810. */
  137811. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137812. private _circleOfConfusion;
  137813. /**
  137814. * @hidden Internal, blurs from high to low
  137815. */
  137816. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137817. private _depthOfFieldBlurY;
  137818. private _dofMerge;
  137819. /**
  137820. * @hidden Internal post processes in depth of field effect
  137821. */
  137822. _effects: Array<PostProcess>;
  137823. /**
  137824. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137825. */
  137826. set focalLength(value: number);
  137827. get focalLength(): number;
  137828. /**
  137829. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137830. */
  137831. set fStop(value: number);
  137832. get fStop(): number;
  137833. /**
  137834. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137835. */
  137836. set focusDistance(value: number);
  137837. get focusDistance(): number;
  137838. /**
  137839. * 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.
  137840. */
  137841. set lensSize(value: number);
  137842. get lensSize(): number;
  137843. /**
  137844. * Creates a new instance DepthOfFieldEffect
  137845. * @param scene The scene the effect belongs to.
  137846. * @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.
  137847. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137848. * @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)
  137849. */
  137850. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137851. /**
  137852. * Get the current class name of the current effet
  137853. * @returns "DepthOfFieldEffect"
  137854. */
  137855. getClassName(): string;
  137856. /**
  137857. * 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.
  137858. */
  137859. set depthTexture(value: RenderTargetTexture);
  137860. /**
  137861. * Disposes each of the internal effects for a given camera.
  137862. * @param camera The camera to dispose the effect on.
  137863. */
  137864. disposeEffects(camera: Camera): void;
  137865. /**
  137866. * @hidden Internal
  137867. */
  137868. _updateEffects(): void;
  137869. /**
  137870. * Internal
  137871. * @returns if all the contained post processes are ready.
  137872. * @hidden
  137873. */
  137874. _isReady(): boolean;
  137875. }
  137876. }
  137877. declare module BABYLON {
  137878. /** @hidden */
  137879. export var displayPassPixelShader: {
  137880. name: string;
  137881. shader: string;
  137882. };
  137883. }
  137884. declare module BABYLON {
  137885. /**
  137886. * DisplayPassPostProcess which produces an output the same as it's input
  137887. */
  137888. export class DisplayPassPostProcess extends PostProcess {
  137889. /**
  137890. * Creates the DisplayPassPostProcess
  137891. * @param name The name of the effect.
  137892. * @param options The required width/height ratio to downsize to before computing the render pass.
  137893. * @param camera The camera to apply the render pass to.
  137894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137895. * @param engine The engine which the post process will be applied. (default: current engine)
  137896. * @param reusable If the post process can be reused on the same frame. (default: false)
  137897. */
  137898. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137899. }
  137900. }
  137901. declare module BABYLON {
  137902. /** @hidden */
  137903. export var filterPixelShader: {
  137904. name: string;
  137905. shader: string;
  137906. };
  137907. }
  137908. declare module BABYLON {
  137909. /**
  137910. * Applies a kernel filter to the image
  137911. */
  137912. export class FilterPostProcess extends PostProcess {
  137913. /** The matrix to be applied to the image */
  137914. kernelMatrix: Matrix;
  137915. /**
  137916. *
  137917. * @param name The name of the effect.
  137918. * @param kernelMatrix The matrix to be applied to the image
  137919. * @param options The required width/height ratio to downsize to before computing the render pass.
  137920. * @param camera The camera to apply the render pass to.
  137921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137922. * @param engine The engine which the post process will be applied. (default: current engine)
  137923. * @param reusable If the post process can be reused on the same frame. (default: false)
  137924. */
  137925. constructor(name: string,
  137926. /** The matrix to be applied to the image */
  137927. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137928. }
  137929. }
  137930. declare module BABYLON {
  137931. /** @hidden */
  137932. export var fxaaPixelShader: {
  137933. name: string;
  137934. shader: string;
  137935. };
  137936. }
  137937. declare module BABYLON {
  137938. /** @hidden */
  137939. export var fxaaVertexShader: {
  137940. name: string;
  137941. shader: string;
  137942. };
  137943. }
  137944. declare module BABYLON {
  137945. /**
  137946. * Fxaa post process
  137947. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137948. */
  137949. export class FxaaPostProcess extends PostProcess {
  137950. /** @hidden */
  137951. texelWidth: number;
  137952. /** @hidden */
  137953. texelHeight: number;
  137954. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137955. private _getDefines;
  137956. }
  137957. }
  137958. declare module BABYLON {
  137959. /** @hidden */
  137960. export var grainPixelShader: {
  137961. name: string;
  137962. shader: string;
  137963. };
  137964. }
  137965. declare module BABYLON {
  137966. /**
  137967. * The GrainPostProcess adds noise to the image at mid luminance levels
  137968. */
  137969. export class GrainPostProcess extends PostProcess {
  137970. /**
  137971. * The intensity of the grain added (default: 30)
  137972. */
  137973. intensity: number;
  137974. /**
  137975. * If the grain should be randomized on every frame
  137976. */
  137977. animated: boolean;
  137978. /**
  137979. * Creates a new instance of @see GrainPostProcess
  137980. * @param name The name of the effect.
  137981. * @param options The required width/height ratio to downsize to before computing the render pass.
  137982. * @param camera The camera to apply the render pass to.
  137983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137984. * @param engine The engine which the post process will be applied. (default: current engine)
  137985. * @param reusable If the post process can be reused on the same frame. (default: false)
  137986. * @param textureType Type of textures used when performing the post process. (default: 0)
  137987. * @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)
  137988. */
  137989. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137990. }
  137991. }
  137992. declare module BABYLON {
  137993. /** @hidden */
  137994. export var highlightsPixelShader: {
  137995. name: string;
  137996. shader: string;
  137997. };
  137998. }
  137999. declare module BABYLON {
  138000. /**
  138001. * Extracts highlights from the image
  138002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138003. */
  138004. export class HighlightsPostProcess extends PostProcess {
  138005. /**
  138006. * Extracts highlights from the image
  138007. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  138008. * @param name The name of the effect.
  138009. * @param options The required width/height ratio to downsize to before computing the render pass.
  138010. * @param camera The camera to apply the render pass to.
  138011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138012. * @param engine The engine which the post process will be applied. (default: current engine)
  138013. * @param reusable If the post process can be reused on the same frame. (default: false)
  138014. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  138015. */
  138016. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138017. }
  138018. }
  138019. declare module BABYLON {
  138020. /** @hidden */
  138021. export var mrtFragmentDeclaration: {
  138022. name: string;
  138023. shader: string;
  138024. };
  138025. }
  138026. declare module BABYLON {
  138027. /** @hidden */
  138028. export var geometryPixelShader: {
  138029. name: string;
  138030. shader: string;
  138031. };
  138032. }
  138033. declare module BABYLON {
  138034. /** @hidden */
  138035. export var geometryVertexShader: {
  138036. name: string;
  138037. shader: string;
  138038. };
  138039. }
  138040. declare module BABYLON {
  138041. /** @hidden */
  138042. interface ISavedTransformationMatrix {
  138043. world: Matrix;
  138044. viewProjection: Matrix;
  138045. }
  138046. /**
  138047. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  138048. */
  138049. export class GeometryBufferRenderer {
  138050. /**
  138051. * Constant used to retrieve the position texture index in the G-Buffer textures array
  138052. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  138053. */
  138054. static readonly POSITION_TEXTURE_TYPE: number;
  138055. /**
  138056. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  138057. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  138058. */
  138059. static readonly VELOCITY_TEXTURE_TYPE: number;
  138060. /**
  138061. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  138062. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  138063. */
  138064. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  138065. /**
  138066. * Dictionary used to store the previous transformation matrices of each rendered mesh
  138067. * in order to compute objects velocities when enableVelocity is set to "true"
  138068. * @hidden
  138069. */
  138070. _previousTransformationMatrices: {
  138071. [index: number]: ISavedTransformationMatrix;
  138072. };
  138073. /**
  138074. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  138075. * in order to compute objects velocities when enableVelocity is set to "true"
  138076. * @hidden
  138077. */
  138078. _previousBonesTransformationMatrices: {
  138079. [index: number]: Float32Array;
  138080. };
  138081. /**
  138082. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  138083. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  138084. */
  138085. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  138086. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  138087. renderTransparentMeshes: boolean;
  138088. private _scene;
  138089. private _multiRenderTarget;
  138090. private _ratio;
  138091. private _enablePosition;
  138092. private _enableVelocity;
  138093. private _enableReflectivity;
  138094. private _positionIndex;
  138095. private _velocityIndex;
  138096. private _reflectivityIndex;
  138097. protected _effect: Effect;
  138098. protected _cachedDefines: string;
  138099. /**
  138100. * Set the render list (meshes to be rendered) used in the G buffer.
  138101. */
  138102. set renderList(meshes: Mesh[]);
  138103. /**
  138104. * Gets wether or not G buffer are supported by the running hardware.
  138105. * This requires draw buffer supports
  138106. */
  138107. get isSupported(): boolean;
  138108. /**
  138109. * Returns the index of the given texture type in the G-Buffer textures array
  138110. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138111. * @returns the index of the given texture type in the G-Buffer textures array
  138112. */
  138113. getTextureIndex(textureType: number): number;
  138114. /**
  138115. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138116. */
  138117. get enablePosition(): boolean;
  138118. /**
  138119. * Sets whether or not objects positions are enabled for the G buffer.
  138120. */
  138121. set enablePosition(enable: boolean);
  138122. /**
  138123. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138124. */
  138125. get enableVelocity(): boolean;
  138126. /**
  138127. * Sets wether or not objects velocities are enabled for the G buffer.
  138128. */
  138129. set enableVelocity(enable: boolean);
  138130. /**
  138131. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138132. */
  138133. get enableReflectivity(): boolean;
  138134. /**
  138135. * Sets wether or not objects roughness are enabled for the G buffer.
  138136. */
  138137. set enableReflectivity(enable: boolean);
  138138. /**
  138139. * Gets the scene associated with the buffer.
  138140. */
  138141. get scene(): Scene;
  138142. /**
  138143. * Gets the ratio used by the buffer during its creation.
  138144. * How big is the buffer related to the main canvas.
  138145. */
  138146. get ratio(): number;
  138147. /** @hidden */
  138148. static _SceneComponentInitialization: (scene: Scene) => void;
  138149. /**
  138150. * Creates a new G Buffer for the scene
  138151. * @param scene The scene the buffer belongs to
  138152. * @param ratio How big is the buffer related to the main canvas.
  138153. */
  138154. constructor(scene: Scene, ratio?: number);
  138155. /**
  138156. * Checks wether everything is ready to render a submesh to the G buffer.
  138157. * @param subMesh the submesh to check readiness for
  138158. * @param useInstances is the mesh drawn using instance or not
  138159. * @returns true if ready otherwise false
  138160. */
  138161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138162. /**
  138163. * Gets the current underlying G Buffer.
  138164. * @returns the buffer
  138165. */
  138166. getGBuffer(): MultiRenderTarget;
  138167. /**
  138168. * Gets the number of samples used to render the buffer (anti aliasing).
  138169. */
  138170. get samples(): number;
  138171. /**
  138172. * Sets the number of samples used to render the buffer (anti aliasing).
  138173. */
  138174. set samples(value: number);
  138175. /**
  138176. * Disposes the renderer and frees up associated resources.
  138177. */
  138178. dispose(): void;
  138179. protected _createRenderTargets(): void;
  138180. private _copyBonesTransformationMatrices;
  138181. }
  138182. }
  138183. declare module BABYLON {
  138184. interface Scene {
  138185. /** @hidden (Backing field) */
  138186. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138187. /**
  138188. * Gets or Sets the current geometry buffer associated to the scene.
  138189. */
  138190. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138191. /**
  138192. * Enables a GeometryBufferRender and associates it with the scene
  138193. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138194. * @returns the GeometryBufferRenderer
  138195. */
  138196. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138197. /**
  138198. * Disables the GeometryBufferRender associated with the scene
  138199. */
  138200. disableGeometryBufferRenderer(): void;
  138201. }
  138202. /**
  138203. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138204. * in several rendering techniques.
  138205. */
  138206. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138207. /**
  138208. * The component name helpful to identify the component in the list of scene components.
  138209. */
  138210. readonly name: string;
  138211. /**
  138212. * The scene the component belongs to.
  138213. */
  138214. scene: Scene;
  138215. /**
  138216. * Creates a new instance of the component for the given scene
  138217. * @param scene Defines the scene to register the component in
  138218. */
  138219. constructor(scene: Scene);
  138220. /**
  138221. * Registers the component in a given scene
  138222. */
  138223. register(): void;
  138224. /**
  138225. * Rebuilds the elements related to this component in case of
  138226. * context lost for instance.
  138227. */
  138228. rebuild(): void;
  138229. /**
  138230. * Disposes the component and the associated ressources
  138231. */
  138232. dispose(): void;
  138233. private _gatherRenderTargets;
  138234. }
  138235. }
  138236. declare module BABYLON {
  138237. /** @hidden */
  138238. export var motionBlurPixelShader: {
  138239. name: string;
  138240. shader: string;
  138241. };
  138242. }
  138243. declare module BABYLON {
  138244. /**
  138245. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138246. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138247. * As an example, all you have to do is to create the post-process:
  138248. * var mb = new BABYLON.MotionBlurPostProcess(
  138249. * 'mb', // The name of the effect.
  138250. * scene, // The scene containing the objects to blur according to their velocity.
  138251. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138252. * camera // The camera to apply the render pass to.
  138253. * );
  138254. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138255. */
  138256. export class MotionBlurPostProcess extends PostProcess {
  138257. /**
  138258. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138259. */
  138260. motionStrength: number;
  138261. /**
  138262. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138263. */
  138264. get motionBlurSamples(): number;
  138265. /**
  138266. * Sets the number of iterations to be used for motion blur quality
  138267. */
  138268. set motionBlurSamples(samples: number);
  138269. private _motionBlurSamples;
  138270. private _geometryBufferRenderer;
  138271. /**
  138272. * Creates a new instance MotionBlurPostProcess
  138273. * @param name The name of the effect.
  138274. * @param scene The scene containing the objects to blur according to their velocity.
  138275. * @param options The required width/height ratio to downsize to before computing the render pass.
  138276. * @param camera The camera to apply the render pass to.
  138277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138278. * @param engine The engine which the post process will be applied. (default: current engine)
  138279. * @param reusable If the post process can be reused on the same frame. (default: false)
  138280. * @param textureType Type of textures used when performing the post process. (default: 0)
  138281. * @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)
  138282. */
  138283. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138284. /**
  138285. * Excludes the given skinned mesh from computing bones velocities.
  138286. * 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.
  138287. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138288. */
  138289. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138290. /**
  138291. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138292. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138293. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138294. */
  138295. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138296. /**
  138297. * Disposes the post process.
  138298. * @param camera The camera to dispose the post process on.
  138299. */
  138300. dispose(camera?: Camera): void;
  138301. }
  138302. }
  138303. declare module BABYLON {
  138304. /** @hidden */
  138305. export var refractionPixelShader: {
  138306. name: string;
  138307. shader: string;
  138308. };
  138309. }
  138310. declare module BABYLON {
  138311. /**
  138312. * Post process which applies a refractin texture
  138313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138314. */
  138315. export class RefractionPostProcess extends PostProcess {
  138316. /** the base color of the refraction (used to taint the rendering) */
  138317. color: Color3;
  138318. /** simulated refraction depth */
  138319. depth: number;
  138320. /** the coefficient of the base color (0 to remove base color tainting) */
  138321. colorLevel: number;
  138322. private _refTexture;
  138323. private _ownRefractionTexture;
  138324. /**
  138325. * Gets or sets the refraction texture
  138326. * Please note that you are responsible for disposing the texture if you set it manually
  138327. */
  138328. get refractionTexture(): Texture;
  138329. set refractionTexture(value: Texture);
  138330. /**
  138331. * Initializes the RefractionPostProcess
  138332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138333. * @param name The name of the effect.
  138334. * @param refractionTextureUrl Url of the refraction texture to use
  138335. * @param color the base color of the refraction (used to taint the rendering)
  138336. * @param depth simulated refraction depth
  138337. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138338. * @param camera The camera to apply the render pass to.
  138339. * @param options The required width/height ratio to downsize to before computing the render pass.
  138340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138341. * @param engine The engine which the post process will be applied. (default: current engine)
  138342. * @param reusable If the post process can be reused on the same frame. (default: false)
  138343. */
  138344. constructor(name: string, refractionTextureUrl: string,
  138345. /** the base color of the refraction (used to taint the rendering) */
  138346. color: Color3,
  138347. /** simulated refraction depth */
  138348. depth: number,
  138349. /** the coefficient of the base color (0 to remove base color tainting) */
  138350. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138351. /**
  138352. * Disposes of the post process
  138353. * @param camera Camera to dispose post process on
  138354. */
  138355. dispose(camera: Camera): void;
  138356. }
  138357. }
  138358. declare module BABYLON {
  138359. /** @hidden */
  138360. export var sharpenPixelShader: {
  138361. name: string;
  138362. shader: string;
  138363. };
  138364. }
  138365. declare module BABYLON {
  138366. /**
  138367. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138368. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138369. */
  138370. export class SharpenPostProcess extends PostProcess {
  138371. /**
  138372. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138373. */
  138374. colorAmount: number;
  138375. /**
  138376. * How much sharpness should be applied (default: 0.3)
  138377. */
  138378. edgeAmount: number;
  138379. /**
  138380. * Creates a new instance ConvolutionPostProcess
  138381. * @param name The name of the effect.
  138382. * @param options The required width/height ratio to downsize to before computing the render pass.
  138383. * @param camera The camera to apply the render pass to.
  138384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138385. * @param engine The engine which the post process will be applied. (default: current engine)
  138386. * @param reusable If the post process can be reused on the same frame. (default: false)
  138387. * @param textureType Type of textures used when performing the post process. (default: 0)
  138388. * @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)
  138389. */
  138390. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138391. }
  138392. }
  138393. declare module BABYLON {
  138394. /**
  138395. * PostProcessRenderPipeline
  138396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138397. */
  138398. export class PostProcessRenderPipeline {
  138399. private engine;
  138400. private _renderEffects;
  138401. private _renderEffectsForIsolatedPass;
  138402. /**
  138403. * List of inspectable custom properties (used by the Inspector)
  138404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138405. */
  138406. inspectableCustomProperties: IInspectable[];
  138407. /**
  138408. * @hidden
  138409. */
  138410. protected _cameras: Camera[];
  138411. /** @hidden */
  138412. _name: string;
  138413. /**
  138414. * Gets pipeline name
  138415. */
  138416. get name(): string;
  138417. /** Gets the list of attached cameras */
  138418. get cameras(): Camera[];
  138419. /**
  138420. * Initializes a PostProcessRenderPipeline
  138421. * @param engine engine to add the pipeline to
  138422. * @param name name of the pipeline
  138423. */
  138424. constructor(engine: Engine, name: string);
  138425. /**
  138426. * Gets the class name
  138427. * @returns "PostProcessRenderPipeline"
  138428. */
  138429. getClassName(): string;
  138430. /**
  138431. * If all the render effects in the pipeline are supported
  138432. */
  138433. get isSupported(): boolean;
  138434. /**
  138435. * Adds an effect to the pipeline
  138436. * @param renderEffect the effect to add
  138437. */
  138438. addEffect(renderEffect: PostProcessRenderEffect): void;
  138439. /** @hidden */
  138440. _rebuild(): void;
  138441. /** @hidden */
  138442. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138443. /** @hidden */
  138444. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138445. /** @hidden */
  138446. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138447. /** @hidden */
  138448. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138449. /** @hidden */
  138450. _attachCameras(cameras: Camera, unique: boolean): void;
  138451. /** @hidden */
  138452. _attachCameras(cameras: Camera[], unique: boolean): void;
  138453. /** @hidden */
  138454. _detachCameras(cameras: Camera): void;
  138455. /** @hidden */
  138456. _detachCameras(cameras: Nullable<Camera[]>): void;
  138457. /** @hidden */
  138458. _update(): void;
  138459. /** @hidden */
  138460. _reset(): void;
  138461. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138462. /**
  138463. * Disposes of the pipeline
  138464. */
  138465. dispose(): void;
  138466. }
  138467. }
  138468. declare module BABYLON {
  138469. /**
  138470. * PostProcessRenderPipelineManager class
  138471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138472. */
  138473. export class PostProcessRenderPipelineManager {
  138474. private _renderPipelines;
  138475. /**
  138476. * Initializes a PostProcessRenderPipelineManager
  138477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138478. */
  138479. constructor();
  138480. /**
  138481. * Gets the list of supported render pipelines
  138482. */
  138483. get supportedPipelines(): PostProcessRenderPipeline[];
  138484. /**
  138485. * Adds a pipeline to the manager
  138486. * @param renderPipeline The pipeline to add
  138487. */
  138488. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138489. /**
  138490. * Attaches a camera to the pipeline
  138491. * @param renderPipelineName The name of the pipeline to attach to
  138492. * @param cameras the camera to attach
  138493. * @param unique if the camera can be attached multiple times to the pipeline
  138494. */
  138495. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138496. /**
  138497. * Detaches a camera from the pipeline
  138498. * @param renderPipelineName The name of the pipeline to detach from
  138499. * @param cameras the camera to detach
  138500. */
  138501. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138502. /**
  138503. * Enables an effect by name on a pipeline
  138504. * @param renderPipelineName the name of the pipeline to enable the effect in
  138505. * @param renderEffectName the name of the effect to enable
  138506. * @param cameras the cameras that the effect should be enabled on
  138507. */
  138508. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138509. /**
  138510. * Disables an effect by name on a pipeline
  138511. * @param renderPipelineName the name of the pipeline to disable the effect in
  138512. * @param renderEffectName the name of the effect to disable
  138513. * @param cameras the cameras that the effect should be disabled on
  138514. */
  138515. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138516. /**
  138517. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138518. */
  138519. update(): void;
  138520. /** @hidden */
  138521. _rebuild(): void;
  138522. /**
  138523. * Disposes of the manager and pipelines
  138524. */
  138525. dispose(): void;
  138526. }
  138527. }
  138528. declare module BABYLON {
  138529. interface Scene {
  138530. /** @hidden (Backing field) */
  138531. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138532. /**
  138533. * Gets the postprocess render pipeline manager
  138534. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138535. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138536. */
  138537. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138538. }
  138539. /**
  138540. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138541. */
  138542. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138543. /**
  138544. * The component name helpfull to identify the component in the list of scene components.
  138545. */
  138546. readonly name: string;
  138547. /**
  138548. * The scene the component belongs to.
  138549. */
  138550. scene: Scene;
  138551. /**
  138552. * Creates a new instance of the component for the given scene
  138553. * @param scene Defines the scene to register the component in
  138554. */
  138555. constructor(scene: Scene);
  138556. /**
  138557. * Registers the component in a given scene
  138558. */
  138559. register(): void;
  138560. /**
  138561. * Rebuilds the elements related to this component in case of
  138562. * context lost for instance.
  138563. */
  138564. rebuild(): void;
  138565. /**
  138566. * Disposes the component and the associated ressources
  138567. */
  138568. dispose(): void;
  138569. private _gatherRenderTargets;
  138570. }
  138571. }
  138572. declare module BABYLON {
  138573. /**
  138574. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138575. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138576. */
  138577. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138578. private _scene;
  138579. private _camerasToBeAttached;
  138580. /**
  138581. * ID of the sharpen post process,
  138582. */
  138583. private readonly SharpenPostProcessId;
  138584. /**
  138585. * @ignore
  138586. * ID of the image processing post process;
  138587. */
  138588. readonly ImageProcessingPostProcessId: string;
  138589. /**
  138590. * @ignore
  138591. * ID of the Fast Approximate Anti-Aliasing post process;
  138592. */
  138593. readonly FxaaPostProcessId: string;
  138594. /**
  138595. * ID of the chromatic aberration post process,
  138596. */
  138597. private readonly ChromaticAberrationPostProcessId;
  138598. /**
  138599. * ID of the grain post process
  138600. */
  138601. private readonly GrainPostProcessId;
  138602. /**
  138603. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138604. */
  138605. sharpen: SharpenPostProcess;
  138606. private _sharpenEffect;
  138607. private bloom;
  138608. /**
  138609. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138610. */
  138611. depthOfField: DepthOfFieldEffect;
  138612. /**
  138613. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138614. */
  138615. fxaa: FxaaPostProcess;
  138616. /**
  138617. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138618. */
  138619. imageProcessing: ImageProcessingPostProcess;
  138620. /**
  138621. * Chromatic aberration post process which will shift rgb colors in the image
  138622. */
  138623. chromaticAberration: ChromaticAberrationPostProcess;
  138624. private _chromaticAberrationEffect;
  138625. /**
  138626. * Grain post process which add noise to the image
  138627. */
  138628. grain: GrainPostProcess;
  138629. private _grainEffect;
  138630. /**
  138631. * Glow post process which adds a glow to emissive areas of the image
  138632. */
  138633. private _glowLayer;
  138634. /**
  138635. * Animations which can be used to tweak settings over a period of time
  138636. */
  138637. animations: Animation[];
  138638. private _imageProcessingConfigurationObserver;
  138639. private _sharpenEnabled;
  138640. private _bloomEnabled;
  138641. private _depthOfFieldEnabled;
  138642. private _depthOfFieldBlurLevel;
  138643. private _fxaaEnabled;
  138644. private _imageProcessingEnabled;
  138645. private _defaultPipelineTextureType;
  138646. private _bloomScale;
  138647. private _chromaticAberrationEnabled;
  138648. private _grainEnabled;
  138649. private _buildAllowed;
  138650. /**
  138651. * Gets active scene
  138652. */
  138653. get scene(): Scene;
  138654. /**
  138655. * Enable or disable the sharpen process from the pipeline
  138656. */
  138657. set sharpenEnabled(enabled: boolean);
  138658. get sharpenEnabled(): boolean;
  138659. private _resizeObserver;
  138660. private _hardwareScaleLevel;
  138661. private _bloomKernel;
  138662. /**
  138663. * Specifies the size of the bloom blur kernel, relative to the final output size
  138664. */
  138665. get bloomKernel(): number;
  138666. set bloomKernel(value: number);
  138667. /**
  138668. * Specifies the weight of the bloom in the final rendering
  138669. */
  138670. private _bloomWeight;
  138671. /**
  138672. * Specifies the luma threshold for the area that will be blurred by the bloom
  138673. */
  138674. private _bloomThreshold;
  138675. private _hdr;
  138676. /**
  138677. * The strength of the bloom.
  138678. */
  138679. set bloomWeight(value: number);
  138680. get bloomWeight(): number;
  138681. /**
  138682. * The strength of the bloom.
  138683. */
  138684. set bloomThreshold(value: number);
  138685. get bloomThreshold(): number;
  138686. /**
  138687. * The scale of the bloom, lower value will provide better performance.
  138688. */
  138689. set bloomScale(value: number);
  138690. get bloomScale(): number;
  138691. /**
  138692. * Enable or disable the bloom from the pipeline
  138693. */
  138694. set bloomEnabled(enabled: boolean);
  138695. get bloomEnabled(): boolean;
  138696. private _rebuildBloom;
  138697. /**
  138698. * If the depth of field is enabled.
  138699. */
  138700. get depthOfFieldEnabled(): boolean;
  138701. set depthOfFieldEnabled(enabled: boolean);
  138702. /**
  138703. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138704. */
  138705. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138706. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138707. /**
  138708. * If the anti aliasing is enabled.
  138709. */
  138710. set fxaaEnabled(enabled: boolean);
  138711. get fxaaEnabled(): boolean;
  138712. private _samples;
  138713. /**
  138714. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138715. */
  138716. set samples(sampleCount: number);
  138717. get samples(): number;
  138718. /**
  138719. * If image processing is enabled.
  138720. */
  138721. set imageProcessingEnabled(enabled: boolean);
  138722. get imageProcessingEnabled(): boolean;
  138723. /**
  138724. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138725. */
  138726. set glowLayerEnabled(enabled: boolean);
  138727. get glowLayerEnabled(): boolean;
  138728. /**
  138729. * Gets the glow layer (or null if not defined)
  138730. */
  138731. get glowLayer(): Nullable<GlowLayer>;
  138732. /**
  138733. * Enable or disable the chromaticAberration process from the pipeline
  138734. */
  138735. set chromaticAberrationEnabled(enabled: boolean);
  138736. get chromaticAberrationEnabled(): boolean;
  138737. /**
  138738. * Enable or disable the grain process from the pipeline
  138739. */
  138740. set grainEnabled(enabled: boolean);
  138741. get grainEnabled(): boolean;
  138742. /**
  138743. * @constructor
  138744. * @param name - The rendering pipeline name (default: "")
  138745. * @param hdr - If high dynamic range textures should be used (default: true)
  138746. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138747. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138748. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138749. */
  138750. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138751. /**
  138752. * Get the class name
  138753. * @returns "DefaultRenderingPipeline"
  138754. */
  138755. getClassName(): string;
  138756. /**
  138757. * Force the compilation of the entire pipeline.
  138758. */
  138759. prepare(): void;
  138760. private _hasCleared;
  138761. private _prevPostProcess;
  138762. private _prevPrevPostProcess;
  138763. private _setAutoClearAndTextureSharing;
  138764. private _depthOfFieldSceneObserver;
  138765. private _buildPipeline;
  138766. private _disposePostProcesses;
  138767. /**
  138768. * Adds a camera to the pipeline
  138769. * @param camera the camera to be added
  138770. */
  138771. addCamera(camera: Camera): void;
  138772. /**
  138773. * Removes a camera from the pipeline
  138774. * @param camera the camera to remove
  138775. */
  138776. removeCamera(camera: Camera): void;
  138777. /**
  138778. * Dispose of the pipeline and stop all post processes
  138779. */
  138780. dispose(): void;
  138781. /**
  138782. * Serialize the rendering pipeline (Used when exporting)
  138783. * @returns the serialized object
  138784. */
  138785. serialize(): any;
  138786. /**
  138787. * Parse the serialized pipeline
  138788. * @param source Source pipeline.
  138789. * @param scene The scene to load the pipeline to.
  138790. * @param rootUrl The URL of the serialized pipeline.
  138791. * @returns An instantiated pipeline from the serialized object.
  138792. */
  138793. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138794. }
  138795. }
  138796. declare module BABYLON {
  138797. /** @hidden */
  138798. export var lensHighlightsPixelShader: {
  138799. name: string;
  138800. shader: string;
  138801. };
  138802. }
  138803. declare module BABYLON {
  138804. /** @hidden */
  138805. export var depthOfFieldPixelShader: {
  138806. name: string;
  138807. shader: string;
  138808. };
  138809. }
  138810. declare module BABYLON {
  138811. /**
  138812. * BABYLON.JS Chromatic Aberration GLSL Shader
  138813. * Author: Olivier Guyot
  138814. * Separates very slightly R, G and B colors on the edges of the screen
  138815. * Inspired by Francois Tarlier & Martins Upitis
  138816. */
  138817. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138818. /**
  138819. * @ignore
  138820. * The chromatic aberration PostProcess id in the pipeline
  138821. */
  138822. LensChromaticAberrationEffect: string;
  138823. /**
  138824. * @ignore
  138825. * The highlights enhancing PostProcess id in the pipeline
  138826. */
  138827. HighlightsEnhancingEffect: string;
  138828. /**
  138829. * @ignore
  138830. * The depth-of-field PostProcess id in the pipeline
  138831. */
  138832. LensDepthOfFieldEffect: string;
  138833. private _scene;
  138834. private _depthTexture;
  138835. private _grainTexture;
  138836. private _chromaticAberrationPostProcess;
  138837. private _highlightsPostProcess;
  138838. private _depthOfFieldPostProcess;
  138839. private _edgeBlur;
  138840. private _grainAmount;
  138841. private _chromaticAberration;
  138842. private _distortion;
  138843. private _highlightsGain;
  138844. private _highlightsThreshold;
  138845. private _dofDistance;
  138846. private _dofAperture;
  138847. private _dofDarken;
  138848. private _dofPentagon;
  138849. private _blurNoise;
  138850. /**
  138851. * @constructor
  138852. *
  138853. * Effect parameters are as follow:
  138854. * {
  138855. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138856. * edge_blur: number; // from 0 to x (1 for realism)
  138857. * distortion: number; // from 0 to x (1 for realism)
  138858. * grain_amount: number; // from 0 to 1
  138859. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138860. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138861. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138862. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138863. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138864. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138865. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138866. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138867. * }
  138868. * Note: if an effect parameter is unset, effect is disabled
  138869. *
  138870. * @param name The rendering pipeline name
  138871. * @param parameters - An object containing all parameters (see above)
  138872. * @param scene The scene linked to this pipeline
  138873. * @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)
  138874. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138875. */
  138876. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138877. /**
  138878. * Get the class name
  138879. * @returns "LensRenderingPipeline"
  138880. */
  138881. getClassName(): string;
  138882. /**
  138883. * Gets associated scene
  138884. */
  138885. get scene(): Scene;
  138886. /**
  138887. * Gets or sets the edge blur
  138888. */
  138889. get edgeBlur(): number;
  138890. set edgeBlur(value: number);
  138891. /**
  138892. * Gets or sets the grain amount
  138893. */
  138894. get grainAmount(): number;
  138895. set grainAmount(value: number);
  138896. /**
  138897. * Gets or sets the chromatic aberration amount
  138898. */
  138899. get chromaticAberration(): number;
  138900. set chromaticAberration(value: number);
  138901. /**
  138902. * Gets or sets the depth of field aperture
  138903. */
  138904. get dofAperture(): number;
  138905. set dofAperture(value: number);
  138906. /**
  138907. * Gets or sets the edge distortion
  138908. */
  138909. get edgeDistortion(): number;
  138910. set edgeDistortion(value: number);
  138911. /**
  138912. * Gets or sets the depth of field distortion
  138913. */
  138914. get dofDistortion(): number;
  138915. set dofDistortion(value: number);
  138916. /**
  138917. * Gets or sets the darken out of focus amount
  138918. */
  138919. get darkenOutOfFocus(): number;
  138920. set darkenOutOfFocus(value: number);
  138921. /**
  138922. * Gets or sets a boolean indicating if blur noise is enabled
  138923. */
  138924. get blurNoise(): boolean;
  138925. set blurNoise(value: boolean);
  138926. /**
  138927. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138928. */
  138929. get pentagonBokeh(): boolean;
  138930. set pentagonBokeh(value: boolean);
  138931. /**
  138932. * Gets or sets the highlight grain amount
  138933. */
  138934. get highlightsGain(): number;
  138935. set highlightsGain(value: number);
  138936. /**
  138937. * Gets or sets the highlight threshold
  138938. */
  138939. get highlightsThreshold(): number;
  138940. set highlightsThreshold(value: number);
  138941. /**
  138942. * Sets the amount of blur at the edges
  138943. * @param amount blur amount
  138944. */
  138945. setEdgeBlur(amount: number): void;
  138946. /**
  138947. * Sets edge blur to 0
  138948. */
  138949. disableEdgeBlur(): void;
  138950. /**
  138951. * Sets the amout of grain
  138952. * @param amount Amount of grain
  138953. */
  138954. setGrainAmount(amount: number): void;
  138955. /**
  138956. * Set grain amount to 0
  138957. */
  138958. disableGrain(): void;
  138959. /**
  138960. * Sets the chromatic aberration amount
  138961. * @param amount amount of chromatic aberration
  138962. */
  138963. setChromaticAberration(amount: number): void;
  138964. /**
  138965. * Sets chromatic aberration amount to 0
  138966. */
  138967. disableChromaticAberration(): void;
  138968. /**
  138969. * Sets the EdgeDistortion amount
  138970. * @param amount amount of EdgeDistortion
  138971. */
  138972. setEdgeDistortion(amount: number): void;
  138973. /**
  138974. * Sets edge distortion to 0
  138975. */
  138976. disableEdgeDistortion(): void;
  138977. /**
  138978. * Sets the FocusDistance amount
  138979. * @param amount amount of FocusDistance
  138980. */
  138981. setFocusDistance(amount: number): void;
  138982. /**
  138983. * Disables depth of field
  138984. */
  138985. disableDepthOfField(): void;
  138986. /**
  138987. * Sets the Aperture amount
  138988. * @param amount amount of Aperture
  138989. */
  138990. setAperture(amount: number): void;
  138991. /**
  138992. * Sets the DarkenOutOfFocus amount
  138993. * @param amount amount of DarkenOutOfFocus
  138994. */
  138995. setDarkenOutOfFocus(amount: number): void;
  138996. private _pentagonBokehIsEnabled;
  138997. /**
  138998. * Creates a pentagon bokeh effect
  138999. */
  139000. enablePentagonBokeh(): void;
  139001. /**
  139002. * Disables the pentagon bokeh effect
  139003. */
  139004. disablePentagonBokeh(): void;
  139005. /**
  139006. * Enables noise blur
  139007. */
  139008. enableNoiseBlur(): void;
  139009. /**
  139010. * Disables noise blur
  139011. */
  139012. disableNoiseBlur(): void;
  139013. /**
  139014. * Sets the HighlightsGain amount
  139015. * @param amount amount of HighlightsGain
  139016. */
  139017. setHighlightsGain(amount: number): void;
  139018. /**
  139019. * Sets the HighlightsThreshold amount
  139020. * @param amount amount of HighlightsThreshold
  139021. */
  139022. setHighlightsThreshold(amount: number): void;
  139023. /**
  139024. * Disables highlights
  139025. */
  139026. disableHighlights(): void;
  139027. /**
  139028. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  139029. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  139030. */
  139031. dispose(disableDepthRender?: boolean): void;
  139032. private _createChromaticAberrationPostProcess;
  139033. private _createHighlightsPostProcess;
  139034. private _createDepthOfFieldPostProcess;
  139035. private _createGrainTexture;
  139036. }
  139037. }
  139038. declare module BABYLON {
  139039. /** @hidden */
  139040. export var ssao2PixelShader: {
  139041. name: string;
  139042. shader: string;
  139043. };
  139044. }
  139045. declare module BABYLON {
  139046. /** @hidden */
  139047. export var ssaoCombinePixelShader: {
  139048. name: string;
  139049. shader: string;
  139050. };
  139051. }
  139052. declare module BABYLON {
  139053. /**
  139054. * Render pipeline to produce ssao effect
  139055. */
  139056. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  139057. /**
  139058. * @ignore
  139059. * The PassPostProcess id in the pipeline that contains the original scene color
  139060. */
  139061. SSAOOriginalSceneColorEffect: string;
  139062. /**
  139063. * @ignore
  139064. * The SSAO PostProcess id in the pipeline
  139065. */
  139066. SSAORenderEffect: string;
  139067. /**
  139068. * @ignore
  139069. * The horizontal blur PostProcess id in the pipeline
  139070. */
  139071. SSAOBlurHRenderEffect: string;
  139072. /**
  139073. * @ignore
  139074. * The vertical blur PostProcess id in the pipeline
  139075. */
  139076. SSAOBlurVRenderEffect: string;
  139077. /**
  139078. * @ignore
  139079. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139080. */
  139081. SSAOCombineRenderEffect: string;
  139082. /**
  139083. * The output strength of the SSAO post-process. Default value is 1.0.
  139084. */
  139085. totalStrength: number;
  139086. /**
  139087. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  139088. */
  139089. maxZ: number;
  139090. /**
  139091. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  139092. */
  139093. minZAspect: number;
  139094. private _samples;
  139095. /**
  139096. * Number of samples used for the SSAO calculations. Default value is 8
  139097. */
  139098. set samples(n: number);
  139099. get samples(): number;
  139100. private _textureSamples;
  139101. /**
  139102. * Number of samples to use for antialiasing
  139103. */
  139104. set textureSamples(n: number);
  139105. get textureSamples(): number;
  139106. /**
  139107. * Ratio object used for SSAO ratio and blur ratio
  139108. */
  139109. private _ratio;
  139110. /**
  139111. * Dynamically generated sphere sampler.
  139112. */
  139113. private _sampleSphere;
  139114. /**
  139115. * Blur filter offsets
  139116. */
  139117. private _samplerOffsets;
  139118. private _expensiveBlur;
  139119. /**
  139120. * If bilateral blur should be used
  139121. */
  139122. set expensiveBlur(b: boolean);
  139123. get expensiveBlur(): boolean;
  139124. /**
  139125. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139126. */
  139127. radius: number;
  139128. /**
  139129. * The base color of the SSAO post-process
  139130. * The final result is "base + ssao" between [0, 1]
  139131. */
  139132. base: number;
  139133. /**
  139134. * Support test.
  139135. */
  139136. static get IsSupported(): boolean;
  139137. private _scene;
  139138. private _depthTexture;
  139139. private _normalTexture;
  139140. private _randomTexture;
  139141. private _originalColorPostProcess;
  139142. private _ssaoPostProcess;
  139143. private _blurHPostProcess;
  139144. private _blurVPostProcess;
  139145. private _ssaoCombinePostProcess;
  139146. /**
  139147. * Gets active scene
  139148. */
  139149. get scene(): Scene;
  139150. /**
  139151. * @constructor
  139152. * @param name The rendering pipeline name
  139153. * @param scene The scene linked to this pipeline
  139154. * @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 }
  139155. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139156. */
  139157. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139158. /**
  139159. * Get the class name
  139160. * @returns "SSAO2RenderingPipeline"
  139161. */
  139162. getClassName(): string;
  139163. /**
  139164. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139165. */
  139166. dispose(disableGeometryBufferRenderer?: boolean): void;
  139167. private _createBlurPostProcess;
  139168. /** @hidden */
  139169. _rebuild(): void;
  139170. private _bits;
  139171. private _radicalInverse_VdC;
  139172. private _hammersley;
  139173. private _hemisphereSample_uniform;
  139174. private _generateHemisphere;
  139175. private _createSSAOPostProcess;
  139176. private _createSSAOCombinePostProcess;
  139177. private _createRandomTexture;
  139178. /**
  139179. * Serialize the rendering pipeline (Used when exporting)
  139180. * @returns the serialized object
  139181. */
  139182. serialize(): any;
  139183. /**
  139184. * Parse the serialized pipeline
  139185. * @param source Source pipeline.
  139186. * @param scene The scene to load the pipeline to.
  139187. * @param rootUrl The URL of the serialized pipeline.
  139188. * @returns An instantiated pipeline from the serialized object.
  139189. */
  139190. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139191. }
  139192. }
  139193. declare module BABYLON {
  139194. /** @hidden */
  139195. export var ssaoPixelShader: {
  139196. name: string;
  139197. shader: string;
  139198. };
  139199. }
  139200. declare module BABYLON {
  139201. /**
  139202. * Render pipeline to produce ssao effect
  139203. */
  139204. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139205. /**
  139206. * @ignore
  139207. * The PassPostProcess id in the pipeline that contains the original scene color
  139208. */
  139209. SSAOOriginalSceneColorEffect: string;
  139210. /**
  139211. * @ignore
  139212. * The SSAO PostProcess id in the pipeline
  139213. */
  139214. SSAORenderEffect: string;
  139215. /**
  139216. * @ignore
  139217. * The horizontal blur PostProcess id in the pipeline
  139218. */
  139219. SSAOBlurHRenderEffect: string;
  139220. /**
  139221. * @ignore
  139222. * The vertical blur PostProcess id in the pipeline
  139223. */
  139224. SSAOBlurVRenderEffect: string;
  139225. /**
  139226. * @ignore
  139227. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139228. */
  139229. SSAOCombineRenderEffect: string;
  139230. /**
  139231. * The output strength of the SSAO post-process. Default value is 1.0.
  139232. */
  139233. totalStrength: number;
  139234. /**
  139235. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139236. */
  139237. radius: number;
  139238. /**
  139239. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139240. * Must not be equal to fallOff and superior to fallOff.
  139241. * Default value is 0.0075
  139242. */
  139243. area: number;
  139244. /**
  139245. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139246. * Must not be equal to area and inferior to area.
  139247. * Default value is 0.000001
  139248. */
  139249. fallOff: number;
  139250. /**
  139251. * The base color of the SSAO post-process
  139252. * The final result is "base + ssao" between [0, 1]
  139253. */
  139254. base: number;
  139255. private _scene;
  139256. private _depthTexture;
  139257. private _randomTexture;
  139258. private _originalColorPostProcess;
  139259. private _ssaoPostProcess;
  139260. private _blurHPostProcess;
  139261. private _blurVPostProcess;
  139262. private _ssaoCombinePostProcess;
  139263. private _firstUpdate;
  139264. /**
  139265. * Gets active scene
  139266. */
  139267. get scene(): Scene;
  139268. /**
  139269. * @constructor
  139270. * @param name - The rendering pipeline name
  139271. * @param scene - The scene linked to this pipeline
  139272. * @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 }
  139273. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139274. */
  139275. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139276. /**
  139277. * Get the class name
  139278. * @returns "SSAORenderingPipeline"
  139279. */
  139280. getClassName(): string;
  139281. /**
  139282. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139283. */
  139284. dispose(disableDepthRender?: boolean): void;
  139285. private _createBlurPostProcess;
  139286. /** @hidden */
  139287. _rebuild(): void;
  139288. private _createSSAOPostProcess;
  139289. private _createSSAOCombinePostProcess;
  139290. private _createRandomTexture;
  139291. }
  139292. }
  139293. declare module BABYLON {
  139294. /** @hidden */
  139295. export var screenSpaceReflectionPixelShader: {
  139296. name: string;
  139297. shader: string;
  139298. };
  139299. }
  139300. declare module BABYLON {
  139301. /**
  139302. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139303. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139304. */
  139305. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139306. /**
  139307. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139308. */
  139309. threshold: number;
  139310. /**
  139311. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139312. */
  139313. strength: number;
  139314. /**
  139315. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139316. */
  139317. reflectionSpecularFalloffExponent: number;
  139318. /**
  139319. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  139320. */
  139321. step: number;
  139322. /**
  139323. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139324. */
  139325. roughnessFactor: number;
  139326. private _geometryBufferRenderer;
  139327. private _enableSmoothReflections;
  139328. private _reflectionSamples;
  139329. private _smoothSteps;
  139330. /**
  139331. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139332. * @param name The name of the effect.
  139333. * @param scene The scene containing the objects to calculate reflections.
  139334. * @param options The required width/height ratio to downsize to before computing the render pass.
  139335. * @param camera The camera to apply the render pass to.
  139336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139337. * @param engine The engine which the post process will be applied. (default: current engine)
  139338. * @param reusable If the post process can be reused on the same frame. (default: false)
  139339. * @param textureType Type of textures used when performing the post process. (default: 0)
  139340. * @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)
  139341. */
  139342. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139343. /**
  139344. * Gets wether or not smoothing reflections is enabled.
  139345. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139346. */
  139347. get enableSmoothReflections(): boolean;
  139348. /**
  139349. * Sets wether or not smoothing reflections is enabled.
  139350. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139351. */
  139352. set enableSmoothReflections(enabled: boolean);
  139353. /**
  139354. * Gets the number of samples taken while computing reflections. More samples count is high,
  139355. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139356. */
  139357. get reflectionSamples(): number;
  139358. /**
  139359. * Sets the number of samples taken while computing reflections. More samples count is high,
  139360. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139361. */
  139362. set reflectionSamples(samples: number);
  139363. /**
  139364. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139365. * more the post-process will require GPU power and can generate a drop in FPS.
  139366. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139367. */
  139368. get smoothSteps(): number;
  139369. set smoothSteps(steps: number);
  139370. private _updateEffectDefines;
  139371. }
  139372. }
  139373. declare module BABYLON {
  139374. /** @hidden */
  139375. export var standardPixelShader: {
  139376. name: string;
  139377. shader: string;
  139378. };
  139379. }
  139380. declare module BABYLON {
  139381. /**
  139382. * Standard rendering pipeline
  139383. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139384. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139385. */
  139386. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139387. /**
  139388. * Public members
  139389. */
  139390. /**
  139391. * Post-process which contains the original scene color before the pipeline applies all the effects
  139392. */
  139393. originalPostProcess: Nullable<PostProcess>;
  139394. /**
  139395. * Post-process used to down scale an image x4
  139396. */
  139397. downSampleX4PostProcess: Nullable<PostProcess>;
  139398. /**
  139399. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139400. */
  139401. brightPassPostProcess: Nullable<PostProcess>;
  139402. /**
  139403. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139404. */
  139405. blurHPostProcesses: PostProcess[];
  139406. /**
  139407. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139408. */
  139409. blurVPostProcesses: PostProcess[];
  139410. /**
  139411. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139412. */
  139413. textureAdderPostProcess: Nullable<PostProcess>;
  139414. /**
  139415. * Post-process used to create volumetric lighting effect
  139416. */
  139417. volumetricLightPostProcess: Nullable<PostProcess>;
  139418. /**
  139419. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139420. */
  139421. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139422. /**
  139423. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139424. */
  139425. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139426. /**
  139427. * Post-process used to merge the volumetric light effect and the real scene color
  139428. */
  139429. volumetricLightMergePostProces: Nullable<PostProcess>;
  139430. /**
  139431. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139432. */
  139433. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139434. /**
  139435. * Base post-process used to calculate the average luminance of the final image for HDR
  139436. */
  139437. luminancePostProcess: Nullable<PostProcess>;
  139438. /**
  139439. * Post-processes used to create down sample post-processes in order to get
  139440. * the average luminance of the final image for HDR
  139441. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139442. */
  139443. luminanceDownSamplePostProcesses: PostProcess[];
  139444. /**
  139445. * Post-process used to create a HDR effect (light adaptation)
  139446. */
  139447. hdrPostProcess: Nullable<PostProcess>;
  139448. /**
  139449. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139450. */
  139451. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139452. /**
  139453. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139454. */
  139455. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139456. /**
  139457. * Post-process used to merge the final HDR post-process and the real scene color
  139458. */
  139459. hdrFinalPostProcess: Nullable<PostProcess>;
  139460. /**
  139461. * Post-process used to create a lens flare effect
  139462. */
  139463. lensFlarePostProcess: Nullable<PostProcess>;
  139464. /**
  139465. * Post-process that merges the result of the lens flare post-process and the real scene color
  139466. */
  139467. lensFlareComposePostProcess: Nullable<PostProcess>;
  139468. /**
  139469. * Post-process used to create a motion blur effect
  139470. */
  139471. motionBlurPostProcess: Nullable<PostProcess>;
  139472. /**
  139473. * Post-process used to create a depth of field effect
  139474. */
  139475. depthOfFieldPostProcess: Nullable<PostProcess>;
  139476. /**
  139477. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139478. */
  139479. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139480. /**
  139481. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139482. */
  139483. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139484. /**
  139485. * Represents the brightness threshold in order to configure the illuminated surfaces
  139486. */
  139487. brightThreshold: number;
  139488. /**
  139489. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139490. */
  139491. blurWidth: number;
  139492. /**
  139493. * Sets if the blur for highlighted surfaces must be only horizontal
  139494. */
  139495. horizontalBlur: boolean;
  139496. /**
  139497. * Gets the overall exposure used by the pipeline
  139498. */
  139499. get exposure(): number;
  139500. /**
  139501. * Sets the overall exposure used by the pipeline
  139502. */
  139503. set exposure(value: number);
  139504. /**
  139505. * Texture used typically to simulate "dirty" on camera lens
  139506. */
  139507. lensTexture: Nullable<Texture>;
  139508. /**
  139509. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139510. */
  139511. volumetricLightCoefficient: number;
  139512. /**
  139513. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139514. */
  139515. volumetricLightPower: number;
  139516. /**
  139517. * Used the set the blur intensity to smooth the volumetric lights
  139518. */
  139519. volumetricLightBlurScale: number;
  139520. /**
  139521. * Light (spot or directional) used to generate the volumetric lights rays
  139522. * The source light must have a shadow generate so the pipeline can get its
  139523. * depth map
  139524. */
  139525. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139526. /**
  139527. * For eye adaptation, represents the minimum luminance the eye can see
  139528. */
  139529. hdrMinimumLuminance: number;
  139530. /**
  139531. * For eye adaptation, represents the decrease luminance speed
  139532. */
  139533. hdrDecreaseRate: number;
  139534. /**
  139535. * For eye adaptation, represents the increase luminance speed
  139536. */
  139537. hdrIncreaseRate: number;
  139538. /**
  139539. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139540. */
  139541. get hdrAutoExposure(): boolean;
  139542. /**
  139543. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139544. */
  139545. set hdrAutoExposure(value: boolean);
  139546. /**
  139547. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139548. */
  139549. lensColorTexture: Nullable<Texture>;
  139550. /**
  139551. * The overall strengh for the lens flare effect
  139552. */
  139553. lensFlareStrength: number;
  139554. /**
  139555. * Dispersion coefficient for lens flare ghosts
  139556. */
  139557. lensFlareGhostDispersal: number;
  139558. /**
  139559. * Main lens flare halo width
  139560. */
  139561. lensFlareHaloWidth: number;
  139562. /**
  139563. * Based on the lens distortion effect, defines how much the lens flare result
  139564. * is distorted
  139565. */
  139566. lensFlareDistortionStrength: number;
  139567. /**
  139568. * Configures the blur intensity used for for lens flare (halo)
  139569. */
  139570. lensFlareBlurWidth: number;
  139571. /**
  139572. * Lens star texture must be used to simulate rays on the flares and is available
  139573. * in the documentation
  139574. */
  139575. lensStarTexture: Nullable<Texture>;
  139576. /**
  139577. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139578. * flare effect by taking account of the dirt texture
  139579. */
  139580. lensFlareDirtTexture: Nullable<Texture>;
  139581. /**
  139582. * Represents the focal length for the depth of field effect
  139583. */
  139584. depthOfFieldDistance: number;
  139585. /**
  139586. * Represents the blur intensity for the blurred part of the depth of field effect
  139587. */
  139588. depthOfFieldBlurWidth: number;
  139589. /**
  139590. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139591. */
  139592. get motionStrength(): number;
  139593. /**
  139594. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139595. */
  139596. set motionStrength(strength: number);
  139597. /**
  139598. * Gets wether or not the motion blur post-process is object based or screen based.
  139599. */
  139600. get objectBasedMotionBlur(): boolean;
  139601. /**
  139602. * Sets wether or not the motion blur post-process should be object based or screen based
  139603. */
  139604. set objectBasedMotionBlur(value: boolean);
  139605. /**
  139606. * List of animations for the pipeline (IAnimatable implementation)
  139607. */
  139608. animations: Animation[];
  139609. /**
  139610. * Private members
  139611. */
  139612. private _scene;
  139613. private _currentDepthOfFieldSource;
  139614. private _basePostProcess;
  139615. private _fixedExposure;
  139616. private _currentExposure;
  139617. private _hdrAutoExposure;
  139618. private _hdrCurrentLuminance;
  139619. private _motionStrength;
  139620. private _isObjectBasedMotionBlur;
  139621. private _floatTextureType;
  139622. private _camerasToBeAttached;
  139623. private _ratio;
  139624. private _bloomEnabled;
  139625. private _depthOfFieldEnabled;
  139626. private _vlsEnabled;
  139627. private _lensFlareEnabled;
  139628. private _hdrEnabled;
  139629. private _motionBlurEnabled;
  139630. private _fxaaEnabled;
  139631. private _screenSpaceReflectionsEnabled;
  139632. private _motionBlurSamples;
  139633. private _volumetricLightStepsCount;
  139634. private _samples;
  139635. /**
  139636. * @ignore
  139637. * Specifies if the bloom pipeline is enabled
  139638. */
  139639. get BloomEnabled(): boolean;
  139640. set BloomEnabled(enabled: boolean);
  139641. /**
  139642. * @ignore
  139643. * Specifies if the depth of field pipeline is enabed
  139644. */
  139645. get DepthOfFieldEnabled(): boolean;
  139646. set DepthOfFieldEnabled(enabled: boolean);
  139647. /**
  139648. * @ignore
  139649. * Specifies if the lens flare pipeline is enabed
  139650. */
  139651. get LensFlareEnabled(): boolean;
  139652. set LensFlareEnabled(enabled: boolean);
  139653. /**
  139654. * @ignore
  139655. * Specifies if the HDR pipeline is enabled
  139656. */
  139657. get HDREnabled(): boolean;
  139658. set HDREnabled(enabled: boolean);
  139659. /**
  139660. * @ignore
  139661. * Specifies if the volumetric lights scattering effect is enabled
  139662. */
  139663. get VLSEnabled(): boolean;
  139664. set VLSEnabled(enabled: boolean);
  139665. /**
  139666. * @ignore
  139667. * Specifies if the motion blur effect is enabled
  139668. */
  139669. get MotionBlurEnabled(): boolean;
  139670. set MotionBlurEnabled(enabled: boolean);
  139671. /**
  139672. * Specifies if anti-aliasing is enabled
  139673. */
  139674. get fxaaEnabled(): boolean;
  139675. set fxaaEnabled(enabled: boolean);
  139676. /**
  139677. * Specifies if screen space reflections are enabled.
  139678. */
  139679. get screenSpaceReflectionsEnabled(): boolean;
  139680. set screenSpaceReflectionsEnabled(enabled: boolean);
  139681. /**
  139682. * Specifies the number of steps used to calculate the volumetric lights
  139683. * Typically in interval [50, 200]
  139684. */
  139685. get volumetricLightStepsCount(): number;
  139686. set volumetricLightStepsCount(count: number);
  139687. /**
  139688. * Specifies the number of samples used for the motion blur effect
  139689. * Typically in interval [16, 64]
  139690. */
  139691. get motionBlurSamples(): number;
  139692. set motionBlurSamples(samples: number);
  139693. /**
  139694. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139695. */
  139696. get samples(): number;
  139697. set samples(sampleCount: number);
  139698. /**
  139699. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139700. * @constructor
  139701. * @param name The rendering pipeline name
  139702. * @param scene The scene linked to this pipeline
  139703. * @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)
  139704. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139705. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139706. */
  139707. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139708. private _buildPipeline;
  139709. private _createDownSampleX4PostProcess;
  139710. private _createBrightPassPostProcess;
  139711. private _createBlurPostProcesses;
  139712. private _createTextureAdderPostProcess;
  139713. private _createVolumetricLightPostProcess;
  139714. private _createLuminancePostProcesses;
  139715. private _createHdrPostProcess;
  139716. private _createLensFlarePostProcess;
  139717. private _createDepthOfFieldPostProcess;
  139718. private _createMotionBlurPostProcess;
  139719. private _getDepthTexture;
  139720. private _disposePostProcesses;
  139721. /**
  139722. * Dispose of the pipeline and stop all post processes
  139723. */
  139724. dispose(): void;
  139725. /**
  139726. * Serialize the rendering pipeline (Used when exporting)
  139727. * @returns the serialized object
  139728. */
  139729. serialize(): any;
  139730. /**
  139731. * Parse the serialized pipeline
  139732. * @param source Source pipeline.
  139733. * @param scene The scene to load the pipeline to.
  139734. * @param rootUrl The URL of the serialized pipeline.
  139735. * @returns An instantiated pipeline from the serialized object.
  139736. */
  139737. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139738. /**
  139739. * Luminance steps
  139740. */
  139741. static LuminanceSteps: number;
  139742. }
  139743. }
  139744. declare module BABYLON {
  139745. /** @hidden */
  139746. export var tonemapPixelShader: {
  139747. name: string;
  139748. shader: string;
  139749. };
  139750. }
  139751. declare module BABYLON {
  139752. /** Defines operator used for tonemapping */
  139753. export enum TonemappingOperator {
  139754. /** Hable */
  139755. Hable = 0,
  139756. /** Reinhard */
  139757. Reinhard = 1,
  139758. /** HejiDawson */
  139759. HejiDawson = 2,
  139760. /** Photographic */
  139761. Photographic = 3
  139762. }
  139763. /**
  139764. * Defines a post process to apply tone mapping
  139765. */
  139766. export class TonemapPostProcess extends PostProcess {
  139767. private _operator;
  139768. /** Defines the required exposure adjustement */
  139769. exposureAdjustment: number;
  139770. /**
  139771. * Creates a new TonemapPostProcess
  139772. * @param name defines the name of the postprocess
  139773. * @param _operator defines the operator to use
  139774. * @param exposureAdjustment defines the required exposure adjustement
  139775. * @param camera defines the camera to use (can be null)
  139776. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139777. * @param engine defines the hosting engine (can be ignore if camera is set)
  139778. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139779. */
  139780. constructor(name: string, _operator: TonemappingOperator,
  139781. /** Defines the required exposure adjustement */
  139782. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139783. }
  139784. }
  139785. declare module BABYLON {
  139786. /** @hidden */
  139787. export var volumetricLightScatteringPixelShader: {
  139788. name: string;
  139789. shader: string;
  139790. };
  139791. }
  139792. declare module BABYLON {
  139793. /** @hidden */
  139794. export var volumetricLightScatteringPassVertexShader: {
  139795. name: string;
  139796. shader: string;
  139797. };
  139798. }
  139799. declare module BABYLON {
  139800. /** @hidden */
  139801. export var volumetricLightScatteringPassPixelShader: {
  139802. name: string;
  139803. shader: string;
  139804. };
  139805. }
  139806. declare module BABYLON {
  139807. /**
  139808. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139809. */
  139810. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139811. private _volumetricLightScatteringPass;
  139812. private _volumetricLightScatteringRTT;
  139813. private _viewPort;
  139814. private _screenCoordinates;
  139815. private _cachedDefines;
  139816. /**
  139817. * If not undefined, the mesh position is computed from the attached node position
  139818. */
  139819. attachedNode: {
  139820. position: Vector3;
  139821. };
  139822. /**
  139823. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139824. */
  139825. customMeshPosition: Vector3;
  139826. /**
  139827. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139828. */
  139829. useCustomMeshPosition: boolean;
  139830. /**
  139831. * If the post-process should inverse the light scattering direction
  139832. */
  139833. invert: boolean;
  139834. /**
  139835. * The internal mesh used by the post-process
  139836. */
  139837. mesh: Mesh;
  139838. /**
  139839. * @hidden
  139840. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139841. */
  139842. get useDiffuseColor(): boolean;
  139843. set useDiffuseColor(useDiffuseColor: boolean);
  139844. /**
  139845. * Array containing the excluded meshes not rendered in the internal pass
  139846. */
  139847. excludedMeshes: AbstractMesh[];
  139848. /**
  139849. * Controls the overall intensity of the post-process
  139850. */
  139851. exposure: number;
  139852. /**
  139853. * Dissipates each sample's contribution in range [0, 1]
  139854. */
  139855. decay: number;
  139856. /**
  139857. * Controls the overall intensity of each sample
  139858. */
  139859. weight: number;
  139860. /**
  139861. * Controls the density of each sample
  139862. */
  139863. density: number;
  139864. /**
  139865. * @constructor
  139866. * @param name The post-process name
  139867. * @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)
  139868. * @param camera The camera that the post-process will be attached to
  139869. * @param mesh The mesh used to create the light scattering
  139870. * @param samples The post-process quality, default 100
  139871. * @param samplingModeThe post-process filtering mode
  139872. * @param engine The babylon engine
  139873. * @param reusable If the post-process is reusable
  139874. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139875. */
  139876. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139877. /**
  139878. * Returns the string "VolumetricLightScatteringPostProcess"
  139879. * @returns "VolumetricLightScatteringPostProcess"
  139880. */
  139881. getClassName(): string;
  139882. private _isReady;
  139883. /**
  139884. * Sets the new light position for light scattering effect
  139885. * @param position The new custom light position
  139886. */
  139887. setCustomMeshPosition(position: Vector3): void;
  139888. /**
  139889. * Returns the light position for light scattering effect
  139890. * @return Vector3 The custom light position
  139891. */
  139892. getCustomMeshPosition(): Vector3;
  139893. /**
  139894. * Disposes the internal assets and detaches the post-process from the camera
  139895. */
  139896. dispose(camera: Camera): void;
  139897. /**
  139898. * Returns the render target texture used by the post-process
  139899. * @return the render target texture used by the post-process
  139900. */
  139901. getPass(): RenderTargetTexture;
  139902. private _meshExcluded;
  139903. private _createPass;
  139904. private _updateMeshScreenCoordinates;
  139905. /**
  139906. * Creates a default mesh for the Volumeric Light Scattering post-process
  139907. * @param name The mesh name
  139908. * @param scene The scene where to create the mesh
  139909. * @return the default mesh
  139910. */
  139911. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139912. }
  139913. }
  139914. declare module BABYLON {
  139915. interface Scene {
  139916. /** @hidden (Backing field) */
  139917. _boundingBoxRenderer: BoundingBoxRenderer;
  139918. /** @hidden (Backing field) */
  139919. _forceShowBoundingBoxes: boolean;
  139920. /**
  139921. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139922. */
  139923. forceShowBoundingBoxes: boolean;
  139924. /**
  139925. * Gets the bounding box renderer associated with the scene
  139926. * @returns a BoundingBoxRenderer
  139927. */
  139928. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139929. }
  139930. interface AbstractMesh {
  139931. /** @hidden (Backing field) */
  139932. _showBoundingBox: boolean;
  139933. /**
  139934. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139935. */
  139936. showBoundingBox: boolean;
  139937. }
  139938. /**
  139939. * Component responsible of rendering the bounding box of the meshes in a scene.
  139940. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139941. */
  139942. export class BoundingBoxRenderer implements ISceneComponent {
  139943. /**
  139944. * The component name helpfull to identify the component in the list of scene components.
  139945. */
  139946. readonly name: string;
  139947. /**
  139948. * The scene the component belongs to.
  139949. */
  139950. scene: Scene;
  139951. /**
  139952. * Color of the bounding box lines placed in front of an object
  139953. */
  139954. frontColor: Color3;
  139955. /**
  139956. * Color of the bounding box lines placed behind an object
  139957. */
  139958. backColor: Color3;
  139959. /**
  139960. * Defines if the renderer should show the back lines or not
  139961. */
  139962. showBackLines: boolean;
  139963. /**
  139964. * @hidden
  139965. */
  139966. renderList: SmartArray<BoundingBox>;
  139967. private _colorShader;
  139968. private _vertexBuffers;
  139969. private _indexBuffer;
  139970. private _fillIndexBuffer;
  139971. private _fillIndexData;
  139972. /**
  139973. * Instantiates a new bounding box renderer in a scene.
  139974. * @param scene the scene the renderer renders in
  139975. */
  139976. constructor(scene: Scene);
  139977. /**
  139978. * Registers the component in a given scene
  139979. */
  139980. register(): void;
  139981. private _evaluateSubMesh;
  139982. private _activeMesh;
  139983. private _prepareRessources;
  139984. private _createIndexBuffer;
  139985. /**
  139986. * Rebuilds the elements related to this component in case of
  139987. * context lost for instance.
  139988. */
  139989. rebuild(): void;
  139990. /**
  139991. * @hidden
  139992. */
  139993. reset(): void;
  139994. /**
  139995. * Render the bounding boxes of a specific rendering group
  139996. * @param renderingGroupId defines the rendering group to render
  139997. */
  139998. render(renderingGroupId: number): void;
  139999. /**
  140000. * In case of occlusion queries, we can render the occlusion bounding box through this method
  140001. * @param mesh Define the mesh to render the occlusion bounding box for
  140002. */
  140003. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  140004. /**
  140005. * Dispose and release the resources attached to this renderer.
  140006. */
  140007. dispose(): void;
  140008. }
  140009. }
  140010. declare module BABYLON {
  140011. interface Scene {
  140012. /** @hidden (Backing field) */
  140013. _depthRenderer: {
  140014. [id: string]: DepthRenderer;
  140015. };
  140016. /**
  140017. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  140018. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  140019. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140020. * @returns the created depth renderer
  140021. */
  140022. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  140023. /**
  140024. * Disables a depth renderer for a given camera
  140025. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  140026. */
  140027. disableDepthRenderer(camera?: Nullable<Camera>): void;
  140028. }
  140029. /**
  140030. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  140031. * in several rendering techniques.
  140032. */
  140033. export class DepthRendererSceneComponent implements ISceneComponent {
  140034. /**
  140035. * The component name helpfull to identify the component in the list of scene components.
  140036. */
  140037. readonly name: string;
  140038. /**
  140039. * The scene the component belongs to.
  140040. */
  140041. scene: Scene;
  140042. /**
  140043. * Creates a new instance of the component for the given scene
  140044. * @param scene Defines the scene to register the component in
  140045. */
  140046. constructor(scene: Scene);
  140047. /**
  140048. * Registers the component in a given scene
  140049. */
  140050. register(): void;
  140051. /**
  140052. * Rebuilds the elements related to this component in case of
  140053. * context lost for instance.
  140054. */
  140055. rebuild(): void;
  140056. /**
  140057. * Disposes the component and the associated ressources
  140058. */
  140059. dispose(): void;
  140060. private _gatherRenderTargets;
  140061. private _gatherActiveCameraRenderTargets;
  140062. }
  140063. }
  140064. declare module BABYLON {
  140065. /** @hidden */
  140066. export var outlinePixelShader: {
  140067. name: string;
  140068. shader: string;
  140069. };
  140070. }
  140071. declare module BABYLON {
  140072. /** @hidden */
  140073. export var outlineVertexShader: {
  140074. name: string;
  140075. shader: string;
  140076. };
  140077. }
  140078. declare module BABYLON {
  140079. interface Scene {
  140080. /** @hidden */
  140081. _outlineRenderer: OutlineRenderer;
  140082. /**
  140083. * Gets the outline renderer associated with the scene
  140084. * @returns a OutlineRenderer
  140085. */
  140086. getOutlineRenderer(): OutlineRenderer;
  140087. }
  140088. interface AbstractMesh {
  140089. /** @hidden (Backing field) */
  140090. _renderOutline: boolean;
  140091. /**
  140092. * Gets or sets a boolean indicating if the outline must be rendered as well
  140093. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  140094. */
  140095. renderOutline: boolean;
  140096. /** @hidden (Backing field) */
  140097. _renderOverlay: boolean;
  140098. /**
  140099. * Gets or sets a boolean indicating if the overlay must be rendered as well
  140100. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  140101. */
  140102. renderOverlay: boolean;
  140103. }
  140104. /**
  140105. * This class is responsible to draw bothe outline/overlay of meshes.
  140106. * It should not be used directly but through the available method on mesh.
  140107. */
  140108. export class OutlineRenderer implements ISceneComponent {
  140109. /**
  140110. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140111. */
  140112. private static _StencilReference;
  140113. /**
  140114. * The name of the component. Each component must have a unique name.
  140115. */
  140116. name: string;
  140117. /**
  140118. * The scene the component belongs to.
  140119. */
  140120. scene: Scene;
  140121. /**
  140122. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140123. */
  140124. zOffset: number;
  140125. private _engine;
  140126. private _effect;
  140127. private _cachedDefines;
  140128. private _savedDepthWrite;
  140129. /**
  140130. * Instantiates a new outline renderer. (There could be only one per scene).
  140131. * @param scene Defines the scene it belongs to
  140132. */
  140133. constructor(scene: Scene);
  140134. /**
  140135. * Register the component to one instance of a scene.
  140136. */
  140137. register(): void;
  140138. /**
  140139. * Rebuilds the elements related to this component in case of
  140140. * context lost for instance.
  140141. */
  140142. rebuild(): void;
  140143. /**
  140144. * Disposes the component and the associated ressources.
  140145. */
  140146. dispose(): void;
  140147. /**
  140148. * Renders the outline in the canvas.
  140149. * @param subMesh Defines the sumesh to render
  140150. * @param batch Defines the batch of meshes in case of instances
  140151. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140152. */
  140153. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140154. /**
  140155. * Returns whether or not the outline renderer is ready for a given submesh.
  140156. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140157. * @param subMesh Defines the submesh to check readyness for
  140158. * @param useInstances Defines wheter wee are trying to render instances or not
  140159. * @returns true if ready otherwise false
  140160. */
  140161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140162. private _beforeRenderingMesh;
  140163. private _afterRenderingMesh;
  140164. }
  140165. }
  140166. declare module BABYLON {
  140167. /**
  140168. * Defines the basic options interface of a Sprite Frame Source Size.
  140169. */
  140170. export interface ISpriteJSONSpriteSourceSize {
  140171. /**
  140172. * number of the original width of the Frame
  140173. */
  140174. w: number;
  140175. /**
  140176. * number of the original height of the Frame
  140177. */
  140178. h: number;
  140179. }
  140180. /**
  140181. * Defines the basic options interface of a Sprite Frame Data.
  140182. */
  140183. export interface ISpriteJSONSpriteFrameData {
  140184. /**
  140185. * number of the x offset of the Frame
  140186. */
  140187. x: number;
  140188. /**
  140189. * number of the y offset of the Frame
  140190. */
  140191. y: number;
  140192. /**
  140193. * number of the width of the Frame
  140194. */
  140195. w: number;
  140196. /**
  140197. * number of the height of the Frame
  140198. */
  140199. h: number;
  140200. }
  140201. /**
  140202. * Defines the basic options interface of a JSON Sprite.
  140203. */
  140204. export interface ISpriteJSONSprite {
  140205. /**
  140206. * string name of the Frame
  140207. */
  140208. filename: string;
  140209. /**
  140210. * ISpriteJSONSpriteFrame basic object of the frame data
  140211. */
  140212. frame: ISpriteJSONSpriteFrameData;
  140213. /**
  140214. * boolean to flag is the frame was rotated.
  140215. */
  140216. rotated: boolean;
  140217. /**
  140218. * boolean to flag is the frame was trimmed.
  140219. */
  140220. trimmed: boolean;
  140221. /**
  140222. * ISpriteJSONSpriteFrame basic object of the source data
  140223. */
  140224. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140225. /**
  140226. * ISpriteJSONSpriteFrame basic object of the source data
  140227. */
  140228. sourceSize: ISpriteJSONSpriteSourceSize;
  140229. }
  140230. /**
  140231. * Defines the basic options interface of a JSON atlas.
  140232. */
  140233. export interface ISpriteJSONAtlas {
  140234. /**
  140235. * Array of objects that contain the frame data.
  140236. */
  140237. frames: Array<ISpriteJSONSprite>;
  140238. /**
  140239. * object basic object containing the sprite meta data.
  140240. */
  140241. meta?: object;
  140242. }
  140243. }
  140244. declare module BABYLON {
  140245. /** @hidden */
  140246. export var spriteMapPixelShader: {
  140247. name: string;
  140248. shader: string;
  140249. };
  140250. }
  140251. declare module BABYLON {
  140252. /** @hidden */
  140253. export var spriteMapVertexShader: {
  140254. name: string;
  140255. shader: string;
  140256. };
  140257. }
  140258. declare module BABYLON {
  140259. /**
  140260. * Defines the basic options interface of a SpriteMap
  140261. */
  140262. export interface ISpriteMapOptions {
  140263. /**
  140264. * Vector2 of the number of cells in the grid.
  140265. */
  140266. stageSize?: Vector2;
  140267. /**
  140268. * Vector2 of the size of the output plane in World Units.
  140269. */
  140270. outputSize?: Vector2;
  140271. /**
  140272. * Vector3 of the position of the output plane in World Units.
  140273. */
  140274. outputPosition?: Vector3;
  140275. /**
  140276. * Vector3 of the rotation of the output plane.
  140277. */
  140278. outputRotation?: Vector3;
  140279. /**
  140280. * number of layers that the system will reserve in resources.
  140281. */
  140282. layerCount?: number;
  140283. /**
  140284. * number of max animation frames a single cell will reserve in resources.
  140285. */
  140286. maxAnimationFrames?: number;
  140287. /**
  140288. * number cell index of the base tile when the system compiles.
  140289. */
  140290. baseTile?: number;
  140291. /**
  140292. * boolean flip the sprite after its been repositioned by the framing data.
  140293. */
  140294. flipU?: boolean;
  140295. /**
  140296. * Vector3 scalar of the global RGB values of the SpriteMap.
  140297. */
  140298. colorMultiply?: Vector3;
  140299. }
  140300. /**
  140301. * Defines the IDisposable interface in order to be cleanable from resources.
  140302. */
  140303. export interface ISpriteMap extends IDisposable {
  140304. /**
  140305. * String name of the SpriteMap.
  140306. */
  140307. name: string;
  140308. /**
  140309. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140310. */
  140311. atlasJSON: ISpriteJSONAtlas;
  140312. /**
  140313. * Texture of the SpriteMap.
  140314. */
  140315. spriteSheet: Texture;
  140316. /**
  140317. * The parameters to initialize the SpriteMap with.
  140318. */
  140319. options: ISpriteMapOptions;
  140320. }
  140321. /**
  140322. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140323. */
  140324. export class SpriteMap implements ISpriteMap {
  140325. /** The Name of the spriteMap */
  140326. name: string;
  140327. /** The JSON file with the frame and meta data */
  140328. atlasJSON: ISpriteJSONAtlas;
  140329. /** The systems Sprite Sheet Texture */
  140330. spriteSheet: Texture;
  140331. /** Arguments passed with the Constructor */
  140332. options: ISpriteMapOptions;
  140333. /** Public Sprite Storage array, parsed from atlasJSON */
  140334. sprites: Array<ISpriteJSONSprite>;
  140335. /** Returns the Number of Sprites in the System */
  140336. get spriteCount(): number;
  140337. /** Returns the Position of Output Plane*/
  140338. get position(): Vector3;
  140339. /** Returns the Position of Output Plane*/
  140340. set position(v: Vector3);
  140341. /** Returns the Rotation of Output Plane*/
  140342. get rotation(): Vector3;
  140343. /** Returns the Rotation of Output Plane*/
  140344. set rotation(v: Vector3);
  140345. /** Sets the AnimationMap*/
  140346. get animationMap(): RawTexture;
  140347. /** Sets the AnimationMap*/
  140348. set animationMap(v: RawTexture);
  140349. /** Scene that the SpriteMap was created in */
  140350. private _scene;
  140351. /** Texture Buffer of Float32 that holds tile frame data*/
  140352. private _frameMap;
  140353. /** Texture Buffers of Float32 that holds tileMap data*/
  140354. private _tileMaps;
  140355. /** Texture Buffer of Float32 that holds Animation Data*/
  140356. private _animationMap;
  140357. /** Custom ShaderMaterial Central to the System*/
  140358. private _material;
  140359. /** Custom ShaderMaterial Central to the System*/
  140360. private _output;
  140361. /** Systems Time Ticker*/
  140362. private _time;
  140363. /**
  140364. * Creates a new SpriteMap
  140365. * @param name defines the SpriteMaps Name
  140366. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140367. * @param spriteSheet is the Texture that the Sprites are on.
  140368. * @param options a basic deployment configuration
  140369. * @param scene The Scene that the map is deployed on
  140370. */
  140371. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140372. /**
  140373. * Returns tileID location
  140374. * @returns Vector2 the cell position ID
  140375. */
  140376. getTileID(): Vector2;
  140377. /**
  140378. * Gets the UV location of the mouse over the SpriteMap.
  140379. * @returns Vector2 the UV position of the mouse interaction
  140380. */
  140381. getMousePosition(): Vector2;
  140382. /**
  140383. * Creates the "frame" texture Buffer
  140384. * -------------------------------------
  140385. * Structure of frames
  140386. * "filename": "Falling-Water-2.png",
  140387. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140388. * "rotated": true,
  140389. * "trimmed": true,
  140390. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140391. * "sourceSize": {"w":32,"h":32}
  140392. * @returns RawTexture of the frameMap
  140393. */
  140394. private _createFrameBuffer;
  140395. /**
  140396. * Creates the tileMap texture Buffer
  140397. * @param buffer normally and array of numbers, or a false to generate from scratch
  140398. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140399. * @returns RawTexture of the tileMap
  140400. */
  140401. private _createTileBuffer;
  140402. /**
  140403. * Modifies the data of the tileMaps
  140404. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140405. * @param pos is the iVector2 Coordinates of the Tile
  140406. * @param tile The SpriteIndex of the new Tile
  140407. */
  140408. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140409. /**
  140410. * Creates the animationMap texture Buffer
  140411. * @param buffer normally and array of numbers, or a false to generate from scratch
  140412. * @returns RawTexture of the animationMap
  140413. */
  140414. private _createTileAnimationBuffer;
  140415. /**
  140416. * Modifies the data of the animationMap
  140417. * @param cellID is the Index of the Sprite
  140418. * @param _frame is the target Animation frame
  140419. * @param toCell is the Target Index of the next frame of the animation
  140420. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140421. * @param speed is a global scalar of the time variable on the map.
  140422. */
  140423. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140424. /**
  140425. * Exports the .tilemaps file
  140426. */
  140427. saveTileMaps(): void;
  140428. /**
  140429. * Imports the .tilemaps file
  140430. * @param url of the .tilemaps file
  140431. */
  140432. loadTileMaps(url: string): void;
  140433. /**
  140434. * Release associated resources
  140435. */
  140436. dispose(): void;
  140437. }
  140438. }
  140439. declare module BABYLON {
  140440. /**
  140441. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140442. * @see http://doc.babylonjs.com/babylon101/sprites
  140443. */
  140444. export class SpritePackedManager extends SpriteManager {
  140445. /** defines the packed manager's name */
  140446. name: string;
  140447. /**
  140448. * Creates a new sprite manager from a packed sprite sheet
  140449. * @param name defines the manager's name
  140450. * @param imgUrl defines the sprite sheet url
  140451. * @param capacity defines the maximum allowed number of sprites
  140452. * @param scene defines the hosting scene
  140453. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140454. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140455. * @param samplingMode defines the smapling mode to use with spritesheet
  140456. * @param fromPacked set to true; do not alter
  140457. */
  140458. constructor(
  140459. /** defines the packed manager's name */
  140460. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140461. }
  140462. }
  140463. declare module BABYLON {
  140464. /**
  140465. * Defines the list of states available for a task inside a AssetsManager
  140466. */
  140467. export enum AssetTaskState {
  140468. /**
  140469. * Initialization
  140470. */
  140471. INIT = 0,
  140472. /**
  140473. * Running
  140474. */
  140475. RUNNING = 1,
  140476. /**
  140477. * Done
  140478. */
  140479. DONE = 2,
  140480. /**
  140481. * Error
  140482. */
  140483. ERROR = 3
  140484. }
  140485. /**
  140486. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140487. */
  140488. export abstract class AbstractAssetTask {
  140489. /**
  140490. * Task name
  140491. */ name: string;
  140492. /**
  140493. * Callback called when the task is successful
  140494. */
  140495. onSuccess: (task: any) => void;
  140496. /**
  140497. * Callback called when the task is not successful
  140498. */
  140499. onError: (task: any, message?: string, exception?: any) => void;
  140500. /**
  140501. * Creates a new AssetsManager
  140502. * @param name defines the name of the task
  140503. */
  140504. constructor(
  140505. /**
  140506. * Task name
  140507. */ name: string);
  140508. private _isCompleted;
  140509. private _taskState;
  140510. private _errorObject;
  140511. /**
  140512. * Get if the task is completed
  140513. */
  140514. get isCompleted(): boolean;
  140515. /**
  140516. * Gets the current state of the task
  140517. */
  140518. get taskState(): AssetTaskState;
  140519. /**
  140520. * Gets the current error object (if task is in error)
  140521. */
  140522. get errorObject(): {
  140523. message?: string;
  140524. exception?: any;
  140525. };
  140526. /**
  140527. * Internal only
  140528. * @hidden
  140529. */
  140530. _setErrorObject(message?: string, exception?: any): void;
  140531. /**
  140532. * Execute the current task
  140533. * @param scene defines the scene where you want your assets to be loaded
  140534. * @param onSuccess is a callback called when the task is successfully executed
  140535. * @param onError is a callback called if an error occurs
  140536. */
  140537. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140538. /**
  140539. * Execute the current task
  140540. * @param scene defines the scene where you want your assets to be loaded
  140541. * @param onSuccess is a callback called when the task is successfully executed
  140542. * @param onError is a callback called if an error occurs
  140543. */
  140544. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140545. /**
  140546. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140547. * This can be used with failed tasks that have the reason for failure fixed.
  140548. */
  140549. reset(): void;
  140550. private onErrorCallback;
  140551. private onDoneCallback;
  140552. }
  140553. /**
  140554. * Define the interface used by progress events raised during assets loading
  140555. */
  140556. export interface IAssetsProgressEvent {
  140557. /**
  140558. * Defines the number of remaining tasks to process
  140559. */
  140560. remainingCount: number;
  140561. /**
  140562. * Defines the total number of tasks
  140563. */
  140564. totalCount: number;
  140565. /**
  140566. * Defines the task that was just processed
  140567. */
  140568. task: AbstractAssetTask;
  140569. }
  140570. /**
  140571. * Class used to share progress information about assets loading
  140572. */
  140573. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140574. /**
  140575. * Defines the number of remaining tasks to process
  140576. */
  140577. remainingCount: number;
  140578. /**
  140579. * Defines the total number of tasks
  140580. */
  140581. totalCount: number;
  140582. /**
  140583. * Defines the task that was just processed
  140584. */
  140585. task: AbstractAssetTask;
  140586. /**
  140587. * Creates a AssetsProgressEvent
  140588. * @param remainingCount defines the number of remaining tasks to process
  140589. * @param totalCount defines the total number of tasks
  140590. * @param task defines the task that was just processed
  140591. */
  140592. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140593. }
  140594. /**
  140595. * Define a task used by AssetsManager to load meshes
  140596. */
  140597. export class MeshAssetTask extends AbstractAssetTask {
  140598. /**
  140599. * Defines the name of the task
  140600. */
  140601. name: string;
  140602. /**
  140603. * Defines the list of mesh's names you want to load
  140604. */
  140605. meshesNames: any;
  140606. /**
  140607. * Defines the root url to use as a base to load your meshes and associated resources
  140608. */
  140609. rootUrl: string;
  140610. /**
  140611. * Defines the filename of the scene to load from
  140612. */
  140613. sceneFilename: string;
  140614. /**
  140615. * Gets the list of loaded meshes
  140616. */
  140617. loadedMeshes: Array<AbstractMesh>;
  140618. /**
  140619. * Gets the list of loaded particle systems
  140620. */
  140621. loadedParticleSystems: Array<IParticleSystem>;
  140622. /**
  140623. * Gets the list of loaded skeletons
  140624. */
  140625. loadedSkeletons: Array<Skeleton>;
  140626. /**
  140627. * Gets the list of loaded animation groups
  140628. */
  140629. loadedAnimationGroups: Array<AnimationGroup>;
  140630. /**
  140631. * Callback called when the task is successful
  140632. */
  140633. onSuccess: (task: MeshAssetTask) => void;
  140634. /**
  140635. * Callback called when the task is successful
  140636. */
  140637. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140638. /**
  140639. * Creates a new MeshAssetTask
  140640. * @param name defines the name of the task
  140641. * @param meshesNames defines the list of mesh's names you want to load
  140642. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140643. * @param sceneFilename defines the filename of the scene to load from
  140644. */
  140645. constructor(
  140646. /**
  140647. * Defines the name of the task
  140648. */
  140649. name: string,
  140650. /**
  140651. * Defines the list of mesh's names you want to load
  140652. */
  140653. meshesNames: any,
  140654. /**
  140655. * Defines the root url to use as a base to load your meshes and associated resources
  140656. */
  140657. rootUrl: string,
  140658. /**
  140659. * Defines the filename of the scene to load from
  140660. */
  140661. sceneFilename: string);
  140662. /**
  140663. * Execute the current task
  140664. * @param scene defines the scene where you want your assets to be loaded
  140665. * @param onSuccess is a callback called when the task is successfully executed
  140666. * @param onError is a callback called if an error occurs
  140667. */
  140668. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140669. }
  140670. /**
  140671. * Define a task used by AssetsManager to load text content
  140672. */
  140673. export class TextFileAssetTask extends AbstractAssetTask {
  140674. /**
  140675. * Defines the name of the task
  140676. */
  140677. name: string;
  140678. /**
  140679. * Defines the location of the file to load
  140680. */
  140681. url: string;
  140682. /**
  140683. * Gets the loaded text string
  140684. */
  140685. text: string;
  140686. /**
  140687. * Callback called when the task is successful
  140688. */
  140689. onSuccess: (task: TextFileAssetTask) => void;
  140690. /**
  140691. * Callback called when the task is successful
  140692. */
  140693. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140694. /**
  140695. * Creates a new TextFileAssetTask object
  140696. * @param name defines the name of the task
  140697. * @param url defines the location of the file to load
  140698. */
  140699. constructor(
  140700. /**
  140701. * Defines the name of the task
  140702. */
  140703. name: string,
  140704. /**
  140705. * Defines the location of the file to load
  140706. */
  140707. url: string);
  140708. /**
  140709. * Execute the current task
  140710. * @param scene defines the scene where you want your assets to be loaded
  140711. * @param onSuccess is a callback called when the task is successfully executed
  140712. * @param onError is a callback called if an error occurs
  140713. */
  140714. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140715. }
  140716. /**
  140717. * Define a task used by AssetsManager to load binary data
  140718. */
  140719. export class BinaryFileAssetTask extends AbstractAssetTask {
  140720. /**
  140721. * Defines the name of the task
  140722. */
  140723. name: string;
  140724. /**
  140725. * Defines the location of the file to load
  140726. */
  140727. url: string;
  140728. /**
  140729. * Gets the lodaded data (as an array buffer)
  140730. */
  140731. data: ArrayBuffer;
  140732. /**
  140733. * Callback called when the task is successful
  140734. */
  140735. onSuccess: (task: BinaryFileAssetTask) => void;
  140736. /**
  140737. * Callback called when the task is successful
  140738. */
  140739. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140740. /**
  140741. * Creates a new BinaryFileAssetTask object
  140742. * @param name defines the name of the new task
  140743. * @param url defines the location of the file to load
  140744. */
  140745. constructor(
  140746. /**
  140747. * Defines the name of the task
  140748. */
  140749. name: string,
  140750. /**
  140751. * Defines the location of the file to load
  140752. */
  140753. url: string);
  140754. /**
  140755. * Execute the current task
  140756. * @param scene defines the scene where you want your assets to be loaded
  140757. * @param onSuccess is a callback called when the task is successfully executed
  140758. * @param onError is a callback called if an error occurs
  140759. */
  140760. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140761. }
  140762. /**
  140763. * Define a task used by AssetsManager to load images
  140764. */
  140765. export class ImageAssetTask extends AbstractAssetTask {
  140766. /**
  140767. * Defines the name of the task
  140768. */
  140769. name: string;
  140770. /**
  140771. * Defines the location of the image to load
  140772. */
  140773. url: string;
  140774. /**
  140775. * Gets the loaded images
  140776. */
  140777. image: HTMLImageElement;
  140778. /**
  140779. * Callback called when the task is successful
  140780. */
  140781. onSuccess: (task: ImageAssetTask) => void;
  140782. /**
  140783. * Callback called when the task is successful
  140784. */
  140785. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140786. /**
  140787. * Creates a new ImageAssetTask
  140788. * @param name defines the name of the task
  140789. * @param url defines the location of the image to load
  140790. */
  140791. constructor(
  140792. /**
  140793. * Defines the name of the task
  140794. */
  140795. name: string,
  140796. /**
  140797. * Defines the location of the image to load
  140798. */
  140799. url: string);
  140800. /**
  140801. * Execute the current task
  140802. * @param scene defines the scene where you want your assets to be loaded
  140803. * @param onSuccess is a callback called when the task is successfully executed
  140804. * @param onError is a callback called if an error occurs
  140805. */
  140806. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140807. }
  140808. /**
  140809. * Defines the interface used by texture loading tasks
  140810. */
  140811. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140812. /**
  140813. * Gets the loaded texture
  140814. */
  140815. texture: TEX;
  140816. }
  140817. /**
  140818. * Define a task used by AssetsManager to load 2D textures
  140819. */
  140820. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140821. /**
  140822. * Defines the name of the task
  140823. */
  140824. name: string;
  140825. /**
  140826. * Defines the location of the file to load
  140827. */
  140828. url: string;
  140829. /**
  140830. * Defines if mipmap should not be generated (default is false)
  140831. */
  140832. noMipmap?: boolean | undefined;
  140833. /**
  140834. * Defines if texture must be inverted on Y axis (default is false)
  140835. */
  140836. invertY?: boolean | undefined;
  140837. /**
  140838. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140839. */
  140840. samplingMode: number;
  140841. /**
  140842. * Gets the loaded texture
  140843. */
  140844. texture: Texture;
  140845. /**
  140846. * Callback called when the task is successful
  140847. */
  140848. onSuccess: (task: TextureAssetTask) => void;
  140849. /**
  140850. * Callback called when the task is successful
  140851. */
  140852. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140853. /**
  140854. * Creates a new TextureAssetTask object
  140855. * @param name defines the name of the task
  140856. * @param url defines the location of the file to load
  140857. * @param noMipmap defines if mipmap should not be generated (default is false)
  140858. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140859. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140860. */
  140861. constructor(
  140862. /**
  140863. * Defines the name of the task
  140864. */
  140865. name: string,
  140866. /**
  140867. * Defines the location of the file to load
  140868. */
  140869. url: string,
  140870. /**
  140871. * Defines if mipmap should not be generated (default is false)
  140872. */
  140873. noMipmap?: boolean | undefined,
  140874. /**
  140875. * Defines if texture must be inverted on Y axis (default is false)
  140876. */
  140877. invertY?: boolean | undefined,
  140878. /**
  140879. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140880. */
  140881. samplingMode?: number);
  140882. /**
  140883. * Execute the current task
  140884. * @param scene defines the scene where you want your assets to be loaded
  140885. * @param onSuccess is a callback called when the task is successfully executed
  140886. * @param onError is a callback called if an error occurs
  140887. */
  140888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140889. }
  140890. /**
  140891. * Define a task used by AssetsManager to load cube textures
  140892. */
  140893. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140894. /**
  140895. * Defines the name of the task
  140896. */
  140897. name: string;
  140898. /**
  140899. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140900. */
  140901. url: string;
  140902. /**
  140903. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140904. */
  140905. extensions?: string[] | undefined;
  140906. /**
  140907. * Defines if mipmaps should not be generated (default is false)
  140908. */
  140909. noMipmap?: boolean | undefined;
  140910. /**
  140911. * Defines the explicit list of files (undefined by default)
  140912. */
  140913. files?: string[] | undefined;
  140914. /**
  140915. * Gets the loaded texture
  140916. */
  140917. texture: CubeTexture;
  140918. /**
  140919. * Callback called when the task is successful
  140920. */
  140921. onSuccess: (task: CubeTextureAssetTask) => void;
  140922. /**
  140923. * Callback called when the task is successful
  140924. */
  140925. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140926. /**
  140927. * Creates a new CubeTextureAssetTask
  140928. * @param name defines the name of the task
  140929. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140930. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140931. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140932. * @param files defines the explicit list of files (undefined by default)
  140933. */
  140934. constructor(
  140935. /**
  140936. * Defines the name of the task
  140937. */
  140938. name: string,
  140939. /**
  140940. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140941. */
  140942. url: string,
  140943. /**
  140944. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140945. */
  140946. extensions?: string[] | undefined,
  140947. /**
  140948. * Defines if mipmaps should not be generated (default is false)
  140949. */
  140950. noMipmap?: boolean | undefined,
  140951. /**
  140952. * Defines the explicit list of files (undefined by default)
  140953. */
  140954. files?: string[] | undefined);
  140955. /**
  140956. * Execute the current task
  140957. * @param scene defines the scene where you want your assets to be loaded
  140958. * @param onSuccess is a callback called when the task is successfully executed
  140959. * @param onError is a callback called if an error occurs
  140960. */
  140961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140962. }
  140963. /**
  140964. * Define a task used by AssetsManager to load HDR cube textures
  140965. */
  140966. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140967. /**
  140968. * Defines the name of the task
  140969. */
  140970. name: string;
  140971. /**
  140972. * Defines the location of the file to load
  140973. */
  140974. url: string;
  140975. /**
  140976. * Defines the desired size (the more it increases the longer the generation will be)
  140977. */
  140978. size: number;
  140979. /**
  140980. * Defines if mipmaps should not be generated (default is false)
  140981. */
  140982. noMipmap: boolean;
  140983. /**
  140984. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140985. */
  140986. generateHarmonics: boolean;
  140987. /**
  140988. * 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)
  140989. */
  140990. gammaSpace: boolean;
  140991. /**
  140992. * Internal Use Only
  140993. */
  140994. reserved: boolean;
  140995. /**
  140996. * Gets the loaded texture
  140997. */
  140998. texture: HDRCubeTexture;
  140999. /**
  141000. * Callback called when the task is successful
  141001. */
  141002. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  141003. /**
  141004. * Callback called when the task is successful
  141005. */
  141006. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  141007. /**
  141008. * Creates a new HDRCubeTextureAssetTask object
  141009. * @param name defines the name of the task
  141010. * @param url defines the location of the file to load
  141011. * @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.
  141012. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141013. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141014. * @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)
  141015. * @param reserved Internal use only
  141016. */
  141017. constructor(
  141018. /**
  141019. * Defines the name of the task
  141020. */
  141021. name: string,
  141022. /**
  141023. * Defines the location of the file to load
  141024. */
  141025. url: string,
  141026. /**
  141027. * Defines the desired size (the more it increases the longer the generation will be)
  141028. */
  141029. size: number,
  141030. /**
  141031. * Defines if mipmaps should not be generated (default is false)
  141032. */
  141033. noMipmap?: boolean,
  141034. /**
  141035. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  141036. */
  141037. generateHarmonics?: boolean,
  141038. /**
  141039. * 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)
  141040. */
  141041. gammaSpace?: boolean,
  141042. /**
  141043. * Internal Use Only
  141044. */
  141045. reserved?: boolean);
  141046. /**
  141047. * Execute the current task
  141048. * @param scene defines the scene where you want your assets to be loaded
  141049. * @param onSuccess is a callback called when the task is successfully executed
  141050. * @param onError is a callback called if an error occurs
  141051. */
  141052. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141053. }
  141054. /**
  141055. * Define a task used by AssetsManager to load Equirectangular cube textures
  141056. */
  141057. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  141058. /**
  141059. * Defines the name of the task
  141060. */
  141061. name: string;
  141062. /**
  141063. * Defines the location of the file to load
  141064. */
  141065. url: string;
  141066. /**
  141067. * Defines the desired size (the more it increases the longer the generation will be)
  141068. */
  141069. size: number;
  141070. /**
  141071. * Defines if mipmaps should not be generated (default is false)
  141072. */
  141073. noMipmap: boolean;
  141074. /**
  141075. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141076. * but the standard material would require them in Gamma space) (default is true)
  141077. */
  141078. gammaSpace: boolean;
  141079. /**
  141080. * Gets the loaded texture
  141081. */
  141082. texture: EquiRectangularCubeTexture;
  141083. /**
  141084. * Callback called when the task is successful
  141085. */
  141086. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  141087. /**
  141088. * Callback called when the task is successful
  141089. */
  141090. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  141091. /**
  141092. * Creates a new EquiRectangularCubeTextureAssetTask object
  141093. * @param name defines the name of the task
  141094. * @param url defines the location of the file to load
  141095. * @param size defines the desired size (the more it increases the longer the generation will be)
  141096. * If the size is omitted this implies you are using a preprocessed cubemap.
  141097. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141098. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  141099. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  141100. * (default is true)
  141101. */
  141102. constructor(
  141103. /**
  141104. * Defines the name of the task
  141105. */
  141106. name: string,
  141107. /**
  141108. * Defines the location of the file to load
  141109. */
  141110. url: string,
  141111. /**
  141112. * Defines the desired size (the more it increases the longer the generation will be)
  141113. */
  141114. size: number,
  141115. /**
  141116. * Defines if mipmaps should not be generated (default is false)
  141117. */
  141118. noMipmap?: boolean,
  141119. /**
  141120. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141121. * but the standard material would require them in Gamma space) (default is true)
  141122. */
  141123. gammaSpace?: boolean);
  141124. /**
  141125. * Execute the current task
  141126. * @param scene defines the scene where you want your assets to be loaded
  141127. * @param onSuccess is a callback called when the task is successfully executed
  141128. * @param onError is a callback called if an error occurs
  141129. */
  141130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141131. }
  141132. /**
  141133. * This class can be used to easily import assets into a scene
  141134. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141135. */
  141136. export class AssetsManager {
  141137. private _scene;
  141138. private _isLoading;
  141139. protected _tasks: AbstractAssetTask[];
  141140. protected _waitingTasksCount: number;
  141141. protected _totalTasksCount: number;
  141142. /**
  141143. * Callback called when all tasks are processed
  141144. */
  141145. onFinish: (tasks: AbstractAssetTask[]) => void;
  141146. /**
  141147. * Callback called when a task is successful
  141148. */
  141149. onTaskSuccess: (task: AbstractAssetTask) => void;
  141150. /**
  141151. * Callback called when a task had an error
  141152. */
  141153. onTaskError: (task: AbstractAssetTask) => void;
  141154. /**
  141155. * Callback called when a task is done (whatever the result is)
  141156. */
  141157. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141158. /**
  141159. * Observable called when all tasks are processed
  141160. */
  141161. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141162. /**
  141163. * Observable called when a task had an error
  141164. */
  141165. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141166. /**
  141167. * Observable called when all tasks were executed
  141168. */
  141169. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141170. /**
  141171. * Observable called when a task is done (whatever the result is)
  141172. */
  141173. onProgressObservable: Observable<IAssetsProgressEvent>;
  141174. /**
  141175. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141176. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141177. */
  141178. useDefaultLoadingScreen: boolean;
  141179. /**
  141180. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141181. * when all assets have been downloaded.
  141182. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141183. */
  141184. autoHideLoadingUI: boolean;
  141185. /**
  141186. * Creates a new AssetsManager
  141187. * @param scene defines the scene to work on
  141188. */
  141189. constructor(scene: Scene);
  141190. /**
  141191. * Add a MeshAssetTask to the list of active tasks
  141192. * @param taskName defines the name of the new task
  141193. * @param meshesNames defines the name of meshes to load
  141194. * @param rootUrl defines the root url to use to locate files
  141195. * @param sceneFilename defines the filename of the scene file
  141196. * @returns a new MeshAssetTask object
  141197. */
  141198. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141199. /**
  141200. * Add a TextFileAssetTask to the list of active tasks
  141201. * @param taskName defines the name of the new task
  141202. * @param url defines the url of the file to load
  141203. * @returns a new TextFileAssetTask object
  141204. */
  141205. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141206. /**
  141207. * Add a BinaryFileAssetTask to the list of active tasks
  141208. * @param taskName defines the name of the new task
  141209. * @param url defines the url of the file to load
  141210. * @returns a new BinaryFileAssetTask object
  141211. */
  141212. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141213. /**
  141214. * Add a ImageAssetTask to the list of active tasks
  141215. * @param taskName defines the name of the new task
  141216. * @param url defines the url of the file to load
  141217. * @returns a new ImageAssetTask object
  141218. */
  141219. addImageTask(taskName: string, url: string): ImageAssetTask;
  141220. /**
  141221. * Add a TextureAssetTask to the list of active tasks
  141222. * @param taskName defines the name of the new task
  141223. * @param url defines the url of the file to load
  141224. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141225. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141226. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141227. * @returns a new TextureAssetTask object
  141228. */
  141229. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141230. /**
  141231. * Add a CubeTextureAssetTask to the list of active tasks
  141232. * @param taskName defines the name of the new task
  141233. * @param url defines the url of the file to load
  141234. * @param extensions defines the extension to use to load the cube map (can be null)
  141235. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141236. * @param files defines the list of files to load (can be null)
  141237. * @returns a new CubeTextureAssetTask object
  141238. */
  141239. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141240. /**
  141241. *
  141242. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141243. * @param taskName defines the name of the new task
  141244. * @param url defines the url of the file to load
  141245. * @param size defines the size you want for the cubemap (can be null)
  141246. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141247. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141248. * @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)
  141249. * @param reserved Internal use only
  141250. * @returns a new HDRCubeTextureAssetTask object
  141251. */
  141252. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141253. /**
  141254. *
  141255. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141256. * @param taskName defines the name of the new task
  141257. * @param url defines the url of the file to load
  141258. * @param size defines the size you want for the cubemap (can be null)
  141259. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141260. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141261. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141262. * @returns a new EquiRectangularCubeTextureAssetTask object
  141263. */
  141264. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141265. /**
  141266. * Remove a task from the assets manager.
  141267. * @param task the task to remove
  141268. */
  141269. removeTask(task: AbstractAssetTask): void;
  141270. private _decreaseWaitingTasksCount;
  141271. private _runTask;
  141272. /**
  141273. * Reset the AssetsManager and remove all tasks
  141274. * @return the current instance of the AssetsManager
  141275. */
  141276. reset(): AssetsManager;
  141277. /**
  141278. * Start the loading process
  141279. * @return the current instance of the AssetsManager
  141280. */
  141281. load(): AssetsManager;
  141282. /**
  141283. * Start the loading process as an async operation
  141284. * @return a promise returning the list of failed tasks
  141285. */
  141286. loadAsync(): Promise<void>;
  141287. }
  141288. }
  141289. declare module BABYLON {
  141290. /**
  141291. * Wrapper class for promise with external resolve and reject.
  141292. */
  141293. export class Deferred<T> {
  141294. /**
  141295. * The promise associated with this deferred object.
  141296. */
  141297. readonly promise: Promise<T>;
  141298. private _resolve;
  141299. private _reject;
  141300. /**
  141301. * The resolve method of the promise associated with this deferred object.
  141302. */
  141303. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141304. /**
  141305. * The reject method of the promise associated with this deferred object.
  141306. */
  141307. get reject(): (reason?: any) => void;
  141308. /**
  141309. * Constructor for this deferred object.
  141310. */
  141311. constructor();
  141312. }
  141313. }
  141314. declare module BABYLON {
  141315. /**
  141316. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141317. */
  141318. export class MeshExploder {
  141319. private _centerMesh;
  141320. private _meshes;
  141321. private _meshesOrigins;
  141322. private _toCenterVectors;
  141323. private _scaledDirection;
  141324. private _newPosition;
  141325. private _centerPosition;
  141326. /**
  141327. * Explodes meshes from a center mesh.
  141328. * @param meshes The meshes to explode.
  141329. * @param centerMesh The mesh to be center of explosion.
  141330. */
  141331. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141332. private _setCenterMesh;
  141333. /**
  141334. * Get class name
  141335. * @returns "MeshExploder"
  141336. */
  141337. getClassName(): string;
  141338. /**
  141339. * "Exploded meshes"
  141340. * @returns Array of meshes with the centerMesh at index 0.
  141341. */
  141342. getMeshes(): Array<Mesh>;
  141343. /**
  141344. * Explodes meshes giving a specific direction
  141345. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141346. */
  141347. explode(direction?: number): void;
  141348. }
  141349. }
  141350. declare module BABYLON {
  141351. /**
  141352. * Class used to help managing file picking and drag'n'drop
  141353. */
  141354. export class FilesInput {
  141355. /**
  141356. * List of files ready to be loaded
  141357. */
  141358. static get FilesToLoad(): {
  141359. [key: string]: File;
  141360. };
  141361. /**
  141362. * Callback called when a file is processed
  141363. */
  141364. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141365. private _engine;
  141366. private _currentScene;
  141367. private _sceneLoadedCallback;
  141368. private _progressCallback;
  141369. private _additionalRenderLoopLogicCallback;
  141370. private _textureLoadingCallback;
  141371. private _startingProcessingFilesCallback;
  141372. private _onReloadCallback;
  141373. private _errorCallback;
  141374. private _elementToMonitor;
  141375. private _sceneFileToLoad;
  141376. private _filesToLoad;
  141377. /**
  141378. * Creates a new FilesInput
  141379. * @param engine defines the rendering engine
  141380. * @param scene defines the hosting scene
  141381. * @param sceneLoadedCallback callback called when scene is loaded
  141382. * @param progressCallback callback called to track progress
  141383. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141384. * @param textureLoadingCallback callback called when a texture is loading
  141385. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141386. * @param onReloadCallback callback called when a reload is requested
  141387. * @param errorCallback callback call if an error occurs
  141388. */
  141389. 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);
  141390. private _dragEnterHandler;
  141391. private _dragOverHandler;
  141392. private _dropHandler;
  141393. /**
  141394. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141395. * @param elementToMonitor defines the DOM element to track
  141396. */
  141397. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141398. /**
  141399. * Release all associated resources
  141400. */
  141401. dispose(): void;
  141402. private renderFunction;
  141403. private drag;
  141404. private drop;
  141405. private _traverseFolder;
  141406. private _processFiles;
  141407. /**
  141408. * Load files from a drop event
  141409. * @param event defines the drop event to use as source
  141410. */
  141411. loadFiles(event: any): void;
  141412. private _processReload;
  141413. /**
  141414. * Reload the current scene from the loaded files
  141415. */
  141416. reload(): void;
  141417. }
  141418. }
  141419. declare module BABYLON {
  141420. /**
  141421. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141422. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141423. */
  141424. export class SceneOptimization {
  141425. /**
  141426. * Defines the priority of this optimization (0 by default which means first in the list)
  141427. */
  141428. priority: number;
  141429. /**
  141430. * Gets a string describing the action executed by the current optimization
  141431. * @returns description string
  141432. */
  141433. getDescription(): string;
  141434. /**
  141435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141436. * @param scene defines the current scene where to apply this optimization
  141437. * @param optimizer defines the current optimizer
  141438. * @returns true if everything that can be done was applied
  141439. */
  141440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141441. /**
  141442. * Creates the SceneOptimization object
  141443. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141444. * @param desc defines the description associated with the optimization
  141445. */
  141446. constructor(
  141447. /**
  141448. * Defines the priority of this optimization (0 by default which means first in the list)
  141449. */
  141450. priority?: number);
  141451. }
  141452. /**
  141453. * Defines an optimization used to reduce the size of render target textures
  141454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141455. */
  141456. export class TextureOptimization extends SceneOptimization {
  141457. /**
  141458. * Defines the priority of this optimization (0 by default which means first in the list)
  141459. */
  141460. priority: number;
  141461. /**
  141462. * 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
  141463. */
  141464. maximumSize: number;
  141465. /**
  141466. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141467. */
  141468. step: number;
  141469. /**
  141470. * Gets a string describing the action executed by the current optimization
  141471. * @returns description string
  141472. */
  141473. getDescription(): string;
  141474. /**
  141475. * Creates the TextureOptimization object
  141476. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141477. * @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
  141478. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141479. */
  141480. constructor(
  141481. /**
  141482. * Defines the priority of this optimization (0 by default which means first in the list)
  141483. */
  141484. priority?: number,
  141485. /**
  141486. * 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
  141487. */
  141488. maximumSize?: number,
  141489. /**
  141490. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141491. */
  141492. step?: number);
  141493. /**
  141494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141495. * @param scene defines the current scene where to apply this optimization
  141496. * @param optimizer defines the current optimizer
  141497. * @returns true if everything that can be done was applied
  141498. */
  141499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141500. }
  141501. /**
  141502. * Defines an optimization used to increase or decrease the rendering resolution
  141503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141504. */
  141505. export class HardwareScalingOptimization extends SceneOptimization {
  141506. /**
  141507. * Defines the priority of this optimization (0 by default which means first in the list)
  141508. */
  141509. priority: number;
  141510. /**
  141511. * Defines the maximum scale to use (2 by default)
  141512. */
  141513. maximumScale: number;
  141514. /**
  141515. * Defines the step to use between two passes (0.5 by default)
  141516. */
  141517. step: number;
  141518. private _currentScale;
  141519. private _directionOffset;
  141520. /**
  141521. * Gets a string describing the action executed by the current optimization
  141522. * @return description string
  141523. */
  141524. getDescription(): string;
  141525. /**
  141526. * Creates the HardwareScalingOptimization object
  141527. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141528. * @param maximumScale defines the maximum scale to use (2 by default)
  141529. * @param step defines the step to use between two passes (0.5 by default)
  141530. */
  141531. constructor(
  141532. /**
  141533. * Defines the priority of this optimization (0 by default which means first in the list)
  141534. */
  141535. priority?: number,
  141536. /**
  141537. * Defines the maximum scale to use (2 by default)
  141538. */
  141539. maximumScale?: number,
  141540. /**
  141541. * Defines the step to use between two passes (0.5 by default)
  141542. */
  141543. step?: number);
  141544. /**
  141545. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141546. * @param scene defines the current scene where to apply this optimization
  141547. * @param optimizer defines the current optimizer
  141548. * @returns true if everything that can be done was applied
  141549. */
  141550. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141551. }
  141552. /**
  141553. * Defines an optimization used to remove shadows
  141554. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141555. */
  141556. export class ShadowsOptimization extends SceneOptimization {
  141557. /**
  141558. * Gets a string describing the action executed by the current optimization
  141559. * @return description string
  141560. */
  141561. getDescription(): string;
  141562. /**
  141563. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141564. * @param scene defines the current scene where to apply this optimization
  141565. * @param optimizer defines the current optimizer
  141566. * @returns true if everything that can be done was applied
  141567. */
  141568. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141569. }
  141570. /**
  141571. * Defines an optimization used to turn post-processes off
  141572. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141573. */
  141574. export class PostProcessesOptimization extends SceneOptimization {
  141575. /**
  141576. * Gets a string describing the action executed by the current optimization
  141577. * @return description string
  141578. */
  141579. getDescription(): string;
  141580. /**
  141581. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141582. * @param scene defines the current scene where to apply this optimization
  141583. * @param optimizer defines the current optimizer
  141584. * @returns true if everything that can be done was applied
  141585. */
  141586. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141587. }
  141588. /**
  141589. * Defines an optimization used to turn lens flares off
  141590. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141591. */
  141592. export class LensFlaresOptimization extends SceneOptimization {
  141593. /**
  141594. * Gets a string describing the action executed by the current optimization
  141595. * @return description string
  141596. */
  141597. getDescription(): string;
  141598. /**
  141599. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141600. * @param scene defines the current scene where to apply this optimization
  141601. * @param optimizer defines the current optimizer
  141602. * @returns true if everything that can be done was applied
  141603. */
  141604. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141605. }
  141606. /**
  141607. * Defines an optimization based on user defined callback.
  141608. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141609. */
  141610. export class CustomOptimization extends SceneOptimization {
  141611. /**
  141612. * Callback called to apply the custom optimization.
  141613. */
  141614. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141615. /**
  141616. * Callback called to get custom description
  141617. */
  141618. onGetDescription: () => string;
  141619. /**
  141620. * Gets a string describing the action executed by the current optimization
  141621. * @returns description string
  141622. */
  141623. getDescription(): string;
  141624. /**
  141625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141626. * @param scene defines the current scene where to apply this optimization
  141627. * @param optimizer defines the current optimizer
  141628. * @returns true if everything that can be done was applied
  141629. */
  141630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141631. }
  141632. /**
  141633. * Defines an optimization used to turn particles off
  141634. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141635. */
  141636. export class ParticlesOptimization extends SceneOptimization {
  141637. /**
  141638. * Gets a string describing the action executed by the current optimization
  141639. * @return description string
  141640. */
  141641. getDescription(): string;
  141642. /**
  141643. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141644. * @param scene defines the current scene where to apply this optimization
  141645. * @param optimizer defines the current optimizer
  141646. * @returns true if everything that can be done was applied
  141647. */
  141648. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141649. }
  141650. /**
  141651. * Defines an optimization used to turn render targets off
  141652. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141653. */
  141654. export class RenderTargetsOptimization extends SceneOptimization {
  141655. /**
  141656. * Gets a string describing the action executed by the current optimization
  141657. * @return description string
  141658. */
  141659. getDescription(): string;
  141660. /**
  141661. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141662. * @param scene defines the current scene where to apply this optimization
  141663. * @param optimizer defines the current optimizer
  141664. * @returns true if everything that can be done was applied
  141665. */
  141666. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141667. }
  141668. /**
  141669. * Defines an optimization used to merge meshes with compatible materials
  141670. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141671. */
  141672. export class MergeMeshesOptimization extends SceneOptimization {
  141673. private static _UpdateSelectionTree;
  141674. /**
  141675. * Gets or sets a boolean which defines if optimization octree has to be updated
  141676. */
  141677. static get UpdateSelectionTree(): boolean;
  141678. /**
  141679. * Gets or sets a boolean which defines if optimization octree has to be updated
  141680. */
  141681. static set UpdateSelectionTree(value: boolean);
  141682. /**
  141683. * Gets a string describing the action executed by the current optimization
  141684. * @return description string
  141685. */
  141686. getDescription(): string;
  141687. private _canBeMerged;
  141688. /**
  141689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141690. * @param scene defines the current scene where to apply this optimization
  141691. * @param optimizer defines the current optimizer
  141692. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141693. * @returns true if everything that can be done was applied
  141694. */
  141695. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141696. }
  141697. /**
  141698. * Defines a list of options used by SceneOptimizer
  141699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141700. */
  141701. export class SceneOptimizerOptions {
  141702. /**
  141703. * Defines the target frame rate to reach (60 by default)
  141704. */
  141705. targetFrameRate: number;
  141706. /**
  141707. * Defines the interval between two checkes (2000ms by default)
  141708. */
  141709. trackerDuration: number;
  141710. /**
  141711. * Gets the list of optimizations to apply
  141712. */
  141713. optimizations: SceneOptimization[];
  141714. /**
  141715. * Creates a new list of options used by SceneOptimizer
  141716. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141717. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141718. */
  141719. constructor(
  141720. /**
  141721. * Defines the target frame rate to reach (60 by default)
  141722. */
  141723. targetFrameRate?: number,
  141724. /**
  141725. * Defines the interval between two checkes (2000ms by default)
  141726. */
  141727. trackerDuration?: number);
  141728. /**
  141729. * Add a new optimization
  141730. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141731. * @returns the current SceneOptimizerOptions
  141732. */
  141733. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141734. /**
  141735. * Add a new custom optimization
  141736. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141737. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141738. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141739. * @returns the current SceneOptimizerOptions
  141740. */
  141741. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141742. /**
  141743. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141744. * @param targetFrameRate defines the target frame rate (60 by default)
  141745. * @returns a SceneOptimizerOptions object
  141746. */
  141747. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141748. /**
  141749. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141750. * @param targetFrameRate defines the target frame rate (60 by default)
  141751. * @returns a SceneOptimizerOptions object
  141752. */
  141753. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141754. /**
  141755. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141756. * @param targetFrameRate defines the target frame rate (60 by default)
  141757. * @returns a SceneOptimizerOptions object
  141758. */
  141759. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141760. }
  141761. /**
  141762. * Class used to run optimizations in order to reach a target frame rate
  141763. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141764. */
  141765. export class SceneOptimizer implements IDisposable {
  141766. private _isRunning;
  141767. private _options;
  141768. private _scene;
  141769. private _currentPriorityLevel;
  141770. private _targetFrameRate;
  141771. private _trackerDuration;
  141772. private _currentFrameRate;
  141773. private _sceneDisposeObserver;
  141774. private _improvementMode;
  141775. /**
  141776. * Defines an observable called when the optimizer reaches the target frame rate
  141777. */
  141778. onSuccessObservable: Observable<SceneOptimizer>;
  141779. /**
  141780. * Defines an observable called when the optimizer enables an optimization
  141781. */
  141782. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141783. /**
  141784. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141785. */
  141786. onFailureObservable: Observable<SceneOptimizer>;
  141787. /**
  141788. * Gets a boolean indicating if the optimizer is in improvement mode
  141789. */
  141790. get isInImprovementMode(): boolean;
  141791. /**
  141792. * Gets the current priority level (0 at start)
  141793. */
  141794. get currentPriorityLevel(): number;
  141795. /**
  141796. * Gets the current frame rate checked by the SceneOptimizer
  141797. */
  141798. get currentFrameRate(): number;
  141799. /**
  141800. * Gets or sets the current target frame rate (60 by default)
  141801. */
  141802. get targetFrameRate(): number;
  141803. /**
  141804. * Gets or sets the current target frame rate (60 by default)
  141805. */
  141806. set targetFrameRate(value: number);
  141807. /**
  141808. * Gets or sets the current interval between two checks (every 2000ms by default)
  141809. */
  141810. get trackerDuration(): number;
  141811. /**
  141812. * Gets or sets the current interval between two checks (every 2000ms by default)
  141813. */
  141814. set trackerDuration(value: number);
  141815. /**
  141816. * Gets the list of active optimizations
  141817. */
  141818. get optimizations(): SceneOptimization[];
  141819. /**
  141820. * Creates a new SceneOptimizer
  141821. * @param scene defines the scene to work on
  141822. * @param options defines the options to use with the SceneOptimizer
  141823. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141824. * @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)
  141825. */
  141826. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141827. /**
  141828. * Stops the current optimizer
  141829. */
  141830. stop(): void;
  141831. /**
  141832. * Reset the optimizer to initial step (current priority level = 0)
  141833. */
  141834. reset(): void;
  141835. /**
  141836. * Start the optimizer. By default it will try to reach a specific framerate
  141837. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141838. */
  141839. start(): void;
  141840. private _checkCurrentState;
  141841. /**
  141842. * Release all resources
  141843. */
  141844. dispose(): void;
  141845. /**
  141846. * Helper function to create a SceneOptimizer with one single line of code
  141847. * @param scene defines the scene to work on
  141848. * @param options defines the options to use with the SceneOptimizer
  141849. * @param onSuccess defines a callback to call on success
  141850. * @param onFailure defines a callback to call on failure
  141851. * @returns the new SceneOptimizer object
  141852. */
  141853. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141854. }
  141855. }
  141856. declare module BABYLON {
  141857. /**
  141858. * Class used to serialize a scene into a string
  141859. */
  141860. export class SceneSerializer {
  141861. /**
  141862. * Clear cache used by a previous serialization
  141863. */
  141864. static ClearCache(): void;
  141865. /**
  141866. * Serialize a scene into a JSON compatible object
  141867. * @param scene defines the scene to serialize
  141868. * @returns a JSON compatible object
  141869. */
  141870. static Serialize(scene: Scene): any;
  141871. /**
  141872. * Serialize a mesh into a JSON compatible object
  141873. * @param toSerialize defines the mesh to serialize
  141874. * @param withParents defines if parents must be serialized as well
  141875. * @param withChildren defines if children must be serialized as well
  141876. * @returns a JSON compatible object
  141877. */
  141878. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141879. }
  141880. }
  141881. declare module BABYLON {
  141882. /**
  141883. * Class used to host texture specific utilities
  141884. */
  141885. export class TextureTools {
  141886. /**
  141887. * Uses the GPU to create a copy texture rescaled at a given size
  141888. * @param texture Texture to copy from
  141889. * @param width defines the desired width
  141890. * @param height defines the desired height
  141891. * @param useBilinearMode defines if bilinear mode has to be used
  141892. * @return the generated texture
  141893. */
  141894. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141895. }
  141896. }
  141897. declare module BABYLON {
  141898. /**
  141899. * This represents the different options available for the video capture.
  141900. */
  141901. export interface VideoRecorderOptions {
  141902. /** Defines the mime type of the video. */
  141903. mimeType: string;
  141904. /** Defines the FPS the video should be recorded at. */
  141905. fps: number;
  141906. /** Defines the chunk size for the recording data. */
  141907. recordChunckSize: number;
  141908. /** The audio tracks to attach to the recording. */
  141909. audioTracks?: MediaStreamTrack[];
  141910. }
  141911. /**
  141912. * This can help with recording videos from BabylonJS.
  141913. * This is based on the available WebRTC functionalities of the browser.
  141914. *
  141915. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141916. */
  141917. export class VideoRecorder {
  141918. private static readonly _defaultOptions;
  141919. /**
  141920. * Returns whether or not the VideoRecorder is available in your browser.
  141921. * @param engine Defines the Babylon Engine.
  141922. * @returns true if supported otherwise false.
  141923. */
  141924. static IsSupported(engine: Engine): boolean;
  141925. private readonly _options;
  141926. private _canvas;
  141927. private _mediaRecorder;
  141928. private _recordedChunks;
  141929. private _fileName;
  141930. private _resolve;
  141931. private _reject;
  141932. /**
  141933. * True when a recording is already in progress.
  141934. */
  141935. get isRecording(): boolean;
  141936. /**
  141937. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141938. * @param engine Defines the BabylonJS Engine you wish to record.
  141939. * @param options Defines options that can be used to customize the capture.
  141940. */
  141941. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141942. /**
  141943. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141944. */
  141945. stopRecording(): void;
  141946. /**
  141947. * Starts recording the canvas for a max duration specified in parameters.
  141948. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141949. * If null no automatic download will start and you can rely on the promise to get the data back.
  141950. * @param maxDuration Defines the maximum recording time in seconds.
  141951. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141952. * @return A promise callback at the end of the recording with the video data in Blob.
  141953. */
  141954. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141955. /**
  141956. * Releases internal resources used during the recording.
  141957. */
  141958. dispose(): void;
  141959. private _handleDataAvailable;
  141960. private _handleError;
  141961. private _handleStop;
  141962. }
  141963. }
  141964. declare module BABYLON {
  141965. /**
  141966. * Class containing a set of static utilities functions for screenshots
  141967. */
  141968. export class ScreenshotTools {
  141969. /**
  141970. * Captures a screenshot of the current rendering
  141971. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141972. * @param engine defines the rendering engine
  141973. * @param camera defines the source camera
  141974. * @param size This parameter can be set to a single number or to an object with the
  141975. * following (optional) properties: precision, width, height. If a single number is passed,
  141976. * it will be used for both width and height. If an object is passed, the screenshot size
  141977. * will be derived from the parameters. The precision property is a multiplier allowing
  141978. * rendering at a higher or lower resolution
  141979. * @param successCallback defines the callback receives a single parameter which contains the
  141980. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141981. * src parameter of an <img> to display it
  141982. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141983. * Check your browser for supported MIME types
  141984. */
  141985. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141986. /**
  141987. * Captures a screenshot of the current rendering
  141988. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141989. * @param engine defines the rendering engine
  141990. * @param camera defines the source camera
  141991. * @param size This parameter can be set to a single number or to an object with the
  141992. * following (optional) properties: precision, width, height. If a single number is passed,
  141993. * it will be used for both width and height. If an object is passed, the screenshot size
  141994. * will be derived from the parameters. The precision property is a multiplier allowing
  141995. * rendering at a higher or lower resolution
  141996. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141997. * Check your browser for supported MIME types
  141998. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141999. * to the src parameter of an <img> to display it
  142000. */
  142001. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  142002. /**
  142003. * Generates an image screenshot from the specified camera.
  142004. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142005. * @param engine The engine to use for rendering
  142006. * @param camera The camera to use for rendering
  142007. * @param size This parameter can be set to a single number or to an object with the
  142008. * following (optional) properties: precision, width, height. If a single number is passed,
  142009. * it will be used for both width and height. If an object is passed, the screenshot size
  142010. * will be derived from the parameters. The precision property is a multiplier allowing
  142011. * rendering at a higher or lower resolution
  142012. * @param successCallback The callback receives a single parameter which contains the
  142013. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  142014. * src parameter of an <img> to display it
  142015. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142016. * Check your browser for supported MIME types
  142017. * @param samples Texture samples (default: 1)
  142018. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142019. * @param fileName A name for for the downloaded file.
  142020. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142021. */
  142022. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  142023. /**
  142024. * Generates an image screenshot from the specified camera.
  142025. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  142026. * @param engine The engine to use for rendering
  142027. * @param camera The camera to use for rendering
  142028. * @param size This parameter can be set to a single number or to an object with the
  142029. * following (optional) properties: precision, width, height. If a single number is passed,
  142030. * it will be used for both width and height. If an object is passed, the screenshot size
  142031. * will be derived from the parameters. The precision property is a multiplier allowing
  142032. * rendering at a higher or lower resolution
  142033. * @param mimeType The MIME type of the screenshot image (default: image/png).
  142034. * Check your browser for supported MIME types
  142035. * @param samples Texture samples (default: 1)
  142036. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  142037. * @param fileName A name for for the downloaded file.
  142038. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  142039. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  142040. * to the src parameter of an <img> to display it
  142041. */
  142042. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  142043. /**
  142044. * Gets height and width for screenshot size
  142045. * @private
  142046. */
  142047. private static _getScreenshotSize;
  142048. }
  142049. }
  142050. declare module BABYLON {
  142051. /**
  142052. * Interface for a data buffer
  142053. */
  142054. export interface IDataBuffer {
  142055. /**
  142056. * Reads bytes from the data buffer.
  142057. * @param byteOffset The byte offset to read
  142058. * @param byteLength The byte length to read
  142059. * @returns A promise that resolves when the bytes are read
  142060. */
  142061. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  142062. /**
  142063. * The byte length of the buffer.
  142064. */
  142065. readonly byteLength: number;
  142066. }
  142067. /**
  142068. * Utility class for reading from a data buffer
  142069. */
  142070. export class DataReader {
  142071. /**
  142072. * The data buffer associated with this data reader.
  142073. */
  142074. readonly buffer: IDataBuffer;
  142075. /**
  142076. * The current byte offset from the beginning of the data buffer.
  142077. */
  142078. byteOffset: number;
  142079. private _dataView;
  142080. private _dataByteOffset;
  142081. /**
  142082. * Constructor
  142083. * @param buffer The buffer to read
  142084. */
  142085. constructor(buffer: IDataBuffer);
  142086. /**
  142087. * Loads the given byte length.
  142088. * @param byteLength The byte length to load
  142089. * @returns A promise that resolves when the load is complete
  142090. */
  142091. loadAsync(byteLength: number): Promise<void>;
  142092. /**
  142093. * Read a unsigned 32-bit integer from the currently loaded data range.
  142094. * @returns The 32-bit integer read
  142095. */
  142096. readUint32(): number;
  142097. /**
  142098. * Read a byte array from the currently loaded data range.
  142099. * @param byteLength The byte length to read
  142100. * @returns The byte array read
  142101. */
  142102. readUint8Array(byteLength: number): Uint8Array;
  142103. /**
  142104. * Read a string from the currently loaded data range.
  142105. * @param byteLength The byte length to read
  142106. * @returns The string read
  142107. */
  142108. readString(byteLength: number): string;
  142109. /**
  142110. * Skips the given byte length the currently loaded data range.
  142111. * @param byteLength The byte length to skip
  142112. */
  142113. skipBytes(byteLength: number): void;
  142114. }
  142115. }
  142116. declare module BABYLON {
  142117. /**
  142118. * Class for storing data to local storage if available or in-memory storage otherwise
  142119. */
  142120. export class DataStorage {
  142121. private static _Storage;
  142122. private static _GetStorage;
  142123. /**
  142124. * Reads a string from the data storage
  142125. * @param key The key to read
  142126. * @param defaultValue The value if the key doesn't exist
  142127. * @returns The string value
  142128. */
  142129. static ReadString(key: string, defaultValue: string): string;
  142130. /**
  142131. * Writes a string to the data storage
  142132. * @param key The key to write
  142133. * @param value The value to write
  142134. */
  142135. static WriteString(key: string, value: string): void;
  142136. /**
  142137. * Reads a boolean from the data storage
  142138. * @param key The key to read
  142139. * @param defaultValue The value if the key doesn't exist
  142140. * @returns The boolean value
  142141. */
  142142. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  142143. /**
  142144. * Writes a boolean to the data storage
  142145. * @param key The key to write
  142146. * @param value The value to write
  142147. */
  142148. static WriteBoolean(key: string, value: boolean): void;
  142149. /**
  142150. * Reads a number from the data storage
  142151. * @param key The key to read
  142152. * @param defaultValue The value if the key doesn't exist
  142153. * @returns The number value
  142154. */
  142155. static ReadNumber(key: string, defaultValue: number): number;
  142156. /**
  142157. * Writes a number to the data storage
  142158. * @param key The key to write
  142159. * @param value The value to write
  142160. */
  142161. static WriteNumber(key: string, value: number): void;
  142162. }
  142163. }
  142164. declare module BABYLON {
  142165. /**
  142166. * Options used for hit testing
  142167. */
  142168. export interface IWebXRHitTestOptions {
  142169. /**
  142170. * Only test when user interacted with the scene. Default - hit test every frame
  142171. */
  142172. testOnPointerDownOnly?: boolean;
  142173. /**
  142174. * The node to use to transform the local results to world coordinates
  142175. */
  142176. worldParentNode?: TransformNode;
  142177. }
  142178. /**
  142179. * Interface defining the babylon result of raycasting/hit-test
  142180. */
  142181. export interface IWebXRHitResult {
  142182. /**
  142183. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142184. */
  142185. transformationMatrix: Matrix;
  142186. /**
  142187. * The native hit test result
  142188. */
  142189. xrHitResult: XRHitResult;
  142190. }
  142191. /**
  142192. * The currently-working hit-test module.
  142193. * Hit test (or Ray-casting) is used to interact with the real world.
  142194. * For further information read here - https://github.com/immersive-web/hit-test
  142195. */
  142196. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142197. /**
  142198. * options to use when constructing this feature
  142199. */
  142200. readonly options: IWebXRHitTestOptions;
  142201. private _direction;
  142202. private _mat;
  142203. private _onSelectEnabled;
  142204. private _origin;
  142205. /**
  142206. * The module's name
  142207. */
  142208. static readonly Name: string;
  142209. /**
  142210. * The (Babylon) version of this module.
  142211. * This is an integer representing the implementation version.
  142212. * This number does not correspond to the WebXR specs version
  142213. */
  142214. static readonly Version: number;
  142215. /**
  142216. * Populated with the last native XR Hit Results
  142217. */
  142218. lastNativeXRHitResults: XRHitResult[];
  142219. /**
  142220. * Triggered when new babylon (transformed) hit test results are available
  142221. */
  142222. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142223. /**
  142224. * Creates a new instance of the (legacy version) hit test feature
  142225. * @param _xrSessionManager an instance of WebXRSessionManager
  142226. * @param options options to use when constructing this feature
  142227. */
  142228. constructor(_xrSessionManager: WebXRSessionManager,
  142229. /**
  142230. * options to use when constructing this feature
  142231. */
  142232. options?: IWebXRHitTestOptions);
  142233. /**
  142234. * execute a hit test with an XR Ray
  142235. *
  142236. * @param xrSession a native xrSession that will execute this hit test
  142237. * @param xrRay the ray (position and direction) to use for ray-casting
  142238. * @param referenceSpace native XR reference space to use for the hit-test
  142239. * @param filter filter function that will filter the results
  142240. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142241. */
  142242. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142243. /**
  142244. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142245. * @param event the (select) event to use to select with
  142246. * @param referenceSpace the reference space to use for this hit test
  142247. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142248. */
  142249. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142250. /**
  142251. * attach this feature
  142252. * Will usually be called by the features manager
  142253. *
  142254. * @returns true if successful.
  142255. */
  142256. attach(): boolean;
  142257. /**
  142258. * detach this feature.
  142259. * Will usually be called by the features manager
  142260. *
  142261. * @returns true if successful.
  142262. */
  142263. detach(): boolean;
  142264. /**
  142265. * Dispose this feature and all of the resources attached
  142266. */
  142267. dispose(): void;
  142268. protected _onXRFrame(frame: XRFrame): void;
  142269. private _onHitTestResults;
  142270. private _onSelect;
  142271. }
  142272. }
  142273. declare module BABYLON {
  142274. /**
  142275. * Options used in the plane detector module
  142276. */
  142277. export interface IWebXRPlaneDetectorOptions {
  142278. /**
  142279. * The node to use to transform the local results to world coordinates
  142280. */
  142281. worldParentNode?: TransformNode;
  142282. }
  142283. /**
  142284. * A babylon interface for a WebXR plane.
  142285. * A Plane is actually a polygon, built from N points in space
  142286. *
  142287. * Supported in chrome 79, not supported in canary 81 ATM
  142288. */
  142289. export interface IWebXRPlane {
  142290. /**
  142291. * a babylon-assigned ID for this polygon
  142292. */
  142293. id: number;
  142294. /**
  142295. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142296. */
  142297. polygonDefinition: Array<Vector3>;
  142298. /**
  142299. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142300. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142301. */
  142302. transformationMatrix: Matrix;
  142303. /**
  142304. * the native xr-plane object
  142305. */
  142306. xrPlane: XRPlane;
  142307. }
  142308. /**
  142309. * The plane detector is used to detect planes in the real world when in AR
  142310. * For more information see https://github.com/immersive-web/real-world-geometry/
  142311. */
  142312. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142313. private _options;
  142314. private _detectedPlanes;
  142315. private _enabled;
  142316. private _lastFrameDetected;
  142317. /**
  142318. * The module's name
  142319. */
  142320. static readonly Name: string;
  142321. /**
  142322. * The (Babylon) version of this module.
  142323. * This is an integer representing the implementation version.
  142324. * This number does not correspond to the WebXR specs version
  142325. */
  142326. static readonly Version: number;
  142327. /**
  142328. * Observers registered here will be executed when a new plane was added to the session
  142329. */
  142330. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142331. /**
  142332. * Observers registered here will be executed when a plane is no longer detected in the session
  142333. */
  142334. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142335. /**
  142336. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142337. * This can execute N times every frame
  142338. */
  142339. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142340. /**
  142341. * construct a new Plane Detector
  142342. * @param _xrSessionManager an instance of xr Session manager
  142343. * @param _options configuration to use when constructing this feature
  142344. */
  142345. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142346. /**
  142347. * Dispose this feature and all of the resources attached
  142348. */
  142349. dispose(): void;
  142350. protected _onXRFrame(frame: XRFrame): void;
  142351. private _init;
  142352. private _updatePlaneWithXRPlane;
  142353. /**
  142354. * avoiding using Array.find for global support.
  142355. * @param xrPlane the plane to find in the array
  142356. */
  142357. private findIndexInPlaneArray;
  142358. }
  142359. }
  142360. declare module BABYLON {
  142361. /**
  142362. * Configuration options of the anchor system
  142363. */
  142364. export interface IWebXRAnchorSystemOptions {
  142365. /**
  142366. * Should a new anchor be added every time a select event is triggered
  142367. */
  142368. addAnchorOnSelect?: boolean;
  142369. /**
  142370. * should the anchor system use plane detection.
  142371. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142372. */
  142373. usePlaneDetection?: boolean;
  142374. /**
  142375. * a node that will be used to convert local to world coordinates
  142376. */
  142377. worldParentNode?: TransformNode;
  142378. }
  142379. /**
  142380. * A babylon container for an XR Anchor
  142381. */
  142382. export interface IWebXRAnchor {
  142383. /**
  142384. * A babylon-assigned ID for this anchor
  142385. */
  142386. id: number;
  142387. /**
  142388. * Transformation matrix to apply to an object attached to this anchor
  142389. */
  142390. transformationMatrix: Matrix;
  142391. /**
  142392. * The native anchor object
  142393. */
  142394. xrAnchor: XRAnchor;
  142395. }
  142396. /**
  142397. * An implementation of the anchor system of WebXR.
  142398. * Note that the current documented implementation is not available in any browser. Future implementations
  142399. * will use the frame to create an anchor and not the session or a detected plane
  142400. * For further information see https://github.com/immersive-web/anchors/
  142401. */
  142402. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142403. private _options;
  142404. private _enabled;
  142405. private _hitTestModule;
  142406. private _lastFrameDetected;
  142407. private _onSelect;
  142408. private _planeDetector;
  142409. private _trackedAnchors;
  142410. /**
  142411. * The module's name
  142412. */
  142413. static readonly Name: string;
  142414. /**
  142415. * The (Babylon) version of this module.
  142416. * This is an integer representing the implementation version.
  142417. * This number does not correspond to the WebXR specs version
  142418. */
  142419. static readonly Version: number;
  142420. /**
  142421. * Observers registered here will be executed when a new anchor was added to the session
  142422. */
  142423. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142424. /**
  142425. * Observers registered here will be executed when an anchor was removed from the session
  142426. */
  142427. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142428. /**
  142429. * Observers registered here will be executed when an existing anchor updates
  142430. * This can execute N times every frame
  142431. */
  142432. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142433. /**
  142434. * constructs a new anchor system
  142435. * @param _xrSessionManager an instance of WebXRSessionManager
  142436. * @param _options configuration object for this feature
  142437. */
  142438. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142439. /**
  142440. * Add anchor at a specific XR point.
  142441. *
  142442. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142443. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142444. * @returns a promise the fulfills when the anchor was created
  142445. */
  142446. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142447. /**
  142448. * attach this feature
  142449. * Will usually be called by the features manager
  142450. *
  142451. * @returns true if successful.
  142452. */
  142453. attach(): boolean;
  142454. /**
  142455. * detach this feature.
  142456. * Will usually be called by the features manager
  142457. *
  142458. * @returns true if successful.
  142459. */
  142460. detach(): boolean;
  142461. /**
  142462. * Dispose this feature and all of the resources attached
  142463. */
  142464. dispose(): void;
  142465. /**
  142466. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142467. * @param hitTestModule the hit-test module to use.
  142468. */
  142469. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142470. /**
  142471. * set the plane detector to use in order to create anchors from frames
  142472. * @param planeDetector the plane-detector module to use
  142473. * @param enable enable plane-anchors. default is true
  142474. */
  142475. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142476. protected _onXRFrame(frame: XRFrame): void;
  142477. /**
  142478. * avoiding using Array.find for global support.
  142479. * @param xrAnchor the plane to find in the array
  142480. */
  142481. private _findIndexInAnchorArray;
  142482. private _updateAnchorWithXRFrame;
  142483. }
  142484. }
  142485. declare module BABYLON {
  142486. /**
  142487. * Options interface for the background remover plugin
  142488. */
  142489. export interface IWebXRBackgroundRemoverOptions {
  142490. /**
  142491. * Further background meshes to disable when entering AR
  142492. */
  142493. backgroundMeshes?: AbstractMesh[];
  142494. /**
  142495. * flags to configure the removal of the environment helper.
  142496. * If not set, the entire background will be removed. If set, flags should be set as well.
  142497. */
  142498. environmentHelperRemovalFlags?: {
  142499. /**
  142500. * Should the skybox be removed (default false)
  142501. */
  142502. skyBox?: boolean;
  142503. /**
  142504. * Should the ground be removed (default false)
  142505. */
  142506. ground?: boolean;
  142507. };
  142508. /**
  142509. * don't disable the environment helper
  142510. */
  142511. ignoreEnvironmentHelper?: boolean;
  142512. }
  142513. /**
  142514. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142515. */
  142516. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142517. /**
  142518. * read-only options to be used in this module
  142519. */
  142520. readonly options: IWebXRBackgroundRemoverOptions;
  142521. /**
  142522. * The module's name
  142523. */
  142524. static readonly Name: string;
  142525. /**
  142526. * The (Babylon) version of this module.
  142527. * This is an integer representing the implementation version.
  142528. * This number does not correspond to the WebXR specs version
  142529. */
  142530. static readonly Version: number;
  142531. /**
  142532. * registered observers will be triggered when the background state changes
  142533. */
  142534. onBackgroundStateChangedObservable: Observable<boolean>;
  142535. /**
  142536. * constructs a new background remover module
  142537. * @param _xrSessionManager the session manager for this module
  142538. * @param options read-only options to be used in this module
  142539. */
  142540. constructor(_xrSessionManager: WebXRSessionManager,
  142541. /**
  142542. * read-only options to be used in this module
  142543. */
  142544. options?: IWebXRBackgroundRemoverOptions);
  142545. /**
  142546. * attach this feature
  142547. * Will usually be called by the features manager
  142548. *
  142549. * @returns true if successful.
  142550. */
  142551. attach(): boolean;
  142552. /**
  142553. * detach this feature.
  142554. * Will usually be called by the features manager
  142555. *
  142556. * @returns true if successful.
  142557. */
  142558. detach(): boolean;
  142559. /**
  142560. * Dispose this feature and all of the resources attached
  142561. */
  142562. dispose(): void;
  142563. protected _onXRFrame(_xrFrame: XRFrame): void;
  142564. private _setBackgroundState;
  142565. }
  142566. }
  142567. declare module BABYLON {
  142568. /**
  142569. * Options for the controller physics feature
  142570. */
  142571. export class IWebXRControllerPhysicsOptions {
  142572. /**
  142573. * Should the headset get its own impostor
  142574. */
  142575. enableHeadsetImpostor?: boolean;
  142576. /**
  142577. * Optional parameters for the headset impostor
  142578. */
  142579. headsetImpostorParams?: {
  142580. /**
  142581. * The type of impostor to create. Default is sphere
  142582. */
  142583. impostorType: number;
  142584. /**
  142585. * the size of the impostor. Defaults to 10cm
  142586. */
  142587. impostorSize?: number | {
  142588. width: number;
  142589. height: number;
  142590. depth: number;
  142591. };
  142592. /**
  142593. * Friction definitions
  142594. */
  142595. friction?: number;
  142596. /**
  142597. * Restitution
  142598. */
  142599. restitution?: number;
  142600. };
  142601. /**
  142602. * The physics properties of the future impostors
  142603. */
  142604. physicsProperties?: {
  142605. /**
  142606. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142607. * Note that this requires a physics engine that supports mesh impostors!
  142608. */
  142609. useControllerMesh?: boolean;
  142610. /**
  142611. * The type of impostor to create. Default is sphere
  142612. */
  142613. impostorType?: number;
  142614. /**
  142615. * the size of the impostor. Defaults to 10cm
  142616. */
  142617. impostorSize?: number | {
  142618. width: number;
  142619. height: number;
  142620. depth: number;
  142621. };
  142622. /**
  142623. * Friction definitions
  142624. */
  142625. friction?: number;
  142626. /**
  142627. * Restitution
  142628. */
  142629. restitution?: number;
  142630. };
  142631. /**
  142632. * the xr input to use with this pointer selection
  142633. */
  142634. xrInput: WebXRInput;
  142635. }
  142636. /**
  142637. * Add physics impostor to your webxr controllers,
  142638. * including naive calculation of their linear and angular velocity
  142639. */
  142640. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142641. private readonly _options;
  142642. private _attachController;
  142643. private _controllers;
  142644. private _debugMode;
  142645. private _delta;
  142646. private _headsetImpostor?;
  142647. private _headsetMesh?;
  142648. private _lastTimestamp;
  142649. private _tmpQuaternion;
  142650. private _tmpVector;
  142651. /**
  142652. * The module's name
  142653. */
  142654. static readonly Name: string;
  142655. /**
  142656. * The (Babylon) version of this module.
  142657. * This is an integer representing the implementation version.
  142658. * This number does not correspond to the webxr specs version
  142659. */
  142660. static readonly Version: number;
  142661. /**
  142662. * Construct a new Controller Physics Feature
  142663. * @param _xrSessionManager the corresponding xr session manager
  142664. * @param _options options to create this feature with
  142665. */
  142666. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142667. /**
  142668. * @hidden
  142669. * enable debugging - will show console outputs and the impostor mesh
  142670. */
  142671. _enablePhysicsDebug(): void;
  142672. /**
  142673. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142674. * @param xrController the controller to add
  142675. */
  142676. addController(xrController: WebXRInputSource): void;
  142677. /**
  142678. * attach this feature
  142679. * Will usually be called by the features manager
  142680. *
  142681. * @returns true if successful.
  142682. */
  142683. attach(): boolean;
  142684. /**
  142685. * detach this feature.
  142686. * Will usually be called by the features manager
  142687. *
  142688. * @returns true if successful.
  142689. */
  142690. detach(): boolean;
  142691. /**
  142692. * Get the headset impostor, if enabled
  142693. * @returns the impostor
  142694. */
  142695. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142696. /**
  142697. * Get the physics impostor of a specific controller.
  142698. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142699. * @param controller the controller or the controller id of which to get the impostor
  142700. * @returns the impostor or null
  142701. */
  142702. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142703. /**
  142704. * Update the physics properties provided in the constructor
  142705. * @param newProperties the new properties object
  142706. */
  142707. setPhysicsProperties(newProperties: {
  142708. impostorType?: number;
  142709. impostorSize?: number | {
  142710. width: number;
  142711. height: number;
  142712. depth: number;
  142713. };
  142714. friction?: number;
  142715. restitution?: number;
  142716. }): void;
  142717. protected _onXRFrame(_xrFrame: any): void;
  142718. private _detachController;
  142719. }
  142720. }
  142721. declare module BABYLON {
  142722. /**
  142723. * The motion controller class for all microsoft mixed reality controllers
  142724. */
  142725. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142726. protected readonly _mapping: {
  142727. defaultButton: {
  142728. "valueNodeName": string;
  142729. "unpressedNodeName": string;
  142730. "pressedNodeName": string;
  142731. };
  142732. defaultAxis: {
  142733. "valueNodeName": string;
  142734. "minNodeName": string;
  142735. "maxNodeName": string;
  142736. };
  142737. buttons: {
  142738. "xr-standard-trigger": {
  142739. "rootNodeName": string;
  142740. "componentProperty": string;
  142741. "states": string[];
  142742. };
  142743. "xr-standard-squeeze": {
  142744. "rootNodeName": string;
  142745. "componentProperty": string;
  142746. "states": string[];
  142747. };
  142748. "xr-standard-touchpad": {
  142749. "rootNodeName": string;
  142750. "labelAnchorNodeName": string;
  142751. "touchPointNodeName": string;
  142752. };
  142753. "xr-standard-thumbstick": {
  142754. "rootNodeName": string;
  142755. "componentProperty": string;
  142756. "states": string[];
  142757. };
  142758. };
  142759. axes: {
  142760. "xr-standard-touchpad": {
  142761. "x-axis": {
  142762. "rootNodeName": string;
  142763. };
  142764. "y-axis": {
  142765. "rootNodeName": string;
  142766. };
  142767. };
  142768. "xr-standard-thumbstick": {
  142769. "x-axis": {
  142770. "rootNodeName": string;
  142771. };
  142772. "y-axis": {
  142773. "rootNodeName": string;
  142774. };
  142775. };
  142776. };
  142777. };
  142778. /**
  142779. * The base url used to load the left and right controller models
  142780. */
  142781. static MODEL_BASE_URL: string;
  142782. /**
  142783. * The name of the left controller model file
  142784. */
  142785. static MODEL_LEFT_FILENAME: string;
  142786. /**
  142787. * The name of the right controller model file
  142788. */
  142789. static MODEL_RIGHT_FILENAME: string;
  142790. profileId: string;
  142791. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142792. protected _getFilenameAndPath(): {
  142793. filename: string;
  142794. path: string;
  142795. };
  142796. protected _getModelLoadingConstraints(): boolean;
  142797. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142798. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142799. protected _updateModel(): void;
  142800. }
  142801. }
  142802. declare module BABYLON {
  142803. /**
  142804. * The motion controller class for oculus touch (quest, rift).
  142805. * This class supports legacy mapping as well the standard xr mapping
  142806. */
  142807. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142808. private _forceLegacyControllers;
  142809. private _modelRootNode;
  142810. /**
  142811. * The base url used to load the left and right controller models
  142812. */
  142813. static MODEL_BASE_URL: string;
  142814. /**
  142815. * The name of the left controller model file
  142816. */
  142817. static MODEL_LEFT_FILENAME: string;
  142818. /**
  142819. * The name of the right controller model file
  142820. */
  142821. static MODEL_RIGHT_FILENAME: string;
  142822. /**
  142823. * Base Url for the Quest controller model.
  142824. */
  142825. static QUEST_MODEL_BASE_URL: string;
  142826. profileId: string;
  142827. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142828. protected _getFilenameAndPath(): {
  142829. filename: string;
  142830. path: string;
  142831. };
  142832. protected _getModelLoadingConstraints(): boolean;
  142833. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142834. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142835. protected _updateModel(): void;
  142836. /**
  142837. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142838. * between the touch and touch 2.
  142839. */
  142840. private _isQuest;
  142841. }
  142842. }
  142843. declare module BABYLON {
  142844. /**
  142845. * The motion controller class for the standard HTC-Vive controllers
  142846. */
  142847. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142848. private _modelRootNode;
  142849. /**
  142850. * The base url used to load the left and right controller models
  142851. */
  142852. static MODEL_BASE_URL: string;
  142853. /**
  142854. * File name for the controller model.
  142855. */
  142856. static MODEL_FILENAME: string;
  142857. profileId: string;
  142858. /**
  142859. * Create a new Vive motion controller object
  142860. * @param scene the scene to use to create this controller
  142861. * @param gamepadObject the corresponding gamepad object
  142862. * @param handness the handness of the controller
  142863. */
  142864. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142865. protected _getFilenameAndPath(): {
  142866. filename: string;
  142867. path: string;
  142868. };
  142869. protected _getModelLoadingConstraints(): boolean;
  142870. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142871. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142872. protected _updateModel(): void;
  142873. }
  142874. }
  142875. declare module BABYLON {
  142876. /**
  142877. * A cursor which tracks a point on a path
  142878. */
  142879. export class PathCursor {
  142880. private path;
  142881. /**
  142882. * Stores path cursor callbacks for when an onchange event is triggered
  142883. */
  142884. private _onchange;
  142885. /**
  142886. * The value of the path cursor
  142887. */
  142888. value: number;
  142889. /**
  142890. * The animation array of the path cursor
  142891. */
  142892. animations: Animation[];
  142893. /**
  142894. * Initializes the path cursor
  142895. * @param path The path to track
  142896. */
  142897. constructor(path: Path2);
  142898. /**
  142899. * Gets the cursor point on the path
  142900. * @returns A point on the path cursor at the cursor location
  142901. */
  142902. getPoint(): Vector3;
  142903. /**
  142904. * Moves the cursor ahead by the step amount
  142905. * @param step The amount to move the cursor forward
  142906. * @returns This path cursor
  142907. */
  142908. moveAhead(step?: number): PathCursor;
  142909. /**
  142910. * Moves the cursor behind by the step amount
  142911. * @param step The amount to move the cursor back
  142912. * @returns This path cursor
  142913. */
  142914. moveBack(step?: number): PathCursor;
  142915. /**
  142916. * Moves the cursor by the step amount
  142917. * If the step amount is greater than one, an exception is thrown
  142918. * @param step The amount to move the cursor
  142919. * @returns This path cursor
  142920. */
  142921. move(step: number): PathCursor;
  142922. /**
  142923. * Ensures that the value is limited between zero and one
  142924. * @returns This path cursor
  142925. */
  142926. private ensureLimits;
  142927. /**
  142928. * Runs onchange callbacks on change (used by the animation engine)
  142929. * @returns This path cursor
  142930. */
  142931. private raiseOnChange;
  142932. /**
  142933. * Executes a function on change
  142934. * @param f A path cursor onchange callback
  142935. * @returns This path cursor
  142936. */
  142937. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142938. }
  142939. }
  142940. declare module BABYLON {
  142941. /** @hidden */
  142942. export var blurPixelShader: {
  142943. name: string;
  142944. shader: string;
  142945. };
  142946. }
  142947. declare module BABYLON {
  142948. /** @hidden */
  142949. export var pointCloudVertexDeclaration: {
  142950. name: string;
  142951. shader: string;
  142952. };
  142953. }
  142954. // Mixins
  142955. interface Window {
  142956. mozIndexedDB: IDBFactory;
  142957. webkitIndexedDB: IDBFactory;
  142958. msIndexedDB: IDBFactory;
  142959. webkitURL: typeof URL;
  142960. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142961. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142962. WebGLRenderingContext: WebGLRenderingContext;
  142963. MSGesture: MSGesture;
  142964. CANNON: any;
  142965. AudioContext: AudioContext;
  142966. webkitAudioContext: AudioContext;
  142967. PointerEvent: any;
  142968. Math: Math;
  142969. Uint8Array: Uint8ArrayConstructor;
  142970. Float32Array: Float32ArrayConstructor;
  142971. mozURL: typeof URL;
  142972. msURL: typeof URL;
  142973. VRFrameData: any; // WebVR, from specs 1.1
  142974. DracoDecoderModule: any;
  142975. setImmediate(handler: (...args: any[]) => void): number;
  142976. }
  142977. interface HTMLCanvasElement {
  142978. requestPointerLock(): void;
  142979. msRequestPointerLock?(): void;
  142980. mozRequestPointerLock?(): void;
  142981. webkitRequestPointerLock?(): void;
  142982. /** Track wether a record is in progress */
  142983. isRecording: boolean;
  142984. /** Capture Stream method defined by some browsers */
  142985. captureStream(fps?: number): MediaStream;
  142986. }
  142987. interface CanvasRenderingContext2D {
  142988. msImageSmoothingEnabled: boolean;
  142989. }
  142990. interface MouseEvent {
  142991. mozMovementX: number;
  142992. mozMovementY: number;
  142993. webkitMovementX: number;
  142994. webkitMovementY: number;
  142995. msMovementX: number;
  142996. msMovementY: number;
  142997. }
  142998. interface Navigator {
  142999. mozGetVRDevices: (any: any) => any;
  143000. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143001. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143002. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  143003. webkitGetGamepads(): Gamepad[];
  143004. msGetGamepads(): Gamepad[];
  143005. webkitGamepads(): Gamepad[];
  143006. }
  143007. interface HTMLVideoElement {
  143008. mozSrcObject: any;
  143009. }
  143010. interface Math {
  143011. fround(x: number): number;
  143012. imul(a: number, b: number): number;
  143013. }
  143014. interface WebGLRenderingContext {
  143015. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  143016. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  143017. vertexAttribDivisor(index: number, divisor: number): void;
  143018. createVertexArray(): any;
  143019. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  143020. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  143021. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  143022. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  143023. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  143024. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  143025. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  143026. // Queries
  143027. createQuery(): WebGLQuery;
  143028. deleteQuery(query: WebGLQuery): void;
  143029. beginQuery(target: number, query: WebGLQuery): void;
  143030. endQuery(target: number): void;
  143031. getQueryParameter(query: WebGLQuery, pname: number): any;
  143032. getQuery(target: number, pname: number): any;
  143033. MAX_SAMPLES: number;
  143034. RGBA8: number;
  143035. READ_FRAMEBUFFER: number;
  143036. DRAW_FRAMEBUFFER: number;
  143037. UNIFORM_BUFFER: number;
  143038. HALF_FLOAT_OES: number;
  143039. RGBA16F: number;
  143040. RGBA32F: number;
  143041. R32F: number;
  143042. RG32F: number;
  143043. RGB32F: number;
  143044. R16F: number;
  143045. RG16F: number;
  143046. RGB16F: number;
  143047. RED: number;
  143048. RG: number;
  143049. R8: number;
  143050. RG8: number;
  143051. UNSIGNED_INT_24_8: number;
  143052. DEPTH24_STENCIL8: number;
  143053. MIN: number;
  143054. MAX: number;
  143055. /* Multiple Render Targets */
  143056. drawBuffers(buffers: number[]): void;
  143057. readBuffer(src: number): void;
  143058. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  143059. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  143060. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  143061. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  143062. // Occlusion Query
  143063. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  143064. ANY_SAMPLES_PASSED: number;
  143065. QUERY_RESULT_AVAILABLE: number;
  143066. QUERY_RESULT: number;
  143067. }
  143068. interface WebGLProgram {
  143069. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  143070. }
  143071. interface EXT_disjoint_timer_query {
  143072. QUERY_COUNTER_BITS_EXT: number;
  143073. TIME_ELAPSED_EXT: number;
  143074. TIMESTAMP_EXT: number;
  143075. GPU_DISJOINT_EXT: number;
  143076. QUERY_RESULT_EXT: number;
  143077. QUERY_RESULT_AVAILABLE_EXT: number;
  143078. queryCounterEXT(query: WebGLQuery, target: number): void;
  143079. createQueryEXT(): WebGLQuery;
  143080. beginQueryEXT(target: number, query: WebGLQuery): void;
  143081. endQueryEXT(target: number): void;
  143082. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  143083. deleteQueryEXT(query: WebGLQuery): void;
  143084. }
  143085. interface WebGLUniformLocation {
  143086. _currentState: any;
  143087. }
  143088. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  143089. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  143090. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  143091. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143092. interface WebGLRenderingContext {
  143093. readonly RASTERIZER_DISCARD: number;
  143094. readonly DEPTH_COMPONENT24: number;
  143095. readonly TEXTURE_3D: number;
  143096. readonly TEXTURE_2D_ARRAY: number;
  143097. readonly TEXTURE_COMPARE_FUNC: number;
  143098. readonly TEXTURE_COMPARE_MODE: number;
  143099. readonly COMPARE_REF_TO_TEXTURE: number;
  143100. readonly TEXTURE_WRAP_R: number;
  143101. readonly HALF_FLOAT: number;
  143102. readonly RGB8: number;
  143103. readonly RED_INTEGER: number;
  143104. readonly RG_INTEGER: number;
  143105. readonly RGB_INTEGER: number;
  143106. readonly RGBA_INTEGER: number;
  143107. readonly R8_SNORM: number;
  143108. readonly RG8_SNORM: number;
  143109. readonly RGB8_SNORM: number;
  143110. readonly RGBA8_SNORM: number;
  143111. readonly R8I: number;
  143112. readonly RG8I: number;
  143113. readonly RGB8I: number;
  143114. readonly RGBA8I: number;
  143115. readonly R8UI: number;
  143116. readonly RG8UI: number;
  143117. readonly RGB8UI: number;
  143118. readonly RGBA8UI: number;
  143119. readonly R16I: number;
  143120. readonly RG16I: number;
  143121. readonly RGB16I: number;
  143122. readonly RGBA16I: number;
  143123. readonly R16UI: number;
  143124. readonly RG16UI: number;
  143125. readonly RGB16UI: number;
  143126. readonly RGBA16UI: number;
  143127. readonly R32I: number;
  143128. readonly RG32I: number;
  143129. readonly RGB32I: number;
  143130. readonly RGBA32I: number;
  143131. readonly R32UI: number;
  143132. readonly RG32UI: number;
  143133. readonly RGB32UI: number;
  143134. readonly RGBA32UI: number;
  143135. readonly RGB10_A2UI: number;
  143136. readonly R11F_G11F_B10F: number;
  143137. readonly RGB9_E5: number;
  143138. readonly RGB10_A2: number;
  143139. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  143140. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  143141. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  143142. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  143143. readonly DEPTH_COMPONENT32F: number;
  143144. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  143145. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  143146. 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;
  143147. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  143148. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  143149. readonly TRANSFORM_FEEDBACK: number;
  143150. readonly INTERLEAVED_ATTRIBS: number;
  143151. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  143152. createTransformFeedback(): WebGLTransformFeedback;
  143153. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143154. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143155. beginTransformFeedback(primitiveMode: number): void;
  143156. endTransformFeedback(): void;
  143157. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143158. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143159. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143160. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143161. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143162. }
  143163. interface ImageBitmap {
  143164. readonly width: number;
  143165. readonly height: number;
  143166. close(): void;
  143167. }
  143168. interface WebGLQuery extends WebGLObject {
  143169. }
  143170. declare var WebGLQuery: {
  143171. prototype: WebGLQuery;
  143172. new(): WebGLQuery;
  143173. };
  143174. interface WebGLSampler extends WebGLObject {
  143175. }
  143176. declare var WebGLSampler: {
  143177. prototype: WebGLSampler;
  143178. new(): WebGLSampler;
  143179. };
  143180. interface WebGLSync extends WebGLObject {
  143181. }
  143182. declare var WebGLSync: {
  143183. prototype: WebGLSync;
  143184. new(): WebGLSync;
  143185. };
  143186. interface WebGLTransformFeedback extends WebGLObject {
  143187. }
  143188. declare var WebGLTransformFeedback: {
  143189. prototype: WebGLTransformFeedback;
  143190. new(): WebGLTransformFeedback;
  143191. };
  143192. interface WebGLVertexArrayObject extends WebGLObject {
  143193. }
  143194. declare var WebGLVertexArrayObject: {
  143195. prototype: WebGLVertexArrayObject;
  143196. new(): WebGLVertexArrayObject;
  143197. };
  143198. // Type definitions for WebVR API
  143199. // Project: https://w3c.github.io/webvr/
  143200. // Definitions by: six a <https://github.com/lostfictions>
  143201. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143202. interface VRDisplay extends EventTarget {
  143203. /**
  143204. * Dictionary of capabilities describing the VRDisplay.
  143205. */
  143206. readonly capabilities: VRDisplayCapabilities;
  143207. /**
  143208. * z-depth defining the far plane of the eye view frustum
  143209. * enables mapping of values in the render target depth
  143210. * attachment to scene coordinates. Initially set to 10000.0.
  143211. */
  143212. depthFar: number;
  143213. /**
  143214. * z-depth defining the near plane of the eye view frustum
  143215. * enables mapping of values in the render target depth
  143216. * attachment to scene coordinates. Initially set to 0.01.
  143217. */
  143218. depthNear: number;
  143219. /**
  143220. * An identifier for this distinct VRDisplay. Used as an
  143221. * association point in the Gamepad API.
  143222. */
  143223. readonly displayId: number;
  143224. /**
  143225. * A display name, a user-readable name identifying it.
  143226. */
  143227. readonly displayName: string;
  143228. readonly isConnected: boolean;
  143229. readonly isPresenting: boolean;
  143230. /**
  143231. * If this VRDisplay supports room-scale experiences, the optional
  143232. * stage attribute contains details on the room-scale parameters.
  143233. */
  143234. readonly stageParameters: VRStageParameters | null;
  143235. /**
  143236. * Passing the value returned by `requestAnimationFrame` to
  143237. * `cancelAnimationFrame` will unregister the callback.
  143238. * @param handle Define the hanle of the request to cancel
  143239. */
  143240. cancelAnimationFrame(handle: number): void;
  143241. /**
  143242. * Stops presenting to the VRDisplay.
  143243. * @returns a promise to know when it stopped
  143244. */
  143245. exitPresent(): Promise<void>;
  143246. /**
  143247. * Return the current VREyeParameters for the given eye.
  143248. * @param whichEye Define the eye we want the parameter for
  143249. * @returns the eye parameters
  143250. */
  143251. getEyeParameters(whichEye: string): VREyeParameters;
  143252. /**
  143253. * Populates the passed VRFrameData with the information required to render
  143254. * the current frame.
  143255. * @param frameData Define the data structure to populate
  143256. * @returns true if ok otherwise false
  143257. */
  143258. getFrameData(frameData: VRFrameData): boolean;
  143259. /**
  143260. * Get the layers currently being presented.
  143261. * @returns the list of VR layers
  143262. */
  143263. getLayers(): VRLayer[];
  143264. /**
  143265. * Return a VRPose containing the future predicted pose of the VRDisplay
  143266. * when the current frame will be presented. The value returned will not
  143267. * change until JavaScript has returned control to the browser.
  143268. *
  143269. * The VRPose will contain the position, orientation, velocity,
  143270. * and acceleration of each of these properties.
  143271. * @returns the pose object
  143272. */
  143273. getPose(): VRPose;
  143274. /**
  143275. * Return the current instantaneous pose of the VRDisplay, with no
  143276. * prediction applied.
  143277. * @returns the current instantaneous pose
  143278. */
  143279. getImmediatePose(): VRPose;
  143280. /**
  143281. * The callback passed to `requestAnimationFrame` will be called
  143282. * any time a new frame should be rendered. When the VRDisplay is
  143283. * presenting the callback will be called at the native refresh
  143284. * rate of the HMD. When not presenting this function acts
  143285. * identically to how window.requestAnimationFrame acts. Content should
  143286. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143287. * asynchronously from other displays and at differing refresh rates.
  143288. * @param callback Define the eaction to run next frame
  143289. * @returns the request handle it
  143290. */
  143291. requestAnimationFrame(callback: FrameRequestCallback): number;
  143292. /**
  143293. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143294. * Repeat calls while already presenting will update the VRLayers being displayed.
  143295. * @param layers Define the list of layer to present
  143296. * @returns a promise to know when the request has been fulfilled
  143297. */
  143298. requestPresent(layers: VRLayer[]): Promise<void>;
  143299. /**
  143300. * Reset the pose for this display, treating its current position and
  143301. * orientation as the "origin/zero" values. VRPose.position,
  143302. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143303. * updated when calling resetPose(). This should be called in only
  143304. * sitting-space experiences.
  143305. */
  143306. resetPose(): void;
  143307. /**
  143308. * The VRLayer provided to the VRDisplay will be captured and presented
  143309. * in the HMD. Calling this function has the same effect on the source
  143310. * canvas as any other operation that uses its source image, and canvases
  143311. * created without preserveDrawingBuffer set to true will be cleared.
  143312. * @param pose Define the pose to submit
  143313. */
  143314. submitFrame(pose?: VRPose): void;
  143315. }
  143316. declare var VRDisplay: {
  143317. prototype: VRDisplay;
  143318. new(): VRDisplay;
  143319. };
  143320. interface VRLayer {
  143321. leftBounds?: number[] | Float32Array | null;
  143322. rightBounds?: number[] | Float32Array | null;
  143323. source?: HTMLCanvasElement | null;
  143324. }
  143325. interface VRDisplayCapabilities {
  143326. readonly canPresent: boolean;
  143327. readonly hasExternalDisplay: boolean;
  143328. readonly hasOrientation: boolean;
  143329. readonly hasPosition: boolean;
  143330. readonly maxLayers: number;
  143331. }
  143332. interface VREyeParameters {
  143333. /** @deprecated */
  143334. readonly fieldOfView: VRFieldOfView;
  143335. readonly offset: Float32Array;
  143336. readonly renderHeight: number;
  143337. readonly renderWidth: number;
  143338. }
  143339. interface VRFieldOfView {
  143340. readonly downDegrees: number;
  143341. readonly leftDegrees: number;
  143342. readonly rightDegrees: number;
  143343. readonly upDegrees: number;
  143344. }
  143345. interface VRFrameData {
  143346. readonly leftProjectionMatrix: Float32Array;
  143347. readonly leftViewMatrix: Float32Array;
  143348. readonly pose: VRPose;
  143349. readonly rightProjectionMatrix: Float32Array;
  143350. readonly rightViewMatrix: Float32Array;
  143351. readonly timestamp: number;
  143352. }
  143353. interface VRPose {
  143354. readonly angularAcceleration: Float32Array | null;
  143355. readonly angularVelocity: Float32Array | null;
  143356. readonly linearAcceleration: Float32Array | null;
  143357. readonly linearVelocity: Float32Array | null;
  143358. readonly orientation: Float32Array | null;
  143359. readonly position: Float32Array | null;
  143360. readonly timestamp: number;
  143361. }
  143362. interface VRStageParameters {
  143363. sittingToStandingTransform?: Float32Array;
  143364. sizeX?: number;
  143365. sizeY?: number;
  143366. }
  143367. interface Navigator {
  143368. getVRDisplays(): Promise<VRDisplay[]>;
  143369. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143370. }
  143371. interface Window {
  143372. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143373. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143374. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143375. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143376. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143377. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143378. }
  143379. interface Gamepad {
  143380. readonly displayId: number;
  143381. }
  143382. type XRSessionMode =
  143383. | "inline"
  143384. | "immersive-vr"
  143385. | "immersive-ar";
  143386. type XRReferenceSpaceType =
  143387. | "viewer"
  143388. | "local"
  143389. | "local-floor"
  143390. | "bounded-floor"
  143391. | "unbounded";
  143392. type XREnvironmentBlendMode =
  143393. | "opaque"
  143394. | "additive"
  143395. | "alpha-blend";
  143396. type XRVisibilityState =
  143397. | "visible"
  143398. | "visible-blurred"
  143399. | "hidden";
  143400. type XRHandedness =
  143401. | "none"
  143402. | "left"
  143403. | "right";
  143404. type XRTargetRayMode =
  143405. | "gaze"
  143406. | "tracked-pointer"
  143407. | "screen";
  143408. type XREye =
  143409. | "none"
  143410. | "left"
  143411. | "right";
  143412. interface XRSpace extends EventTarget {
  143413. }
  143414. interface XRRenderState {
  143415. depthNear?: number;
  143416. depthFar?: number;
  143417. inlineVerticalFieldOfView?: number;
  143418. baseLayer?: XRWebGLLayer;
  143419. }
  143420. interface XRInputSource {
  143421. handedness: XRHandedness;
  143422. targetRayMode: XRTargetRayMode;
  143423. targetRaySpace: XRSpace;
  143424. gripSpace: XRSpace | undefined;
  143425. gamepad: Gamepad | undefined;
  143426. profiles: Array<string>;
  143427. }
  143428. interface XRSessionInit {
  143429. optionalFeatures?: XRReferenceSpaceType[];
  143430. requiredFeatures?: XRReferenceSpaceType[];
  143431. }
  143432. interface XRSession extends XRAnchorCreator {
  143433. addEventListener: Function;
  143434. removeEventListener: Function;
  143435. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143436. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143437. requestAnimationFrame: Function;
  143438. end(): Promise<void>;
  143439. renderState: XRRenderState;
  143440. inputSources: Array<XRInputSource>;
  143441. // AR hit test
  143442. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143443. updateWorldTrackingState(options: {
  143444. planeDetectionState?: { enabled: boolean; }
  143445. }): void;
  143446. }
  143447. interface XRReferenceSpace extends XRSpace {
  143448. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143449. onreset: any;
  143450. }
  143451. type XRPlaneSet = Set<XRPlane>;
  143452. type XRAnchorSet = Set<XRAnchor>;
  143453. interface XRFrame {
  143454. session: XRSession;
  143455. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143456. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143457. // Anchors
  143458. trackedAnchors?: XRAnchorSet;
  143459. // Planes
  143460. worldInformation: {
  143461. detectedPlanes?: XRPlaneSet;
  143462. };
  143463. }
  143464. interface XRViewerPose extends XRPose {
  143465. views: Array<XRView>;
  143466. }
  143467. interface XRPose {
  143468. transform: XRRigidTransform;
  143469. emulatedPosition: boolean;
  143470. }
  143471. interface XRWebGLLayerOptions {
  143472. antialias?: boolean;
  143473. depth?: boolean;
  143474. stencil?: boolean;
  143475. alpha?: boolean;
  143476. multiview?: boolean;
  143477. framebufferScaleFactor?: number;
  143478. }
  143479. declare var XRWebGLLayer: {
  143480. prototype: XRWebGLLayer;
  143481. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143482. };
  143483. interface XRWebGLLayer {
  143484. framebuffer: WebGLFramebuffer;
  143485. framebufferWidth: number;
  143486. framebufferHeight: number;
  143487. getViewport: Function;
  143488. }
  143489. declare class XRRigidTransform {
  143490. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143491. position: DOMPointReadOnly;
  143492. orientation: DOMPointReadOnly;
  143493. matrix: Float32Array;
  143494. inverse: XRRigidTransform;
  143495. }
  143496. interface XRView {
  143497. eye: XREye;
  143498. projectionMatrix: Float32Array;
  143499. transform: XRRigidTransform;
  143500. }
  143501. interface XRInputSourceChangeEvent {
  143502. session: XRSession;
  143503. removed: Array<XRInputSource>;
  143504. added: Array<XRInputSource>;
  143505. }
  143506. interface XRInputSourceEvent extends Event {
  143507. readonly frame: XRFrame;
  143508. readonly inputSource: XRInputSource;
  143509. }
  143510. // Experimental(er) features
  143511. declare class XRRay {
  143512. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143513. origin: DOMPointReadOnly;
  143514. direction: DOMPointReadOnly;
  143515. matrix: Float32Array;
  143516. }
  143517. interface XRHitResult {
  143518. hitMatrix: Float32Array;
  143519. }
  143520. interface XRAnchor {
  143521. // remove?
  143522. id?: string;
  143523. anchorSpace: XRSpace;
  143524. lastChangedTime: number;
  143525. detach(): void;
  143526. }
  143527. interface XRPlane extends XRAnchorCreator {
  143528. orientation: "Horizontal" | "Vertical";
  143529. planeSpace: XRSpace;
  143530. polygon: Array<DOMPointReadOnly>;
  143531. lastChangedTime: number;
  143532. }
  143533. interface XRAnchorCreator {
  143534. // AR Anchors
  143535. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143536. }